@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 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);
@@ -26,11 +26,11 @@ blockquote{
26
26
  .editor-wrapper table{
27
27
  border-collapse: collapse;
28
28
  }
29
- button{
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
  }
@@ -15,6 +15,6 @@
15
15
  width: fit-content;
16
16
  z-index: 1;
17
17
  }
18
- img{
18
+ .link img{
19
19
  height: 15px;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"