@flozy/editor 9.3.3 → 9.3.4
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.
@@ -241,7 +241,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
241
241
|
|
242
242
|
const onSwitchBreakpoint = b => {
|
243
243
|
setBreakpoint(b);
|
244
|
-
|
244
|
+
setTimeout(() => {
|
245
|
+
reRenderAllNodes();
|
246
|
+
}, 0);
|
245
247
|
};
|
246
248
|
useImperativeHandle(ref, () => ({
|
247
249
|
async getThumbnail(needBackground = false, options = {}) {
|
@@ -522,7 +524,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
522
524
|
style.background = pageColor || "";
|
523
525
|
}
|
524
526
|
return style;
|
525
|
-
}, [pageBgImage, pageColor]);
|
527
|
+
}, [pageBgImage, pageColor, pageTextColor]);
|
526
528
|
const themeProps = getTheme(selectedTheme);
|
527
529
|
|
528
530
|
// const handleContextMenu = (e) => {
|
@@ -205,6 +205,7 @@ const ELEMENTS_LIST = [{
|
|
205
205
|
icon: "table"
|
206
206
|
}),
|
207
207
|
onInsert: editor => {
|
208
|
+
Transforms.delete(editor, editor.selection);
|
208
209
|
const table = new TableUtil(editor);
|
209
210
|
table.insertTable(3, 3);
|
210
211
|
}
|
@@ -255,6 +256,7 @@ const ELEMENTS_LIST = [{
|
|
255
256
|
icon: "grid"
|
256
257
|
}),
|
257
258
|
onInsert: editor => {
|
259
|
+
Transforms.delete(editor, editor.selection);
|
258
260
|
insertGrid(editor);
|
259
261
|
}
|
260
262
|
}, {
|
@@ -289,6 +291,7 @@ const ELEMENTS_LIST = [{
|
|
289
291
|
icon: "button"
|
290
292
|
}),
|
291
293
|
onInsert: editor => {
|
294
|
+
Transforms.delete(editor, editor.selection);
|
292
295
|
insertButton(editor);
|
293
296
|
}
|
294
297
|
}, {
|
@@ -300,6 +303,7 @@ const ELEMENTS_LIST = [{
|
|
300
303
|
icon: "signature"
|
301
304
|
}),
|
302
305
|
onInsert: editor => {
|
306
|
+
Transforms.delete(editor, editor.selection);
|
303
307
|
insertSignature(editor);
|
304
308
|
}
|
305
309
|
}, {
|
@@ -344,6 +348,7 @@ const ELEMENTS_LIST = [{
|
|
344
348
|
icon: "dataTable"
|
345
349
|
}),
|
346
350
|
onInsert: editor => {
|
351
|
+
Transforms.delete(editor, editor.selection);
|
347
352
|
insertDataView(editor);
|
348
353
|
}
|
349
354
|
}];
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import { Transforms } from "slate";
|
1
|
+
import { Path, Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
3
|
import { windowVar } from "./helper";
|
4
|
+
import { getCurrentElementText } from "../plugins/withHTML";
|
4
5
|
export const insertButton = editor => {
|
5
6
|
const button = {
|
6
7
|
type: "button",
|
@@ -11,9 +12,27 @@ export const insertButton = editor => {
|
|
11
12
|
linkType: "webAddress"
|
12
13
|
},
|
13
14
|
iconPosition: "start",
|
15
|
+
bgColor: "#2563EB",
|
16
|
+
textColor: "#FFF",
|
17
|
+
borderRadius: {
|
18
|
+
topLeft: 30,
|
19
|
+
topRight: 30,
|
20
|
+
bottomLeft: 30,
|
21
|
+
bottomRight: 30
|
22
|
+
},
|
23
|
+
bannerSpacing: {
|
24
|
+
left: 16,
|
25
|
+
top: 8,
|
26
|
+
right: 16,
|
27
|
+
bottom: 8
|
28
|
+
},
|
14
29
|
...(windowVar.lastButtonProps || {})
|
15
30
|
};
|
16
|
-
|
31
|
+
const hasText = getCurrentElementText(editor);
|
32
|
+
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;
|
33
|
+
Transforms.insertNodes(editor, button, {
|
34
|
+
at: insertPath
|
35
|
+
});
|
17
36
|
Transforms.move(editor);
|
18
37
|
insertNewLine(editor);
|
19
38
|
};
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { Transforms } from "slate";
|
1
|
+
import { Path, Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
+
import { getCurrentElementText } from "../plugins/withHTML";
|
3
4
|
const getDefaultDatView = () => ({
|
4
5
|
type: "dataView",
|
5
6
|
title: "",
|
@@ -31,10 +32,12 @@ const getDefaultDatView = () => ({
|
|
31
32
|
});
|
32
33
|
export const insertDataView = editor => {
|
33
34
|
try {
|
35
|
+
const hasText = getCurrentElementText(editor);
|
36
|
+
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;
|
34
37
|
Transforms.insertNodes(editor, {
|
35
38
|
...getDefaultDatView()
|
36
39
|
}, {
|
37
|
-
at:
|
40
|
+
at: insertPath
|
38
41
|
});
|
39
42
|
insertNewLine(editor);
|
40
43
|
} catch (err) {
|
@@ -261,7 +261,15 @@ export const customInsertNode = (editor, insertNode, defaultInsertOptions = {})
|
|
261
261
|
if (isListItem) {
|
262
262
|
insertOptions.at = editor.selection.focus;
|
263
263
|
}
|
264
|
-
|
264
|
+
const hasText = getCurrentNodeText(editor);
|
265
|
+
if (hasText) {
|
266
|
+
Transforms.insertNodes(editor, insertNode, {
|
267
|
+
at: Path.next(Path.parent(editor?.selection.focus.path)),
|
268
|
+
select: true
|
269
|
+
});
|
270
|
+
} else {
|
271
|
+
Transforms.insertNodes(editor, insertNode, insertOptions);
|
272
|
+
}
|
265
273
|
insertNewLine(editor);
|
266
274
|
};
|
267
275
|
export const decodeAndParseBase64 = encodedString => {
|
@@ -1,6 +1,9 @@
|
|
1
|
-
import { Transforms } from "slate";
|
1
|
+
import { Path, Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
+
import { getCurrentElementText } from "../plugins/withHTML";
|
3
4
|
export const insertSignature = editor => {
|
5
|
+
const hasText = getCurrentElementText(editor);
|
6
|
+
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor.selection.anchor.path;
|
4
7
|
const signature = {
|
5
8
|
type: "signature",
|
6
9
|
alignment: "center",
|
@@ -15,7 +18,7 @@ export const insertSignature = editor => {
|
|
15
18
|
}]
|
16
19
|
};
|
17
20
|
Transforms.insertNodes(editor, signature, {
|
18
|
-
at:
|
21
|
+
at: insertPath
|
19
22
|
});
|
20
23
|
insertNewLine(editor);
|
21
24
|
};
|