@react-fabric/lexical 1.0.0-beta.9 → 1.0.1

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 (148) hide show
  1. package/{src/editor/Lexical.module.css → css/_lexical.css} +79 -13
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +98 -45
  4. package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +147 -140
  5. package/dist/cjs/i18n/ar/lexical.json.js +30 -0
  6. package/dist/cjs/i18n/en/lexical.json.js +30 -0
  7. package/{src/plugins/StickyPlugin.ts → dist/cjs/i18n/index.js} +10 -15
  8. package/dist/cjs/index.js +36 -0
  9. package/dist/cjs/plugins/CommentPlugin.js +481 -0
  10. package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +17 -20
  11. package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +58 -37
  12. package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +101 -48
  13. package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +95 -88
  14. package/dist/esm/i18n/ar/lexical.json.js +25 -0
  15. package/dist/esm/i18n/en/lexical.json.js +25 -0
  16. package/dist/esm/i18n/index.js +33 -0
  17. package/dist/esm/index.js +34 -0
  18. package/dist/esm/plugins/CommentPlugin.js +481 -0
  19. package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +15 -18
  20. package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +59 -38
  21. package/dist/types/editor/LexicalEditor.d.ts +33 -4
  22. package/dist/types/hooks/useFormatWatcher.d.ts +7 -4
  23. package/dist/types/i18n/index.d.ts +1 -0
  24. package/dist/types/index.d.ts +27 -0
  25. package/dist/types/plugins/CommentPlugin.d.ts +5 -0
  26. package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -2
  27. package/dist/types/plugins/ToolbarPlugin.d.ts +1 -1
  28. package/dist/types/utils/index.d.ts +3 -6
  29. package/package.json +18 -18
  30. package/src/editor/LexicalEditor.tsx +95 -55
  31. package/src/hooks/useFormatWatcher.ts +50 -74
  32. package/src/i18n/ar/lexical.json +18 -0
  33. package/src/i18n/en/lexical.json +18 -0
  34. package/src/i18n/index.ts +28 -0
  35. package/src/index.ts +24 -17
  36. package/src/plugins/CommentPlugin.tsx +523 -0
  37. package/src/plugins/DraggableBlockPlugin.tsx +23 -68
  38. package/src/plugins/ToolbarPlugin.tsx +83 -131
  39. package/src/utils/index.ts +12 -108
  40. package/dist/cjs/_virtual/prism.js +0 -5
  41. package/dist/cjs/editor/Lexical.module.css +0 -1
  42. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
  43. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
  44. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
  45. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
  46. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
  47. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
  48. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
  49. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
  50. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
  51. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
  52. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
  53. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
  54. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
  55. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
  56. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
  57. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
  58. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
  59. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
  60. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
  61. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
  62. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
  63. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
  64. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
  65. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
  66. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
  67. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
  68. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
  69. package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
  70. package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
  71. package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
  72. package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
  73. package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
  74. package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
  75. package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
  76. package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
  77. package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
  78. package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
  79. package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
  80. package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
  81. package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
  82. package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
  83. package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
  84. package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
  85. package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
  86. package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
  87. package/dist/cjs/packages/lexical/src/index.js +0 -7
  88. package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
  89. package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
  90. package/dist/esm/_virtual/prism.js +0 -5
  91. package/dist/esm/editor/Lexical.module.css +0 -1
  92. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
  93. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
  94. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
  95. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
  96. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
  97. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
  98. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
  99. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
  100. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
  101. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
  102. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
  103. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
  104. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
  105. package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
  106. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
  107. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
  108. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
  109. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
  110. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
  111. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
  112. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
  113. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
  114. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
  115. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
  116. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
  117. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
  118. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
  119. package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
  120. package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
  121. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
  122. package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
  123. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
  124. package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
  125. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
  126. package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
  127. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
  128. package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
  129. package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
  130. package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
  131. package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
  132. package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
  133. package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
  134. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
  135. package/dist/esm/node_modules/prismjs/prism.js +0 -1951
  136. package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
  137. package/dist/esm/packages/lexical/src/index.js +0 -3
  138. package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
  139. package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
  140. package/dist/types/components/StickyComponent.d.ts +0 -9
  141. package/dist/types/nodes/StickyNode.d.ts +0 -35
  142. package/dist/types/plugins/StickyPlugin.d.ts +0 -1
  143. package/src/components/StickyComponent.tsx +0 -271
  144. package/src/nodes/StickyNode.tsx +0 -249
  145. /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
  146. /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
  147. /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
  148. /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
@@ -3,16 +3,17 @@
3
3
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import _regeneratorRuntime from '@babel/runtime/regenerator';
6
- import { $isCodeNode, CODE_LANGUAGE_MAP, $createCodeNode } from '../../../../node_modules/@lexical/code/LexicalCode.js';
7
- import { $isLinkNode } from '../../../../node_modules/@lexical/link/LexicalLink.js';
8
- import { $isListNode, ListNode, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND } from '../../../../node_modules/@lexical/list/LexicalList.js';
6
+ import { $isCodeNode, CODE_LANGUAGE_MAP, $createCodeNode } from '@lexical/code';
7
+ import { $isLinkNode } from '@lexical/link';
8
+ import { $isListNode, ListNode, INSERT_ORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND } from '@lexical/list';
9
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import { $isHeadingNode, $createQuoteNode, $createHeadingNode, $isQuoteNode } from '../../../../node_modules/@lexical/rich-text/LexicalRichText.js';
11
- import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType, $isAtNodeEnd } from '../../../../node_modules/@lexical/selection/LexicalSelection.js';
12
- import { $isTableNode } from '../../../../node_modules/@lexical/table/LexicalTable.js';
13
- import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '../../../../node_modules/@lexical/utils/LexicalUtils.js';
14
- import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, FOCUS_COMMAND, COMMAND_PRIORITY_CRITICAL, SELECTION_CHANGE_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $createParagraphNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, $isTextNode } from 'lexical';
15
- import { useTransition, useState, useCallback, useEffect } from 'react';
10
+ import { $isHeadingNode, $createQuoteNode, $createHeadingNode, $isQuoteNode } from '@lexical/rich-text';
11
+ import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType, $isAtNodeEnd } from '@lexical/selection';
12
+ import { $isTableNode } from '@lexical/table';
13
+ import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';
14
+ import { isNil } from '@react-fabric/utilities';
15
+ import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $setSelection, $createParagraphNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, $isTextNode } from 'lexical';
16
+ import { useState, useCallback, useEffect } from 'react';
16
17
 
17
18
  var blockTypeToBlockName = {
18
19
  bullet: "Bulleted List",
@@ -44,9 +45,6 @@ function getSelectedNode(selection) {
44
45
  }
45
46
  }
46
47
  var useFormatWatcher = function useFormatWatcher() {
47
- var _useTransition = useTransition(),
48
- _useTransition2 = _slicedToArray(_useTransition, 2),
49
- startTransition = _useTransition2[1];
50
48
  var _useLexicalComposerCo = 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 = useState("paragraph"),
55
+ var _useState3 = useState(),
58
56
  _useState4 = _slicedToArray(_useState3, 2),
59
- blockType = _useState4[0],
60
- setBlockType = _useState4[1];
61
- var _useState5 = useState("root"),
57
+ currentSelection = _useState4[0],
58
+ setCurrentSelection = _useState4[1];
59
+ var _useState5 = useState("paragraph"),
62
60
  _useState6 = _slicedToArray(_useState5, 2),
63
- rootType = _useState6[0],
64
- setRootType = _useState6[1];
65
- var _useState7 = useState(null),
61
+ blockType = _useState6[0],
62
+ setBlockType = _useState6[1];
63
+ var _useState7 = useState("root"),
66
64
  _useState8 = _slicedToArray(_useState7, 2),
67
- selectedElementKey = _useState8[0],
68
- setSelectedElementKey = _useState8[1];
69
- var _useState9 = useState("16"),
70
- _useState10 = _slicedToArray(_useState9, 2),
65
+ rootType = _useState8[0],
66
+ setRootType = _useState8[1];
67
+ var _useState9 = useState(null),
68
+ _useState0 = _slicedToArray(_useState9, 2),
69
+ selectedElementKey = _useState0[0],
70
+ setSelectedElementKey = _useState0[1];
71
+ var _useState1 = useState("16"),
72
+ _useState10 = _slicedToArray(_useState1, 2),
71
73
  fontSize = _useState10[0],
72
74
  setFontSize = _useState10[1];
73
75
  var _useState11 = useState("#000"),
@@ -82,60 +84,64 @@ var useFormatWatcher = function useFormatWatcher() {
82
84
  _useState16 = _slicedToArray(_useState15, 2),
83
85
  fontFamily = _useState16[0],
84
86
  setFontFamily = _useState16[1];
85
- var _useState17 = useState(false),
87
+ var _useState17 = useState(""),
86
88
  _useState18 = _slicedToArray(_useState17, 2),
87
- isLink = _useState18[0],
88
- setIsLink = _useState18[1];
89
+ align = _useState18[0],
90
+ setAlign = _useState18[1];
89
91
  var _useState19 = useState(false),
90
92
  _useState20 = _slicedToArray(_useState19, 2),
91
- isBold = _useState20[0],
92
- setIsBold = _useState20[1];
93
+ isLink = _useState20[0],
94
+ setIsLink = _useState20[1];
93
95
  var _useState21 = useState(false),
94
96
  _useState22 = _slicedToArray(_useState21, 2),
95
- isItalic = _useState22[0],
96
- setIsItalic = _useState22[1];
97
+ isBold = _useState22[0],
98
+ setIsBold = _useState22[1];
97
99
  var _useState23 = useState(false),
98
100
  _useState24 = _slicedToArray(_useState23, 2),
99
- isUnderline = _useState24[0],
100
- setIsUnderline = _useState24[1];
101
+ isItalic = _useState24[0],
102
+ setIsItalic = _useState24[1];
101
103
  var _useState25 = useState(false),
102
104
  _useState26 = _slicedToArray(_useState25, 2),
103
- isStrikethrough = _useState26[0],
104
- setIsStrikethrough = _useState26[1];
105
+ isUnderline = _useState26[0],
106
+ setIsUnderline = _useState26[1];
105
107
  var _useState27 = useState(false),
106
108
  _useState28 = _slicedToArray(_useState27, 2),
107
- isSubscript = _useState28[0],
108
- setIsSubscript = _useState28[1];
109
+ isStrikethrough = _useState28[0],
110
+ setIsStrikethrough = _useState28[1];
109
111
  var _useState29 = useState(false),
110
112
  _useState30 = _slicedToArray(_useState29, 2),
111
- isSuperscript = _useState30[0],
112
- setIsSuperscript = _useState30[1];
113
+ isSubscript = _useState30[0],
114
+ setIsSubscript = _useState30[1];
113
115
  var _useState31 = useState(false),
114
116
  _useState32 = _slicedToArray(_useState31, 2),
115
- isCode = _useState32[0],
116
- setIsCode = _useState32[1];
117
+ isSuperscript = _useState32[0],
118
+ setIsSuperscript = _useState32[1];
117
119
  var _useState33 = useState(false),
118
120
  _useState34 = _slicedToArray(_useState33, 2),
119
- canUndo = _useState34[0],
120
- setCanUndo = _useState34[1];
121
+ isCode = _useState34[0],
122
+ setIsCode = _useState34[1];
121
123
  var _useState35 = useState(false),
122
124
  _useState36 = _slicedToArray(_useState35, 2),
123
- canRedo = _useState36[0],
124
- setCanRedo = _useState36[1];
125
+ canUndo = _useState36[0],
126
+ setCanUndo = _useState36[1];
125
127
  var _useState37 = useState(false),
126
128
  _useState38 = _slicedToArray(_useState37, 2),
127
- isRTL = _useState38[0],
128
- setIsRTL = _useState38[1];
129
- var _useState39 = useState(""),
129
+ canRedo = _useState38[0],
130
+ setCanRedo = _useState38[1];
131
+ var _useState39 = useState(false),
130
132
  _useState40 = _slicedToArray(_useState39, 2),
131
- codeLanguage = _useState40[0],
132
- setCodeLanguage = _useState40[1];
133
- var _useState41 = useState(function () {
133
+ isRTL = _useState40[0],
134
+ setIsRTL = _useState40[1];
135
+ var _useState41 = useState(""),
136
+ _useState42 = _slicedToArray(_useState41, 2),
137
+ codeLanguage = _useState42[0],
138
+ setCodeLanguage = _useState42[1];
139
+ var _useState43 = useState(function () {
134
140
  return editor.isEditable();
135
141
  }),
136
- _useState42 = _slicedToArray(_useState41, 2),
137
- isEditable = _useState42[0],
138
- setIsEditable = _useState42[1];
142
+ _useState44 = _slicedToArray(_useState43, 2),
143
+ isEditable = _useState44[0],
144
+ setIsEditable = _useState44[1];
139
145
  var $updateToolbar = useCallback(function () {
140
146
  var selection = $getSelection();
141
147
  if ($isRangeSelection(selection)) {
@@ -158,7 +164,9 @@ var useFormatWatcher = function useFormatWatcher() {
158
164
  setIsSubscript(selection.hasFormat("subscript"));
159
165
  setIsSuperscript(selection.hasFormat("superscript"));
160
166
  setIsCode(selection.hasFormat("code"));
161
- setIsRTL($isParentElementRTL(selection));
167
+ editor.read(function () {
168
+ setIsRTL($isParentElementRTL(selection));
169
+ });
162
170
 
163
171
  // Update links
164
172
  var node = getSelectedNode(selection);
@@ -176,6 +184,7 @@ var useFormatWatcher = function useFormatWatcher() {
176
184
  }
177
185
  if (elementDOM !== null) {
178
186
  setSelectedElementKey(elementKey);
187
+ if (elementDOM) setAlign(getComputedStyle(elementDOM).textAlign);
179
188
  if ($isListNode(element)) {
180
189
  var parentList = $getNearestNodeOfType(anchorNode, ListNode);
181
190
  var type = parentList ? parentList.getListType() : element.getListType();
@@ -194,22 +203,27 @@ var useFormatWatcher = function useFormatWatcher() {
194
203
  }
195
204
  // Handle buttons
196
205
  setFontSize(parseInt($getSelectionStyleValueForProperty(selection, "font-size", "16")) + "");
197
- setFontColor($getSelectionStyleValueForProperty(selection, "color", "#000"));
198
- setBgColor($getSelectionStyleValueForProperty(selection, "background-color", "#fff"));
206
+ setFontColor($getSelectionStyleValueForProperty(selection, "color",
207
+ // @ts-expect-error ignore
208
+ new String("#000")));
209
+ setBgColor($getSelectionStyleValueForProperty(selection, "background-color",
210
+ // @ts-expect-error ignore
211
+ new String("#fff")));
199
212
  setFontFamily($getSelectionStyleValueForProperty(selection, "font-family", "inherit"));
200
213
  }
201
- }, [activeEditor]);
214
+ }, [activeEditor, editor]);
202
215
  useEffect(function () {
203
- return editor.registerCommand(FOCUS_COMMAND, function (_payload, newEditor) {
216
+ return editor.registerCommand(SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
204
217
  setActiveEditor(newEditor);
218
+ setCurrentSelection($getSelection());
219
+ $updateToolbar();
205
220
  return false;
206
221
  }, COMMAND_PRIORITY_CRITICAL);
207
- }, [editor]);
222
+ }, [editor, $updateToolbar]);
208
223
  useEffect(function () {
209
- return activeEditor.registerCommand(SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
224
+ activeEditor.getEditorState().read(function () {
210
225
  $updateToolbar();
211
- return false;
212
- }, COMMAND_PRIORITY_CRITICAL);
226
+ });
213
227
  }, [activeEditor, $updateToolbar]);
214
228
  useEffect(function () {
215
229
  return mergeRegister(editor.registerEditableListener(function (editable) {
@@ -228,15 +242,14 @@ var useFormatWatcher = function useFormatWatcher() {
228
242
  }, COMMAND_PRIORITY_CRITICAL));
229
243
  }, [$updateToolbar, activeEditor, editor]);
230
244
  var applyStyleText = useCallback(function (styles) {
231
- setTimeout(function () {
232
- editor.update(function () {
233
- var selection = $getSelection();
234
- if ($isRangeSelection(selection)) {
235
- $patchStyleText(selection, styles);
236
- }
237
- });
238
- }, 100);
239
- }, [editor]);
245
+ // activeEditor.focus();
246
+ activeEditor.update(function () {
247
+ if (!isNil(currentSelection)) {
248
+ $setSelection(currentSelection.clone());
249
+ $patchStyleText(currentSelection, styles);
250
+ }
251
+ });
252
+ }, [activeEditor, currentSelection]);
240
253
  var formatBulletList = function formatBulletList() {
241
254
  setTimeout(function () {
242
255
  if (blockType !== "bullet") {
@@ -275,7 +288,7 @@ var useFormatWatcher = function useFormatWatcher() {
275
288
  }
276
289
  });
277
290
  }, 100);
278
- }, [activeEditor, blockType]);
291
+ }, [activeEditor]);
279
292
  var formatQuote = useCallback(function () {
280
293
  if (blockType !== "quote") {
281
294
  setTimeout(function () {
@@ -364,45 +377,38 @@ var useFormatWatcher = function useFormatWatcher() {
364
377
  });
365
378
  }, [activeEditor]);
366
379
  var onSizeChange = 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 = useCallback(function (value) {
375
- startTransition(function () {
376
- return setFontColor(value);
377
- });
384
+ var onFontColorSelect = 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 = useCallback(function (value) {
383
- startTransition(function () {
384
- return setBgColor(value);
385
- });
390
+ var onBgColorSelect = 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( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
393
- return _regeneratorRuntime.wrap(function _callee$(_context) {
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 = 2;
402
+ _context.next = 1;
397
403
  return new Promise(function (resolve) {
398
404
  activeEditor.update(function () {
399
405
  var selection = $getSelection();
400
406
  resolve(selection);
401
407
  });
402
408
  });
403
- case 2:
409
+ case 1:
404
410
  return _context.abrupt("return", _context.sent);
405
- case 3:
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,25 @@
1
+ 'use client';
2
+
3
+ var addComment = "أضف تعليقا";
4
+ var reply = "رد";
5
+ var tool = {
6
+ alignCenter: "محاذاة المركز",
7
+ alignEnd: "محاذاة النهاية",
8
+ alignJustify: "محاذاة وضبط",
9
+ alignStart: "محاذاة البداية",
10
+ bold: "عريض",
11
+ clear: "مسح التنسيق",
12
+ hilight: "تسليط الضوء",
13
+ indentIn: "المسافة البادئة في",
14
+ indentOut: "مسافة بادئة للخارج",
15
+ italic: "مائل",
16
+ strikethrough: "يتوسطه خط",
17
+ underline: "تسطير"
18
+ };
19
+ var ar = {
20
+ addComment: addComment,
21
+ reply: reply,
22
+ tool: tool
23
+ };
24
+
25
+ export { addComment, ar as default, reply, tool };
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+
3
+ var tool = {
4
+ alignStart: "Align Start",
5
+ alignCenter: "Align Center",
6
+ alignEnd: "Align End",
7
+ alignJustify: "Align Justify",
8
+ bold: "Bold",
9
+ italic: "Italic",
10
+ underline: "Underline",
11
+ strikethrough: "Strikethrough",
12
+ indentOut: "Indent Out",
13
+ indentIn: "Indent In",
14
+ hilight: "Highlight",
15
+ clear: "Clear Formatting"
16
+ };
17
+ var addComment = "Add comment";
18
+ var reply = "Reply";
19
+ var en = {
20
+ tool: tool,
21
+ addComment: addComment,
22
+ reply: reply
23
+ };
24
+
25
+ export { addComment, en as default, reply, tool };
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+
3
+ import { addTranslationBundle } from '@react-fabric/core';
4
+ import ar from './ar/lexical.json.js';
5
+ import en from './en/lexical.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
+ addTranslationBundle("lexical", {
31
+ en: en,
32
+ ar: ar
33
+ });
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+
3
+ import './i18n/index.js';
4
+ export { LexicalEditor } from './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
+ export { LEXICAL_PACKAGE, LEXICAL_VERSION };