@flozy/editor 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +16 -8
- package/package.json +1 -1
@@ -75,15 +75,23 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
75
75
|
}));
|
76
76
|
}, [id, content]);
|
77
77
|
useEffect(() => {
|
78
|
-
if (editorWrapper && editorWrapper?.current && loadedValue !== deboundedValue && isInteracted) {
|
79
|
-
const
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
});
|
78
|
+
if (editorWrapper && editorWrapper?.current && loadedValue !== deboundedValue && isInteracted && onSave) {
|
79
|
+
const {
|
80
|
+
value: strVal,
|
81
|
+
...restVal
|
82
|
+
} = getOnSaveData(deboundedValue);
|
83
|
+
onSave(strVal, restVal);
|
85
84
|
}
|
86
85
|
}, [deboundedValue]);
|
86
|
+
const getOnSaveData = val => {
|
87
|
+
const text = serialize(val);
|
88
|
+
const title = val?.find(f => f.type === "title");
|
89
|
+
return {
|
90
|
+
value: JSON.stringify(val),
|
91
|
+
text: text,
|
92
|
+
title: serialize(title?.children) || "Untitled"
|
93
|
+
};
|
94
|
+
};
|
87
95
|
const getPreviewImage = async (needBackground = false, options = {}) => {
|
88
96
|
ReactEditor.blur(editor);
|
89
97
|
const dom = needBackground ? editorWrapper?.current : editorWrapper?.current.getElementsByClassName("innert-editor-textbox")[0];
|
@@ -119,7 +127,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
119
127
|
return editor;
|
120
128
|
},
|
121
129
|
getContent() {
|
122
|
-
return
|
130
|
+
return getOnSaveData(deboundedValue);
|
123
131
|
},
|
124
132
|
insertFragments(fragments) {
|
125
133
|
editor.insertNode(fragments);
|