@react-fabric/lexical 1.0.0-beta.9 → 1.0.2
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.
- package/{src/editor/Lexical.module.css → css/_lexical.css} +79 -13
- package/css/styles.css +24 -0
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +98 -45
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +147 -140
- package/dist/cjs/i18n/ar/lexical.json.js +30 -0
- package/dist/cjs/i18n/en/lexical.json.js +30 -0
- package/{src/plugins/StickyPlugin.ts → dist/cjs/i18n/index.js} +10 -15
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/plugins/CommentPlugin.js +481 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +17 -20
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +58 -37
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +101 -48
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +95 -88
- package/dist/esm/i18n/ar/lexical.json.js +25 -0
- package/dist/esm/i18n/en/lexical.json.js +25 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/plugins/CommentPlugin.js +481 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +15 -18
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +59 -38
- package/dist/types/editor/LexicalEditor.d.ts +33 -4
- package/dist/types/hooks/useFormatWatcher.d.ts +7 -4
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/plugins/CommentPlugin.d.ts +5 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -2
- package/dist/types/plugins/ToolbarPlugin.d.ts +1 -1
- package/dist/types/utils/index.d.ts +3 -6
- package/package.json +18 -18
- package/src/editor/LexicalEditor.tsx +95 -55
- package/src/hooks/useFormatWatcher.ts +50 -74
- package/src/i18n/ar/lexical.json +18 -0
- package/src/i18n/en/lexical.json +18 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +24 -17
- package/src/plugins/CommentPlugin.tsx +523 -0
- package/src/plugins/DraggableBlockPlugin.tsx +23 -68
- package/src/plugins/ToolbarPlugin.tsx +83 -131
- package/src/utils/index.ts +12 -108
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/editor/Lexical.module.css +0 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/cjs/packages/lexical/src/index.js +0 -7
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/editor/Lexical.module.css +0 -1
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/esm/packages/lexical/src/index.js +0 -3
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/types/components/StickyComponent.d.ts +0 -9
- package/dist/types/nodes/StickyNode.d.ts +0 -35
- package/dist/types/plugins/StickyPlugin.d.ts +0 -1
- package/src/components/StickyComponent.tsx +0 -271
- package/src/nodes/StickyNode.tsx +0 -249
- /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
- /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
4
4
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
5
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
6
|
+
var code = require('@lexical/code');
|
|
7
|
+
var link = require('@lexical/link');
|
|
8
|
+
var list = require('@lexical/list');
|
|
9
9
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
10
|
+
var richText = require('@lexical/rich-text');
|
|
11
|
+
var selection = require('@lexical/selection');
|
|
12
|
+
var table = require('@lexical/table');
|
|
13
|
+
var utils = require('@lexical/utils');
|
|
14
|
+
var utilities = require('@react-fabric/utilities');
|
|
14
15
|
var lexical = require('lexical');
|
|
15
16
|
var react = require('react');
|
|
16
17
|
|
|
@@ -28,25 +29,22 @@ var blockTypeToBlockName = {
|
|
|
28
29
|
paragraph: "Normal",
|
|
29
30
|
quote: "Quote"
|
|
30
31
|
};
|
|
31
|
-
function getSelectedNode(selection) {
|
|
32
|
-
var anchor = selection.anchor;
|
|
33
|
-
var focus = selection.focus;
|
|
34
|
-
var anchorNode = selection.anchor.getNode();
|
|
35
|
-
var focusNode = selection.focus.getNode();
|
|
32
|
+
function getSelectedNode(selection$1) {
|
|
33
|
+
var anchor = selection$1.anchor;
|
|
34
|
+
var focus = selection$1.focus;
|
|
35
|
+
var anchorNode = selection$1.anchor.getNode();
|
|
36
|
+
var focusNode = selection$1.focus.getNode();
|
|
36
37
|
if (anchorNode === focusNode) {
|
|
37
38
|
return anchorNode;
|
|
38
39
|
}
|
|
39
|
-
var isBackward = selection.isBackward();
|
|
40
|
+
var isBackward = selection$1.isBackward();
|
|
40
41
|
if (isBackward) {
|
|
41
|
-
return
|
|
42
|
+
return selection.$isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
42
43
|
} else {
|
|
43
|
-
return
|
|
44
|
+
return selection.$isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
var useFormatWatcher = function useFormatWatcher() {
|
|
47
|
-
var _useTransition = react.useTransition(),
|
|
48
|
-
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
49
|
-
startTransition = _useTransition2[1];
|
|
50
48
|
var _useLexicalComposerCo = LexicalComposerContext.useLexicalComposerContext(),
|
|
51
49
|
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
52
50
|
editor = _useLexicalComposerCo2[0];
|
|
@@ -54,20 +52,24 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
54
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
55
53
|
activeEditor = _useState2[0],
|
|
56
54
|
setActiveEditor = _useState2[1];
|
|
57
|
-
var _useState3 = react.useState(
|
|
55
|
+
var _useState3 = react.useState(),
|
|
58
56
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _useState5 = react.useState("
|
|
57
|
+
currentSelection = _useState4[0],
|
|
58
|
+
setCurrentSelection = _useState4[1];
|
|
59
|
+
var _useState5 = react.useState("paragraph"),
|
|
62
60
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _useState7 = react.useState(
|
|
61
|
+
blockType = _useState6[0],
|
|
62
|
+
setBlockType = _useState6[1];
|
|
63
|
+
var _useState7 = react.useState("root"),
|
|
66
64
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var _useState9 = react.useState(
|
|
70
|
-
|
|
65
|
+
rootType = _useState8[0],
|
|
66
|
+
setRootType = _useState8[1];
|
|
67
|
+
var _useState9 = react.useState(null),
|
|
68
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
69
|
+
selectedElementKey = _useState0[0],
|
|
70
|
+
setSelectedElementKey = _useState0[1];
|
|
71
|
+
var _useState1 = react.useState("16"),
|
|
72
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
71
73
|
fontSize = _useState10[0],
|
|
72
74
|
setFontSize = _useState10[1];
|
|
73
75
|
var _useState11 = react.useState("#000"),
|
|
@@ -82,65 +84,69 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
82
84
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
83
85
|
fontFamily = _useState16[0],
|
|
84
86
|
setFontFamily = _useState16[1];
|
|
85
|
-
var _useState17 = react.useState(
|
|
87
|
+
var _useState17 = react.useState(""),
|
|
86
88
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
align = _useState18[0],
|
|
90
|
+
setAlign = _useState18[1];
|
|
89
91
|
var _useState19 = react.useState(false),
|
|
90
92
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
isLink = _useState20[0],
|
|
94
|
+
setIsLink = _useState20[1];
|
|
93
95
|
var _useState21 = react.useState(false),
|
|
94
96
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
isBold = _useState22[0],
|
|
98
|
+
setIsBold = _useState22[1];
|
|
97
99
|
var _useState23 = react.useState(false),
|
|
98
100
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
isItalic = _useState24[0],
|
|
102
|
+
setIsItalic = _useState24[1];
|
|
101
103
|
var _useState25 = react.useState(false),
|
|
102
104
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
isUnderline = _useState26[0],
|
|
106
|
+
setIsUnderline = _useState26[1];
|
|
105
107
|
var _useState27 = react.useState(false),
|
|
106
108
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
isStrikethrough = _useState28[0],
|
|
110
|
+
setIsStrikethrough = _useState28[1];
|
|
109
111
|
var _useState29 = react.useState(false),
|
|
110
112
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
isSubscript = _useState30[0],
|
|
114
|
+
setIsSubscript = _useState30[1];
|
|
113
115
|
var _useState31 = react.useState(false),
|
|
114
116
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
isSuperscript = _useState32[0],
|
|
118
|
+
setIsSuperscript = _useState32[1];
|
|
117
119
|
var _useState33 = react.useState(false),
|
|
118
120
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
isCode = _useState34[0],
|
|
122
|
+
setIsCode = _useState34[1];
|
|
121
123
|
var _useState35 = react.useState(false),
|
|
122
124
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
canUndo = _useState36[0],
|
|
126
|
+
setCanUndo = _useState36[1];
|
|
125
127
|
var _useState37 = react.useState(false),
|
|
126
128
|
_useState38 = _slicedToArray(_useState37, 2),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var _useState39 = react.useState(
|
|
129
|
+
canRedo = _useState38[0],
|
|
130
|
+
setCanRedo = _useState38[1];
|
|
131
|
+
var _useState39 = react.useState(false),
|
|
130
132
|
_useState40 = _slicedToArray(_useState39, 2),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var _useState41 = react.useState(
|
|
133
|
+
isRTL = _useState40[0],
|
|
134
|
+
setIsRTL = _useState40[1];
|
|
135
|
+
var _useState41 = react.useState(""),
|
|
136
|
+
_useState42 = _slicedToArray(_useState41, 2),
|
|
137
|
+
codeLanguage = _useState42[0],
|
|
138
|
+
setCodeLanguage = _useState42[1];
|
|
139
|
+
var _useState43 = react.useState(function () {
|
|
134
140
|
return editor.isEditable();
|
|
135
141
|
}),
|
|
136
|
-
|
|
137
|
-
isEditable =
|
|
138
|
-
setIsEditable =
|
|
142
|
+
_useState44 = _slicedToArray(_useState43, 2),
|
|
143
|
+
isEditable = _useState44[0],
|
|
144
|
+
setIsEditable = _useState44[1];
|
|
139
145
|
var $updateToolbar = react.useCallback(function () {
|
|
140
|
-
var selection = lexical.$getSelection();
|
|
141
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
142
|
-
var anchorNode = selection.anchor.getNode();
|
|
143
|
-
var element = anchorNode.getKey() === "root" ? anchorNode :
|
|
146
|
+
var selection$1 = lexical.$getSelection();
|
|
147
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
148
|
+
var anchorNode = selection$1.anchor.getNode();
|
|
149
|
+
var element = anchorNode.getKey() === "root" ? anchorNode : utils.$findMatchingParent(anchorNode, function (e) {
|
|
144
150
|
var parent = e.getParent();
|
|
145
151
|
return parent !== null && lexical.$isRootOrShadowRoot(parent);
|
|
146
152
|
});
|
|
@@ -151,68 +157,76 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
151
157
|
var elementDOM = activeEditor.getElementByKey(elementKey);
|
|
152
158
|
|
|
153
159
|
// Update text format
|
|
154
|
-
setIsBold(selection.hasFormat("bold"));
|
|
155
|
-
setIsItalic(selection.hasFormat("italic"));
|
|
156
|
-
setIsUnderline(selection.hasFormat("underline"));
|
|
157
|
-
setIsStrikethrough(selection.hasFormat("strikethrough"));
|
|
158
|
-
setIsSubscript(selection.hasFormat("subscript"));
|
|
159
|
-
setIsSuperscript(selection.hasFormat("superscript"));
|
|
160
|
-
setIsCode(selection.hasFormat("code"));
|
|
161
|
-
|
|
160
|
+
setIsBold(selection$1.hasFormat("bold"));
|
|
161
|
+
setIsItalic(selection$1.hasFormat("italic"));
|
|
162
|
+
setIsUnderline(selection$1.hasFormat("underline"));
|
|
163
|
+
setIsStrikethrough(selection$1.hasFormat("strikethrough"));
|
|
164
|
+
setIsSubscript(selection$1.hasFormat("subscript"));
|
|
165
|
+
setIsSuperscript(selection$1.hasFormat("superscript"));
|
|
166
|
+
setIsCode(selection$1.hasFormat("code"));
|
|
167
|
+
editor.read(function () {
|
|
168
|
+
setIsRTL(selection.$isParentElementRTL(selection$1));
|
|
169
|
+
});
|
|
162
170
|
|
|
163
171
|
// Update links
|
|
164
|
-
var node = getSelectedNode(selection);
|
|
172
|
+
var node = getSelectedNode(selection$1);
|
|
165
173
|
var parent = node.getParent();
|
|
166
|
-
if (
|
|
174
|
+
if (link.$isLinkNode(parent) || link.$isLinkNode(node)) {
|
|
167
175
|
setIsLink(true);
|
|
168
176
|
} else {
|
|
169
177
|
setIsLink(false);
|
|
170
178
|
}
|
|
171
|
-
var tableNode =
|
|
172
|
-
if (
|
|
179
|
+
var tableNode = utils.$findMatchingParent(node, table.$isTableNode);
|
|
180
|
+
if (table.$isTableNode(tableNode)) {
|
|
173
181
|
setRootType("table");
|
|
174
182
|
} else {
|
|
175
183
|
setRootType("root");
|
|
176
184
|
}
|
|
177
185
|
if (elementDOM !== null) {
|
|
178
186
|
setSelectedElementKey(elementKey);
|
|
179
|
-
if (
|
|
180
|
-
|
|
187
|
+
if (elementDOM) setAlign(getComputedStyle(elementDOM).textAlign);
|
|
188
|
+
if (list.$isListNode(element)) {
|
|
189
|
+
var parentList = utils.$getNearestNodeOfType(anchorNode, list.ListNode);
|
|
181
190
|
var type = parentList ? parentList.getListType() : element.getListType();
|
|
182
191
|
setBlockType(type);
|
|
183
192
|
} else {
|
|
184
|
-
var _type =
|
|
193
|
+
var _type = richText.$isHeadingNode(element) ? element.getTag() : element.getType();
|
|
185
194
|
if (_type in blockTypeToBlockName) {
|
|
186
195
|
setBlockType(_type);
|
|
187
196
|
}
|
|
188
|
-
if (
|
|
197
|
+
if (code.$isCodeNode(element)) {
|
|
189
198
|
var language = element.getLanguage();
|
|
190
|
-
setCodeLanguage(language ?
|
|
199
|
+
setCodeLanguage(language ? code.CODE_LANGUAGE_MAP[language] || language : "");
|
|
191
200
|
return;
|
|
192
201
|
}
|
|
193
202
|
}
|
|
194
203
|
}
|
|
195
204
|
// Handle buttons
|
|
196
|
-
setFontSize(parseInt(
|
|
197
|
-
setFontColor(
|
|
198
|
-
|
|
199
|
-
|
|
205
|
+
setFontSize(parseInt(selection.$getSelectionStyleValueForProperty(selection$1, "font-size", "16")) + "");
|
|
206
|
+
setFontColor(selection.$getSelectionStyleValueForProperty(selection$1, "color",
|
|
207
|
+
// @ts-expect-error ignore
|
|
208
|
+
new String("#000")));
|
|
209
|
+
setBgColor(selection.$getSelectionStyleValueForProperty(selection$1, "background-color",
|
|
210
|
+
// @ts-expect-error ignore
|
|
211
|
+
new String("#fff")));
|
|
212
|
+
setFontFamily(selection.$getSelectionStyleValueForProperty(selection$1, "font-family", "inherit"));
|
|
200
213
|
}
|
|
201
|
-
}, [activeEditor]);
|
|
214
|
+
}, [activeEditor, editor]);
|
|
202
215
|
react.useEffect(function () {
|
|
203
|
-
return editor.registerCommand(lexical.
|
|
216
|
+
return editor.registerCommand(lexical.SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
|
|
204
217
|
setActiveEditor(newEditor);
|
|
218
|
+
setCurrentSelection(lexical.$getSelection());
|
|
219
|
+
$updateToolbar();
|
|
205
220
|
return false;
|
|
206
221
|
}, lexical.COMMAND_PRIORITY_CRITICAL);
|
|
207
|
-
}, [editor]);
|
|
222
|
+
}, [editor, $updateToolbar]);
|
|
208
223
|
react.useEffect(function () {
|
|
209
|
-
|
|
224
|
+
activeEditor.getEditorState().read(function () {
|
|
210
225
|
$updateToolbar();
|
|
211
|
-
|
|
212
|
-
}, lexical.COMMAND_PRIORITY_CRITICAL);
|
|
226
|
+
});
|
|
213
227
|
}, [activeEditor, $updateToolbar]);
|
|
214
228
|
react.useEffect(function () {
|
|
215
|
-
return
|
|
229
|
+
return utils.mergeRegister(editor.registerEditableListener(function (editable) {
|
|
216
230
|
setIsEditable(editable);
|
|
217
231
|
}), activeEditor.registerUpdateListener(function (_ref) {
|
|
218
232
|
var editorState = _ref.editorState;
|
|
@@ -228,62 +242,61 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
228
242
|
}, lexical.COMMAND_PRIORITY_CRITICAL));
|
|
229
243
|
}, [$updateToolbar, activeEditor, editor]);
|
|
230
244
|
var applyStyleText = react.useCallback(function (styles) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}, [editor]);
|
|
245
|
+
// activeEditor.focus();
|
|
246
|
+
activeEditor.update(function () {
|
|
247
|
+
if (!utilities.isNil(currentSelection)) {
|
|
248
|
+
lexical.$setSelection(currentSelection.clone());
|
|
249
|
+
selection.$patchStyleText(currentSelection, styles);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}, [activeEditor, currentSelection]);
|
|
240
253
|
var formatBulletList = function formatBulletList() {
|
|
241
254
|
setTimeout(function () {
|
|
242
255
|
if (blockType !== "bullet") {
|
|
243
|
-
editor.dispatchCommand(
|
|
256
|
+
editor.dispatchCommand(list.INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
244
257
|
} else {
|
|
245
|
-
editor.dispatchCommand(
|
|
258
|
+
editor.dispatchCommand(list.REMOVE_LIST_COMMAND, undefined);
|
|
246
259
|
}
|
|
247
260
|
}, 100);
|
|
248
261
|
};
|
|
249
262
|
var formatCheckList = function formatCheckList() {
|
|
250
263
|
setTimeout(function () {
|
|
251
264
|
if (blockType !== "check") {
|
|
252
|
-
editor.dispatchCommand(
|
|
265
|
+
editor.dispatchCommand(list.INSERT_CHECK_LIST_COMMAND, undefined);
|
|
253
266
|
} else {
|
|
254
|
-
editor.dispatchCommand(
|
|
267
|
+
editor.dispatchCommand(list.REMOVE_LIST_COMMAND, undefined);
|
|
255
268
|
}
|
|
256
269
|
}, 100);
|
|
257
270
|
};
|
|
258
271
|
var formatNumberedList = function formatNumberedList() {
|
|
259
272
|
setTimeout(function () {
|
|
260
273
|
if (blockType !== "number") {
|
|
261
|
-
editor.dispatchCommand(
|
|
274
|
+
editor.dispatchCommand(list.INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
262
275
|
} else {
|
|
263
|
-
editor.dispatchCommand(
|
|
276
|
+
editor.dispatchCommand(list.REMOVE_LIST_COMMAND, undefined);
|
|
264
277
|
}
|
|
265
278
|
}, 100);
|
|
266
279
|
};
|
|
267
280
|
var formatNormal = react.useCallback(function () {
|
|
268
281
|
setTimeout(function () {
|
|
269
282
|
activeEditor.update(function () {
|
|
270
|
-
var selection = lexical.$getSelection();
|
|
271
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
272
|
-
|
|
283
|
+
var selection$1 = lexical.$getSelection();
|
|
284
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
285
|
+
selection.$setBlocksType(selection$1, function () {
|
|
273
286
|
return lexical.$createParagraphNode();
|
|
274
287
|
});
|
|
275
288
|
}
|
|
276
289
|
});
|
|
277
290
|
}, 100);
|
|
278
|
-
}, [activeEditor
|
|
291
|
+
}, [activeEditor]);
|
|
279
292
|
var formatQuote = react.useCallback(function () {
|
|
280
293
|
if (blockType !== "quote") {
|
|
281
294
|
setTimeout(function () {
|
|
282
295
|
activeEditor.update(function () {
|
|
283
|
-
var selection = lexical.$getSelection();
|
|
284
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
285
|
-
|
|
286
|
-
return
|
|
296
|
+
var selection$1 = lexical.$getSelection();
|
|
297
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
298
|
+
selection.$setBlocksType(selection$1, function () {
|
|
299
|
+
return richText.$createQuoteNode();
|
|
287
300
|
});
|
|
288
301
|
}
|
|
289
302
|
});
|
|
@@ -294,10 +307,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
294
307
|
if (blockType !== "code") {
|
|
295
308
|
setTimeout(function () {
|
|
296
309
|
activeEditor.update(function () {
|
|
297
|
-
var selection = lexical.$getSelection();
|
|
298
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
299
|
-
|
|
300
|
-
return
|
|
310
|
+
var selection$1 = lexical.$getSelection();
|
|
311
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
312
|
+
selection.$setBlocksType(selection$1, function () {
|
|
313
|
+
return code.$createCodeNode();
|
|
301
314
|
});
|
|
302
315
|
}
|
|
303
316
|
});
|
|
@@ -308,10 +321,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
308
321
|
if (blockType !== headingSize) {
|
|
309
322
|
setTimeout(function () {
|
|
310
323
|
activeEditor.update(function () {
|
|
311
|
-
var selection = lexical.$getSelection();
|
|
312
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
313
|
-
|
|
314
|
-
return
|
|
324
|
+
var selection$1 = lexical.$getSelection();
|
|
325
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
326
|
+
selection.$setBlocksType(selection$1, function () {
|
|
327
|
+
return richText.$createHeadingNode(headingSize);
|
|
315
328
|
});
|
|
316
329
|
}
|
|
317
330
|
});
|
|
@@ -353,10 +366,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
353
366
|
}
|
|
354
367
|
if (node.__format !== 0) {
|
|
355
368
|
node.setFormat(0);
|
|
356
|
-
|
|
369
|
+
utils.$getNearestBlockElementAncestorOrThrow(node).setFormat("");
|
|
357
370
|
}
|
|
358
371
|
}
|
|
359
|
-
} else if (
|
|
372
|
+
} else if (richText.$isHeadingNode(node) || richText.$isQuoteNode(node)) {
|
|
360
373
|
node.replace(lexical.$createParagraphNode(), true);
|
|
361
374
|
}
|
|
362
375
|
});
|
|
@@ -364,45 +377,38 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
364
377
|
});
|
|
365
378
|
}, [activeEditor]);
|
|
366
379
|
var onSizeChange = react.useCallback(function (value) {
|
|
367
|
-
startTransition(function () {
|
|
368
|
-
return setFontColor(value);
|
|
369
|
-
});
|
|
370
380
|
applyStyleText({
|
|
371
381
|
"font-size": +value + "px"
|
|
372
382
|
});
|
|
373
383
|
}, [applyStyleText]);
|
|
374
|
-
var onFontColorSelect = react.useCallback(function (
|
|
375
|
-
|
|
376
|
-
return setFontColor(value);
|
|
377
|
-
});
|
|
384
|
+
var onFontColorSelect = react.useCallback(function () {
|
|
385
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#000000";
|
|
378
386
|
applyStyleText({
|
|
379
387
|
color: value
|
|
380
388
|
});
|
|
381
389
|
}, [applyStyleText]);
|
|
382
|
-
var onBgColorSelect = react.useCallback(function (
|
|
383
|
-
|
|
384
|
-
return setBgColor(value);
|
|
385
|
-
});
|
|
390
|
+
var onBgColorSelect = react.useCallback(function () {
|
|
391
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#ffffff";
|
|
386
392
|
applyStyleText({
|
|
387
393
|
"background-color": value
|
|
388
394
|
});
|
|
389
395
|
}, [applyStyleText]);
|
|
390
396
|
|
|
391
397
|
// @ts-expect-error ignore
|
|
392
|
-
window.$getSelection = /*#__PURE__*/_asyncToGenerator(
|
|
393
|
-
return _regeneratorRuntime.wrap(function
|
|
398
|
+
window.$getSelection = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
399
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
394
400
|
while (1) switch (_context.prev = _context.next) {
|
|
395
401
|
case 0:
|
|
396
|
-
_context.next =
|
|
402
|
+
_context.next = 1;
|
|
397
403
|
return new Promise(function (resolve) {
|
|
398
404
|
activeEditor.update(function () {
|
|
399
405
|
var selection = lexical.$getSelection();
|
|
400
406
|
resolve(selection);
|
|
401
407
|
});
|
|
402
408
|
});
|
|
403
|
-
case
|
|
409
|
+
case 1:
|
|
404
410
|
return _context.abrupt("return", _context.sent);
|
|
405
|
-
case
|
|
411
|
+
case 2:
|
|
406
412
|
case "end":
|
|
407
413
|
return _context.stop();
|
|
408
414
|
}
|
|
@@ -428,6 +434,7 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
428
434
|
canUndo: canUndo,
|
|
429
435
|
canRedo: canRedo,
|
|
430
436
|
isRTL: isRTL,
|
|
437
|
+
align: align,
|
|
431
438
|
isEditable: isEditable,
|
|
432
439
|
codeLanguage: codeLanguage,
|
|
433
440
|
activeEditor: activeEditor,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var addComment = "أضف تعليقا";
|
|
6
|
+
var reply = "رد";
|
|
7
|
+
var tool = {
|
|
8
|
+
alignCenter: "محاذاة المركز",
|
|
9
|
+
alignEnd: "محاذاة النهاية",
|
|
10
|
+
alignJustify: "محاذاة وضبط",
|
|
11
|
+
alignStart: "محاذاة البداية",
|
|
12
|
+
bold: "عريض",
|
|
13
|
+
clear: "مسح التنسيق",
|
|
14
|
+
hilight: "تسليط الضوء",
|
|
15
|
+
indentIn: "المسافة البادئة في",
|
|
16
|
+
indentOut: "مسافة بادئة للخارج",
|
|
17
|
+
italic: "مائل",
|
|
18
|
+
strikethrough: "يتوسطه خط",
|
|
19
|
+
underline: "تسطير"
|
|
20
|
+
};
|
|
21
|
+
var ar = {
|
|
22
|
+
addComment: addComment,
|
|
23
|
+
reply: reply,
|
|
24
|
+
tool: tool
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.addComment = addComment;
|
|
28
|
+
exports.default = ar;
|
|
29
|
+
exports.reply = reply;
|
|
30
|
+
exports.tool = tool;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tool = {
|
|
6
|
+
alignStart: "Align Start",
|
|
7
|
+
alignCenter: "Align Center",
|
|
8
|
+
alignEnd: "Align End",
|
|
9
|
+
alignJustify: "Align Justify",
|
|
10
|
+
bold: "Bold",
|
|
11
|
+
italic: "Italic",
|
|
12
|
+
underline: "Underline",
|
|
13
|
+
strikethrough: "Strikethrough",
|
|
14
|
+
indentOut: "Indent Out",
|
|
15
|
+
indentIn: "Indent In",
|
|
16
|
+
hilight: "Highlight",
|
|
17
|
+
clear: "Clear Formatting"
|
|
18
|
+
};
|
|
19
|
+
var addComment = "Add comment";
|
|
20
|
+
var reply = "Reply";
|
|
21
|
+
var en = {
|
|
22
|
+
tool: tool,
|
|
23
|
+
addComment: addComment,
|
|
24
|
+
reply: reply
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.addComment = addComment;
|
|
28
|
+
exports.default = en;
|
|
29
|
+
exports.reply = reply;
|
|
30
|
+
exports.tool = tool;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@react-fabric/core');
|
|
4
|
+
var lexical = require('./ar/lexical.json.js');
|
|
5
|
+
var lexical$1 = require('./en/lexical.json.js');
|
|
6
|
+
|
|
1
7
|
/*
|
|
2
8
|
* React Fabric
|
|
3
9
|
* @version: 1.0.0
|
|
@@ -21,18 +27,7 @@
|
|
|
21
27
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
28
|
*/
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import { StickyNode } from "../nodes/StickyNode";
|
|
29
|
-
|
|
30
|
-
export const StickyPlugin = (): JSX.Element | null => {
|
|
31
|
-
const [editor] = useLexicalComposerContext();
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (!editor.hasNodes([StickyNode])) {
|
|
34
|
-
throw new Error("StickyPlugin: StickyNode not registered on editor");
|
|
35
|
-
}
|
|
36
|
-
}, [editor]);
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
30
|
+
core.addTranslationBundle("lexical", {
|
|
31
|
+
en: lexical$1.default,
|
|
32
|
+
ar: lexical.default
|
|
33
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('./i18n/index.js');
|
|
4
|
+
var LexicalEditor = require('./editor/LexicalEditor.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* React Fabric
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
* @license MIT
|
|
10
|
+
* @copyright 2024 Adarsh Pastakia
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var LEXICAL_PACKAGE = "@react-fabric/lexical";
|
|
32
|
+
var LEXICAL_VERSION = "1.0.0";
|
|
33
|
+
|
|
34
|
+
exports.LexicalEditor = LexicalEditor.LexicalEditor;
|
|
35
|
+
exports.LEXICAL_PACKAGE = LEXICAL_PACKAGE;
|
|
36
|
+
exports.LEXICAL_VERSION = LEXICAL_VERSION;
|