Skip to content

Commit 8f71c77

Browse files
committed
Merge branch 'develop' of github.com:pie-framework/pie-elements into fix/PD-4068
2 parents c4976b6 + 5b075f0 commit 8f71c77

6 files changed

Lines changed: 50 additions & 7 deletions

File tree

packages/drawing-response/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [7.23.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response@7.22.4...@pie-element/drawing-response@7.23.0) (2024-09-11)
7+
8+
9+
### Features
10+
11+
* upload images for drawing-response and only store url in db, not full base64 PD-4067 ([429b47d](https://github.com/pie-framework/pie-elements/commit/429b47d309052cbec17cb592df0ae9bc878e590a))
12+
13+
14+
15+
16+
617
## [7.22.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response@7.22.3...@pie-element/drawing-response@7.22.4) (2024-09-10)
718

819

packages/drawing-response/configure/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [7.22.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-configure@7.21.4...@pie-element/drawing-response-configure@7.22.0) (2024-09-11)
7+
8+
9+
### Features
10+
11+
* upload images for drawing-response and only store url in db, not full base64 PD-4067 ([429b47d](https://github.com/pie-framework/pie-elements/commit/429b47d309052cbec17cb592df0ae9bc878e590a))
12+
13+
14+
15+
16+
617
## [7.21.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-configure@7.21.3...@pie-element/drawing-response-configure@7.21.4) (2024-09-10)
718

819

packages/drawing-response/configure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pie-element/drawing-response-configure",
33
"private": true,
4-
"version": "7.21.4",
4+
"version": "7.22.0",
55
"description": "",
66
"main": "lib/index.js",
77
"module": "src/index.js",

packages/drawing-response/configure/src/image-container.jsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export class ImageContainer extends Component {
2525
dragEnabled: true,
2626
dropzoneActive: false,
2727
};
28+
this.fakeImageHandler = {
29+
cancel: () => {},
30+
done: (a, url) => this.props.onImageUpload(url),
31+
fileChosen: () => {},
32+
progress: () => {},
33+
};
2834
}
2935

3036
componentDidMount() {
@@ -39,12 +45,19 @@ export class ImageContainer extends Component {
3945
}
4046

4147
handleFileRead = (file) => {
42-
const { onImageUpload } = this.props;
48+
const { onImageUpload, insertImage } = this.props;
4349
const reader = new FileReader();
44-
reader.onloadend = () => {
45-
onImageUpload(reader.result);
46-
};
50+
51+
reader.onloadend = () => onImageUpload(reader.result);
4752
reader.readAsDataURL(file);
53+
54+
if (insertImage) {
55+
insertImage({
56+
...this.fakeImageHandler,
57+
getChosenFile: () => file,
58+
isPasted: true,
59+
});
60+
}
4861
};
4962

5063
handleUploadImage = (e) => {
@@ -89,7 +102,13 @@ export class ImageContainer extends Component {
89102

90103
handleEnableDrag = () => this.setState({ dragEnabled: true });
91104
handleDisableDrag = () => this.setState({ dragEnabled: false });
92-
handleInputClick = () => this.input.click();
105+
handleInputClick = () => {
106+
const { insertImage } = this.props;
107+
108+
if (insertImage) {
109+
insertImage(this.fakeImageHandler);
110+
}
111+
};
93112

94113
handleOnImageLoad = ({ target: { offsetHeight, offsetWidth, naturalHeight, naturalWidth } }) => {
95114
const { onUpdateImageDimension, imageDimensions } = this.props;
@@ -295,6 +314,7 @@ ImageContainer.propTypes = {
295314
imageUrl: PropTypes.string.isRequired,
296315
onImageUpload: PropTypes.func.isRequired,
297316
onUpdateImageDimension: PropTypes.func.isRequired,
317+
insertImage: PropTypes.func,
298318
};
299319

300320
export default withStyles(styles)(ImageContainer);

packages/drawing-response/configure/src/root.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export class Root extends React.Component {
156156
onUpdateImageDimension={this.onUpdateImageDimension}
157157
onImageUpload={this.onImageUpload}
158158
imageDimensions={model.imageDimensions}
159+
insertImage={imageSupport && imageSupport.add}
159160
/>
160161
</React.Fragment>
161162
)}

packages/drawing-response/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pie-element/drawing-response",
3-
"version": "7.22.4",
3+
"version": "7.23.0",
44
"description": "",
55
"repository": "pie-framework/pie-elements",
66
"publishConfig": {

0 commit comments

Comments
 (0)