@react-fabric/lexical 1.0.0-beta.6 → 1.0.0-beta.61
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} +8 -4
- package/css/styles.css +24 -0
- package/dist/cjs/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +35 -10
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +154 -145
- package/dist/cjs/i18n/ar.json.js +24 -0
- package/dist/cjs/i18n/en.json.js +24 -0
- package/dist/cjs/i18n/index.js +33 -0
- package/dist/cjs/{packages/lexical/src/index.js → index.js} +1 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +5 -5
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +55 -34
- package/dist/esm/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +34 -9
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +102 -93
- package/dist/esm/i18n/ar.json.js +21 -0
- package/dist/esm/i18n/en.json.js +21 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/{packages/lexical/src/index.js → index.js} +1 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +2 -2
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +56 -35
- package/dist/types/editor/LexicalEditor.d.ts +25 -0
- package/dist/types/hooks/useFormatWatcher.d.ts +3 -2
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/nodes/StickyNode.d.ts +0 -1
- package/package.json +14 -13
- package/src/components/StickyComponent.tsx +4 -5
- package/src/editor/LexicalEditor.tsx +57 -26
- package/src/hooks/useFormatWatcher.ts +38 -31
- package/src/i18n/ar.json +16 -0
- package/src/i18n/en.json +16 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +2 -0
- package/src/plugins/ToolbarPlugin.tsx +56 -35
- 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/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/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/cjs/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
- /package/dist/cjs/{packages/lexical/src/plugins → plugins}/StickyPlugin.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/nodes → nodes}/StickyNode.js +0 -0
- /package/dist/esm/{packages/lexical/src/plugins → plugins}/StickyPlugin.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,93 +52,101 @@ 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(
|
|
65
|
+
rootType = _useState8[0],
|
|
66
|
+
setRootType = _useState8[1];
|
|
67
|
+
var _useState9 = react.useState(null),
|
|
70
68
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var _useState11 = react.useState("
|
|
69
|
+
selectedElementKey = _useState10[0],
|
|
70
|
+
setSelectedElementKey = _useState10[1];
|
|
71
|
+
var _useState11 = react.useState("16"),
|
|
74
72
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var _useState13 = react.useState("#
|
|
73
|
+
fontSize = _useState12[0],
|
|
74
|
+
setFontSize = _useState12[1];
|
|
75
|
+
var _useState13 = react.useState("#000"),
|
|
78
76
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var _useState15 = react.useState("
|
|
77
|
+
fontColor = _useState14[0],
|
|
78
|
+
setFontColor = _useState14[1];
|
|
79
|
+
var _useState15 = react.useState("#fff"),
|
|
82
80
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var _useState17 = react.useState(
|
|
81
|
+
bgColor = _useState16[0],
|
|
82
|
+
setBgColor = _useState16[1];
|
|
83
|
+
var _useState17 = react.useState("Arial"),
|
|
86
84
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _useState19 = react.useState(
|
|
85
|
+
fontFamily = _useState18[0],
|
|
86
|
+
setFontFamily = _useState18[1];
|
|
87
|
+
var _useState19 = react.useState(""),
|
|
90
88
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
align = _useState20[0],
|
|
90
|
+
setAlign = _useState20[1];
|
|
93
91
|
var _useState21 = react.useState(false),
|
|
94
92
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
isLink = _useState22[0],
|
|
94
|
+
setIsLink = _useState22[1];
|
|
97
95
|
var _useState23 = react.useState(false),
|
|
98
96
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
isBold = _useState24[0],
|
|
98
|
+
setIsBold = _useState24[1];
|
|
101
99
|
var _useState25 = react.useState(false),
|
|
102
100
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
isItalic = _useState26[0],
|
|
102
|
+
setIsItalic = _useState26[1];
|
|
105
103
|
var _useState27 = react.useState(false),
|
|
106
104
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
isUnderline = _useState28[0],
|
|
106
|
+
setIsUnderline = _useState28[1];
|
|
109
107
|
var _useState29 = react.useState(false),
|
|
110
108
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
isStrikethrough = _useState30[0],
|
|
110
|
+
setIsStrikethrough = _useState30[1];
|
|
113
111
|
var _useState31 = react.useState(false),
|
|
114
112
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
isSubscript = _useState32[0],
|
|
114
|
+
setIsSubscript = _useState32[1];
|
|
117
115
|
var _useState33 = react.useState(false),
|
|
118
116
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
isSuperscript = _useState34[0],
|
|
118
|
+
setIsSuperscript = _useState34[1];
|
|
121
119
|
var _useState35 = react.useState(false),
|
|
122
120
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
isCode = _useState36[0],
|
|
122
|
+
setIsCode = _useState36[1];
|
|
125
123
|
var _useState37 = react.useState(false),
|
|
126
124
|
_useState38 = _slicedToArray(_useState37, 2),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var _useState39 = react.useState(
|
|
125
|
+
canUndo = _useState38[0],
|
|
126
|
+
setCanUndo = _useState38[1];
|
|
127
|
+
var _useState39 = react.useState(false),
|
|
130
128
|
_useState40 = _slicedToArray(_useState39, 2),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var _useState41 = react.useState(
|
|
129
|
+
canRedo = _useState40[0],
|
|
130
|
+
setCanRedo = _useState40[1];
|
|
131
|
+
var _useState41 = react.useState(false),
|
|
132
|
+
_useState42 = _slicedToArray(_useState41, 2),
|
|
133
|
+
isRTL = _useState42[0],
|
|
134
|
+
setIsRTL = _useState42[1];
|
|
135
|
+
var _useState43 = react.useState(""),
|
|
136
|
+
_useState44 = _slicedToArray(_useState43, 2),
|
|
137
|
+
codeLanguage = _useState44[0],
|
|
138
|
+
setCodeLanguage = _useState44[1];
|
|
139
|
+
var _useState45 = react.useState(function () {
|
|
134
140
|
return editor.isEditable();
|
|
135
141
|
}),
|
|
136
|
-
|
|
137
|
-
isEditable =
|
|
138
|
-
setIsEditable =
|
|
142
|
+
_useState46 = _slicedToArray(_useState45, 2),
|
|
143
|
+
isEditable = _useState46[0],
|
|
144
|
+
setIsEditable = _useState46[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,78 @@ 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
|
-
|
|
180
|
-
|
|
187
|
+
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
|
+
// eslint-disable-next-line no-new-wrappers
|
|
209
|
+
new String("#000")));
|
|
210
|
+
setBgColor(selection.$getSelectionStyleValueForProperty(selection$1, "background-color",
|
|
211
|
+
// @ts-expect-error ignore
|
|
212
|
+
// eslint-disable-next-line no-new-wrappers
|
|
213
|
+
new String("#fff")));
|
|
214
|
+
setFontFamily(selection.$getSelectionStyleValueForProperty(selection$1, "font-family", "inherit"));
|
|
200
215
|
}
|
|
201
|
-
}, [
|
|
216
|
+
}, []);
|
|
202
217
|
react.useEffect(function () {
|
|
203
|
-
return editor.registerCommand(lexical.
|
|
218
|
+
return editor.registerCommand(lexical.SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
|
|
204
219
|
setActiveEditor(newEditor);
|
|
220
|
+
setCurrentSelection(lexical.$getSelection());
|
|
221
|
+
$updateToolbar();
|
|
205
222
|
return false;
|
|
206
223
|
}, lexical.COMMAND_PRIORITY_CRITICAL);
|
|
207
|
-
}, [editor]);
|
|
224
|
+
}, [editor, $updateToolbar]);
|
|
208
225
|
react.useEffect(function () {
|
|
209
|
-
|
|
226
|
+
activeEditor.getEditorState().read(function () {
|
|
210
227
|
$updateToolbar();
|
|
211
|
-
|
|
212
|
-
}, lexical.COMMAND_PRIORITY_CRITICAL);
|
|
228
|
+
});
|
|
213
229
|
}, [activeEditor, $updateToolbar]);
|
|
214
230
|
react.useEffect(function () {
|
|
215
|
-
return
|
|
231
|
+
return utils.mergeRegister(editor.registerEditableListener(function (editable) {
|
|
216
232
|
setIsEditable(editable);
|
|
217
233
|
}), activeEditor.registerUpdateListener(function (_ref) {
|
|
218
234
|
var editorState = _ref.editorState;
|
|
@@ -228,48 +244,47 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
228
244
|
}, lexical.COMMAND_PRIORITY_CRITICAL));
|
|
229
245
|
}, [$updateToolbar, activeEditor, editor]);
|
|
230
246
|
var applyStyleText = react.useCallback(function (styles) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}, [editor]);
|
|
247
|
+
// activeEditor.focus();
|
|
248
|
+
activeEditor.update(function () {
|
|
249
|
+
if (!utilities.isNil(currentSelection)) {
|
|
250
|
+
lexical.$setSelection(currentSelection.clone());
|
|
251
|
+
selection.$patchStyleText(currentSelection, styles);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}, [activeEditor, currentSelection]);
|
|
240
255
|
var formatBulletList = function formatBulletList() {
|
|
241
256
|
setTimeout(function () {
|
|
242
257
|
if (blockType !== "bullet") {
|
|
243
|
-
editor.dispatchCommand(
|
|
258
|
+
editor.dispatchCommand(list.INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
244
259
|
} else {
|
|
245
|
-
editor.dispatchCommand(
|
|
260
|
+
editor.dispatchCommand(list.REMOVE_LIST_COMMAND, undefined);
|
|
246
261
|
}
|
|
247
262
|
}, 100);
|
|
248
263
|
};
|
|
249
264
|
var formatCheckList = function formatCheckList() {
|
|
250
265
|
setTimeout(function () {
|
|
251
266
|
if (blockType !== "check") {
|
|
252
|
-
editor.dispatchCommand(
|
|
267
|
+
editor.dispatchCommand(list.INSERT_CHECK_LIST_COMMAND, undefined);
|
|
253
268
|
} else {
|
|
254
|
-
editor.dispatchCommand(
|
|
269
|
+
editor.dispatchCommand(list.REMOVE_LIST_COMMAND, undefined);
|
|
255
270
|
}
|
|
256
271
|
}, 100);
|
|
257
272
|
};
|
|
258
273
|
var formatNumberedList = function formatNumberedList() {
|
|
259
274
|
setTimeout(function () {
|
|
260
275
|
if (blockType !== "number") {
|
|
261
|
-
editor.dispatchCommand(
|
|
276
|
+
editor.dispatchCommand(list.INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
262
277
|
} else {
|
|
263
|
-
editor.dispatchCommand(
|
|
278
|
+
editor.dispatchCommand(list.REMOVE_LIST_COMMAND, undefined);
|
|
264
279
|
}
|
|
265
280
|
}, 100);
|
|
266
281
|
};
|
|
267
282
|
var formatNormal = react.useCallback(function () {
|
|
268
283
|
setTimeout(function () {
|
|
269
284
|
activeEditor.update(function () {
|
|
270
|
-
var selection = lexical.$getSelection();
|
|
271
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
272
|
-
|
|
285
|
+
var selection$1 = lexical.$getSelection();
|
|
286
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
287
|
+
selection.$setBlocksType(selection$1, function () {
|
|
273
288
|
return lexical.$createParagraphNode();
|
|
274
289
|
});
|
|
275
290
|
}
|
|
@@ -280,10 +295,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
280
295
|
if (blockType !== "quote") {
|
|
281
296
|
setTimeout(function () {
|
|
282
297
|
activeEditor.update(function () {
|
|
283
|
-
var selection = lexical.$getSelection();
|
|
284
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
285
|
-
|
|
286
|
-
return
|
|
298
|
+
var selection$1 = lexical.$getSelection();
|
|
299
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
300
|
+
selection.$setBlocksType(selection$1, function () {
|
|
301
|
+
return richText.$createQuoteNode();
|
|
287
302
|
});
|
|
288
303
|
}
|
|
289
304
|
});
|
|
@@ -294,10 +309,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
294
309
|
if (blockType !== "code") {
|
|
295
310
|
setTimeout(function () {
|
|
296
311
|
activeEditor.update(function () {
|
|
297
|
-
var selection = lexical.$getSelection();
|
|
298
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
299
|
-
|
|
300
|
-
return
|
|
312
|
+
var selection$1 = lexical.$getSelection();
|
|
313
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
314
|
+
selection.$setBlocksType(selection$1, function () {
|
|
315
|
+
return code.$createCodeNode();
|
|
301
316
|
});
|
|
302
317
|
}
|
|
303
318
|
});
|
|
@@ -308,10 +323,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
308
323
|
if (blockType !== headingSize) {
|
|
309
324
|
setTimeout(function () {
|
|
310
325
|
activeEditor.update(function () {
|
|
311
|
-
var selection = lexical.$getSelection();
|
|
312
|
-
if (lexical.$isRangeSelection(selection)) {
|
|
313
|
-
|
|
314
|
-
return
|
|
326
|
+
var selection$1 = lexical.$getSelection();
|
|
327
|
+
if (lexical.$isRangeSelection(selection$1)) {
|
|
328
|
+
selection.$setBlocksType(selection$1, function () {
|
|
329
|
+
return richText.$createHeadingNode(headingSize);
|
|
315
330
|
});
|
|
316
331
|
}
|
|
317
332
|
});
|
|
@@ -353,10 +368,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
353
368
|
}
|
|
354
369
|
if (node.__format !== 0) {
|
|
355
370
|
node.setFormat(0);
|
|
356
|
-
|
|
371
|
+
utils.$getNearestBlockElementAncestorOrThrow(node).setFormat("");
|
|
357
372
|
}
|
|
358
373
|
}
|
|
359
|
-
} else if (
|
|
374
|
+
} else if (richText.$isHeadingNode(node) || richText.$isQuoteNode(node)) {
|
|
360
375
|
node.replace(lexical.$createParagraphNode(), true);
|
|
361
376
|
}
|
|
362
377
|
});
|
|
@@ -364,25 +379,18 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
364
379
|
});
|
|
365
380
|
}, [activeEditor]);
|
|
366
381
|
var onSizeChange = react.useCallback(function (value) {
|
|
367
|
-
startTransition(function () {
|
|
368
|
-
return setFontColor(value);
|
|
369
|
-
});
|
|
370
382
|
applyStyleText({
|
|
371
383
|
"font-size": +value + "px"
|
|
372
384
|
});
|
|
373
385
|
}, [applyStyleText]);
|
|
374
|
-
var onFontColorSelect = react.useCallback(function (
|
|
375
|
-
|
|
376
|
-
return setFontColor(value);
|
|
377
|
-
});
|
|
386
|
+
var onFontColorSelect = react.useCallback(function () {
|
|
387
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#000000";
|
|
378
388
|
applyStyleText({
|
|
379
389
|
color: value
|
|
380
390
|
});
|
|
381
391
|
}, [applyStyleText]);
|
|
382
|
-
var onBgColorSelect = react.useCallback(function (
|
|
383
|
-
|
|
384
|
-
return setBgColor(value);
|
|
385
|
-
});
|
|
392
|
+
var onBgColorSelect = react.useCallback(function () {
|
|
393
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#ffffff";
|
|
386
394
|
applyStyleText({
|
|
387
395
|
"background-color": value
|
|
388
396
|
});
|
|
@@ -428,6 +436,7 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
428
436
|
canUndo: canUndo,
|
|
429
437
|
canRedo: canRedo,
|
|
430
438
|
isRTL: isRTL,
|
|
439
|
+
align: align,
|
|
431
440
|
isEditable: isEditable,
|
|
432
441
|
codeLanguage: codeLanguage,
|
|
433
442
|
activeEditor: activeEditor,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tool = {
|
|
6
|
+
alignCenter: "محاذاة المركز",
|
|
7
|
+
alignJustify: "محاذاة وضبط",
|
|
8
|
+
alignEnd: "محاذاة النهاية",
|
|
9
|
+
alignStart: "محاذاة البداية",
|
|
10
|
+
bold: "عريض",
|
|
11
|
+
clear: "مسح التنسيق",
|
|
12
|
+
hilight: "تسليط الضوء",
|
|
13
|
+
indentIn: "المسافة البادئة في",
|
|
14
|
+
underline: "تسطير",
|
|
15
|
+
strikethrough: "يتوسطه خط",
|
|
16
|
+
italic: "مائل",
|
|
17
|
+
indentOut: "مسافة بادئة للخارج"
|
|
18
|
+
};
|
|
19
|
+
var ar = {
|
|
20
|
+
tool: tool
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.default = ar;
|
|
24
|
+
exports.tool = tool;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 en = {
|
|
20
|
+
tool: tool
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.default = en;
|
|
24
|
+
exports.tool = tool;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@react-fabric/core');
|
|
4
|
+
var ar = require('./ar.json.js');
|
|
5
|
+
var en = require('./en.json.js');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* React Fabric
|
|
9
|
+
* @version: 1.0.0
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* The MIT License (MIT)
|
|
13
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
16
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
17
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
18
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
+
* subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
22
|
+
* portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
25
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
26
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
27
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
core.addTranslationBundle("lexical", {
|
|
31
|
+
en: en.default,
|
|
32
|
+
ar: ar.default
|
|
33
|
+
});
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
4
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var richText = require('@lexical/rich-text');
|
|
6
|
+
var utils = require('@lexical/utils');
|
|
7
7
|
var lexical = require('lexical');
|
|
8
8
|
var react = require('react');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
@@ -184,7 +184,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
184
184
|
if (!isDraggingBlockRef.current) {
|
|
185
185
|
return false;
|
|
186
186
|
}
|
|
187
|
-
var _eventFiles =
|
|
187
|
+
var _eventFiles = richText.eventFiles(event),
|
|
188
188
|
_eventFiles2 = _slicedToArray(_eventFiles, 1),
|
|
189
189
|
isFileTransfer = _eventFiles2[0];
|
|
190
190
|
if (isFileTransfer) {
|
|
@@ -210,7 +210,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
210
210
|
if (!isDraggingBlockRef.current) {
|
|
211
211
|
return false;
|
|
212
212
|
}
|
|
213
|
-
var _eventFiles3 =
|
|
213
|
+
var _eventFiles3 = richText.eventFiles(event),
|
|
214
214
|
_eventFiles4 = _slicedToArray(_eventFiles3, 1),
|
|
215
215
|
isFileTransfer = _eventFiles4[0];
|
|
216
216
|
if (isFileTransfer) {
|
|
@@ -250,7 +250,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
250
250
|
setDraggableBlockElem(null);
|
|
251
251
|
return true;
|
|
252
252
|
}
|
|
253
|
-
return
|
|
253
|
+
return utils.mergeRegister(editor.registerCommand(lexical.DRAGOVER_COMMAND, function (event) {
|
|
254
254
|
return onDragover(event);
|
|
255
255
|
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.DROP_COMMAND, function (event) {
|
|
256
256
|
return onDrop(event);
|