@flozy/editor 1.6.0 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +131 -104
- package/dist/Editor/DialogWrapper.js +3 -0
- package/dist/Editor/Editor.css +27 -36
- package/dist/Editor/Elements/Accordion/AccordionButton.js +13 -12
- package/dist/Editor/Elements/AppHeader/AppHeader.js +2 -2
- package/dist/Editor/Elements/Button/ButtonToolIcon.js +10 -9
- package/dist/Editor/Elements/Button/EditorButton.js +4 -20
- package/dist/Editor/Elements/Carousel/Carousel.js +47 -28
- package/dist/Editor/Elements/Carousel/CarouselButton.js +7 -8
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +133 -0
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +39 -19
- package/dist/Editor/Elements/Color Picker/Styles.js +51 -0
- package/dist/Editor/Elements/Color Picker/defaultColors.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.js +33 -126
- package/dist/Editor/Elements/Embed/Image.js +15 -7
- package/dist/Editor/Elements/Embed/Video.js +12 -5
- package/dist/Editor/Elements/Emoji/EmojiButton.js +73 -0
- package/dist/Editor/Elements/Emoji/EmojiPicker.js +0 -0
- package/dist/Editor/Elements/Form/Form.js +24 -12
- package/dist/Editor/Elements/Form/FormButton.js +11 -9
- package/dist/Editor/Elements/Form/FormElements/FormText.js +1 -0
- package/dist/Editor/Elements/Form/FormField.js +7 -1
- package/dist/Editor/Elements/Grid/Grid.js +15 -4
- package/dist/Editor/Elements/Grid/GridButton.js +52 -29
- package/dist/Editor/Elements/Grid/GridItem.js +30 -19
- package/dist/Editor/Elements/Grid/Styles.js +11 -0
- package/dist/Editor/Elements/List/CheckList.js +57 -0
- package/dist/Editor/Elements/List/CheckListButton.js +24 -0
- package/dist/Editor/Elements/NewLine/NewLineButton.js +14 -14
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +17 -60
- package/dist/Editor/Elements/Signature/Signature.js +9 -3
- package/dist/Editor/Elements/Signature/SignatureButton.js +10 -9
- package/dist/Editor/Elements/Signature/SignaturePopup.js +50 -7
- package/dist/Editor/Elements/SimpleText.js +62 -0
- package/dist/Editor/Elements/Table/Styles.js +66 -0
- package/dist/Editor/Elements/Table/Table.js +33 -16
- package/dist/Editor/Elements/Table/TableCell.js +54 -24
- package/dist/Editor/Elements/Table/TableSelector.js +13 -15
- package/dist/Editor/Elements/Table/table.css +0 -10
- package/dist/Editor/Elements/TopBanner/Styles.js +33 -0
- package/dist/Editor/Elements/TopBanner/TopBanner.js +106 -0
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +47 -0
- package/dist/Editor/Styles/EditorStyles.js +50 -0
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +8 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyDropdown.js +16 -16
- package/dist/Editor/Toolbar/FormatTools/FontSize.js +17 -17
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -3
- package/dist/Editor/Toolbar/FormatTools/index.js +3 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +101 -0
- package/dist/Editor/Toolbar/Mini/Options/Options.js +17 -0
- package/dist/Editor/Toolbar/Mini/Styles.js +30 -0
- package/dist/Editor/Toolbar/PopupTool/AddElements.js +32 -0
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +115 -0
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +65 -0
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +160 -6
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +263 -80
- package/dist/Editor/Toolbar/PopupTool/index.js +33 -44
- package/dist/Editor/Toolbar/Toolbar.js +178 -134
- package/dist/Editor/Toolbar/styles.css +1 -1
- package/dist/Editor/Toolbar/toolbarGroups.js +83 -34
- package/dist/Editor/assets/svg/AddElementIcon.js +29 -0
- package/dist/Editor/assets/svg/AddTemplateIcon.js +29 -0
- package/dist/Editor/assets/svg/TextIcon.js +29 -0
- package/dist/Editor/common/Icon.js +48 -5
- package/dist/Editor/common/ImageList.js +10 -4
- package/dist/Editor/common/ImageSelector/ImageSelector.js +117 -0
- package/dist/Editor/common/ImageSelector/Options/AddLink.js +44 -0
- package/dist/Editor/common/ImageSelector/Options/ChooseAssets.js +39 -0
- package/dist/Editor/common/ImageSelector/Options/Upload.js +30 -0
- package/dist/Editor/common/ImageSelector/Styles.js +41 -0
- package/dist/Editor/common/ImageUploader.js +19 -8
- package/dist/Editor/common/MentionsPopup/ElementsListCard.js +66 -0
- package/dist/Editor/common/MentionsPopup/MentionsListCard.js +70 -0
- package/dist/Editor/common/MentionsPopup/Styles.js +68 -0
- package/dist/Editor/common/MentionsPopup/index.js +129 -0
- package/dist/Editor/common/Shorthands/elements.js +191 -0
- package/dist/Editor/common/Shorthands/index.js +7 -0
- package/dist/Editor/common/Shorthands/mentions.js +8 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +21 -73
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +3 -20
- package/dist/Editor/common/StyleBuilder/index.js +0 -1
- package/dist/Editor/common/StyleBuilder/tableStyle.js +9 -5
- package/dist/Editor/common/ToolbarIcon.js +43 -0
- package/dist/Editor/common/Uploader.js +10 -7
- package/dist/Editor/common/iconslist.js +46 -1
- package/dist/Editor/hooks/useMentions.js +104 -17
- package/dist/Editor/hooks/useMouseMove.js +53 -0
- package/dist/Editor/hooks/useScroll.js +26 -0
- package/dist/Editor/plugins/withEmbeds.js +12 -0
- package/dist/Editor/service/fileupload.js +2 -2
- package/dist/Editor/utils/SlateUtilityFunctions.js +61 -10
- package/dist/Editor/utils/carousel.js +5 -2
- package/dist/Editor/utils/carouselItem.js +2 -2
- package/dist/Editor/utils/customHooks/useResize.js +2 -3
- package/dist/Editor/utils/customHooks/useTableResize.js +2 -1
- package/dist/Editor/utils/embed.js +19 -5
- package/dist/Editor/utils/emoji.js +8 -0
- package/dist/Editor/utils/events.js +49 -12
- package/dist/Editor/utils/form.js +3 -9
- package/dist/Editor/utils/formfield.js +2 -1
- package/dist/Editor/utils/grid.js +44 -8
- package/dist/Editor/utils/gridItem.js +4 -3
- package/dist/Editor/utils/insertNewLine.js +12 -0
- package/dist/Editor/utils/mentions.js +14 -10
- package/dist/Editor/utils/pageSettings.js +67 -0
- package/dist/Editor/utils/signature.js +6 -8
- package/dist/Editor/utils/table.js +79 -18
- package/dist/Editor/utils/topBanner.js +58 -0
- package/package.json +4 -1
- package/dist/Editor/common/MentionsPopup.js +0 -56
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
2
|
import { formField } from "./formfield";
|
3
|
+
import insertNewLine from "./insertNewLine";
|
3
4
|
export const insertForm = (editor, item) => {
|
4
5
|
const grid = !item ? {
|
5
6
|
type: "form",
|
@@ -18,15 +19,8 @@ export const insertForm = (editor, item) => {
|
|
18
19
|
},
|
19
20
|
children: [{
|
20
21
|
...formField()
|
21
|
-
}, {
|
22
|
-
text: ""
|
23
22
|
}]
|
24
23
|
} : item;
|
25
|
-
|
26
|
-
|
27
|
-
} = editor;
|
28
|
-
Transforms.insertNodes(editor, grid, {
|
29
|
-
at: selection.focus.path
|
30
|
-
});
|
31
|
-
Transforms.move(editor);
|
24
|
+
Transforms.insertNodes(editor, grid);
|
25
|
+
insertNewLine(editor);
|
32
26
|
};
|
@@ -1,12 +1,48 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
2
|
import default_grid from "../Elements/Grid/templates/default_grid";
|
3
|
+
import insertNewLine from "./insertNewLine";
|
4
|
+
import { gridItem } from "./gridItem";
|
5
|
+
export const insertPlainGrid = count => {
|
6
|
+
const size = 12 / count;
|
7
|
+
const items = Array.from(Array(count).keys()).map(() => gridItem({
|
8
|
+
grid: size,
|
9
|
+
borderColor: "#ccc",
|
10
|
+
lockSpacing: true,
|
11
|
+
bannerSpacing: {
|
12
|
+
top: "16",
|
13
|
+
left: "16",
|
14
|
+
right: "16",
|
15
|
+
bottom: "16"
|
16
|
+
}
|
17
|
+
}));
|
18
|
+
return {
|
19
|
+
type: "grid",
|
20
|
+
grid: "container",
|
21
|
+
children: [...items],
|
22
|
+
alignment: {
|
23
|
+
flexDirection: "row"
|
24
|
+
},
|
25
|
+
lockSpacing: true,
|
26
|
+
bannerSpacing: {
|
27
|
+
top: "16",
|
28
|
+
left: "16",
|
29
|
+
right: "16",
|
30
|
+
bottom: "16"
|
31
|
+
}
|
32
|
+
};
|
33
|
+
};
|
3
34
|
export const insertGrid = (editor, item, path) => {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
35
|
+
try {
|
36
|
+
const grid = !item ? JSON.parse(default_grid) : item;
|
37
|
+
const {
|
38
|
+
selection
|
39
|
+
} = editor;
|
40
|
+
Transforms.insertNodes(editor, grid, {
|
41
|
+
at: path || selection.focus.path,
|
42
|
+
select: true
|
43
|
+
});
|
44
|
+
insertNewLine(editor);
|
45
|
+
} catch (err) {
|
46
|
+
console.log(err);
|
47
|
+
}
|
12
48
|
};
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
|
-
export const gridItem = () => {
|
2
|
+
export const gridItem = (props = {}) => {
|
3
3
|
return {
|
4
4
|
type: "grid-item",
|
5
5
|
grid: 6,
|
6
6
|
children: [{
|
7
7
|
type: "paragraph",
|
8
8
|
children: [{
|
9
|
-
text:
|
9
|
+
text: " "
|
10
10
|
}]
|
11
11
|
}],
|
12
|
-
bgColor: "rgba(255, 255, 255, 0)"
|
12
|
+
bgColor: "rgba(255, 255, 255, 0)",
|
13
|
+
...(props || {})
|
13
14
|
};
|
14
15
|
};
|
15
16
|
export const insertGridItem = editor => {
|
@@ -1,12 +1,16 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
|
-
export const insertMention = (editor, character) => {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
export const insertMention = (editor, character, type) => {
|
3
|
+
if (type === "mentions") {
|
4
|
+
const mention = {
|
5
|
+
type: "mention",
|
6
|
+
character,
|
7
|
+
children: [{
|
8
|
+
text: ""
|
9
|
+
}]
|
10
|
+
};
|
11
|
+
Transforms.insertNodes(editor, mention);
|
12
|
+
Transforms.move(editor);
|
13
|
+
} else if (type === "elements" && character && character.onInsert) {
|
14
|
+
character.onInsert(editor);
|
15
|
+
}
|
12
16
|
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { Editor, Transforms, Element } from "slate";
|
2
|
+
export const getPageSettings = editor => {
|
3
|
+
try {
|
4
|
+
const [pageSettingsNode] = Editor.nodes(editor, {
|
5
|
+
at: [],
|
6
|
+
match: n => {
|
7
|
+
return !Editor.isEditor(n) && Element.isElement(n) && n.type === "page-settings";
|
8
|
+
}
|
9
|
+
});
|
10
|
+
if (pageSettingsNode && pageSettingsNode[0] && pageSettingsNode[1]) {
|
11
|
+
const [element, path] = pageSettingsNode;
|
12
|
+
return {
|
13
|
+
path,
|
14
|
+
element
|
15
|
+
};
|
16
|
+
} else {
|
17
|
+
return {
|
18
|
+
path: null,
|
19
|
+
element: {
|
20
|
+
pageProps: {
|
21
|
+
pageWidth: "fixed"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
};
|
25
|
+
}
|
26
|
+
} catch (err) {
|
27
|
+
console.log(err);
|
28
|
+
return {
|
29
|
+
path: null,
|
30
|
+
element: {}
|
31
|
+
};
|
32
|
+
}
|
33
|
+
};
|
34
|
+
export const insertPageSettings = (editor, pageProps = {}) => {
|
35
|
+
Transforms.insertNodes(editor, [{
|
36
|
+
type: "page-settings",
|
37
|
+
pageProps: {
|
38
|
+
...pageProps,
|
39
|
+
pageWidth: "fixed"
|
40
|
+
},
|
41
|
+
children: [{
|
42
|
+
text: ""
|
43
|
+
}]
|
44
|
+
}], {
|
45
|
+
at: [editor.children.length]
|
46
|
+
});
|
47
|
+
};
|
48
|
+
export const updatePageSettings = (editor, pageProps = {}) => {
|
49
|
+
try {
|
50
|
+
const {
|
51
|
+
path
|
52
|
+
} = getPageSettings(editor);
|
53
|
+
if (path) {
|
54
|
+
Transforms.setNodes(editor, {
|
55
|
+
pageProps: {
|
56
|
+
...pageProps
|
57
|
+
}
|
58
|
+
}, {
|
59
|
+
at: path
|
60
|
+
});
|
61
|
+
} else {
|
62
|
+
insertPageSettings(editor, pageProps);
|
63
|
+
}
|
64
|
+
} catch (err) {
|
65
|
+
console.log(err);
|
66
|
+
}
|
67
|
+
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
|
+
import insertNewLine from "./insertNewLine";
|
2
3
|
export const insertSignature = editor => {
|
3
4
|
const signature = {
|
4
5
|
type: "signature",
|
@@ -9,15 +10,12 @@ export const insertSignature = editor => {
|
|
9
10
|
date: "" // YYYY-MM-DD
|
10
11
|
},
|
11
12
|
|
12
|
-
size: {
|
13
|
-
height: 535,
|
14
|
-
widthInPercent: 99.75490196078437,
|
15
|
-
width: 1628.000000000001
|
16
|
-
},
|
17
13
|
children: [{
|
18
|
-
text: ""
|
14
|
+
text: " "
|
19
15
|
}]
|
20
16
|
};
|
21
|
-
Transforms.insertNodes(editor, signature
|
22
|
-
|
17
|
+
Transforms.insertNodes(editor, signature, {
|
18
|
+
at: editor.selection.anchor.path
|
19
|
+
});
|
20
|
+
insertNewLine(editor);
|
23
21
|
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Transforms, Editor, Range, Element, Path, Node } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
|
+
import insertNewLine from "./insertNewLine";
|
3
4
|
const prefixKey = (obj, pk = "") => {
|
4
5
|
return Object.keys(obj).reduce((a, b) => {
|
5
6
|
a[`${pk}${b}`] = obj[b];
|
@@ -36,18 +37,11 @@ export class TableUtil {
|
|
36
37
|
}, () => ""));
|
37
38
|
const newTable = createTableNode(cellText, rows, columns);
|
38
39
|
Transforms.insertNodes(this.editor, newTable, {
|
39
|
-
//
|
40
|
+
// to insert in current line
|
41
|
+
// at: this.editor.selection.anchor.path,
|
40
42
|
});
|
41
|
-
|
42
|
-
type: "paragraph",
|
43
|
-
children: [{
|
44
|
-
text: ""
|
45
|
-
}]
|
46
|
-
}
|
47
|
-
// { mode: "highest" }
|
48
|
-
);
|
43
|
+
insertNewLine(this.editor);
|
49
44
|
};
|
50
|
-
|
51
45
|
removeTable = () => {
|
52
46
|
Transforms.removeNodes(this.editor, {
|
53
47
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
@@ -64,7 +58,7 @@ export class TableUtil {
|
|
64
58
|
const tableDOM = ReactEditor.toDOMNode(this.editor, tableNode[0]);
|
65
59
|
return tableDOM;
|
66
60
|
} catch (err) {
|
67
|
-
console.log(err);
|
61
|
+
// console.log(err);
|
68
62
|
}
|
69
63
|
};
|
70
64
|
getTotalWidth = (path, colCount = 0) => {
|
@@ -223,6 +217,21 @@ export class TableUtil {
|
|
223
217
|
}, {
|
224
218
|
at: currentCellPath
|
225
219
|
});
|
220
|
+
|
221
|
+
// cell bg entire
|
222
|
+
if (cellProps?.entireBgColor) {
|
223
|
+
const {
|
224
|
+
rows
|
225
|
+
} = tableProps;
|
226
|
+
for (let r = 0; r < rows; r++) {
|
227
|
+
Transforms.setNodes(this.editor, {
|
228
|
+
...cellProps,
|
229
|
+
entireBgColor: cellProps?.entireBgColor
|
230
|
+
}, {
|
231
|
+
at: [currentCellPath[0], r, currentCellPath[2]]
|
232
|
+
});
|
233
|
+
}
|
234
|
+
}
|
226
235
|
}
|
227
236
|
} catch (err) {
|
228
237
|
console.log(err);
|
@@ -290,6 +299,61 @@ export class TableUtil {
|
|
290
299
|
return null;
|
291
300
|
}
|
292
301
|
};
|
302
|
+
isCellSelected = selection => {
|
303
|
+
try {
|
304
|
+
if (!selection || Range.isCollapsed(selection) || Editor.string(this.editor, selection) === "") {
|
305
|
+
return false;
|
306
|
+
}
|
307
|
+
const [tableNode] = Editor.nodes(this.editor, {
|
308
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
309
|
+
});
|
310
|
+
const [, tableCellPath] = Editor.nodes(this.editor, {
|
311
|
+
at: selection,
|
312
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
313
|
+
});
|
314
|
+
const {
|
315
|
+
anchor,
|
316
|
+
focus
|
317
|
+
} = this.editor.selection || {};
|
318
|
+
if (tableNode && tableNode[0] && tableCellPath && tableCellPath[1] && focus?.path) {
|
319
|
+
let startCell = anchor?.path;
|
320
|
+
let endCell = focus?.path;
|
321
|
+
|
322
|
+
// swap for reverse selection
|
323
|
+
if (startCell[1] > endCell[1]) {
|
324
|
+
startCell = focus?.path;
|
325
|
+
endCell = anchor?.path;
|
326
|
+
} else if (startCell[2] > endCell[2]) {
|
327
|
+
startCell = focus?.path;
|
328
|
+
endCell = anchor?.path;
|
329
|
+
}
|
330
|
+
const {
|
331
|
+
columns
|
332
|
+
} = tableNode[0];
|
333
|
+
const startPath = startCell[0];
|
334
|
+
const startRow = startCell[1];
|
335
|
+
let startCol = startCell[2];
|
336
|
+
const endRow = endCell[1];
|
337
|
+
const endCol = endCell[2];
|
338
|
+
const selectedCellsPath = [];
|
339
|
+
let uptoCol = startRow !== endRow ? columns - 1 : endCol;
|
340
|
+
for (let row = startRow; row <= endRow; row++) {
|
341
|
+
for (let col = startCol; col <= uptoCol; col++) {
|
342
|
+
let nextPath = [startPath, row, col];
|
343
|
+
selectedCellsPath.push(nextPath);
|
344
|
+
}
|
345
|
+
startCol = 0;
|
346
|
+
uptoCol = endCol;
|
347
|
+
}
|
348
|
+
return selectedCellsPath;
|
349
|
+
} else {
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
} catch (err) {
|
353
|
+
console.log(err);
|
354
|
+
return false;
|
355
|
+
}
|
356
|
+
};
|
293
357
|
}
|
294
358
|
const createRow = cellText => {
|
295
359
|
const newRow = Array.from(cellText, value => createTableCell(value));
|
@@ -312,13 +376,10 @@ export const createTableCell = text => {
|
|
312
376
|
const createTableNode = (cellText, rows, columns) => {
|
313
377
|
const tableChildren = Array.from(cellText, value => createRow(value));
|
314
378
|
let tableNode = {
|
315
|
-
type: "
|
316
|
-
children:
|
317
|
-
|
318
|
-
|
319
|
-
rows,
|
320
|
-
columns
|
321
|
-
}]
|
379
|
+
type: "table",
|
380
|
+
children: tableChildren,
|
381
|
+
rows,
|
382
|
+
columns
|
322
383
|
};
|
323
384
|
return tableNode;
|
324
385
|
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { Transforms } from "slate";
|
2
|
+
import insertNewLine from "./insertNewLine";
|
3
|
+
export const createTopBannerNode = ({
|
4
|
+
url,
|
5
|
+
alt
|
6
|
+
}) => ({
|
7
|
+
type: "topbanner",
|
8
|
+
alt,
|
9
|
+
url,
|
10
|
+
children: [{
|
11
|
+
text: " "
|
12
|
+
}],
|
13
|
+
size: {
|
14
|
+
widthInPercent: "100%",
|
15
|
+
height: "auto"
|
16
|
+
}
|
17
|
+
});
|
18
|
+
export const insertTopBanner = (editor, embedData) => {
|
19
|
+
try {
|
20
|
+
const {
|
21
|
+
url
|
22
|
+
} = embedData;
|
23
|
+
if (!url) return;
|
24
|
+
const embed = createTopBannerNode(embedData);
|
25
|
+
Transforms.insertNodes(editor, embed, {
|
26
|
+
at: [0]
|
27
|
+
});
|
28
|
+
insertNewLine(editor);
|
29
|
+
} catch (err) {
|
30
|
+
console.log(err);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
export const removeTopBanner = editor => {
|
34
|
+
try {
|
35
|
+
const isTopBanner = editor?.children[0]?.type === "topbanner";
|
36
|
+
if (isTopBanner) {
|
37
|
+
Transforms.removeNodes(editor, {
|
38
|
+
at: [0]
|
39
|
+
});
|
40
|
+
}
|
41
|
+
} catch (err) {
|
42
|
+
console.log(err);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
export const updateTopBanner = (editor, attr = {}) => {
|
46
|
+
try {
|
47
|
+
const isTopBanner = editor?.children[0]?.type === "topbanner";
|
48
|
+
if (isTopBanner) {
|
49
|
+
Transforms.setNodes(editor, {
|
50
|
+
...attr
|
51
|
+
}, {
|
52
|
+
at: [0]
|
53
|
+
});
|
54
|
+
}
|
55
|
+
} catch (err) {
|
56
|
+
console.log(err);
|
57
|
+
}
|
58
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "1.6.
|
3
|
+
"version": "1.6.2",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -9,6 +9,8 @@
|
|
9
9
|
"dependencies": {
|
10
10
|
"@dnd-kit/core": "^6.1.0",
|
11
11
|
"@dnd-kit/sortable": "^8.0.0",
|
12
|
+
"@emoji-mart/data": "^1.1.2",
|
13
|
+
"@emoji-mart/react": "^1.1.1",
|
12
14
|
"@emotion/react": "^11.11.1",
|
13
15
|
"@emotion/styled": "^11.11.0",
|
14
16
|
"@hocuspocus/provider": "^2.5.0",
|
@@ -20,6 +22,7 @@
|
|
20
22
|
"@testing-library/jest-dom": "^5.16.5",
|
21
23
|
"@testing-library/react": "^13.4.0",
|
22
24
|
"@testing-library/user-event": "^13.5.0",
|
25
|
+
"emoji-mart": "^5.5.2",
|
23
26
|
"html2canvas": "^1.4.1",
|
24
27
|
"husky": "^8.0.3",
|
25
28
|
"interweave": "^13.1.0",
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import React, { useRef, useEffect } from "react";
|
2
|
-
import { Transforms } from "slate";
|
3
|
-
import { ReactEditor } from "slate-react";
|
4
|
-
import { insertMention } from "../utils/mentions";
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
-
const MentionsPopup = props => {
|
7
|
-
const {
|
8
|
-
editor,
|
9
|
-
index,
|
10
|
-
target,
|
11
|
-
chars,
|
12
|
-
mentions,
|
13
|
-
setMentions
|
14
|
-
} = props;
|
15
|
-
const ref = useRef(null);
|
16
|
-
useEffect(() => {
|
17
|
-
if (target && chars.length > 0) {
|
18
|
-
const el = ref.current;
|
19
|
-
const domRange = ReactEditor.toDOMRange(editor, target);
|
20
|
-
const rect = domRange.getBoundingClientRect();
|
21
|
-
el.style.top = `${rect.top + window.scrollY + 24}px`;
|
22
|
-
el.style.left = `${rect.left + window.scrollX}px`;
|
23
|
-
}
|
24
|
-
}, [chars.length, editor, index, target]);
|
25
|
-
return target && chars.length > 0 ? /*#__PURE__*/_jsx("div", {
|
26
|
-
ref: ref,
|
27
|
-
style: {
|
28
|
-
top: "-9999px",
|
29
|
-
left: "-9999px",
|
30
|
-
position: "absolute",
|
31
|
-
zIndex: 1,
|
32
|
-
padding: "3px",
|
33
|
-
background: "white",
|
34
|
-
borderRadius: "4px",
|
35
|
-
boxShadow: "0 1px 5px rgba(0,0,0,.2)"
|
36
|
-
},
|
37
|
-
"data-cy": "mentions-portal",
|
38
|
-
children: chars.map((char, i) => /*#__PURE__*/_jsx("div", {
|
39
|
-
onClick: () => {
|
40
|
-
Transforms.select(editor, target);
|
41
|
-
insertMention(editor, char);
|
42
|
-
setMentions({
|
43
|
-
...mentions,
|
44
|
-
target: null
|
45
|
-
});
|
46
|
-
},
|
47
|
-
style: {
|
48
|
-
padding: "1px 3px",
|
49
|
-
borderRadius: "3px",
|
50
|
-
background: i === index ? "#B4D5FF" : "transparent"
|
51
|
-
},
|
52
|
-
children: char.name
|
53
|
-
}, char))
|
54
|
-
}) : null;
|
55
|
-
};
|
56
|
-
export default MentionsPopup;
|