@seafile/seafile-editor 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ var _simpleEditor = _interopRequireDefault(require("../simple-editor"));
12
12
  var _getPreviewContent = _interopRequireDefault(require("../../utils/get-preview-content"));
13
13
  var _getBrowserInfo = _interopRequireDefault(require("../../utils/get-browser-Info"));
14
14
  var _components = require("../../components");
15
+ var _slateConvert = require("../../slate-convert");
15
16
  var _markdownPreview = _interopRequireDefault(require("../markdown-preview"));
16
17
  require("./style.css");
17
18
  function LongTextEditorDialog(_ref) {
@@ -116,30 +117,24 @@ function LongTextEditorDialog(_ref) {
116
117
  setIsFullScreen(!isFullScreen);
117
118
  setDialogStyle(containerStyle);
118
119
  }, [isFullScreen]);
119
- const onContentChanged = (0, _react.useCallback)(() => {
120
- // delay to update editor's content
121
- setTimeout(() => {
122
- // update parent's component cache value
123
- if (onEditorValueChanged && typeof onEditorValueChanged === 'function') {
124
- var _editorRef$current5, _editorRef$current6;
125
- const markdownString = (_editorRef$current5 = editorRef.current) === null || _editorRef$current5 === void 0 ? void 0 : _editorRef$current5.getValue();
126
- const slateNodes = (_editorRef$current6 = editorRef.current) === null || _editorRef$current6 === void 0 ? void 0 : _editorRef$current6.getSlateValue();
127
- const {
128
- previewText,
129
- images,
130
- links,
131
- checklist
132
- } = (0, _getPreviewContent.default)(slateNodes, false);
133
- onEditorValueChanged({
134
- text: markdownString,
135
- preview: previewText,
136
- images: images,
137
- links: links,
138
- checklist
139
- });
140
- }
141
- setValueChanged(true);
142
- }, 0);
120
+ const onContentChanged = (0, _react.useCallback)(newContent => {
121
+ // update parent's component cache value
122
+ if (typeof onEditorValueChanged === 'function') {
123
+ const {
124
+ previewText: preview,
125
+ images,
126
+ links,
127
+ checklist
128
+ } = (0, _getPreviewContent.default)(newContent, false);
129
+ onEditorValueChanged({
130
+ text: (0, _slateConvert.slateToMdString)(newContent),
131
+ preview,
132
+ images,
133
+ links,
134
+ checklist
135
+ });
136
+ }
137
+ setValueChanged(true);
143
138
  }, [onEditorValueChanged]);
144
139
  const onContainerKeyDown = event => {
145
140
  event.stopPropagation();
@@ -50,7 +50,7 @@ const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
50
50
  }, [isFetching]);
51
51
  const onContentChanged = (0, _react.useCallback)(content => {
52
52
  setRichValue(content);
53
- propsOnContentChanged && propsOnContentChanged();
53
+ propsOnContentChanged && propsOnContentChanged(content);
54
54
  }, [propsOnContentChanged]);
55
55
  const props = {
56
56
  isSupportFormula: !!mathJaxSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {