Skip to content

Commit

Permalink
Merge pull request #82 from EmmanuelDemey/fix
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
alicela authored Oct 25, 2019
2 parents cccf7d4 + a6b8c9d commit b7d3c5f
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"react-bootstrap-tabs": "1.0.2",
"react-d3-tree": "1.10.3",
"react-dom": "16.8.6",
"react-draft-wysiwyg": "1.12.0",
"react-draft-wysiwyg": "1.13.2",
"react-dropzone": "^10.1.5",
"react-loading": "2.0.3",
"react-modal": "3.1.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ class Field extends Component {
<>
<EditorMarkdown
aria-label={D.simsValue}
text={currentSection[secondLang ? 'labelLg2' : 'labelLg1']}
text={
currentSection[secondLang ? 'labelLg2' : 'labelLg1'] || ''
}
handleChange={this.handleTextInput}
/>
<DocumentsBloc
Expand Down
32 changes: 24 additions & 8 deletions app/src/js/components/shared/editor-html/editor-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,39 @@ class EditorMarkdown extends Component {
editorState: editorStateFromMd(text || ''),
text,
};
this.handleChange = editorState => {
this.setState({
editorState,
});
};
this.handleLeave = () =>
this.props.handleChange(mdFromEditorState(this.state.editorState));

this.editorRef = React.createRef();
}

handleChange = editorState => {
this.setState({
editorState,
});
};
handleLeave = () => {
this.props.handleChange(mdFromEditorState(this.state.editorState));
};

componentWillReceiveProps(nextProps) {
this.setState({
editorState: editorStateFromMd(nextProps.text || ''),
});
}

componentDidMount() {
// hack to trigger the leave event when we click on the submit button when inserting a link
document
.getElementById(this.editorRef.current.wrapperId)
.querySelector('.rdw-link-wrapper')
.addEventListener('click', e => {
if (e.target.tagName === 'BUTTON') {
setTimeout(() => this.handleLeave(), 0);
}
});
}
render() {
return (
<Editor
ref={this.editorRef}
editorState={this.state.editorState}
toolbar={toolbar}
toolbarClassName="home-toolbar"
Expand Down
79 changes: 42 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3059,15 +3059,6 @@ babel-plugin-transform-undefined-to-void@^6.9.4:
resolved "https://registry.yarnpkg.com/babel-plugin-transform-undefined-to-void/-/babel-plugin-transform-undefined-to-void-6.9.4.tgz#be241ca81404030678b748717322b89d0c8fe280"
integrity sha1-viQcqBQEAwZ4t0hxcyK4nQyP4oA=

[email protected]:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
integrity sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=
dependencies:
babel-runtime "^6.26.0"
core-js "^2.5.0"
regenerator-runtime "^0.10.5"

babel-preset-jest@^24.6.0:
version "24.6.0"
resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.6.0.tgz#66f06136eefce87797539c0d63f1769cc3915984"
Expand Down Expand Up @@ -5146,10 +5137,10 @@ [email protected]:
dependencies:
"@textlint/markdown-to-ast" "^6.0.8"

draftjs-utils@^0.8.07:
version "0.8.8"
resolved "https://registry.yarnpkg.com/draftjs-utils/-/draftjs-utils-0.8.8.tgz#5835daed95f59d3ee1f96fdcbbb9809772c86490"
integrity sha1-WDXa7ZX1nT7h+W/cu7mAl3LIZJA=
draftjs-utils@^0.9.3:
version "0.9.4"
resolved "https://registry.npmjs.org/draftjs-utils/-/draftjs-utils-0.9.4.tgz#976c61aa133dbbbfedd65ae1dd6627d7b98c6f08"
integrity sha512-KYjABSbGpJrwrwmxVj5UhfV37MF/p0QRxKIyL+/+QOaJ8J9z1FBKxkblThbpR0nJi9lxPQWGg+gh+v0dAsSCCg==

[email protected], duplexer@^0.1.1, duplexer@~0.1.1:
version "0.1.1"
Expand Down Expand Up @@ -6862,16 +6853,16 @@ highlight.js@~9.12.0:
integrity sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=

history@^4.7.2:
version "4.9.0"
resolved "https://registry.npmjs.org/history/-/history-4.9.0.tgz#84587c2068039ead8af769e9d6a6860a14fa1bca"
integrity sha512-H2DkjCjXf0Op9OAr6nJ56fcRkTSNrUiv41vNJ6IswJjif6wlpZK0BTfFbi7qK9dXLSYZxkq5lBsj3vUjlYBYZA==
version "4.10.1"
resolved "https://registry.npmjs.org/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==
dependencies:
"@babel/runtime" "^7.1.2"
loose-envify "^1.2.0"
resolve-pathname "^2.2.0"
resolve-pathname "^3.0.0"
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
value-equal "^0.4.0"
value-equal "^1.0.1"

hmac-drbg@^1.0.0:
version "1.0.1"
Expand Down Expand Up @@ -6986,6 +6977,11 @@ html-minifier@^4.0.0:
relateurl "^0.2.7"
uglify-js "^3.5.1"

html-to-draftjs@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/html-to-draftjs/-/html-to-draftjs-1.4.0.tgz#8a3cbbba5b49d50be8ce85cc08b112d5bf00fc1d"
integrity sha1-ijy7ultJ1QvozoXMCLES1b8A/B0=

[email protected]:
version "4.0.0-beta.5"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-4.0.0-beta.5.tgz#2c53083c1151bfec20479b1f8aaf0039e77b5513"
Expand Down Expand Up @@ -8643,6 +8639,13 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

linkify-it@^2.0.3:
version "2.2.0"
resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf"
integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==
dependencies:
uc.micro "^1.0.1"

listr-silent-renderer@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz#924b5a3757153770bf1a8e3fbf74b8bbf3f9242e"
Expand Down Expand Up @@ -11741,13 +11744,15 @@ react-dom@^16.8.3:
prop-types "^15.6.2"
scheduler "^0.15.0"

react-draft-wysiwyg@1.12.0:
version "1.12.0"
resolved "https://registry.yarnpkg.com/react-draft-wysiwyg/-/react-draft-wysiwyg-1.12.0.tgz#60c172f852bf44caf64f5bc1dfabcce21803cd73"
integrity sha1-YMFy+FK/RMr2T1vB36vM4hgDzXM=
react-draft-wysiwyg@1.13.2:
version "1.13.2"
resolved "https://registry.npmjs.org/react-draft-wysiwyg/-/react-draft-wysiwyg-1.13.2.tgz#1fc4130d057f0e731386bf831acca71108141899"
integrity sha512-qENNISR+bxO6G/ThTD6cai+LGrzkiGt6Fx9mqecJGPmyTIYVE5odsO7yEQVNBpZhgr5TvHAvwm3IoamcuFanDw==
dependencies:
classnames "^2.2.5"
draftjs-utils "^0.8.07"
draftjs-utils "^0.9.3"
html-to-draftjs "^1.4.0"
linkify-it "^2.0.3"
prop-types "^15.6.0"

react-draggable@^3.1.1:
Expand Down Expand Up @@ -11923,7 +11928,7 @@ [email protected]:

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/react-router-hash-link/-/react-router-hash-link-1.2.0.tgz#ce824cc5f0502ce9b0686bb6dd9c08659b24094c"
resolved "https://registry.npmjs.org/react-router-hash-link/-/react-router-hash-link-1.2.0.tgz#ce824cc5f0502ce9b0686bb6dd9c08659b24094c"
integrity sha1-zoJMxfBQLOmwaGu23ZwIZZskCUw=
dependencies:
prop-types "^15.6.0"
Expand Down Expand Up @@ -12361,11 +12366,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz#32e59c9a6fb9b1a4aff09b4930ca2d4477343447"
integrity sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==

regenerator-runtime@^0.10.5:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
integrity sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=

regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
Expand Down Expand Up @@ -12660,10 +12660,10 @@ resolve-options@^1.1.0:
dependencies:
value-or-function "^3.0.0"

resolve-pathname@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879"
integrity sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg==
resolve-pathname@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"
integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==

resolve-url@^0.2.1:
version "0.2.1"
Expand Down Expand Up @@ -14368,6 +14368,11 @@ ua-parser-js@^0.7.18:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.20.tgz#7527178b82f6a62a0f243d1f94fd30e3e3c21098"
integrity sha512-8OaIKfzL5cpx8eCMAhhvTlft8GYF8b2eQr6JkCyVdrgjcytyOmPCXrqXFcUnhonRpLlh5yxEZVohm6mzaowUOw==

uc.micro@^1.0.1:
version "1.0.6"
resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==

[email protected]:
version "3.4.10"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"
Expand Down Expand Up @@ -14642,10 +14647,10 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

value-equal@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7"
integrity sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw==
value-equal@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c"
integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==

value-or-function@^3.0.0:
version "3.0.0"
Expand Down

0 comments on commit b7d3c5f

Please sign in to comment.