@liveblocks/react-lexical 2.18.3 → 2.18.4-uns2

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 (135) hide show
  1. package/dist/{classnames.mjs → classnames.cjs} +4 -2
  2. package/dist/{classnames.mjs.map → classnames.cjs.map} +1 -1
  3. package/dist/classnames.js +1 -3
  4. package/dist/classnames.js.map +1 -1
  5. package/dist/comments/{anchored-threads.mjs → anchored-threads.cjs} +44 -41
  6. package/dist/comments/{anchored-threads.mjs.map → anchored-threads.cjs.map} +1 -1
  7. package/dist/comments/anchored-threads.js +40 -43
  8. package/dist/comments/anchored-threads.js.map +1 -1
  9. package/dist/comments/{comment-plugin-provider.mjs → comment-plugin-provider.cjs} +62 -55
  10. package/dist/comments/{comment-plugin-provider.mjs.map → comment-plugin-provider.cjs.map} +1 -1
  11. package/dist/comments/comment-plugin-provider.js +54 -61
  12. package/dist/comments/comment-plugin-provider.js.map +1 -1
  13. package/dist/comments/{floating-composer.mjs → floating-composer.cjs} +68 -64
  14. package/dist/comments/{floating-composer.mjs.map → floating-composer.cjs.map} +1 -1
  15. package/dist/comments/floating-composer.js +63 -67
  16. package/dist/comments/floating-composer.js.map +1 -1
  17. package/dist/comments/{floating-threads.mjs → floating-threads.cjs} +51 -48
  18. package/dist/comments/{floating-threads.mjs.map → floating-threads.cjs.map} +1 -1
  19. package/dist/comments/floating-threads.js +47 -50
  20. package/dist/comments/floating-threads.js.map +1 -1
  21. package/dist/comments/get-thread-mark-ids.cjs +23 -0
  22. package/dist/comments/{get-thread-mark-ids.mjs.map → get-thread-mark-ids.cjs.map} +1 -1
  23. package/dist/comments/get-thread-mark-ids.js +6 -8
  24. package/dist/comments/get-thread-mark-ids.js.map +1 -1
  25. package/dist/comments/{thread-mark-node.mjs → thread-mark-node.cjs} +10 -6
  26. package/dist/comments/{thread-mark-node.mjs.map → thread-mark-node.cjs.map} +1 -1
  27. package/dist/comments/thread-mark-node.js +5 -9
  28. package/dist/comments/thread-mark-node.js.map +1 -1
  29. package/dist/comments/{unwrap-thread-mark-node.mjs → unwrap-thread-mark-node.cjs} +4 -2
  30. package/dist/comments/unwrap-thread-mark-node.cjs.map +1 -0
  31. package/dist/comments/unwrap-thread-mark-node.js +1 -3
  32. package/dist/comments/unwrap-thread-mark-node.js.map +1 -1
  33. package/dist/comments/{wrap-selection-in-thread-mark-node.mjs → wrap-selection-in-thread-mark-node.cjs} +12 -10
  34. package/dist/comments/{wrap-selection-in-thread-mark-node.mjs.map → wrap-selection-in-thread-mark-node.cjs.map} +1 -1
  35. package/dist/comments/wrap-selection-in-thread-mark-node.js +9 -11
  36. package/dist/comments/wrap-selection-in-thread-mark-node.js.map +1 -1
  37. package/dist/{create-dom-range.mjs → create-dom-range.cjs} +7 -5
  38. package/dist/{create-dom-range.mjs.map → create-dom-range.cjs.map} +1 -1
  39. package/dist/create-dom-range.js +4 -6
  40. package/dist/create-dom-range.js.map +1 -1
  41. package/dist/{create-rects-from-dom-range.mjs → create-rects-from-dom-range.cjs} +4 -2
  42. package/dist/{create-rects-from-dom-range.mjs.map → create-rects-from-dom-range.cjs.map} +1 -1
  43. package/dist/create-rects-from-dom-range.js +1 -3
  44. package/dist/create-rects-from-dom-range.js.map +1 -1
  45. package/dist/index.cjs +33 -0
  46. package/dist/{index.mjs.map → index.cjs.map} +1 -1
  47. package/dist/index.js +14 -31
  48. package/dist/index.js.map +1 -1
  49. package/dist/{is-block-node-active.mjs → is-block-node-active.cjs} +12 -10
  50. package/dist/{is-block-node-active.mjs.map → is-block-node-active.cjs.map} +1 -1
  51. package/dist/is-block-node-active.js +9 -11
  52. package/dist/is-block-node-active.js.map +1 -1
  53. package/dist/is-command-registered.cjs +11 -0
  54. package/dist/{is-command-registered.mjs.map → is-command-registered.cjs.map} +1 -1
  55. package/dist/is-command-registered.js +3 -5
  56. package/dist/is-command-registered.js.map +1 -1
  57. package/dist/is-text-format-active.cjs +16 -0
  58. package/dist/{is-text-format-active.mjs.map → is-text-format-active.cjs.map} +1 -1
  59. package/dist/is-text-format-active.js +4 -6
  60. package/dist/is-text-format-active.js.map +1 -1
  61. package/dist/liveblocks-config.cjs +17 -0
  62. package/dist/{liveblocks-config.mjs.map → liveblocks-config.cjs.map} +1 -1
  63. package/dist/liveblocks-config.js +4 -6
  64. package/dist/liveblocks-config.js.map +1 -1
  65. package/dist/liveblocks-plugin-provider.cjs +151 -0
  66. package/dist/liveblocks-plugin-provider.cjs.map +1 -0
  67. package/dist/liveblocks-plugin-provider.js +43 -47
  68. package/dist/liveblocks-plugin-provider.js.map +1 -1
  69. package/dist/mentions/{avatar.mjs → avatar.cjs} +16 -14
  70. package/dist/mentions/avatar.cjs.map +1 -0
  71. package/dist/mentions/avatar.js +13 -15
  72. package/dist/mentions/avatar.js.map +1 -1
  73. package/dist/mentions/mention-component.cjs +51 -0
  74. package/dist/mentions/{mention-component.mjs.map → mention-component.cjs.map} +1 -1
  75. package/dist/mentions/mention-component.js +14 -16
  76. package/dist/mentions/mention-component.js.map +1 -1
  77. package/dist/mentions/{mention-node.mjs → mention-node.cjs} +16 -12
  78. package/dist/mentions/{mention-node.mjs.map → mention-node.cjs.map} +1 -1
  79. package/dist/mentions/mention-node.js +11 -15
  80. package/dist/mentions/mention-node.js.map +1 -1
  81. package/dist/mentions/{mention-plugin.mjs → mention-plugin.cjs} +81 -78
  82. package/dist/mentions/{mention-plugin.mjs.map → mention-plugin.cjs.map} +1 -1
  83. package/dist/mentions/mention-plugin.js +77 -80
  84. package/dist/mentions/mention-plugin.js.map +1 -1
  85. package/dist/mentions/{suggestions.mjs → suggestions.cjs} +43 -37
  86. package/dist/mentions/{suggestions.mjs.map → suggestions.cjs.map} +1 -1
  87. package/dist/mentions/suggestions.js +36 -42
  88. package/dist/mentions/suggestions.js.map +1 -1
  89. package/dist/mentions/user.cjs +26 -0
  90. package/dist/mentions/{user.mjs.map → user.cjs.map} +1 -1
  91. package/dist/mentions/user.js +11 -13
  92. package/dist/mentions/user.js.map +1 -1
  93. package/dist/toolbar/{floating-toolbar.mjs → floating-toolbar.cjs} +73 -70
  94. package/dist/toolbar/{floating-toolbar.mjs.map → floating-toolbar.cjs.map} +1 -1
  95. package/dist/toolbar/floating-toolbar.js +69 -72
  96. package/dist/toolbar/floating-toolbar.js.map +1 -1
  97. package/dist/toolbar/shared.cjs +36 -0
  98. package/dist/toolbar/{shared.mjs.map → shared.cjs.map} +1 -1
  99. package/dist/toolbar/shared.js +12 -15
  100. package/dist/toolbar/shared.js.map +1 -1
  101. package/dist/toolbar/toolbar.cjs +433 -0
  102. package/dist/toolbar/{toolbar.mjs.map → toolbar.cjs.map} +1 -1
  103. package/dist/toolbar/toolbar.js +131 -156
  104. package/dist/toolbar/toolbar.js.map +1 -1
  105. package/dist/use-root-element.cjs +21 -0
  106. package/dist/use-root-element.cjs.map +1 -0
  107. package/dist/use-root-element.js +7 -9
  108. package/dist/use-root-element.js.map +1 -1
  109. package/dist/version-history/{history-version-preview.mjs → history-version-preview.cjs} +52 -50
  110. package/dist/version-history/{history-version-preview.mjs.map → history-version-preview.cjs.map} +1 -1
  111. package/dist/version-history/history-version-preview.js +49 -51
  112. package/dist/version-history/history-version-preview.js.map +1 -1
  113. package/dist/version.cjs +10 -0
  114. package/dist/{version.mjs.map → version.cjs.map} +1 -1
  115. package/dist/version.js +3 -7
  116. package/dist/version.js.map +1 -1
  117. package/package.json +18 -17
  118. package/styles.css.d.cts +1 -0
  119. package/dist/comments/get-thread-mark-ids.mjs +0 -21
  120. package/dist/comments/unwrap-thread-mark-node.mjs.map +0 -1
  121. package/dist/index.mjs +0 -16
  122. package/dist/is-command-registered.mjs +0 -9
  123. package/dist/is-text-format-active.mjs +0 -14
  124. package/dist/liveblocks-config.mjs +0 -15
  125. package/dist/liveblocks-plugin-provider.mjs +0 -147
  126. package/dist/liveblocks-plugin-provider.mjs.map +0 -1
  127. package/dist/mentions/avatar.mjs.map +0 -1
  128. package/dist/mentions/mention-component.mjs +0 -49
  129. package/dist/mentions/user.mjs +0 -24
  130. package/dist/toolbar/shared.mjs +0 -33
  131. package/dist/toolbar/toolbar.mjs +0 -408
  132. package/dist/use-root-element.mjs +0 -19
  133. package/dist/use-root-element.mjs.map +0 -1
  134. package/dist/version.mjs +0 -6
  135. /package/dist/{index.d.mts → index.d.cts} +0 -0
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- var lexical = require('lexical');
1
+ import { $isTextNode } from 'lexical';
4
2
 
5
3
  function getDOMTextNode(element) {
6
4
  let node = element;
@@ -27,10 +25,10 @@ function createDOMRange(editor, anchorNode, _anchorOffset, focusNode, _focusOffs
27
25
  let focusDOM = editor.getElementByKey(focusKey);
28
26
  let anchorOffset = _anchorOffset;
29
27
  let focusOffset = _focusOffset;
30
- if (lexical.$isTextNode(anchorNode)) {
28
+ if ($isTextNode(anchorNode)) {
31
29
  anchorDOM = getDOMTextNode(anchorDOM);
32
30
  }
33
- if (lexical.$isTextNode(focusNode)) {
31
+ if ($isTextNode(focusNode)) {
34
32
  focusDOM = getDOMTextNode(focusDOM);
35
33
  }
36
34
  if (anchorNode === void 0 || focusNode === void 0 || anchorDOM === null || focusDOM === null) {
@@ -59,5 +57,5 @@ function createDOMRange(editor, anchorNode, _anchorOffset, focusNode, _focusOffs
59
57
  return range;
60
58
  }
61
59
 
62
- exports.createDOMRange = createDOMRange;
60
+ export { createDOMRange };
63
61
  //# sourceMappingURL=create-dom-range.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-dom-range.js","sources":["../src/create-dom-range.ts"],"sourcesContent":["/**\n * MIT License\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { LexicalEditor, LexicalNode } from \"lexical\";\nimport { $isTextNode } from \"lexical\";\n\nfunction getDOMTextNode(element: Node | null): Text | null {\n let node = element;\n\n while (node !== null) {\n if (node.nodeType === Node.TEXT_NODE) {\n return node as Text;\n }\n\n node = node.firstChild;\n }\n\n return null;\n}\n\nfunction getDOMIndexWithinParent(node: ChildNode): [ParentNode, number] {\n const parent = node.parentNode;\n\n if (parent === null) {\n throw new Error(\"Should never happen\");\n }\n\n return [parent, Array.from(parent.childNodes).indexOf(node)];\n}\n\n/**\n * Creates a selection range for the DOM.\n * @param editor - The lexical editor.\n * @param anchorNode - The anchor node of a selection.\n * @param _anchorOffset - The amount of space offset from the anchor to the focus.\n * @param focusNode - The current focus.\n * @param _focusOffset - The amount of space offset from the focus to the anchor.\n * @returns The range of selection for the DOM that was created.\n */\nexport function createDOMRange(\n editor: LexicalEditor,\n anchorNode: LexicalNode,\n _anchorOffset: number,\n focusNode: LexicalNode,\n _focusOffset: number\n): Range | null {\n const anchorKey = anchorNode.getKey();\n const focusKey = focusNode.getKey();\n const range = document.createRange();\n let anchorDOM: Node | Text | null = editor.getElementByKey(anchorKey);\n let focusDOM: Node | Text | null = editor.getElementByKey(focusKey);\n let anchorOffset = _anchorOffset;\n let focusOffset = _focusOffset;\n\n if ($isTextNode(anchorNode)) {\n anchorDOM = getDOMTextNode(anchorDOM);\n }\n\n if ($isTextNode(focusNode)) {\n focusDOM = getDOMTextNode(focusDOM);\n }\n\n if (\n anchorNode === undefined ||\n focusNode === undefined ||\n anchorDOM === null ||\n focusDOM === null\n ) {\n return null;\n }\n\n if (anchorDOM.nodeName === \"BR\") {\n [anchorDOM, anchorOffset] = getDOMIndexWithinParent(anchorDOM as ChildNode);\n }\n\n if (focusDOM.nodeName === \"BR\") {\n [focusDOM, focusOffset] = getDOMIndexWithinParent(focusDOM as ChildNode);\n }\n\n const firstChild = anchorDOM.firstChild;\n\n if (\n anchorDOM === focusDOM &&\n firstChild !== null &&\n firstChild.nodeName === \"BR\" &&\n anchorOffset === 0 &&\n focusOffset === 0\n ) {\n focusOffset = 1;\n }\n\n try {\n range.setStart(anchorDOM, anchorOffset);\n range.setEnd(focusDOM, focusOffset);\n } catch (e) {\n return null;\n }\n\n if (\n range.collapsed &&\n (anchorOffset !== focusOffset || anchorKey !== focusKey)\n ) {\n // Range is backwards, we need to reverse it\n range.setStart(focusDOM, focusOffset);\n range.setEnd(anchorDOM, anchorOffset);\n }\n\n return range;\n}\n"],"names":["$isTextNode"],"mappings":";;;;AA0BA,SAAS,eAAe,OAAmC,EAAA;AACzD,EAAA,IAAI,IAAO,GAAA,OAAA,CAAA;AAEX,EAAA,OAAO,SAAS,IAAM,EAAA;AACpB,IAAI,IAAA,IAAA,CAAK,QAAa,KAAA,IAAA,CAAK,SAAW,EAAA;AACpC,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAA,IAAA,GAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GACd;AAEA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEA,SAAS,wBAAwB,IAAuC,EAAA;AACtE,EAAA,MAAM,SAAS,IAAK,CAAA,UAAA,CAAA;AAEpB,EAAA,IAAI,WAAW,IAAM,EAAA;AACnB,IAAM,MAAA,IAAI,MAAM,qBAAqB,CAAA,CAAA;AAAA,GACvC;A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;AAAA,GACzE;AAEA,EAAA,MAAM,aAAa,SAAU,CAAA,UAAA,CAAA;AAE7B,EACE,IAAA,SAAA,KAAc,QACd,IAAA,UAAA,KAAe,IACf,IAAA,UAAA,CAAW,aAAa,IACxB,IAAA,YAAA,KAAiB,CACjB,IAAA,WAAA,KAAgB,CAChB,EAAA;AACA,IAAc,WAAA,GAAA,CAAA,CAAA;AAAA,GAChB;AAEA,EAAI,IAAA;AACF,IAAM,KAAA,CAAA,QAAA,CAAS,WAAW,YAAY,CAAA,CAAA;AACtC,IAAM,KAAA,CAAA,MAAA,CAAO,UAAU,WAAW,CAAA,CAAA;AAAA,WAC3B,CAAP,EAAA;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,IACE,KAAM,CAAA,SAAA,KACL,YAAiB,KAAA,WAAA,IAAe,cAAc,QAC/C,CAAA,EAAA;AAEA,IAAM,KAAA,CAAA,QAAA,CAAS,UAAU,WAAW,CAAA,CAAA;AACpC,IAAM,KAAA,CAAA,MAAA,CAAO,WAAW,YAAY,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"create-dom-range.js","sources":["../src/create-dom-range.ts"],"sourcesContent":["/**\n * MIT License\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { LexicalEditor, LexicalNode } from \"lexical\";\nimport { $isTextNode } from \"lexical\";\n\nfunction getDOMTextNode(element: Node | null): Text | null {\n let node = element;\n\n while (node !== null) {\n if (node.nodeType === Node.TEXT_NODE) {\n return node as Text;\n }\n\n node = node.firstChild;\n }\n\n return null;\n}\n\nfunction getDOMIndexWithinParent(node: ChildNode): [ParentNode, number] {\n const parent = node.parentNode;\n\n if (parent === null) {\n throw new Error(\"Should never happen\");\n }\n\n return [parent, Array.from(parent.childNodes).indexOf(node)];\n}\n\n/**\n * Creates a selection range for the DOM.\n * @param editor - The lexical editor.\n * @param anchorNode - The anchor node of a selection.\n * @param _anchorOffset - The amount of space offset from the anchor to the focus.\n * @param focusNode - The current focus.\n * @param _focusOffset - The amount of space offset from the focus to the anchor.\n * @returns The range of selection for the DOM that was created.\n */\nexport function createDOMRange(\n editor: LexicalEditor,\n anchorNode: LexicalNode,\n _anchorOffset: number,\n focusNode: LexicalNode,\n _focusOffset: number\n): Range | null {\n const anchorKey = anchorNode.getKey();\n const focusKey = focusNode.getKey();\n const range = document.createRange();\n let anchorDOM: Node | Text | null = editor.getElementByKey(anchorKey);\n let focusDOM: Node | Text | null = editor.getElementByKey(focusKey);\n let anchorOffset = _anchorOffset;\n let focusOffset = _focusOffset;\n\n if ($isTextNode(anchorNode)) {\n anchorDOM = getDOMTextNode(anchorDOM);\n }\n\n if ($isTextNode(focusNode)) {\n focusDOM = getDOMTextNode(focusDOM);\n }\n\n if (\n anchorNode === undefined ||\n focusNode === undefined ||\n anchorDOM === null ||\n focusDOM === null\n ) {\n return null;\n }\n\n if (anchorDOM.nodeName === \"BR\") {\n [anchorDOM, anchorOffset] = getDOMIndexWithinParent(anchorDOM as ChildNode);\n }\n\n if (focusDOM.nodeName === \"BR\") {\n [focusDOM, focusOffset] = getDOMIndexWithinParent(focusDOM as ChildNode);\n }\n\n const firstChild = anchorDOM.firstChild;\n\n if (\n anchorDOM === focusDOM &&\n firstChild !== null &&\n firstChild.nodeName === \"BR\" &&\n anchorOffset === 0 &&\n focusOffset === 0\n ) {\n focusOffset = 1;\n }\n\n try {\n range.setStart(anchorDOM, anchorOffset);\n range.setEnd(focusDOM, focusOffset);\n } catch (e) {\n return null;\n }\n\n if (\n range.collapsed &&\n (anchorOffset !== focusOffset || anchorKey !== focusKey)\n ) {\n // Range is backwards, we need to reverse it\n range.setStart(focusDOM, focusOffset);\n range.setEnd(anchorDOM, anchorOffset);\n }\n\n return range;\n}\n"],"names":[],"mappings":";;AA0BA,SAAS,eAAe,OAAmC,EAAA;AACzD,EAAA,IAAI,IAAO,GAAA,OAAA,CAAA;AAEX,EAAA,OAAO,SAAS,IAAM,EAAA;AACpB,IAAI,IAAA,IAAA,CAAK,QAAa,KAAA,IAAA,CAAK,SAAW,EAAA;AACpC,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAA,IAAA,GAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GACd;AAEA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEA,SAAS,wBAAwB,IAAuC,EAAA;AACtE,EAAA,MAAM,SAAS,IAAK,CAAA,UAAA,CAAA;AAEpB,EAAA,IAAI,WAAW,IAAM,EAAA;AACnB,IAAM,MAAA,IAAI,MAAM,qBAAqB,CAAA,CAAA;AAAA,GACvC;AAEA,EAAO,OAAA,CAAC,QAAQ,KAAM,CAAA,IAAA,CAAK,OAAO,UAAU,CAAA,CAAE,OAAQ,CAAA,IAAI,CAAC,CAAA,CAAA;AAC7D,CAAA;AAWO,SAAS,cACd,CAAA,MAAA,EACA,UACA,EAAA,aAAA,EACA,WACA,Y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AChB,EAAA;AACA,IAAc,WAAA,GAAA,CAAA,CAAA;AAAA,GAChB;AAEA,EAAI,IAAA;AACF,IAAM,KAAA,CAAA,QAAA,CAAS,WAAW,YAAY,CAAA,CAAA;AACtC,IAAM,KAAA,CAAA,MAAA,CAAO,UAAU,WAAW,CAAA,CAAA;AAAA,WAC3B,CAAP,EAAA;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,IACE,KAAM,CAAA,SAAA,KACL,YAAiB,KAAA,WAAA,IAAe,cAAc,QAC/C,CAAA,EAAA;AAEA,IAAM,KAAA,CAAA,QAAA,CAAS,UAAU,WAAW,CAAA,CAAA;AACpC,IAAM,KAAA,CAAA,MAAA,CAAO,WAAW,YAAY,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  function createRectsFromDOMRange(editor, range) {
2
4
  const rootElement = editor.getRootElement();
3
5
  if (rootElement === null) {
@@ -30,5 +32,5 @@ function createRectsFromDOMRange(editor, range) {
30
32
  return selectionRects;
31
33
  }
32
34
 
33
- export { createRectsFromDOMRange };
34
- //# sourceMappingURL=create-rects-from-dom-range.mjs.map
35
+ exports.createRectsFromDOMRange = createRectsFromDOMRange;
36
+ //# sourceMappingURL=create-rects-from-dom-range.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-rects-from-dom-range.mjs","sources":["../src/create-rects-from-dom-range.ts"],"sourcesContent":["/**\n * MIT License\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\n/**\n * Creates DOMRects, generally used to help the editor find a specific location on the screen.\n * @param editor - The lexical editor\n * @param range - A fragment of a document that can contain nodes and parts of text nodes.\n * @returns The selectionRects as an array.\n */\nexport function createRectsFromDOMRange(\n editor: LexicalEditor,\n range: Range\n): Array<ClientRect> {\n const rootElement = editor.getRootElement();\n\n if (rootElement === null) {\n return [];\n }\n const rootRect = rootElement.getBoundingClientRect();\n const computedStyle = getComputedStyle(rootElement);\n const rootPadding =\n parseFloat(computedStyle.paddingLeft) +\n parseFloat(computedStyle.paddingRight);\n const selectionRects = Array.from(range.getClientRects());\n let selectionRectsLength = selectionRects.length;\n //sort rects from top left to bottom right.\n selectionRects.sort((a, b) => {\n const top = a.top - b.top;\n // Some rects match position closely, but not perfectly,\n // so we give a 3px tolerance.\n if (Math.abs(top) <= 3) {\n return a.left - b.left;\n }\n return top;\n });\n let prevRect;\n for (let i = 0; i < selectionRectsLength; i++) {\n const selectionRect = selectionRects[i];\n // Exclude rects that overlap preceding Rects in the sorted list.\n const isOverlappingRect =\n prevRect &&\n prevRect.top <= selectionRect.top &&\n prevRect.top + prevRect.height > selectionRect.top &&\n prevRect.left + prevRect.width > selectionRect.left;\n // Exclude selections that span the entire element\n const selectionSpansElement =\n selectionRect.width + rootPadding === rootRect.width;\n if (isOverlappingRect || selectionSpansElement) {\n selectionRects.splice(i--, 1);\n selectionRectsLength--;\n continue;\n }\n prevRect = selectionRect;\n }\n return selectionRects;\n}\n"],"names":[],"mappings":"AA+BgB,SAAA,uBAAA,CACd,QACA,KACmB,EAAA;AACnB,EAAM,MAAA,WAAA,GAAc,OAAO,cAAe,EAAA,CAAA;AAE1C,EAAA,IAAI,gBAAgB,IAAM,EAAA;AACxB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AACA,EAAM,MAAA,QAAA,GAAW,YAAY,qBAAsB,EAAA,CAAA;AACnD,EAAM,MAAA,aAAA,GAAgB,iBAAiB,WAAW,CAAA,CAAA;AAClD,EAAA,MAAM,cACJ,UAAW,CAAA,aAAA,CAAc,WAAW,CACpC,GAAA,UAAA,CAAW,cAAc,YAAY,CAAA,CAAA;AACvC,EAAA,MAAM,cAAiB,GAAA,KAAA,CAAM,IAAK,CAAA,KAAA,CAAM,gBAAgB,CAAA,CAAA;AACxD,EAAA,IAAI,uBAAuB,cAAe,CAAA,MAAA,CAAA;AAE1C,EAAe,cAAA,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAM,KAAA;AAC5B,IAAM,MAAA,GAAA,GAAM,CAAE,CAAA,GAAA,GAAM,CAAE,CAAA,GAAA,CAAA;AAGtB,IAAA,IAAI,IAAK,CAAA,GAAA,CAAI,GAAG,CAAA,IAAK,CAAG,EAAA;AACtB,MAAO,OAAA,CAAA,CAAE,OAAO,CAAE,CAAA,IAAA,CAAA;AAAA,KACpB;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACD,EAAI,IAAA,QAAA,CAAA;AACJ,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,oBAAA,EAAsB,CAAK,EAAA,EAAA;AAC7C,IAAA,MAAM,gBAAgB,cAAe,CAAA,CAAA,CAAA,CAAA;AAErC,IAAA,MAAM,oBACJ,QACA,IAAA,QAAA,CAAS,GAAO,IAAA,aAAA,CAAc,OAC9B,QAAS,CAAA,GAAA,GAAM,QAAS,CAAA,MAAA,GAAS,cAAc,GAC/C,IAAA,QAAA,CAAS,IAAO,GAAA,QAAA,CAAS,QAAQ,aAAc,CAAA,IAAA,CAAA;AAEjD,IAAA,MAAM,qBACJ,GAAA,aAAA,CAAc,KAAQ,GAAA,WAAA,KAAgB,QAAS,CAAA,KAAA,CAAA;AACjD,IAAA,IAAI,qBAAqB,qBAAuB,EAAA;AAC9C,MAAe,cAAA,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAC5B,MAAA,oBAAA,EAAA,CAAA;AACA,MAAA,SAAA;AAAA,KACF;AACA,IAAW,QAAA,GAAA,aAAA,CAAA;AAAA,GACb;AACA,EAAO,OAAA,cAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"create-rects-from-dom-range.cjs","sources":["../src/create-rects-from-dom-range.ts"],"sourcesContent":["/**\n * MIT License\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\n/**\n * Creates DOMRects, generally used to help the editor find a specific location on the screen.\n * @param editor - The lexical editor\n * @param range - A fragment of a document that can contain nodes and parts of text nodes.\n * @returns The selectionRects as an array.\n */\nexport function createRectsFromDOMRange(\n editor: LexicalEditor,\n range: Range\n): Array<ClientRect> {\n const rootElement = editor.getRootElement();\n\n if (rootElement === null) {\n return [];\n }\n const rootRect = rootElement.getBoundingClientRect();\n const computedStyle = getComputedStyle(rootElement);\n const rootPadding =\n parseFloat(computedStyle.paddingLeft) +\n parseFloat(computedStyle.paddingRight);\n const selectionRects = Array.from(range.getClientRects());\n let selectionRectsLength = selectionRects.length;\n //sort rects from top left to bottom right.\n selectionRects.sort((a, b) => {\n const top = a.top - b.top;\n // Some rects match position closely, but not perfectly,\n // so we give a 3px tolerance.\n if (Math.abs(top) <= 3) {\n return a.left - b.left;\n }\n return top;\n });\n let prevRect;\n for (let i = 0; i < selectionRectsLength; i++) {\n const selectionRect = selectionRects[i];\n // Exclude rects that overlap preceding Rects in the sorted list.\n const isOverlappingRect =\n prevRect &&\n prevRect.top <= selectionRect.top &&\n prevRect.top + prevRect.height > selectionRect.top &&\n prevRect.left + prevRect.width > selectionRect.left;\n // Exclude selections that span the entire element\n const selectionSpansElement =\n selectionRect.width + rootPadding === rootRect.width;\n if (isOverlappingRect || selectionSpansElement) {\n selectionRects.splice(i--, 1);\n selectionRectsLength--;\n continue;\n }\n prevRect = selectionRect;\n }\n return selectionRects;\n}\n"],"names":[],"mappings":";;AA+BgB,SAAA,uBAAA,CACd,QACA,KACmB,EAAA;AACnB,EAAM,MAAA,WAAA,GAAc,OAAO,cAAe,EAAA,CAAA;AAE1C,EAAA,IAAI,gBAAgB,IAAM,EAAA;AACxB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AACA,EAAM,MAAA,QAAA,GAAW,YAAY,qBAAsB,EAAA,CAAA;AACnD,EAAM,MAAA,aAAA,GAAgB,iBAAiB,WAAW,C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AA;AAAA,KACF;AACA,IAAW,QAAA,GAAA,aAAA,CAAA;AAAA,GACb;AACA,EAAO,OAAA,cAAA,CAAA;AACT;;;;"}
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  function createRectsFromDOMRange(editor, range) {
4
2
  const rootElement = editor.getRootElement();
5
3
  if (rootElement === null) {
@@ -32,5 +30,5 @@ function createRectsFromDOMRange(editor, range) {
32
30
  return selectionRects;
33
31
  }
34
32
 
35
- exports.createRectsFromDOMRange = createRectsFromDOMRange;
33
+ export { createRectsFromDOMRange };
36
34
  //# sourceMappingURL=create-rects-from-dom-range.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-rects-from-dom-range.js","sources":["../src/create-rects-from-dom-range.ts"],"sourcesContent":["/**\n * MIT License\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\n/**\n * Creates DOMRects, generally used to help the editor find a specific location on the screen.\n * @param editor - The lexical editor\n * @param range - A fragment of a document that can contain nodes and parts of text nodes.\n * @returns The selectionRects as an array.\n */\nexport function createRectsFromDOMRange(\n editor: LexicalEditor,\n range: Range\n): Array<ClientRect> {\n const rootElement = editor.getRootElement();\n\n if (rootElement === null) {\n return [];\n }\n const rootRect = rootElement.getBoundingClientRect();\n const computedStyle = getComputedStyle(rootElement);\n const rootPadding =\n parseFloat(computedStyle.paddingLeft) +\n parseFloat(computedStyle.paddingRight);\n const selectionRects = Array.from(range.getClientRects());\n let selectionRectsLength = selectionRects.length;\n //sort rects from top left to bottom right.\n selectionRects.sort((a, b) => {\n const top = a.top - b.top;\n // Some rects match position closely, but not perfectly,\n // so we give a 3px tolerance.\n if (Math.abs(top) <= 3) {\n return a.left - b.left;\n }\n return top;\n });\n let prevRect;\n for (let i = 0; i < selectionRectsLength; i++) {\n const selectionRect = selectionRects[i];\n // Exclude rects that overlap preceding Rects in the sorted list.\n const isOverlappingRect =\n prevRect &&\n prevRect.top <= selectionRect.top &&\n prevRect.top + prevRect.height > selectionRect.top &&\n prevRect.left + prevRect.width > selectionRect.left;\n // Exclude selections that span the entire element\n const selectionSpansElement =\n selectionRect.width + rootPadding === rootRect.width;\n if (isOverlappingRect || selectionSpansElement) {\n selectionRects.splice(i--, 1);\n selectionRectsLength--;\n continue;\n }\n prevRect = selectionRect;\n }\n return selectionRects;\n}\n"],"names":[],"mappings":";;AA+BgB,SAAA,uBAAA,CACd,QACA,KACmB,EAAA;AACnB,EAAM,MAAA,WAAA,GAAc,OAAO,cAAe,EAAA,CAAA;AAE1C,EAAA,IAAI,gBAAgB,IAAM,EAAA;AACxB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AACA,EAAM,MAAA,QAAA,GAAW,YAAY,qBAAsB,EAAA,CAAA;AACnD,EAAM,MAAA,aAAA,GAAgB,iBAAiB,WAAW,CAAA,CAAA;AAClD,EAAA,MAAM,cACJ,UAAW,CAAA,aAAA,CAAc,WAAW,CACpC,GAAA,UAAA,CA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AA;AACT;;;;"}
1
+ {"version":3,"file":"create-rects-from-dom-range.js","sources":["../src/create-rects-from-dom-range.ts"],"sourcesContent":["/**\n * MIT License\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\n/**\n * Creates DOMRects, generally used to help the editor find a specific location on the screen.\n * @param editor - The lexical editor\n * @param range - A fragment of a document that can contain nodes and parts of text nodes.\n * @returns The selectionRects as an array.\n */\nexport function createRectsFromDOMRange(\n editor: LexicalEditor,\n range: Range\n): Array<ClientRect> {\n const rootElement = editor.getRootElement();\n\n if (rootElement === null) {\n return [];\n }\n const rootRect = rootElement.getBoundingClientRect();\n const computedStyle = getComputedStyle(rootElement);\n const rootPadding =\n parseFloat(computedStyle.paddingLeft) +\n parseFloat(computedStyle.paddingRight);\n const selectionRects = Array.from(range.getClientRects());\n let selectionRectsLength = selectionRects.length;\n //sort rects from top left to bottom right.\n selectionRects.sort((a, b) => {\n const top = a.top - b.top;\n // Some rects match position closely, but not perfectly,\n // so we give a 3px tolerance.\n if (Math.abs(top) <= 3) {\n return a.left - b.left;\n }\n return top;\n });\n let prevRect;\n for (let i = 0; i < selectionRectsLength; i++) {\n const selectionRect = selectionRects[i];\n // Exclude rects that overlap preceding Rects in the sorted list.\n const isOverlappingRect =\n prevRect &&\n prevRect.top <= selectionRect.top &&\n prevRect.top + prevRect.height > selectionRect.top &&\n prevRect.left + prevRect.width > selectionRect.left;\n // Exclude selections that span the entire element\n const selectionSpansElement =\n selectionRect.width + rootPadding === rootRect.width;\n if (isOverlappingRect || selectionSpansElement) {\n selectionRects.splice(i--, 1);\n selectionRectsLength--;\n continue;\n }\n prevRect = selectionRect;\n }\n return selectionRects;\n}\n"],"names":[],"mappings":"AA+BgB,SAAA,uBAAA,CACd,QACA,KACmB,EAAA;AACnB,EAAM,MAAA,WAAA,GAAc,OAAO,cAAe,EAAA,CAAA;AAE1C,EAAA,IAAI,gBAAgB,IAAM,EAAA;AACxB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AACA,EAAM,MAAA,QAAA,GAAW,YAAY,qBAAsB,EAAA,CAAA;AACnD,EAAM,MAAA,aAAA,GAAgB,iBAAiB,WAAW,CAAA,CAAA;AAClD,EAAA,MAAM,cACJ,UAAW,CAAA,aAAA,CAAc,WAAW,CACpC,GAAA,UAAA,CAAW,cAAc,YAAY,CAAA,CAAA;AACvC,EAAA,MAAM,cAAiB,GAAA,KAAA,CAAM,IAAK,CAAA,KAAA,CAAM,gBAAgB,CAAA,CAAA;AACxD,EAAA,IAAI,uBAAuB,cAAe,CAAA,MAAA,CAAA;AAE1C,EAAe,cAAA,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAM,KAAA;AAC5B,IAAM,MAAA,GAAA,GAAM,CAAE,CAAA,GAAA,GAAM,CAAE,CAAA,GAAA,CAAA;AAGtB,IAAA,IAAI,IAAK,CAAA,GAAA,CAAI,GAAG,CAAA,IAAK,CAAG,EAAA;AACtB,MAAO,OAAA,CAAA,CAAE,OAAO,CAAE,CAAA,IAAA,CAAA;AAAA,KACpB;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACD,EAAI,IAAA,QAAA,CAAA;AACJ,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,oBAAA,EAAsB,CAAK,EAAA,EAAA;AAC7C,IAAA,MAAM,gBAAgB,cAAe,CAAA,CAAA,CAAA,CAAA;AAErC,IAAA,MAAM,oBACJ,QACA,IAAA,QAAA,CAAS,GAAO,IAAA,aAAA,CAAc,OAC9B,QAAS,CAAA,GAAA,GAAM,QAAS,CAAA,MAAA,GAAS,cAAc,GAC/C,IAAA,QAAA,CAAS,IAAO,GAAA,QAAA,CAAS,QAAQ,aAAc,CAAA,IAAA,CAAA;AAEjD,IAAA,MAAM,qBACJ,GAAA,aAAA,CAAc,KAAQ,GAAA,WAAA,KAAgB,QAAS,CAAA,KAAA,CAAA;AACjD,IAAA,IAAI,qBAAqB,qBAAuB,EAAA;AAC9C,MAAe,cAAA,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAC5B,MAAA,oBAAA,EAAA,CAAA;AACA,MAAA,SAAA;AAAA,KACF;AACA,IAAW,QAAA,GAAA,aAAA,CAAA;AAAA,GACb;AACA,EAAO,OAAA,cAAA,CAAA;AACT;;;;"}
package/dist/index.cjs ADDED
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var core = require('@liveblocks/core');
4
+ var version = require('./version.cjs');
5
+ var anchoredThreads = require('./comments/anchored-threads.cjs');
6
+ var commentPluginProvider = require('./comments/comment-plugin-provider.cjs');
7
+ var floatingComposer = require('./comments/floating-composer.cjs');
8
+ var floatingThreads = require('./comments/floating-threads.cjs');
9
+ var isBlockNodeActive = require('./is-block-node-active.cjs');
10
+ var isTextFormatActive = require('./is-text-format-active.cjs');
11
+ var liveblocksConfig = require('./liveblocks-config.cjs');
12
+ var liveblocksPluginProvider = require('./liveblocks-plugin-provider.cjs');
13
+ var floatingToolbar = require('./toolbar/floating-toolbar.cjs');
14
+ var toolbar = require('./toolbar/toolbar.cjs');
15
+ var historyVersionPreview = require('./version-history/history-version-preview.cjs');
16
+
17
+ core.detectDupes(version.PKG_NAME, version.PKG_VERSION, version.PKG_FORMAT);
18
+
19
+ exports.AnchoredThreads = anchoredThreads.AnchoredThreads;
20
+ exports.useIsThreadActive = commentPluginProvider.useIsThreadActive;
21
+ exports.FloatingComposer = floatingComposer.FloatingComposer;
22
+ exports.OPEN_FLOATING_COMPOSER_COMMAND = floatingComposer.OPEN_FLOATING_COMPOSER_COMMAND;
23
+ exports.FloatingThreads = floatingThreads.FloatingThreads;
24
+ exports.isBlockNodeActive = isBlockNodeActive.isBlockNodeActive;
25
+ exports.isTextFormatActive = isTextFormatActive.isTextFormatActive;
26
+ exports.liveblocksConfig = liveblocksConfig.liveblocksConfig;
27
+ exports.LiveblocksPlugin = liveblocksPluginProvider.LiveblocksPlugin;
28
+ exports.useEditorStatus = liveblocksPluginProvider.useEditorStatus;
29
+ exports.useIsEditorReady = liveblocksPluginProvider.useIsEditorReady;
30
+ exports.FloatingToolbar = floatingToolbar.FloatingToolbar;
31
+ exports.Toolbar = toolbar.Toolbar;
32
+ exports.HistoryVersionPreview = historyVersionPreview.HistoryVersionPreview;
33
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { AnchoredThreadsProps } from \"./comments/anchored-threads\";\nexport { AnchoredThreads } from \"./comments/anchored-threads\";\nexport { useIsThreadActive } from \"./comments/comment-plugin-provider\";\nexport type { FloatingComposerProps } from \"./comments/floating-composer\";\nexport {\n FloatingComposer,\n OPEN_FLOATING_COMPOSER_COMMAND,\n} from \"./comments/floating-composer\";\nexport type { FloatingThreadsProps } from \"./comments/floating-threads\";\nexport { FloatingThreads } from \"./comments/floating-threads\";\nexport { isBlockNodeActive } from \"./is-block-node-active\";\nexport { isTextFormatActive } from \"./is-text-format-active\";\nexport { liveblocksConfig } from \"./liveblocks-config\";\nexport {\n LiveblocksPlugin,\n useEditorStatus,\n useIsEditorReady,\n} from \"./liveblocks-plugin-provider\";\nexport type { FloatingToolbarProps } from \"./toolbar/floating-toolbar\";\nexport { FloatingToolbar } from \"./toolbar/floating-toolbar\";\nexport type {\n ToolbarBlockSelectorItem,\n ToolbarBlockSelectorProps,\n ToolbarButtonProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n ToolbarToggleProps,\n} from \"./toolbar/toolbar\";\nexport { Toolbar } from \"./toolbar/toolbar\";\nexport type { HistoryVersionPreviewProps } from \"./version-history/history-version-preview\";\nexport { HistoryVersionPreview } from \"./version-history/history-version-preview\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { AnchoredThreadsProps } from \"./comments/anchored-threads\";\nexport { AnchoredThreads } from \"./comments/anchored-threads\";\nexport { useIsThreadActive } from \"./comments/comment-plugin-provider\";\nexport type { FloatingComposerProps } from \"./comments/floating-composer\";\nexport {\n FloatingComposer,\n OPEN_FLOATING_COMPOSER_COMMAND,\n} from \"./comments/floating-composer\";\nexport type { FloatingThreadsProps } from \"./comments/floating-threads\";\nexport { FloatingThreads } from \"./comments/floating-threads\";\nexport { isBlockNodeActive } from \"./is-block-node-active\";\nexport { isTextFormatActive } from \"./is-text-format-active\";\nexport { liveblocksConfig } from \"./liveblocks-config\";\nexport {\n LiveblocksPlugin,\n useEditorStatus,\n useIsEditorReady,\n} from \"./liveblocks-plugin-provider\";\nexport type { FloatingToolbarProps } from \"./toolbar/floating-toolbar\";\nexport { FloatingToolbar } from \"./toolbar/floating-toolbar\";\nexport type {\n ToolbarBlockSelectorItem,\n ToolbarBlockSelectorProps,\n ToolbarButtonProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n ToolbarToggleProps,\n} from \"./toolbar/toolbar\";\nexport { Toolbar } from \"./toolbar/toolbar\";\nexport type { HistoryVersionPreviewProps } from \"./version-history/history-version-preview\";\nexport { HistoryVersionPreview } from \"./version-history/history-version-preview\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,33 +1,16 @@
1
- 'use strict';
1
+ import { detectDupes } from '@liveblocks/core';
2
+ import { PKG_NAME, PKG_VERSION, PKG_FORMAT } from './version.js';
3
+ export { AnchoredThreads } from './comments/anchored-threads.js';
4
+ export { useIsThreadActive } from './comments/comment-plugin-provider.js';
5
+ export { FloatingComposer, OPEN_FLOATING_COMPOSER_COMMAND } from './comments/floating-composer.js';
6
+ export { FloatingThreads } from './comments/floating-threads.js';
7
+ export { isBlockNodeActive } from './is-block-node-active.js';
8
+ export { isTextFormatActive } from './is-text-format-active.js';
9
+ export { liveblocksConfig } from './liveblocks-config.js';
10
+ export { LiveblocksPlugin, useEditorStatus, useIsEditorReady } from './liveblocks-plugin-provider.js';
11
+ export { FloatingToolbar } from './toolbar/floating-toolbar.js';
12
+ export { Toolbar } from './toolbar/toolbar.js';
13
+ export { HistoryVersionPreview } from './version-history/history-version-preview.js';
2
14
 
3
- var core = require('@liveblocks/core');
4
- var version = require('./version.js');
5
- var anchoredThreads = require('./comments/anchored-threads.js');
6
- var commentPluginProvider = require('./comments/comment-plugin-provider.js');
7
- var floatingComposer = require('./comments/floating-composer.js');
8
- var floatingThreads = require('./comments/floating-threads.js');
9
- var isBlockNodeActive = require('./is-block-node-active.js');
10
- var isTextFormatActive = require('./is-text-format-active.js');
11
- var liveblocksConfig = require('./liveblocks-config.js');
12
- var liveblocksPluginProvider = require('./liveblocks-plugin-provider.js');
13
- var floatingToolbar = require('./toolbar/floating-toolbar.js');
14
- var toolbar = require('./toolbar/toolbar.js');
15
- var historyVersionPreview = require('./version-history/history-version-preview.js');
16
-
17
- core.detectDupes(version.PKG_NAME, version.PKG_VERSION, version.PKG_FORMAT);
18
-
19
- exports.AnchoredThreads = anchoredThreads.AnchoredThreads;
20
- exports.useIsThreadActive = commentPluginProvider.useIsThreadActive;
21
- exports.FloatingComposer = floatingComposer.FloatingComposer;
22
- exports.OPEN_FLOATING_COMPOSER_COMMAND = floatingComposer.OPEN_FLOATING_COMPOSER_COMMAND;
23
- exports.FloatingThreads = floatingThreads.FloatingThreads;
24
- exports.isBlockNodeActive = isBlockNodeActive.isBlockNodeActive;
25
- exports.isTextFormatActive = isTextFormatActive.isTextFormatActive;
26
- exports.liveblocksConfig = liveblocksConfig.liveblocksConfig;
27
- exports.LiveblocksPlugin = liveblocksPluginProvider.LiveblocksPlugin;
28
- exports.useEditorStatus = liveblocksPluginProvider.useEditorStatus;
29
- exports.useIsEditorReady = liveblocksPluginProvider.useIsEditorReady;
30
- exports.FloatingToolbar = floatingToolbar.FloatingToolbar;
31
- exports.Toolbar = toolbar.Toolbar;
32
- exports.HistoryVersionPreview = historyVersionPreview.HistoryVersionPreview;
15
+ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
33
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { AnchoredThreadsProps } from \"./comments/anchored-threads\";\nexport { AnchoredThreads } from \"./comments/anchored-threads\";\nexport { useIsThreadActive } from \"./comments/comment-plugin-provider\";\nexport type { FloatingComposerProps } from \"./comments/floating-composer\";\nexport {\n FloatingComposer,\n OPEN_FLOATING_COMPOSER_COMMAND,\n} from \"./comments/floating-composer\";\nexport type { FloatingThreadsProps } from \"./comments/floating-threads\";\nexport { FloatingThreads } from \"./comments/floating-threads\";\nexport { isBlockNodeActive } from \"./is-block-node-active\";\nexport { isTextFormatActive } from \"./is-text-format-active\";\nexport { liveblocksConfig } from \"./liveblocks-config\";\nexport {\n LiveblocksPlugin,\n useEditorStatus,\n useIsEditorReady,\n} from \"./liveblocks-plugin-provider\";\nexport type { FloatingToolbarProps } from \"./toolbar/floating-toolbar\";\nexport { FloatingToolbar } from \"./toolbar/floating-toolbar\";\nexport type {\n ToolbarBlockSelectorItem,\n ToolbarBlockSelectorProps,\n ToolbarButtonProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n ToolbarToggleProps,\n} from \"./toolbar/toolbar\";\nexport { Toolbar } from \"./toolbar/toolbar\";\nexport type { HistoryVersionPreviewProps } from \"./version-history/history-version-preview\";\nexport { HistoryVersionPreview } from \"./version-history/history-version-preview\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { AnchoredThreadsProps } from \"./comments/anchored-threads\";\nexport { AnchoredThreads } from \"./comments/anchored-threads\";\nexport { useIsThreadActive } from \"./comments/comment-plugin-provider\";\nexport type { FloatingComposerProps } from \"./comments/floating-composer\";\nexport {\n FloatingComposer,\n OPEN_FLOATING_COMPOSER_COMMAND,\n} from \"./comments/floating-composer\";\nexport type { FloatingThreadsProps } from \"./comments/floating-threads\";\nexport { FloatingThreads } from \"./comments/floating-threads\";\nexport { isBlockNodeActive } from \"./is-block-node-active\";\nexport { isTextFormatActive } from \"./is-text-format-active\";\nexport { liveblocksConfig } from \"./liveblocks-config\";\nexport {\n LiveblocksPlugin,\n useEditorStatus,\n useIsEditorReady,\n} from \"./liveblocks-plugin-provider\";\nexport type { FloatingToolbarProps } from \"./toolbar/floating-toolbar\";\nexport { FloatingToolbar } from \"./toolbar/floating-toolbar\";\nexport type {\n ToolbarBlockSelectorItem,\n ToolbarBlockSelectorProps,\n ToolbarButtonProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n ToolbarToggleProps,\n} from \"./toolbar/toolbar\";\nexport { Toolbar } from \"./toolbar/toolbar\";\nexport type { HistoryVersionPreviewProps } from \"./version-history/history-version-preview\";\nexport { HistoryVersionPreview } from \"./version-history/history-version-preview\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
@@ -1,16 +1,18 @@
1
- import { $findMatchingParent } from '@lexical/utils';
2
- import { $isRootOrShadowRoot, $getSelection, $isRangeSelection } from 'lexical';
1
+ 'use strict';
2
+
3
+ var utils = require('@lexical/utils');
4
+ var lexical = require('lexical');
3
5
 
4
6
  function isParentRootOrShadowRoot(node) {
5
7
  const parent = node.getParent();
6
- return parent !== null && $isRootOrShadowRoot(parent);
8
+ return parent !== null && lexical.$isRootOrShadowRoot(parent);
7
9
  }
8
10
  const activeNodesByEditor = /* @__PURE__ */ new WeakMap();
9
11
  function getActiveBlockNodes(editor) {
10
12
  const currentState = editor.getEditorState();
11
13
  return currentState.read(() => {
12
- const selection = $getSelection();
13
- if (!$isRangeSelection(selection)) {
14
+ const selection = lexical.$getSelection();
15
+ if (!lexical.$isRangeSelection(selection)) {
14
16
  activeNodesByEditor.delete(editor);
15
17
  return [];
16
18
  }
@@ -22,13 +24,13 @@ function getActiveBlockNodes(editor) {
22
24
  const focus = selection.focus.getNode();
23
25
  const commonAncestor = anchor.getCommonAncestor(focus);
24
26
  let activeNodes = [];
25
- if (commonAncestor && !$isRootOrShadowRoot(commonAncestor)) {
26
- const activeNode = isParentRootOrShadowRoot(commonAncestor) ? commonAncestor : $findMatchingParent(commonAncestor, isParentRootOrShadowRoot);
27
+ if (commonAncestor && !lexical.$isRootOrShadowRoot(commonAncestor)) {
28
+ const activeNode = isParentRootOrShadowRoot(commonAncestor) ? commonAncestor : utils.$findMatchingParent(commonAncestor, isParentRootOrShadowRoot);
27
29
  if (activeNode) {
28
30
  activeNodes = [activeNode];
29
31
  }
30
32
  } else {
31
- activeNodes = selection.getNodes().filter((node) => $isRootOrShadowRoot(node.getParent()));
33
+ activeNodes = selection.getNodes().filter((node) => lexical.$isRootOrShadowRoot(node.getParent()));
32
34
  }
33
35
  activeNodesByEditor.set(editor, {
34
36
  state: currentState,
@@ -45,5 +47,5 @@ function isBlockNodeActive(editor, isActive) {
45
47
  return activeNodes.every(isActive);
46
48
  }
47
49
 
48
- export { isBlockNodeActive };
49
- //# sourceMappingURL=is-block-node-active.mjs.map
50
+ exports.isBlockNodeActive = isBlockNodeActive;
51
+ //# sourceMappingURL=is-block-node-active.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-block-node-active.mjs","sources":["../src/is-block-node-active.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport type { EditorState, LexicalEditor, LexicalNode } from \"lexical\";\nimport { $getSelection, $isRangeSelection, $isRootOrShadowRoot } from \"lexical\";\n\nfunction isParentRootOrShadowRoot(node: LexicalNode) {\n const parent = node.getParent();\n\n return parent !== null && $isRootOrShadowRoot(parent);\n}\n\nconst activeNodesByEditor = new WeakMap<\n LexicalEditor,\n {\n state: EditorState;\n nodes: LexicalNode[];\n }\n>();\n\nfunction getActiveBlockNodes(editor: LexicalEditor) {\n const currentState = editor.getEditorState();\n\n return currentState.read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection)) {\n activeNodesByEditor.delete(editor);\n\n return [];\n }\n\n const cache = activeNodesByEditor.get(editor);\n\n if (cache?.state === currentState) {\n return cache.nodes;\n }\n\n const anchor = selection.anchor.getNode();\n const focus = selection.focus.getNode();\n const commonAncestor = anchor.getCommonAncestor(focus);\n\n let activeNodes: LexicalNode[] = [];\n\n if (commonAncestor && !$isRootOrShadowRoot(commonAncestor)) {\n const activeNode = isParentRootOrShadowRoot(commonAncestor)\n ? commonAncestor\n : $findMatchingParent(commonAncestor, isParentRootOrShadowRoot);\n\n if (activeNode) {\n activeNodes = [activeNode];\n }\n } else {\n activeNodes = selection\n .getNodes()\n .filter((node) => $isRootOrShadowRoot(node.getParent()));\n }\n\n activeNodesByEditor.set(editor, {\n state: currentState,\n nodes: activeNodes,\n });\n\n return activeNodes;\n });\n}\n\n/**\n * Checks if a block node is active in the current selection.\n * If the selection contains multiple block nodes, it will return\n * `true` only if all of them are of the same type.\n */\nexport function isBlockNodeActive(\n editor: LexicalEditor,\n isActive: (node: LexicalNode) => boolean\n): boolean {\n const activeNodes = getActiveBlockNodes(editor);\n\n if (activeNodes.length === 0) {\n return false;\n }\n\n return activeNodes.every(isActive);\n}\n"],"names":[],"mappings":";;;AAIA,SAAS,yBAAyB,IAAmB,EAAA;AACnD,EAAM,MAAA,MAAA,GAAS,KAAK,SAAU,EAAA,CAAA;AAE9B,EAAO,OAAA,MAAA,KAAW,IAAQ,IAAA,mBAAA,CAAoB,MAAM,CAAA,CAAA;AACtD,CAAA;AAEA,MAAM,mBAAA,uBAA0B,OAM9B,EAAA,CAAA;AAEF,SAAS,oBAAoB,MAAuB,EAAA;AAClD,EAAM,MAAA,YAAA,GAAe,OAAO,cAAe,EAAA,CAAA;AAE3C,EAAO,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AAA,WAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACH,CAAA;AAOgB,SAAA,iBAAA,CACd,QACA,QACS,EAAA;AACT,EAAM,MAAA,WAAA,GAAc,oBAAoB,MAAM,CAAA,CAAA;AAE9C,EAAI,IAAA,WAAA,CAAY,WAAW,CAAG,EAAA;AAC5B,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,WAAA,CAAY,MAAM,QAAQ,CAAA,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"is-block-node-active.cjs","sources":["../src/is-block-node-active.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport type { EditorState, LexicalEditor, LexicalNode } from \"lexical\";\nimport { $getSelection, $isRangeSelection, $isRootOrShadowRoot } from \"lexical\";\n\nfunction isParentRootOrShadowRoot(node: LexicalNode) {\n const parent = node.getParent();\n\n return parent !== null && $isRootOrShadowRoot(parent);\n}\n\nconst activeNodesByEditor = new WeakMap<\n LexicalEditor,\n {\n state: EditorState;\n nodes: LexicalNode[];\n }\n>();\n\nfunction getActiveBlockNodes(editor: LexicalEditor) {\n const currentState = editor.getEditorState();\n\n return currentState.read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection)) {\n activeNodesByEditor.delete(editor);\n\n return [];\n }\n\n const cache = activeNodesByEditor.get(editor);\n\n if (cache?.state === currentState) {\n return cache.nodes;\n }\n\n const anchor = selection.anchor.getNode();\n const focus = selection.focus.getNode();\n const commonAncestor = anchor.getCommonAncestor(focus);\n\n let activeNodes: LexicalNode[] = [];\n\n if (commonAncestor && !$isRootOrShadowRoot(commonAncestor)) {\n const activeNode = isParentRootOrShadowRoot(commonAncestor)\n ? commonAncestor\n : $findMatchingParent(commonAncestor, isParentRootOrShadowRoot);\n\n if (activeNode) {\n activeNodes = [activeNode];\n }\n } else {\n activeNodes = selection\n .getNodes()\n .filter((node) => $isRootOrShadowRoot(node.getParent()));\n }\n\n activeNodesByEditor.set(editor, {\n state: currentState,\n nodes: activeNodes,\n });\n\n return activeNodes;\n });\n}\n\n/**\n * Checks if a block node is active in the current selection.\n * If the selection contains multiple block nodes, it will return\n * `true` only if all of them are of the same type.\n */\nexport function isBlockNodeActive(\n editor: LexicalEditor,\n isActive: (node: LexicalNode) => boolean\n): boolean {\n const activeNodes = getActiveBlockNodes(editor);\n\n if (activeNodes.length === 0) {\n return false;\n }\n\n return activeNodes.every(isActive);\n}\n"],"names":["$isRootOrShadowRoot","$getSelection","$isRangeSelection","$findMatchingParent"],"mappings":";;;;;AAIA,SAAS,yBAAyB,IAAmB,EAAA;AACnD,EAAM,MAAA,MAAA,GAAS,KAAK,SAAU,EAAA,CAAA;AAE9B,EAAO,OAAA,MAAA,KAAW,IAAQ,IAAAA,2BAAA,CAAoB,MAAM,CAAA,CAAA;AACtD,CAAA;AAEA,MAAM,mBAAA,uBAA0B,OAM9B,EAAA,CAAA;AAEF,SAAS,oBAAoB,MAAuB,EAAA;AAClD,EAAM,MAAA,YAAA,GAAe,OAAO,cAAe,EAAA,CAAA;AAE3C,EAAO,OAAA,YAAA,CAAa,KAAK,MAAM;AAC7B,IAAA,MAAM,YAAYC,qBAAc,EAAA,CAAA;AAEhC,IAAI,IAAA,CAACC,yBAAkB,CAAA,SAAS,CAAG,EAAA;AACjC,MAAA,mBAAA,CAAoB,OAAO,MAAM,CAAA,CAAA;AAEjC,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AAEA,IAAM,MAAA,KAAA,GAAQ,mBAAoB,CAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AAE5C,IAAI,IAAA,KAAA,EAAO,UAAU,YAAc,EAAA;AACjC,MAAA,OAAO,KAAM,CAAA,KAAA,CAAA;AAAA,KACf;AAEA,IAAM,MAAA,MAAA,GAAS,SAAU,CAAA,MAAA,CAAO,OAAQ,EAAA,CAAA;AACxC,IAAM,MAAA,KAAA,GAAQ,SAAU,CAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AACtC,IAAM,MAAA,cAAA,GAAiB,MAAO,CAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAErD,IAAA,IAAI,cAA6B,EAAC,CAAA;AAElC,IAAA,IAAI,cAAkB,IAAA,CAACF,2BAAoB,CAAA,cAAc,CAAG,EAAA;AAC1D,MAAA,MAAM,aAAa,wBAAyB,CAAA,cAAc,IACtD,cACA,GAAAG,yBAAA,CAAoB,gBAAgB,wBAAwB,CAAA,CAAA;AAEhE,MAAA,IAAI,UAAY,EAAA;AACd,QAAA,WAAA,GAAc,CAAC,UAAU,CAAA,CAAA;AAAA,OAC3B;AAAA,KACK,MAAA;AACL,MAAc,WAAA,GAAA,SAAA,CACX,QAAS,EAAA,CACT,MAAO,CAAA,CAAC,SAASH,2BAAoB,CAAA,IAAA,CAAK,SAAU,EAAC,CAAC,CAAA,CAAA;AAAA,KAC3D;AAEA,IAAA,mBAAA,CAAoB,IAAI,MAAQ,EAAA;AAAA,MAC9B,KAAO,EAAA,YAAA;AAAA,MACP,KAAO,EAAA,WAAA;AAAA,KACR,CAAA,CAAA;AAED,IAAO,OAAA,WAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACH,CAAA;AAOgB,SAAA,iBAAA,CACd,QACA,QACS,EAAA;AACT,EAAM,MAAA,WAAA,GAAc,oBAAoB,MAAM,CAAA,CAAA;AAE9C,EAAI,IAAA,WAAA,CAAY,WAAW,CAAG,EAAA;AAC5B,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,WAAA,CAAY,MAAM,QAAQ,CAAA,CAAA;AACnC;;;;"}
@@ -1,18 +1,16 @@
1
- 'use strict';
2
-
3
- var utils = require('@lexical/utils');
4
- var lexical = require('lexical');
1
+ import { $findMatchingParent } from '@lexical/utils';
2
+ import { $isRootOrShadowRoot, $getSelection, $isRangeSelection } from 'lexical';
5
3
 
6
4
  function isParentRootOrShadowRoot(node) {
7
5
  const parent = node.getParent();
8
- return parent !== null && lexical.$isRootOrShadowRoot(parent);
6
+ return parent !== null && $isRootOrShadowRoot(parent);
9
7
  }
10
8
  const activeNodesByEditor = /* @__PURE__ */ new WeakMap();
11
9
  function getActiveBlockNodes(editor) {
12
10
  const currentState = editor.getEditorState();
13
11
  return currentState.read(() => {
14
- const selection = lexical.$getSelection();
15
- if (!lexical.$isRangeSelection(selection)) {
12
+ const selection = $getSelection();
13
+ if (!$isRangeSelection(selection)) {
16
14
  activeNodesByEditor.delete(editor);
17
15
  return [];
18
16
  }
@@ -24,13 +22,13 @@ function getActiveBlockNodes(editor) {
24
22
  const focus = selection.focus.getNode();
25
23
  const commonAncestor = anchor.getCommonAncestor(focus);
26
24
  let activeNodes = [];
27
- if (commonAncestor && !lexical.$isRootOrShadowRoot(commonAncestor)) {
28
- const activeNode = isParentRootOrShadowRoot(commonAncestor) ? commonAncestor : utils.$findMatchingParent(commonAncestor, isParentRootOrShadowRoot);
25
+ if (commonAncestor && !$isRootOrShadowRoot(commonAncestor)) {
26
+ const activeNode = isParentRootOrShadowRoot(commonAncestor) ? commonAncestor : $findMatchingParent(commonAncestor, isParentRootOrShadowRoot);
29
27
  if (activeNode) {
30
28
  activeNodes = [activeNode];
31
29
  }
32
30
  } else {
33
- activeNodes = selection.getNodes().filter((node) => lexical.$isRootOrShadowRoot(node.getParent()));
31
+ activeNodes = selection.getNodes().filter((node) => $isRootOrShadowRoot(node.getParent()));
34
32
  }
35
33
  activeNodesByEditor.set(editor, {
36
34
  state: currentState,
@@ -47,5 +45,5 @@ function isBlockNodeActive(editor, isActive) {
47
45
  return activeNodes.every(isActive);
48
46
  }
49
47
 
50
- exports.isBlockNodeActive = isBlockNodeActive;
48
+ export { isBlockNodeActive };
51
49
  //# sourceMappingURL=is-block-node-active.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-block-node-active.js","sources":["../src/is-block-node-active.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport type { EditorState, LexicalEditor, LexicalNode } from \"lexical\";\nimport { $getSelection, $isRangeSelection, $isRootOrShadowRoot } from \"lexical\";\n\nfunction isParentRootOrShadowRoot(node: LexicalNode) {\n const parent = node.getParent();\n\n return parent !== null && $isRootOrShadowRoot(parent);\n}\n\nconst activeNodesByEditor = new WeakMap<\n LexicalEditor,\n {\n state: EditorState;\n nodes: LexicalNode[];\n }\n>();\n\nfunction getActiveBlockNodes(editor: LexicalEditor) {\n const currentState = editor.getEditorState();\n\n return currentState.read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection)) {\n activeNodesByEditor.delete(editor);\n\n return [];\n }\n\n const cache = activeNodesByEditor.get(editor);\n\n if (cache?.state === currentState) {\n return cache.nodes;\n }\n\n const anchor = selection.anchor.getNode();\n const focus = selection.focus.getNode();\n const commonAncestor = anchor.getCommonAncestor(focus);\n\n let activeNodes: LexicalNode[] = [];\n\n if (commonAncestor && !$isRootOrShadowRoot(commonAncestor)) {\n const activeNode = isParentRootOrShadowRoot(commonAncestor)\n ? commonAncestor\n : $findMatchingParent(commonAncestor, isParentRootOrShadowRoot);\n\n if (activeNode) {\n activeNodes = [activeNode];\n }\n } else {\n activeNodes = selection\n .getNodes()\n .filter((node) => $isRootOrShadowRoot(node.getParent()));\n }\n\n activeNodesByEditor.set(editor, {\n state: currentState,\n nodes: activeNodes,\n });\n\n return activeNodes;\n });\n}\n\n/**\n * Checks if a block node is active in the current selection.\n * If the selection contains multiple block nodes, it will return\n * `true` only if all of them are of the same type.\n */\nexport function isBlockNodeActive(\n editor: LexicalEditor,\n isActive: (node: LexicalNode) => boolean\n): boolean {\n const activeNodes = getActiveBlockNodes(editor);\n\n if (activeNodes.length === 0) {\n return false;\n }\n\n return activeNodes.every(isActive);\n}\n"],"names":["$isRootOrShadowRoot","$getSelection","$isRangeSelection","$findMatchingParent"],"mappings":";;;;;AAIA,SAAS,yBAAyB,IAAmB,EAAA;AACnD,EAAM,MAAA,MAAA,GAAS,KAAK,SAAU,EAAA,CAAA;AAE9B,EAAO,OAAA,MAAA,KAAW,IAAQ,IAAAA,2BAAA,C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AK,SAAU,EAAC,CAAC,CAAA,CAAA;AAAA,KAC3D;AAEA,IAAA,mBAAA,CAAoB,IAAI,MAAQ,EAAA;AAAA,MAC9B,KAAO,EAAA,YAAA;AAAA,MACP,KAAO,EAAA,WAAA;AAAA,KACR,CAAA,CAAA;AAED,IAAO,OAAA,WAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACH,CAAA;AAOgB,SAAA,iBAAA,CACd,QACA,QACS,EAAA;AACT,EAAM,MAAA,WAAA,GAAc,oBAAoB,MAAM,CAAA,CAAA;AAE9C,EAAI,IAAA,WAAA,CAAY,WAAW,CAAG,EAAA;AAC5B,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,WAAA,CAAY,MAAM,QAAQ,CAAA,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"is-block-node-active.js","sources":["../src/is-block-node-active.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport type { EditorState, LexicalEditor, LexicalNode } from \"lexical\";\nimport { $getSelection, $isRangeSelection, $isRootOrShadowRoot } from \"lexical\";\n\nfunction isParentRootOrShadowRoot(node: LexicalNode) {\n const parent = node.getParent();\n\n return parent !== null && $isRootOrShadowRoot(parent);\n}\n\nconst activeNodesByEditor = new WeakMap<\n LexicalEditor,\n {\n state: EditorState;\n nodes: LexicalNode[];\n }\n>();\n\nfunction getActiveBlockNodes(editor: LexicalEditor) {\n const currentState = editor.getEditorState();\n\n return currentState.read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection)) {\n activeNodesByEditor.delete(editor);\n\n return [];\n }\n\n const cache = activeNodesByEditor.get(editor);\n\n if (cache?.state === currentState) {\n return cache.nodes;\n }\n\n const anchor = selection.anchor.getNode();\n const focus = selection.focus.getNode();\n const commonAncestor = anchor.getCommonAncestor(focus);\n\n let activeNodes: LexicalNode[] = [];\n\n if (commonAncestor && !$isRootOrShadowRoot(commonAncestor)) {\n const activeNode = isParentRootOrShadowRoot(commonAncestor)\n ? commonAncestor\n : $findMatchingParent(commonAncestor, isParentRootOrShadowRoot);\n\n if (activeNode) {\n activeNodes = [activeNode];\n }\n } else {\n activeNodes = selection\n .getNodes()\n .filter((node) => $isRootOrShadowRoot(node.getParent()));\n }\n\n activeNodesByEditor.set(editor, {\n state: currentState,\n nodes: activeNodes,\n });\n\n return activeNodes;\n });\n}\n\n/**\n * Checks if a block node is active in the current selection.\n * If the selection contains multiple block nodes, it will return\n * `true` only if all of them are of the same type.\n */\nexport function isBlockNodeActive(\n editor: LexicalEditor,\n isActive: (node: LexicalNode) => boolean\n): boolean {\n const activeNodes = getActiveBlockNodes(editor);\n\n if (activeNodes.length === 0) {\n return false;\n }\n\n return activeNodes.every(isActive);\n}\n"],"names":[],"mappings":";;;AAIA,SAAS,yBAAyB,IAAmB,EAAA;AACnD,EAAM,MAAA,MAAA,GAAS,KAAK,SAAU,EAAA,CAAA;AAE9B,EAAO,OAAA,MAAA,KAAW,IAAQ,IAAA,mBAAA,CAAoB,MAAM,CAAA,CAAA;AACtD,CAAA;AAEA,MAAM,mBAAA,uBAA0B,OAM9B,EAAA,CAAA;AAEF,SAAS,oBAAoB,MAAuB,EAAA;AAClD,EAAM,MAAA,YAAA,GAAe,OAAO,cAAe,EAAA,CAAA;AAE3C,EAAO,OAAA,YAAA,CAAa,KAAK,MAAM;AAC7B,IAAA,MAAM,YAAY,aAAc,EAAA,CAAA;AAEhC,IAAI,IAAA,CAAC,iBAAkB,CAAA,SAAS,CAAG,EAAA;AACjC,MAAA,mBAAA,CAAoB,OAAO,MAAM,CAAA,CAAA;AAEjC,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AAEA,IAAM,MAAA,KAAA,GAAQ,mBAAoB,CAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AAE5C,IAAI,IAAA,KAAA,EAAO,UAAU,YAAc,EAAA;AACjC,MAAA,OAAO,KAAM,CAAA,KAAA,CAAA;AAAA,KACf;AAEA,IAAM,MAAA,MAAA,GAAS,SAAU,CAAA,MAAA,CAAO,OAAQ,EAAA,CAAA;AACxC,IAAM,MAAA,KAAA,GAAQ,SAAU,CAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AACtC,IAAM,MAAA,cAAA,GAAiB,MAAO,CAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAErD,IAAA,IAAI,cAA6B,EAAC,CAAA;AAElC,IAAA,IAAI,cAAkB,IAAA,CAAC,mBAAoB,CAAA,cAAc,CAAG,EAAA;AAC1D,MAAA,MAAM,aAAa,wBAAyB,CAAA,cAAc,IACtD,cACA,GAAA,mBAAA,CAAoB,gBAAgB,wBAAwB,CAAA,CAAA;AAEhE,MAAA,IAAI,UAAY,EAAA;AACd,QAAA,WAAA,GAAc,CAAC,UAAU,CAAA,CAAA;AAAA,OAC3B;AAAA,KACK,MAAA;AACL,MAAc,WAAA,GAAA,SAAA,CACX,QAAS,EAAA,CACT,MAAO,CAAA,CAAC,SAAS,mBAAoB,CAAA,IAAA,CAAK,SAAU,EAAC,CAAC,CAAA,CAAA;AAAA,KAC3D;AAEA,IAAA,mBAAA,CAAoB,IAAI,MAAQ,EAAA;AAAA,MAC9B,KAAO,EAAA,YAAA;AAAA,MACP,KAAO,EAAA,WAAA;AAAA,KACR,CAAA,CAAA;AAED,IAAO,OAAA,WAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACH,CAAA;AAOgB,SAAA,iBAAA,CACd,QACA,QACS,EAAA;AACT,EAAM,MAAA,WAAA,GAAc,oBAAoB,MAAM,CAAA,CAAA;AAE9C,EAAI,IAAA,WAAA,CAAY,WAAW,CAAG,EAAA;AAC5B,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,WAAA,CAAY,MAAM,QAAQ,CAAA,CAAA;AACnC;;;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
4
+
5
+ function useIsCommandRegistered(command) {
6
+ const [editor] = LexicalComposerContext.useLexicalComposerContext();
7
+ return editor._commands.has(command);
8
+ }
9
+
10
+ exports.useIsCommandRegistered = useIsCommandRegistered;
11
+ //# sourceMappingURL=is-command-registered.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-command-registered.mjs","sources":["../src/is-command-registered.ts"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { LexicalCommand } from \"lexical\";\n\n/**\n * Checks if a command is registered in the current Lexical editor.\n */\nexport function useIsCommandRegistered(command: LexicalCommand<unknown>) {\n const [editor] = useLexicalComposerContext();\n\n return editor._commands.has(command);\n}\n"],"names":[],"mappings":";;AAMO,SAAS,uBAAuB,OAAkC,EAAA;AACvE,EAAM,MAAA,CAAC,MAAM,CAAA,GAAI,yBAA0B,EAAA,CAAA;AAE3C,EAAO,OAAA,MAAA,CAAO,SAAU,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AACrC;;;;"}
1
+ {"version":3,"file":"is-command-registered.cjs","sources":["../src/is-command-registered.ts"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { LexicalCommand } from \"lexical\";\n\n/**\n * Checks if a command is registered in the current Lexical editor.\n */\nexport function useIsCommandRegistered(command: LexicalCommand<unknown>) {\n const [editor] = useLexicalComposerContext();\n\n return editor._commands.has(command);\n}\n"],"names":["useLexicalComposerContext"],"mappings":";;;;AAMO,SAAS,uBAAuB,OAAkC,EAAA;AACvE,EAAM,MAAA,CAAC,MAAM,CAAA,GAAIA,gDAA0B,EAAA,CAAA;AAE3C,EAAO,OAAA,MAAA,CAAO,SAAU,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AACrC;;;;"}
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
1
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
2
 
5
3
  function useIsCommandRegistered(command) {
6
- const [editor] = LexicalComposerContext.useLexicalComposerContext();
4
+ const [editor] = useLexicalComposerContext();
7
5
  return editor._commands.has(command);
8
6
  }
9
7
 
10
- exports.useIsCommandRegistered = useIsCommandRegistered;
8
+ export { useIsCommandRegistered };
11
9
  //# sourceMappingURL=is-command-registered.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-command-registered.js","sources":["../src/is-command-registered.ts"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { LexicalCommand } from \"lexical\";\n\n/**\n * Checks if a command is registered in the current Lexical editor.\n */\nexport function useIsCommandRegistered(command: LexicalCommand<unknown>) {\n const [editor] = useLexicalComposerContext();\n\n return editor._commands.has(command);\n}\n"],"names":["useLexicalComposerContext"],"mappings":";;;;AAMO,SAAS,uBAAuB,OAAkC,EAAA;AACvE,EAAM,MAAA,CAAC,MAAM,CAAA,GAAIA,gDAA0B,EAAA,CAAA;AAE3C,EAAO,OAAA,MAAA,CAAO,SAAU,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AACrC;;;;"}
1
+ {"version":3,"file":"is-command-registered.js","sources":["../src/is-command-registered.ts"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { LexicalCommand } from \"lexical\";\n\n/**\n * Checks if a command is registered in the current Lexical editor.\n */\nexport function useIsCommandRegistered(command: LexicalCommand<unknown>) {\n const [editor] = useLexicalComposerContext();\n\n return editor._commands.has(command);\n}\n"],"names":[],"mappings":";;AAMO,SAAS,uBAAuB,OAAkC,EAAA;AACvE,EAAM,MAAA,CAAC,MAAM,CAAA,GAAI,yBAA0B,EAAA,CAAA;AAE3C,EAAO,OAAA,MAAA,CAAO,SAAU,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AACrC;;;;"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var lexical = require('lexical');
4
+
5
+ function isTextFormatActive(editor, format) {
6
+ return editor.getEditorState().read(() => {
7
+ const selection = lexical.$getSelection();
8
+ if (!lexical.$isRangeSelection(selection) || selection.isCollapsed()) {
9
+ return false;
10
+ }
11
+ return selection.hasFormat(format);
12
+ });
13
+ }
14
+
15
+ exports.isTextFormatActive = isTextFormatActive;
16
+ //# sourceMappingURL=is-text-format-active.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-text-format-active.mjs","sources":["../src/is-text-format-active.ts"],"sourcesContent":["import type { LexicalEditor, TextFormatType } from \"lexical\";\nimport { $getSelection, $isRangeSelection } from \"lexical\";\n\n/**\n * Checks if a text format (e.g. bold, italic, …) is active in\n * the current selection.\n */\nexport function isTextFormatActive(\n editor: LexicalEditor,\n format: TextFormatType\n) {\n return editor.getEditorState().read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection) || selection.isCollapsed()) {\n return false;\n }\n\n return selection.hasFormat(format);\n });\n}\n"],"names":[],"mappings":";;AAOgB,SAAA,kBAAA,CACd,QACA,MACA,EAAA;AACA,EAAA,OAAO,MAAO,CAAA,cAAA,EAAiB,CAAA,IAAA,CAAK,MAAM;AACxC,IAAA,MAAM,YAAY,aAAc,EAAA,CAAA;AAEhC,IAAA,IAAI,CAAC,iBAAkB,CAAA,SAAS,CAAK,IAAA,SAAA,CAAU,aAAe,EAAA;AAC5D,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,SAAA,CAAU,UAAU,MAAM,CAAA,CAAA;AAAA,GAClC,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"is-text-format-active.cjs","sources":["../src/is-text-format-active.ts"],"sourcesContent":["import type { LexicalEditor, TextFormatType } from \"lexical\";\nimport { $getSelection, $isRangeSelection } from \"lexical\";\n\n/**\n * Checks if a text format (e.g. bold, italic, …) is active in\n * the current selection.\n */\nexport function isTextFormatActive(\n editor: LexicalEditor,\n format: TextFormatType\n) {\n return editor.getEditorState().read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection) || selection.isCollapsed()) {\n return false;\n }\n\n return selection.hasFormat(format);\n });\n}\n"],"names":["$getSelection","$isRangeSelection"],"mappings":";;;;AAOgB,SAAA,kBAAA,CACd,QACA,MACA,EAAA;AACA,EAAA,OAAO,MAAO,CAAA,cAAA,EAAiB,CAAA,IAAA,CAAK,MAAM;AACxC,IAAA,MAAM,YAAYA,qBAAc,EAAA,CAAA;AAEhC,IAAA,IAAI,CAACC,yBAAkB,CAAA,SAAS,CAAK,IAAA,SAAA,CAAU,aAAe,EAAA;AAC5D,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,SAAA,CAAU,UAAU,MAAM,CAAA,CAAA;AAAA,GAClC,CAAA,CAAA;AACH;;;;"}
@@ -1,16 +1,14 @@
1
- 'use strict';
2
-
3
- var lexical = require('lexical');
1
+ import { $getSelection, $isRangeSelection } from 'lexical';
4
2
 
5
3
  function isTextFormatActive(editor, format) {
6
4
  return editor.getEditorState().read(() => {
7
- const selection = lexical.$getSelection();
8
- if (!lexical.$isRangeSelection(selection) || selection.isCollapsed()) {
5
+ const selection = $getSelection();
6
+ if (!$isRangeSelection(selection) || selection.isCollapsed()) {
9
7
  return false;
10
8
  }
11
9
  return selection.hasFormat(format);
12
10
  });
13
11
  }
14
12
 
15
- exports.isTextFormatActive = isTextFormatActive;
13
+ export { isTextFormatActive };
16
14
  //# sourceMappingURL=is-text-format-active.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-text-format-active.js","sources":["../src/is-text-format-active.ts"],"sourcesContent":["import type { LexicalEditor, TextFormatType } from \"lexical\";\nimport { $getSelection, $isRangeSelection } from \"lexical\";\n\n/**\n * Checks if a text format (e.g. bold, italic, …) is active in\n * the current selection.\n */\nexport function isTextFormatActive(\n editor: LexicalEditor,\n format: TextFormatType\n) {\n return editor.getEditorState().read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection) || selection.isCollapsed()) {\n return false;\n }\n\n return selection.hasFormat(format);\n });\n}\n"],"names":["$getSelection","$isRangeSelection"],"mappings":";;;;AAOgB,SAAA,kBAAA,CACd,QACA,MACA,EAAA;AACA,EAAA,OAAO,MAAO,CAAA,cAAA,EAAiB,CAAA,IAAA,CAAK,MAAM;AACxC,IAAA,MAAM,YAAYA,qBAAc,EAAA,CAAA;AAEhC,IAAA,IAAI,CAACC,yBAAkB,CAAA,SAAS,CAAK,IAAA,SAAA,CAAU,aAAe,EAAA;AAC5D,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,SAAA,CAAU,UAAU,MAAM,CAAA,CAAA;AAAA,GAClC,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"is-text-format-active.js","sources":["../src/is-text-format-active.ts"],"sourcesContent":["import type { LexicalEditor, TextFormatType } from \"lexical\";\nimport { $getSelection, $isRangeSelection } from \"lexical\";\n\n/**\n * Checks if a text format (e.g. bold, italic, …) is active in\n * the current selection.\n */\nexport function isTextFormatActive(\n editor: LexicalEditor,\n format: TextFormatType\n) {\n return editor.getEditorState().read(() => {\n const selection = $getSelection();\n\n if (!$isRangeSelection(selection) || selection.isCollapsed()) {\n return false;\n }\n\n return selection.hasFormat(format);\n });\n}\n"],"names":[],"mappings":";;AAOgB,SAAA,kBAAA,CACd,QACA,MACA,EAAA;AACA,EAAA,OAAO,MAAO,CAAA,cAAA,EAAiB,CAAA,IAAA,CAAK,MAAM;AACxC,IAAA,MAAM,YAAY,aAAc,EAAA,CAAA;AAEhC,IAAA,IAAI,CAAC,iBAAkB,CAAA,SAAS,CAAK,IAAA,SAAA,CAAU,aAAe,EAAA;AAC5D,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,SAAA,CAAU,UAAU,MAAM,CAAA,CAAA;AAAA,GAClC,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var threadMarkNode = require('./comments/thread-mark-node.cjs');
4
+ var mentionNode = require('./mentions/mention-node.cjs');
5
+
6
+ function liveblocksConfig(editorConfig) {
7
+ const nodes = [...editorConfig.nodes ?? []];
8
+ nodes.push(threadMarkNode.ThreadMarkNode, mentionNode.MentionNode);
9
+ return {
10
+ ...editorConfig,
11
+ nodes,
12
+ editorState: null
13
+ };
14
+ }
15
+
16
+ exports.liveblocksConfig = liveblocksConfig;
17
+ //# sourceMappingURL=liveblocks-config.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-config.mjs","sources":["../src/liveblocks-config.ts"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\n\n/**\n * Function that takes a Lexical editor config and modifies it to add the necessary\n * `nodes` and `theme` to make `LiveblocksPlugin` works correctly.\n *\n * @example\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport function liveblocksConfig(\n editorConfig: Omit<InitialConfigType, \"editorState\">\n) {\n const nodes = [...(editorConfig.nodes ?? [])];\n\n nodes.push(ThreadMarkNode, MentionNode);\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n"],"names":[],"mappings":";;;AAoCO,SAAS,iBACd,YACA,EAAA;AACA,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAM,KAAA,CAAA,IAAA,CAAK,gBAAgB,WAAW,CAAA,CAAA;AAEtC,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"liveblocks-config.cjs","sources":["../src/liveblocks-config.ts"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\n\n/**\n * Function that takes a Lexical editor config and modifies it to add the necessary\n * `nodes` and `theme` to make `LiveblocksPlugin` works correctly.\n *\n * @example\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport function liveblocksConfig(\n editorConfig: Omit<InitialConfigType, \"editorState\">\n) {\n const nodes = [...(editorConfig.nodes ?? [])];\n\n nodes.push(ThreadMarkNode, MentionNode);\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n"],"names":["ThreadMarkNode","MentionNode"],"mappings":";;;;;AAoCO,SAAS,iBACd,YACA,EAAA;AACA,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAM,KAAA,CAAA,IAAA,CAAKA,+BAAgBC,uBAAW,CAAA,CAAA;AAEtC,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF;;;;"}
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- var threadMarkNode = require('./comments/thread-mark-node.js');
4
- var mentionNode = require('./mentions/mention-node.js');
1
+ import { ThreadMarkNode } from './comments/thread-mark-node.js';
2
+ import { MentionNode } from './mentions/mention-node.js';
5
3
 
6
4
  function liveblocksConfig(editorConfig) {
7
5
  const nodes = [...editorConfig.nodes ?? []];
8
- nodes.push(threadMarkNode.ThreadMarkNode, mentionNode.MentionNode);
6
+ nodes.push(ThreadMarkNode, MentionNode);
9
7
  return {
10
8
  ...editorConfig,
11
9
  nodes,
@@ -13,5 +11,5 @@ function liveblocksConfig(editorConfig) {
13
11
  };
14
12
  }
15
13
 
16
- exports.liveblocksConfig = liveblocksConfig;
14
+ export { liveblocksConfig };
17
15
  //# sourceMappingURL=liveblocks-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-config.js","sources":["../src/liveblocks-config.ts"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\n\n/**\n * Function that takes a Lexical editor config and modifies it to add the necessary\n * `nodes` and `theme` to make `LiveblocksPlugin` works correctly.\n *\n * @example\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport function liveblocksConfig(\n editorConfig: Omit<InitialConfigType, \"editorState\">\n) {\n const nodes = [...(editorConfig.nodes ?? [])];\n\n nodes.push(ThreadMarkNode, MentionNode);\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n"],"names":["ThreadMarkNode","MentionNode"],"mappings":";;;;;AAoCO,SAAS,iBACd,YACA,EAAA;AACA,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAM,KAAA,CAAA,IAAA,CAAKA,+BAAgBC,uBAAW,CAAA,CAAA;AAEtC,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"liveblocks-config.js","sources":["../src/liveblocks-config.ts"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\n\n/**\n * Function that takes a Lexical editor config and modifies it to add the necessary\n * `nodes` and `theme` to make `LiveblocksPlugin` works correctly.\n *\n * @example\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport function liveblocksConfig(\n editorConfig: Omit<InitialConfigType, \"editorState\">\n) {\n const nodes = [...(editorConfig.nodes ?? [])];\n\n nodes.push(ThreadMarkNode, MentionNode);\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n"],"names":[],"mappings":";;;AAoCO,SAAS,iBACd,YACA,EAAA;AACA,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAM,KAAA,CAAA,IAAA,CAAK,gBAAgB,WAAW,CAAA,CAAA;AAEtC,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF;;;;"}