@flozy/editor 1.2.7 → 1.2.8

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.
@@ -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 text = serialize(deboundedValue);
80
- const title = deboundedValue?.find(f => f.type === "title");
81
- onSave(JSON.stringify(deboundedValue), {
82
- text: text,
83
- title: serialize(title?.children) || "Untitled"
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 value;
130
+ return getOnSaveData(deboundedValue);
123
131
  },
124
132
  insertFragments(fragments) {
125
133
  editor.insertNode(fragments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"