@lobehub/editor 1.0.2 → 1.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.
|
@@ -15,7 +15,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
-
import { Children, memo, useEffect, useLayoutEffect, useRef } from 'react';
|
|
18
|
+
import { Children, memo, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
19
19
|
import { LexicalErrorBoundary } from "../../../editor-kernel/react/LexicalErrorBoundary";
|
|
20
20
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
21
21
|
import { useDecorators } from "../../../editor-kernel/react/useDecorators";
|
|
@@ -58,6 +58,10 @@ var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
|
58
58
|
}),
|
|
59
59
|
cx = _useStyles.cx,
|
|
60
60
|
styles = _useStyles.styles;
|
|
61
|
+
var _useState = useState(false),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
isInitialized = _useState2[0],
|
|
64
|
+
setIsInitialized = _useState2[1];
|
|
61
65
|
var _Children$only = Children.only(children),
|
|
62
66
|
_Children$only$props = _Children$only.props,
|
|
63
67
|
type = _Children$only$props.type,
|
|
@@ -72,15 +76,18 @@ var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
|
72
76
|
useEffect(function () {
|
|
73
77
|
var _editor$getLexicalEdi;
|
|
74
78
|
var container = editorContainerRef.current;
|
|
75
|
-
if (container) {
|
|
79
|
+
if (container && !isInitialized) {
|
|
76
80
|
// Initialize the editor
|
|
77
81
|
editor.setRootElement(container);
|
|
82
|
+
|
|
83
|
+
// Set initial document content only once
|
|
84
|
+
editor.setDocument(type, content);
|
|
85
|
+
setIsInitialized(true);
|
|
78
86
|
}
|
|
79
|
-
editor.setDocument(type, content);
|
|
80
87
|
return (_editor$getLexicalEdi = editor.getLexicalEditor()) === null || _editor$getLexicalEdi === void 0 ? void 0 : _editor$getLexicalEdi.registerUpdateListener(function () {
|
|
81
88
|
onChange === null || onChange === void 0 || onChange(editor);
|
|
82
89
|
});
|
|
83
|
-
}, [editor, type, content, onChange]);
|
|
90
|
+
}, [editor, type, content, onChange, isInitialized]);
|
|
84
91
|
return /*#__PURE__*/_jsxs("div", {
|
|
85
92
|
className: cx(styles.root, styles.variant, className),
|
|
86
93
|
style: style,
|
package/package.json
CHANGED