@flozy/editor 1.2.6 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -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);
|
package/dist/Editor/Editor.css
CHANGED
@@ -26,11 +26,11 @@ blockquote{
|
|
26
26
|
.editor-wrapper table{
|
27
27
|
border-collapse: collapse;
|
28
28
|
}
|
29
|
-
|
29
|
+
.editor-wrapper .editor-wrapperbutton{
|
30
30
|
background-color: white;
|
31
31
|
border:none;
|
32
32
|
}
|
33
|
-
.btnActive{
|
33
|
+
.editor-wrapper .btnActive{
|
34
34
|
opacity: 1;
|
35
35
|
}
|
36
36
|
.editor-wrapper{
|
@@ -76,9 +76,6 @@ button{
|
|
76
76
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
77
77
|
monospace;
|
78
78
|
}
|
79
|
-
[data-slate-node="element"] {
|
80
|
-
margin: 10px 0;
|
81
|
-
}
|
82
79
|
.editor-wrapper html{
|
83
80
|
scroll-behavior: smooth;
|
84
81
|
}
|