@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.
Files changed (134) hide show
  1. package/{src/editor/Lexical.module.css → css/_lexical.css} +8 -4
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
  4. package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +35 -10
  5. package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +154 -145
  6. package/dist/cjs/i18n/ar.json.js +24 -0
  7. package/dist/cjs/i18n/en.json.js +24 -0
  8. package/dist/cjs/i18n/index.js +33 -0
  9. package/dist/cjs/{packages/lexical/src/index.js → index.js} +1 -0
  10. package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +5 -5
  11. package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +55 -34
  12. package/dist/esm/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
  13. package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +34 -9
  14. package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +102 -93
  15. package/dist/esm/i18n/ar.json.js +21 -0
  16. package/dist/esm/i18n/en.json.js +21 -0
  17. package/dist/esm/i18n/index.js +33 -0
  18. package/dist/esm/{packages/lexical/src/index.js → index.js} +1 -0
  19. package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +2 -2
  20. package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +56 -35
  21. package/dist/types/editor/LexicalEditor.d.ts +25 -0
  22. package/dist/types/hooks/useFormatWatcher.d.ts +3 -2
  23. package/dist/types/i18n/index.d.ts +1 -0
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/nodes/StickyNode.d.ts +0 -1
  26. package/package.json +14 -13
  27. package/src/components/StickyComponent.tsx +4 -5
  28. package/src/editor/LexicalEditor.tsx +57 -26
  29. package/src/hooks/useFormatWatcher.ts +38 -31
  30. package/src/i18n/ar.json +16 -0
  31. package/src/i18n/en.json +16 -0
  32. package/src/i18n/index.ts +28 -0
  33. package/src/index.ts +2 -0
  34. package/src/plugins/ToolbarPlugin.tsx +56 -35
  35. package/dist/cjs/_virtual/prism.js +0 -5
  36. package/dist/cjs/editor/Lexical.module.css +0 -1
  37. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
  38. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
  39. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
  40. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
  41. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
  42. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
  43. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
  44. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
  45. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
  46. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
  47. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
  48. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
  49. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
  50. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
  51. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
  52. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
  53. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
  54. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
  55. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
  56. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
  57. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
  58. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
  59. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
  60. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
  61. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
  62. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
  63. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
  64. package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
  65. package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
  66. package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
  67. package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
  68. package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
  69. package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
  70. package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
  71. package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
  72. package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
  73. package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
  74. package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
  75. package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
  76. package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
  77. package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
  78. package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
  79. package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
  80. package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
  81. package/dist/esm/_virtual/prism.js +0 -5
  82. package/dist/esm/editor/Lexical.module.css +0 -1
  83. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
  84. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
  85. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
  86. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
  87. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
  88. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
  89. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
  90. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
  91. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
  92. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
  93. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
  94. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
  95. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
  96. package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
  97. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
  98. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
  99. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
  100. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
  101. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
  102. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
  103. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
  104. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
  105. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
  106. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
  107. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
  108. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
  109. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
  110. package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
  111. package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
  112. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
  113. package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
  114. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
  115. package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
  116. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
  117. package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
  118. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
  119. package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
  120. package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
  121. package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
  122. package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
  123. package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
  124. package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
  125. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
  126. package/dist/esm/node_modules/prismjs/prism.js +0 -1951
  127. /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
  128. /package/dist/cjs/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
  129. /package/dist/cjs/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
  130. /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
  131. /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
  132. /package/dist/esm/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
  133. /package/dist/esm/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
  134. /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 LexicalCode = require('../../../../node_modules/@lexical/code/LexicalCode.js');
7
- var LexicalLink = require('../../../../node_modules/@lexical/link/LexicalLink.js');
8
- var LexicalList = require('../../../../node_modules/@lexical/list/LexicalList.js');
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 LexicalRichText = require('../../../../node_modules/@lexical/rich-text/LexicalRichText.js');
11
- var LexicalSelection = require('../../../../node_modules/@lexical/selection/LexicalSelection.js');
12
- var LexicalTable = require('../../../../node_modules/@lexical/table/LexicalTable.js');
13
- var LexicalUtils = require('../../../../node_modules/@lexical/utils/LexicalUtils.js');
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 LexicalSelection.$isAtNodeEnd(focus) ? anchorNode : focusNode;
42
+ return selection.$isAtNodeEnd(focus) ? anchorNode : focusNode;
42
43
  } else {
43
- return LexicalSelection.$isAtNodeEnd(anchor) ? anchorNode : focusNode;
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("paragraph"),
55
+ var _useState3 = react.useState(),
58
56
  _useState4 = _slicedToArray(_useState3, 2),
59
- blockType = _useState4[0],
60
- setBlockType = _useState4[1];
61
- var _useState5 = react.useState("root"),
57
+ currentSelection = _useState4[0],
58
+ setCurrentSelection = _useState4[1];
59
+ var _useState5 = react.useState("paragraph"),
62
60
  _useState6 = _slicedToArray(_useState5, 2),
63
- rootType = _useState6[0],
64
- setRootType = _useState6[1];
65
- var _useState7 = react.useState(null),
61
+ blockType = _useState6[0],
62
+ setBlockType = _useState6[1];
63
+ var _useState7 = react.useState("root"),
66
64
  _useState8 = _slicedToArray(_useState7, 2),
67
- selectedElementKey = _useState8[0],
68
- setSelectedElementKey = _useState8[1];
69
- var _useState9 = react.useState("16"),
65
+ rootType = _useState8[0],
66
+ setRootType = _useState8[1];
67
+ var _useState9 = react.useState(null),
70
68
  _useState10 = _slicedToArray(_useState9, 2),
71
- fontSize = _useState10[0],
72
- setFontSize = _useState10[1];
73
- var _useState11 = react.useState("#000"),
69
+ selectedElementKey = _useState10[0],
70
+ setSelectedElementKey = _useState10[1];
71
+ var _useState11 = react.useState("16"),
74
72
  _useState12 = _slicedToArray(_useState11, 2),
75
- fontColor = _useState12[0],
76
- setFontColor = _useState12[1];
77
- var _useState13 = react.useState("#fff"),
73
+ fontSize = _useState12[0],
74
+ setFontSize = _useState12[1];
75
+ var _useState13 = react.useState("#000"),
78
76
  _useState14 = _slicedToArray(_useState13, 2),
79
- bgColor = _useState14[0],
80
- setBgColor = _useState14[1];
81
- var _useState15 = react.useState("Arial"),
77
+ fontColor = _useState14[0],
78
+ setFontColor = _useState14[1];
79
+ var _useState15 = react.useState("#fff"),
82
80
  _useState16 = _slicedToArray(_useState15, 2),
83
- fontFamily = _useState16[0],
84
- setFontFamily = _useState16[1];
85
- var _useState17 = react.useState(false),
81
+ bgColor = _useState16[0],
82
+ setBgColor = _useState16[1];
83
+ var _useState17 = react.useState("Arial"),
86
84
  _useState18 = _slicedToArray(_useState17, 2),
87
- isLink = _useState18[0],
88
- setIsLink = _useState18[1];
89
- var _useState19 = react.useState(false),
85
+ fontFamily = _useState18[0],
86
+ setFontFamily = _useState18[1];
87
+ var _useState19 = react.useState(""),
90
88
  _useState20 = _slicedToArray(_useState19, 2),
91
- isBold = _useState20[0],
92
- setIsBold = _useState20[1];
89
+ align = _useState20[0],
90
+ setAlign = _useState20[1];
93
91
  var _useState21 = react.useState(false),
94
92
  _useState22 = _slicedToArray(_useState21, 2),
95
- isItalic = _useState22[0],
96
- setIsItalic = _useState22[1];
93
+ isLink = _useState22[0],
94
+ setIsLink = _useState22[1];
97
95
  var _useState23 = react.useState(false),
98
96
  _useState24 = _slicedToArray(_useState23, 2),
99
- isUnderline = _useState24[0],
100
- setIsUnderline = _useState24[1];
97
+ isBold = _useState24[0],
98
+ setIsBold = _useState24[1];
101
99
  var _useState25 = react.useState(false),
102
100
  _useState26 = _slicedToArray(_useState25, 2),
103
- isStrikethrough = _useState26[0],
104
- setIsStrikethrough = _useState26[1];
101
+ isItalic = _useState26[0],
102
+ setIsItalic = _useState26[1];
105
103
  var _useState27 = react.useState(false),
106
104
  _useState28 = _slicedToArray(_useState27, 2),
107
- isSubscript = _useState28[0],
108
- setIsSubscript = _useState28[1];
105
+ isUnderline = _useState28[0],
106
+ setIsUnderline = _useState28[1];
109
107
  var _useState29 = react.useState(false),
110
108
  _useState30 = _slicedToArray(_useState29, 2),
111
- isSuperscript = _useState30[0],
112
- setIsSuperscript = _useState30[1];
109
+ isStrikethrough = _useState30[0],
110
+ setIsStrikethrough = _useState30[1];
113
111
  var _useState31 = react.useState(false),
114
112
  _useState32 = _slicedToArray(_useState31, 2),
115
- isCode = _useState32[0],
116
- setIsCode = _useState32[1];
113
+ isSubscript = _useState32[0],
114
+ setIsSubscript = _useState32[1];
117
115
  var _useState33 = react.useState(false),
118
116
  _useState34 = _slicedToArray(_useState33, 2),
119
- canUndo = _useState34[0],
120
- setCanUndo = _useState34[1];
117
+ isSuperscript = _useState34[0],
118
+ setIsSuperscript = _useState34[1];
121
119
  var _useState35 = react.useState(false),
122
120
  _useState36 = _slicedToArray(_useState35, 2),
123
- canRedo = _useState36[0],
124
- setCanRedo = _useState36[1];
121
+ isCode = _useState36[0],
122
+ setIsCode = _useState36[1];
125
123
  var _useState37 = react.useState(false),
126
124
  _useState38 = _slicedToArray(_useState37, 2),
127
- isRTL = _useState38[0],
128
- setIsRTL = _useState38[1];
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
- codeLanguage = _useState40[0],
132
- setCodeLanguage = _useState40[1];
133
- var _useState41 = react.useState(function () {
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
- _useState42 = _slicedToArray(_useState41, 2),
137
- isEditable = _useState42[0],
138
- setIsEditable = _useState42[1];
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 : LexicalUtils.$findMatchingParent(anchorNode, function (e) {
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
- setIsRTL(LexicalSelection.$isParentElementRTL(selection));
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 (LexicalLink.$isLinkNode(parent) || LexicalLink.$isLinkNode(node)) {
174
+ if (link.$isLinkNode(parent) || link.$isLinkNode(node)) {
167
175
  setIsLink(true);
168
176
  } else {
169
177
  setIsLink(false);
170
178
  }
171
- var tableNode = LexicalUtils.$findMatchingParent(node, LexicalTable.$isTableNode);
172
- if (LexicalTable.$isTableNode(tableNode)) {
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 (LexicalList.$isListNode(element)) {
180
- var parentList = LexicalUtils.$getNearestNodeOfType(anchorNode, LexicalList.ListNode);
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 = LexicalRichText.$isHeadingNode(element) ? element.getTag() : element.getType();
193
+ var _type = richText.$isHeadingNode(element) ? element.getTag() : element.getType();
185
194
  if (_type in blockTypeToBlockName) {
186
195
  setBlockType(_type);
187
196
  }
188
- if (LexicalCode.$isCodeNode(element)) {
197
+ if (code.$isCodeNode(element)) {
189
198
  var language = element.getLanguage();
190
- setCodeLanguage(language ? LexicalCode.CODE_LANGUAGE_MAP[language] || 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(LexicalSelection.$getSelectionStyleValueForProperty(selection, "font-size", "16")) + "");
197
- setFontColor(LexicalSelection.$getSelectionStyleValueForProperty(selection, "color", "#000"));
198
- setBgColor(LexicalSelection.$getSelectionStyleValueForProperty(selection, "background-color", "#fff"));
199
- setFontFamily(LexicalSelection.$getSelectionStyleValueForProperty(selection, "font-family", "inherit"));
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
- }, [activeEditor]);
216
+ }, []);
202
217
  react.useEffect(function () {
203
- return editor.registerCommand(lexical.FOCUS_COMMAND, function (_payload, newEditor) {
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
- return activeEditor.registerCommand(lexical.SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
226
+ activeEditor.getEditorState().read(function () {
210
227
  $updateToolbar();
211
- return false;
212
- }, lexical.COMMAND_PRIORITY_CRITICAL);
228
+ });
213
229
  }, [activeEditor, $updateToolbar]);
214
230
  react.useEffect(function () {
215
- return LexicalUtils.mergeRegister(editor.registerEditableListener(function (editable) {
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
- setTimeout(function () {
232
- editor.update(function () {
233
- var selection = lexical.$getSelection();
234
- if (lexical.$isRangeSelection(selection)) {
235
- LexicalSelection.$patchStyleText(selection, styles);
236
- }
237
- });
238
- }, 100);
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(LexicalList.INSERT_UNORDERED_LIST_COMMAND, undefined);
258
+ editor.dispatchCommand(list.INSERT_UNORDERED_LIST_COMMAND, undefined);
244
259
  } else {
245
- editor.dispatchCommand(LexicalList.REMOVE_LIST_COMMAND, undefined);
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(LexicalList.INSERT_CHECK_LIST_COMMAND, undefined);
267
+ editor.dispatchCommand(list.INSERT_CHECK_LIST_COMMAND, undefined);
253
268
  } else {
254
- editor.dispatchCommand(LexicalList.REMOVE_LIST_COMMAND, undefined);
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(LexicalList.INSERT_ORDERED_LIST_COMMAND, undefined);
276
+ editor.dispatchCommand(list.INSERT_ORDERED_LIST_COMMAND, undefined);
262
277
  } else {
263
- editor.dispatchCommand(LexicalList.REMOVE_LIST_COMMAND, undefined);
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
- LexicalSelection.$setBlocksType(selection, function () {
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
- LexicalSelection.$setBlocksType(selection, function () {
286
- return LexicalRichText.$createQuoteNode();
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
- LexicalSelection.$setBlocksType(selection, function () {
300
- return LexicalCode.$createCodeNode();
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
- LexicalSelection.$setBlocksType(selection, function () {
314
- return LexicalRichText.$createHeadingNode(headingSize);
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
- LexicalUtils.$getNearestBlockElementAncestorOrThrow(node).setFormat("");
371
+ utils.$getNearestBlockElementAncestorOrThrow(node).setFormat("");
357
372
  }
358
373
  }
359
- } else if (LexicalRichText.$isHeadingNode(node) || LexicalRichText.$isQuoteNode(node)) {
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 (value) {
375
- startTransition(function () {
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 (value) {
383
- startTransition(function () {
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
+ });
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ require('./i18n/index.js');
3
4
  var LexicalEditor = require('./editor/LexicalEditor.js');
4
5
 
5
6
 
@@ -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 LexicalRichText = require('../../../../node_modules/@lexical/rich-text/LexicalRichText.js');
6
- var LexicalUtils = require('../../../../node_modules/@lexical/utils/LexicalUtils.js');
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 = LexicalRichText.eventFiles(event),
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 = LexicalRichText.eventFiles(event),
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 LexicalUtils.mergeRegister(editor.registerCommand(lexical.DRAGOVER_COMMAND, function (event) {
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);