@lexical/react 0.15.0 → 0.16.0

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 (118) hide show
  1. package/LexicalAutoEmbedPlugin.dev.js +12 -24
  2. package/LexicalAutoEmbedPlugin.dev.mjs +2 -2
  3. package/LexicalAutoEmbedPlugin.prod.js +4 -5
  4. package/LexicalAutoEmbedPlugin.prod.mjs +1 -1
  5. package/LexicalBlockWithAlignableContents.dev.js +9 -20
  6. package/LexicalBlockWithAlignableContents.dev.mjs +5 -4
  7. package/LexicalBlockWithAlignableContents.prod.js +4 -4
  8. package/LexicalBlockWithAlignableContents.prod.mjs +1 -1
  9. package/LexicalCharacterLimitPlugin.dev.js +10 -22
  10. package/LexicalCharacterLimitPlugin.dev.mjs +5 -5
  11. package/LexicalCharacterLimitPlugin.prod.js +9 -9
  12. package/LexicalCharacterLimitPlugin.prod.mjs +1 -1
  13. package/LexicalCheckListPlugin.dev.js +2 -0
  14. package/LexicalCheckListPlugin.dev.mjs +2 -0
  15. package/LexicalCheckListPlugin.prod.js +2 -2
  16. package/LexicalCheckListPlugin.prod.mjs +1 -1
  17. package/LexicalClearEditorPlugin.dev.js +4 -0
  18. package/LexicalClearEditorPlugin.dev.mjs +4 -0
  19. package/LexicalClickableLinkPlugin.d.ts +3 -1
  20. package/LexicalClickableLinkPlugin.dev.js +3 -2
  21. package/LexicalClickableLinkPlugin.dev.mjs +2 -2
  22. package/LexicalClickableLinkPlugin.js.flow +3 -1
  23. package/LexicalClickableLinkPlugin.mjs +1 -0
  24. package/LexicalClickableLinkPlugin.node.mjs +1 -0
  25. package/LexicalClickableLinkPlugin.prod.js +4 -3
  26. package/LexicalClickableLinkPlugin.prod.mjs +1 -1
  27. package/LexicalCollaborationPlugin.dev.js +2 -1
  28. package/LexicalCollaborationPlugin.dev.mjs +2 -1
  29. package/LexicalCollaborationPlugin.prod.js +9 -9
  30. package/LexicalCollaborationPlugin.prod.mjs +1 -1
  31. package/LexicalComposer.dev.js +12 -19
  32. package/LexicalComposer.dev.mjs +9 -4
  33. package/LexicalComposer.prod.js +3 -4
  34. package/LexicalComposer.prod.mjs +1 -1
  35. package/LexicalContentEditable.dev.js +20 -34
  36. package/LexicalContentEditable.dev.mjs +16 -18
  37. package/LexicalContentEditable.prod.js +3 -4
  38. package/LexicalContentEditable.prod.mjs +1 -1
  39. package/LexicalContextMenuPlugin.dev.js +6 -1
  40. package/LexicalContextMenuPlugin.dev.mjs +6 -1
  41. package/LexicalContextMenuPlugin.prod.js +15 -15
  42. package/LexicalContextMenuPlugin.prod.mjs +1 -1
  43. package/LexicalErrorBoundary.d.ts +3 -1
  44. package/LexicalErrorBoundary.dev.js +11 -7
  45. package/LexicalErrorBoundary.dev.mjs +10 -7
  46. package/LexicalErrorBoundary.js.flow +4 -1
  47. package/LexicalErrorBoundary.mjs +1 -0
  48. package/LexicalErrorBoundary.node.mjs +1 -0
  49. package/LexicalErrorBoundary.prod.js +4 -4
  50. package/LexicalErrorBoundary.prod.mjs +1 -1
  51. package/LexicalHorizontalRuleNode.d.ts +2 -2
  52. package/LexicalHorizontalRuleNode.dev.js +16 -21
  53. package/LexicalHorizontalRuleNode.dev.mjs +13 -6
  54. package/LexicalHorizontalRuleNode.prod.js +5 -5
  55. package/LexicalHorizontalRuleNode.prod.mjs +1 -1
  56. package/LexicalNestedComposer.dev.js +11 -22
  57. package/LexicalNestedComposer.dev.mjs +5 -4
  58. package/LexicalNestedComposer.prod.js +5 -5
  59. package/LexicalNestedComposer.prod.mjs +1 -1
  60. package/LexicalNodeMenuPlugin.dev.js +6 -1
  61. package/LexicalNodeMenuPlugin.dev.mjs +6 -1
  62. package/LexicalNodeMenuPlugin.prod.js +13 -13
  63. package/LexicalNodeMenuPlugin.prod.mjs +1 -1
  64. package/LexicalOnChangePlugin.dev.js +4 -0
  65. package/LexicalOnChangePlugin.dev.mjs +4 -0
  66. package/LexicalPlainTextPlugin.dev.js +24 -28
  67. package/LexicalPlainTextPlugin.dev.mjs +19 -11
  68. package/LexicalPlainTextPlugin.js.flow +1 -1
  69. package/LexicalPlainTextPlugin.prod.js +4 -4
  70. package/LexicalPlainTextPlugin.prod.mjs +1 -1
  71. package/LexicalRichTextPlugin.dev.js +24 -28
  72. package/LexicalRichTextPlugin.dev.mjs +19 -11
  73. package/LexicalRichTextPlugin.js.flow +1 -1
  74. package/LexicalRichTextPlugin.prod.js +4 -4
  75. package/LexicalRichTextPlugin.prod.mjs +1 -1
  76. package/LexicalTableOfContents.d.ts +6 -13
  77. package/LexicalTableOfContents.dev.js +10 -2
  78. package/LexicalTableOfContents.dev.mjs +10 -2
  79. package/LexicalTableOfContents.js.flow +3 -7
  80. package/LexicalTableOfContents.prod.js +1 -1
  81. package/LexicalTableOfContentsPlugin.d.ts +20 -0
  82. package/LexicalTableOfContentsPlugin.dev.js +198 -0
  83. package/LexicalTableOfContentsPlugin.dev.mjs +196 -0
  84. package/LexicalTableOfContentsPlugin.js +11 -0
  85. package/LexicalTableOfContentsPlugin.js.flow +18 -0
  86. package/LexicalTableOfContentsPlugin.mjs +12 -0
  87. package/LexicalTableOfContentsPlugin.node.mjs +10 -0
  88. package/LexicalTableOfContentsPlugin.prod.js +12 -0
  89. package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
  90. package/LexicalTreeView.d.ts +3 -1
  91. package/LexicalTreeView.dev.js +5 -3
  92. package/LexicalTreeView.dev.mjs +5 -3
  93. package/LexicalTreeView.js.flow +2 -0
  94. package/LexicalTreeView.prod.js +3 -3
  95. package/LexicalTreeView.prod.mjs +1 -1
  96. package/LexicalTypeaheadMenuPlugin.dev.js +6 -1
  97. package/LexicalTypeaheadMenuPlugin.dev.mjs +6 -1
  98. package/LexicalTypeaheadMenuPlugin.prod.js +17 -17
  99. package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
  100. package/package.json +50 -20
  101. package/useLexicalEditable.d.ts +11 -1
  102. package/useLexicalEditable.dev.js +16 -1
  103. package/useLexicalEditable.dev.mjs +15 -1
  104. package/useLexicalEditable.js.flow +4 -1
  105. package/useLexicalEditable.mjs +2 -1
  106. package/useLexicalEditable.node.mjs +2 -1
  107. package/useLexicalEditable.prod.js +1 -1
  108. package/useLexicalEditable.prod.mjs +1 -1
  109. package/useLexicalIsTextContentEmpty.dev.js +4 -0
  110. package/useLexicalIsTextContentEmpty.dev.mjs +4 -0
  111. package/useLexicalSubscription.d.ts +4 -1
  112. package/useLexicalSubscription.dev.js +7 -1
  113. package/useLexicalSubscription.dev.mjs +6 -1
  114. package/useLexicalSubscription.js.flow +4 -1
  115. package/useLexicalSubscription.mjs +2 -1
  116. package/useLexicalSubscription.node.mjs +2 -1
  117. package/useLexicalSubscription.prod.js +2 -2
  118. package/useLexicalSubscription.prod.mjs +1 -1
@@ -13,20 +13,8 @@ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
13
13
  var LexicalNodeMenuPlugin = require('@lexical/react/LexicalNodeMenuPlugin');
14
14
  var utils = require('@lexical/utils');
15
15
  var lexical = require('lexical');
16
- var React = require('react');
17
-
18
- function _interopNamespaceDefault(e) {
19
- var n = Object.create(null);
20
- if (e) {
21
- for (var k in e) {
22
- n[k] = e[k];
23
- }
24
- }
25
- n.default = e;
26
- return n;
27
- }
28
-
29
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
16
+ var react = require('react');
17
+ var jsxRuntime = require('react/jsx-runtime');
30
18
 
31
19
  /**
32
20
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -53,13 +41,13 @@ function LexicalAutoEmbedPlugin({
53
41
  menuCommandPriority = lexical.COMMAND_PRIORITY_LOW
54
42
  }) {
55
43
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
56
- const [nodeKey, setNodeKey] = React.useState(null);
57
- const [activeEmbedConfig, setActiveEmbedConfig] = React.useState(null);
58
- const reset = React.useCallback(() => {
44
+ const [nodeKey, setNodeKey] = react.useState(null);
45
+ const [activeEmbedConfig, setActiveEmbedConfig] = react.useState(null);
46
+ const reset = react.useCallback(() => {
59
47
  setNodeKey(null);
60
48
  setActiveEmbedConfig(null);
61
49
  }, []);
62
- const checkIfLinkNodeIsEmbeddable = React.useCallback(key => {
50
+ const checkIfLinkNodeIsEmbeddable = react.useCallback(key => {
63
51
  editor.getEditorState().read(async function () {
64
52
  const linkNode = lexical.$getNodeByKey(key);
65
53
  if (link.$isLinkNode(linkNode)) {
@@ -74,7 +62,7 @@ function LexicalAutoEmbedPlugin({
74
62
  }
75
63
  });
76
64
  }, [editor, embedConfigs]);
77
- React.useEffect(() => {
65
+ react.useEffect(() => {
78
66
  const listener = (nodeMutations, {
79
67
  updateTags,
80
68
  dirtyLeaves
@@ -89,7 +77,7 @@ function LexicalAutoEmbedPlugin({
89
77
  };
90
78
  return utils.mergeRegister(...[link.LinkNode, link.AutoLinkNode].map(Klass => editor.registerMutationListener(Klass, (...args) => listener(...args))));
91
79
  }, [checkIfLinkNodeIsEmbeddable, editor, embedConfigs, nodeKey, reset]);
92
- React.useEffect(() => {
80
+ react.useEffect(() => {
93
81
  return editor.registerCommand(INSERT_EMBED_COMMAND, embedConfigType => {
94
82
  const embedConfig = embedConfigs.find(({
95
83
  type
@@ -101,7 +89,7 @@ function LexicalAutoEmbedPlugin({
101
89
  return false;
102
90
  }, lexical.COMMAND_PRIORITY_EDITOR);
103
91
  }, [editor, embedConfigs, onOpenEmbedModalForConfig]);
104
- const embedLinkViaActiveEmbedConfig = React.useCallback(async function () {
92
+ const embedLinkViaActiveEmbedConfig = react.useCallback(async function () {
105
93
  if (activeEmbedConfig != null && nodeKey != null) {
106
94
  const linkNode = editor.getEditorState().read(() => {
107
95
  const node = lexical.$getNodeByKey(nodeKey);
@@ -126,16 +114,16 @@ function LexicalAutoEmbedPlugin({
126
114
  }
127
115
  }
128
116
  }, [activeEmbedConfig, editor, nodeKey]);
129
- const options = React.useMemo(() => {
117
+ const options = react.useMemo(() => {
130
118
  return activeEmbedConfig != null && nodeKey != null ? getMenuOptions(activeEmbedConfig, embedLinkViaActiveEmbedConfig, reset) : [];
131
119
  }, [activeEmbedConfig, embedLinkViaActiveEmbedConfig, getMenuOptions, nodeKey, reset]);
132
- const onSelectOption = React.useCallback((selectedOption, targetNode, closeMenu) => {
120
+ const onSelectOption = react.useCallback((selectedOption, targetNode, closeMenu) => {
133
121
  editor.update(() => {
134
122
  selectedOption.onSelect(targetNode);
135
123
  closeMenu();
136
124
  });
137
125
  }, [editor]);
138
- return nodeKey != null ? /*#__PURE__*/React__namespace.createElement(LexicalNodeMenuPlugin.LexicalNodeMenuPlugin, {
126
+ return nodeKey != null ? /*#__PURE__*/jsxRuntime.jsx(LexicalNodeMenuPlugin.LexicalNodeMenuPlugin, {
139
127
  nodeKey: nodeKey,
140
128
  onClose: reset,
141
129
  onSelectOption: onSelectOption,
@@ -11,8 +11,8 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
11
11
  import { MenuOption, LexicalNodeMenuPlugin } from '@lexical/react/LexicalNodeMenuPlugin';
12
12
  import { mergeRegister } from '@lexical/utils';
13
13
  import { createCommand, $getNodeByKey, COMMAND_PRIORITY_EDITOR, $getSelection, COMMAND_PRIORITY_LOW } from 'lexical';
14
- import * as React from 'react';
15
14
  import { useState, useCallback, useEffect, useMemo } from 'react';
15
+ import { jsx } from 'react/jsx-runtime';
16
16
 
17
17
  /**
18
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -121,7 +121,7 @@ function LexicalAutoEmbedPlugin({
121
121
  closeMenu();
122
122
  });
123
123
  }, [editor]);
124
- return nodeKey != null ? /*#__PURE__*/React.createElement(LexicalNodeMenuPlugin, {
124
+ return nodeKey != null ? /*#__PURE__*/jsx(LexicalNodeMenuPlugin, {
125
125
  nodeKey: nodeKey,
126
126
  onClose: reset,
127
127
  onSelectOption: onSelectOption,
@@ -6,8 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var b=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/react/LexicalNodeMenuPlugin"),q=require("@lexical/utils"),r=require("lexical"),t=require("react"),u=Object.create(null);if(t)for(var B in t)u[B]=t[B];u.default=t;let C=r.createCommand("INSERT_EMBED_COMMAND");class D extends l.MenuOption{constructor(f,n){super(f);this.title=f;this.onSelect=n.onSelect.bind(this)}}exports.AutoEmbedOption=D;exports.INSERT_EMBED_COMMAND=C;
10
- exports.LexicalAutoEmbedPlugin=function({embedConfigs:f,onOpenEmbedModalForConfig:n,getMenuOptions:v,menuRenderFn:E,menuCommandPriority:F=r.COMMAND_PRIORITY_LOW}){let [d]=k.useLexicalComposerContext(),[g,w]=t.useState(null),[h,x]=t.useState(null),m=t.useCallback(()=>{w(null);x(null)},[]),y=t.useCallback(c=>{d.getEditorState().read(async function(){const a=r.$getNodeByKey(c);if(b.$isLinkNode(a))for(let e=0;e<f.length;e++){const p=f[e];null!=await Promise.resolve(p.parseUrl(a.__url))&&(x(p),w(a.getKey()))}})},
11
- [d,f]);t.useEffect(()=>{let c=(a,{updateTags:e,dirtyLeaves:p})=>{for(const [z,G]of a)"created"===G&&e.has("paste")&&3>=p.size?y(z):z===g&&m()};return q.mergeRegister(...[b.LinkNode,b.AutoLinkNode].map(a=>d.registerMutationListener(a,(...e)=>c(...e))))},[y,d,f,g,m]);t.useEffect(()=>d.registerCommand(C,c=>{let a=f.find(({type:e})=>e===c);return a?(n(a),!0):!1},r.COMMAND_PRIORITY_EDITOR),[d,f,n]);let A=t.useCallback(async function(){if(null!=h&&null!=g){const c=d.getEditorState().read(()=>{const a=r.$getNodeByKey(g);
12
- return b.$isLinkNode(a)?a:null});if(b.$isLinkNode(c)){const a=await Promise.resolve(h.parseUrl(c.__url));null!=a&&d.update(()=>{r.$getSelection()||c.selectEnd();h.insertNode(d,a);c.isAttached()&&c.remove()})}}},[h,d,g]),H=t.useMemo(()=>null!=h&&null!=g?v(h,A,m):[],[h,A,v,g,m]),I=t.useCallback((c,a,e)=>{d.update(()=>{c.onSelect(a);e()})},[d]);return null!=g?u.createElement(l.LexicalNodeMenuPlugin,{nodeKey:g,onClose:m,onSelectOption:I,options:H,menuRenderFn:E,commandPriority:F}):null};
13
- exports.URL_MATCHER=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
9
+ 'use strict';var e=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/react/LexicalNodeMenuPlugin"),q=require("@lexical/utils"),r=require("lexical"),z=require("react"),A=require("react/jsx-runtime");let B=r.createCommand("INSERT_EMBED_COMMAND");class C extends l.MenuOption{constructor(f,n){super(f);this.title=f;this.onSelect=n.onSelect.bind(this)}}exports.AutoEmbedOption=C;exports.INSERT_EMBED_COMMAND=B;
10
+ exports.LexicalAutoEmbedPlugin=function({embedConfigs:f,onOpenEmbedModalForConfig:n,getMenuOptions:t,menuRenderFn:D,menuCommandPriority:E=r.COMMAND_PRIORITY_LOW}){let [c]=k.useLexicalComposerContext(),[g,u]=z.useState(null),[h,v]=z.useState(null),m=z.useCallback(()=>{u(null);v(null)},[]),w=z.useCallback(b=>{c.getEditorState().read(async function(){const a=r.$getNodeByKey(b);if(e.$isLinkNode(a))for(let d=0;d<f.length;d++){const p=f[d];null!=await Promise.resolve(p.parseUrl(a.__url))&&(v(p),u(a.getKey()))}})},
11
+ [c,f]);z.useEffect(()=>{let b=(a,{updateTags:d,dirtyLeaves:p})=>{for(const [x,F]of a)"created"===F&&d.has("paste")&&3>=p.size?w(x):x===g&&m()};return q.mergeRegister(...[e.LinkNode,e.AutoLinkNode].map(a=>c.registerMutationListener(a,(...d)=>b(...d))))},[w,c,f,g,m]);z.useEffect(()=>c.registerCommand(B,b=>{let a=f.find(({type:d})=>d===b);return a?(n(a),!0):!1},r.COMMAND_PRIORITY_EDITOR),[c,f,n]);let y=z.useCallback(async function(){if(null!=h&&null!=g){const b=c.getEditorState().read(()=>{const a=r.$getNodeByKey(g);
12
+ return e.$isLinkNode(a)?a:null});if(e.$isLinkNode(b)){const a=await Promise.resolve(h.parseUrl(b.__url));null!=a&&c.update(()=>{r.$getSelection()||b.selectEnd();h.insertNode(c,a);b.isAttached()&&b.remove()})}}},[h,c,g]),G=z.useMemo(()=>null!=h&&null!=g?t(h,y,m):[],[h,y,t,g,m]),H=z.useCallback((b,a,d)=>{c.update(()=>{b.onSelect(a);d()})},[c]);return null!=g?A.jsx(l.LexicalNodeMenuPlugin,{nodeKey:g,onClose:m,onSelectOption:H,options:G,menuRenderFn:D,commandPriority:E}):null};exports.URL_MATCHER=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$isLinkNode as e,LinkNode as t,AutoLinkNode as n}from"@lexical/link";import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{MenuOption as r,LexicalNodeMenuPlugin as l}from"@lexical/react/LexicalNodeMenuPlugin";import{mergeRegister as i}from"@lexical/utils";import{createCommand as s,$getNodeByKey as a,COMMAND_PRIORITY_EDITOR as c,$getSelection as u,COMMAND_PRIORITY_LOW as m}from"lexical";import*as d from"react";import{useState as p,useCallback as f,useEffect as g,useMemo as x}from"react";const w=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,y=s("INSERT_EMBED_COMMAND");class C extends r{constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}}function E({embedConfigs:r,onOpenEmbedModalForConfig:s,getMenuOptions:w,menuRenderFn:C,menuCommandPriority:E=m}){const[_]=o(),[h,M]=p(null),[S,A]=p(null),P=f((()=>{M(null),A(null)}),[]),b=f((t=>{_.getEditorState().read((async function(){const n=a(t);if(e(n))for(let e=0;e<r.length;e++){const t=r[e];null!=await Promise.resolve(t.parseUrl(n.__url))&&(A(t),M(n.getKey()))}}))}),[_,r]);g((()=>i(...[t,n].map((e=>_.registerMutationListener(e,((...e)=>((e,{updateTags:t,dirtyLeaves:n})=>{for(const[o,r]of e)"created"===r&&t.has("paste")&&n.size<=3?b(o):o===h&&P()})(...e))))))),[b,_,r,h,P]),g((()=>_.registerCommand(y,(e=>{const t=r.find((({type:t})=>t===e));return!!t&&(s(t),!0)}),c)),[_,r,s]);const v=f((async function(){if(null!=S&&null!=h){const t=_.getEditorState().read((()=>{const t=a(h);return e(t)?t:null}));if(e(t)){const e=await Promise.resolve(S.parseUrl(t.__url));null!=e&&_.update((()=>{u()||t.selectEnd(),S.insertNode(_,e),t.isAttached()&&t.remove()}))}}}),[S,_,h]),z=x((()=>null!=S&&null!=h?w(S,v,P):[]),[S,v,w,h,P]),L=f(((e,t,n)=>{_.update((()=>{e.onSelect(t),n()}))}),[_]);return null!=h?d.createElement(l,{nodeKey:h,onClose:P,onSelectOption:L,options:z,menuRenderFn:C,commandPriority:E}):null}export{C as AutoEmbedOption,y as INSERT_EMBED_COMMAND,E as LexicalAutoEmbedPlugin,w as URL_MATCHER};
9
+ import{$isLinkNode as e,LinkNode as t,AutoLinkNode as n}from"@lexical/link";import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{MenuOption as r,LexicalNodeMenuPlugin as l}from"@lexical/react/LexicalNodeMenuPlugin";import{mergeRegister as i}from"@lexical/utils";import{createCommand as s,$getNodeByKey as a,COMMAND_PRIORITY_EDITOR as c,$getSelection as u,COMMAND_PRIORITY_LOW as m}from"lexical";import{useState as d,useCallback as p,useEffect as f,useMemo as g}from"react";import{jsx as x}from"react/jsx-runtime";const w=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,y=s("INSERT_EMBED_COMMAND");class C extends r{constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}}function _({embedConfigs:r,onOpenEmbedModalForConfig:s,getMenuOptions:w,menuRenderFn:C,menuCommandPriority:_=m}){const[h]=o(),[E,M]=d(null),[S,A]=d(null),P=p((()=>{M(null),A(null)}),[]),b=p((t=>{h.getEditorState().read((async function(){const n=a(t);if(e(n))for(let e=0;e<r.length;e++){const t=r[e];null!=await Promise.resolve(t.parseUrl(n.__url))&&(A(t),M(n.getKey()))}}))}),[h,r]);f((()=>i(...[t,n].map((e=>h.registerMutationListener(e,((...e)=>((e,{updateTags:t,dirtyLeaves:n})=>{for(const[o,r]of e)"created"===r&&t.has("paste")&&n.size<=3?b(o):o===E&&P()})(...e))))))),[b,h,r,E,P]),f((()=>h.registerCommand(y,(e=>{const t=r.find((({type:t})=>t===e));return!!t&&(s(t),!0)}),c)),[h,r,s]);const v=p((async function(){if(null!=S&&null!=E){const t=h.getEditorState().read((()=>{const t=a(E);return e(t)?t:null}));if(e(t)){const e=await Promise.resolve(S.parseUrl(t.__url));null!=e&&h.update((()=>{u()||t.selectEnd(),S.insertNode(h,e),t.isAttached()&&t.remove()}))}}}),[S,h,E]),z=g((()=>null!=S&&null!=E?w(S,v,P):[]),[S,v,w,E,P]),L=p(((e,t,n)=>{h.update((()=>{e.onSelect(t),n()}))}),[h]);return null!=E?x(l,{nodeKey:E,onClose:P,onSelectOption:L,options:z,menuRenderFn:C,commandPriority:_}):null}export{C as AutoEmbedOption,y as INSERT_EMBED_COMMAND,_ as LexicalAutoEmbedPlugin,w as URL_MATCHER};
@@ -13,20 +13,8 @@ var LexicalDecoratorBlockNode = require('@lexical/react/LexicalDecoratorBlockNod
13
13
  var useLexicalNodeSelection = require('@lexical/react/useLexicalNodeSelection');
14
14
  var utils = require('@lexical/utils');
15
15
  var lexical = require('lexical');
16
- var React = require('react');
17
-
18
- function _interopNamespaceDefault(e) {
19
- var n = Object.create(null);
20
- if (e) {
21
- for (var k in e) {
22
- n[k] = e[k];
23
- }
24
- }
25
- n.default = e;
26
- return n;
27
- }
28
-
29
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
16
+ var react = require('react');
17
+ var jsxRuntime = require('react/jsx-runtime');
30
18
 
31
19
  /**
32
20
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -44,8 +32,8 @@ function BlockWithAlignableContents({
44
32
  }) {
45
33
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
46
34
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
47
- const ref = React.useRef(null);
48
- const $onDelete = React.useCallback(event => {
35
+ const ref = react.useRef(null);
36
+ const $onDelete = react.useCallback(event => {
49
37
  if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
50
38
  event.preventDefault();
51
39
  const node = lexical.$getNodeByKey(nodeKey);
@@ -56,7 +44,7 @@ function BlockWithAlignableContents({
56
44
  }
57
45
  return false;
58
46
  }, [isSelected, nodeKey]);
59
- React.useEffect(() => {
47
+ react.useEffect(() => {
60
48
  return utils.mergeRegister(editor.registerCommand(lexical.FORMAT_ELEMENT_COMMAND, formatType => {
61
49
  if (isSelected) {
62
50
  const selection = lexical.$getSelection();
@@ -91,13 +79,14 @@ function BlockWithAlignableContents({
91
79
  return false;
92
80
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_DELETE_COMMAND, $onDelete, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, $onDelete, lexical.COMMAND_PRIORITY_LOW));
93
81
  }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
94
- return /*#__PURE__*/React__namespace.createElement("div", {
82
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
95
83
  className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
96
84
  ref: ref,
97
85
  style: {
98
86
  textAlign: format ? format : undefined
99
- }
100
- }, children);
87
+ },
88
+ children: children
89
+ });
101
90
  }
102
91
 
103
92
  exports.BlockWithAlignableContents = BlockWithAlignableContents;
@@ -11,8 +11,8 @@ import { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'
11
11
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
12
12
  import { mergeRegister, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';
13
13
  import { $isNodeSelection, $getSelection, $getNodeByKey, $isDecoratorNode, FORMAT_ELEMENT_COMMAND, $isRangeSelection, COMMAND_PRIORITY_LOW, CLICK_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND } from 'lexical';
14
- import * as React from 'react';
15
14
  import { useRef, useCallback, useEffect } from 'react';
15
+ import { jsx } from 'react/jsx-runtime';
16
16
 
17
17
  /**
18
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -77,13 +77,14 @@ function BlockWithAlignableContents({
77
77
  return false;
78
78
  }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW));
79
79
  }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
80
- return /*#__PURE__*/React.createElement("div", {
80
+ return /*#__PURE__*/jsx("div", {
81
81
  className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
82
82
  ref: ref,
83
83
  style: {
84
84
  textAlign: format ? format : undefined
85
- }
86
- }, children);
85
+ },
86
+ children: children
87
+ });
87
88
  }
88
89
 
89
90
  export { BlockWithAlignableContents };
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var a=require("@lexical/react/LexicalComposerContext"),c=require("@lexical/react/LexicalDecoratorBlockNode"),k=require("@lexical/react/useLexicalNodeSelection"),m=require("@lexical/utils"),n=require("lexical"),p=require("react"),w=Object.create(null);if(p)for(var x in p)w[x]=p[x];w.default=p;
10
- exports.BlockWithAlignableContents=function({children:y,format:q,nodeKey:f,className:r}){let [g]=a.useLexicalComposerContext(),[d,t,u]=k.useLexicalNodeSelection(f),v=p.useRef(null),l=p.useCallback(b=>d&&n.$isNodeSelection(n.$getSelection())&&(b.preventDefault(),b=n.$getNodeByKey(f),n.$isDecoratorNode(b))?(b.remove(),!0):!1,[d,f]);p.useEffect(()=>m.mergeRegister(g.registerCommand(n.FORMAT_ELEMENT_COMMAND,b=>{if(d){var h=n.$getSelection();if(n.$isNodeSelection(h)){var e=n.$getNodeByKey(f);c.$isDecoratorBlockNode(e)&&
11
- e.setFormat(b)}else if(n.$isRangeSelection(h)){h=h.getNodes();for(e of h)c.$isDecoratorBlockNode(e)?e.setFormat(b):m.$getNearestBlockElementAncestorOrThrow(e).setFormat(b)}return!0}return!1},n.COMMAND_PRIORITY_LOW),g.registerCommand(n.CLICK_COMMAND,b=>b.target===v.current?(b.preventDefault(),b.shiftKey||u(),t(!d),!0):!1,n.COMMAND_PRIORITY_LOW),g.registerCommand(n.KEY_DELETE_COMMAND,l,n.COMMAND_PRIORITY_LOW),g.registerCommand(n.KEY_BACKSPACE_COMMAND,l,n.COMMAND_PRIORITY_LOW)),[u,g,d,f,l,t]);return w.createElement("div",
12
- {className:[r.base,d?r.focus:null].filter(Boolean).join(" "),ref:v,style:{textAlign:q?q:void 0}},y)}
9
+ 'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),l=require("@lexical/react/useLexicalNodeSelection"),m=require("@lexical/utils"),u=require("lexical"),v=require("react"),w=require("react/jsx-runtime");
10
+ exports.BlockWithAlignableContents=function({children:x,format:n,nodeKey:e,className:p}){let [f]=a.useLexicalComposerContext(),[c,q,r]=l.useLexicalNodeSelection(e),t=v.useRef(null),k=v.useCallback(b=>c&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),b=u.$getNodeByKey(e),u.$isDecoratorNode(b))?(b.remove(),!0):!1,[c,e]);v.useEffect(()=>m.mergeRegister(f.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(c){var g=u.$getSelection();if(u.$isNodeSelection(g)){var d=u.$getNodeByKey(e);h.$isDecoratorBlockNode(d)&&
11
+ d.setFormat(b)}else if(u.$isRangeSelection(g)){g=g.getNodes();for(d of g)h.$isDecoratorBlockNode(d)?d.setFormat(b):m.$getNearestBlockElementAncestorOrThrow(d).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),f.registerCommand(u.CLICK_COMMAND,b=>b.target===t.current?(b.preventDefault(),b.shiftKey||r(),q(!c),!0):!1,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_DELETE_COMMAND,k,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_BACKSPACE_COMMAND,k,u.COMMAND_PRIORITY_LOW)),[r,f,c,e,k,q]);return w.jsx("div",
12
+ {className:[p.base,c?p.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:n?n:void 0},children:x})}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$isDecoratorBlockNode as r}from"@lexical/react/LexicalDecoratorBlockNode";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as o,$getNearestBlockElementAncestorOrThrow as i}from"@lexical/utils";import{$isNodeSelection as a,$getSelection as l,$getNodeByKey as m,$isDecoratorNode as n,FORMAT_ELEMENT_COMMAND as c,$isRangeSelection as s,COMMAND_PRIORITY_LOW as f,CLICK_COMMAND as u,KEY_DELETE_COMMAND as d,KEY_BACKSPACE_COMMAND as p}from"lexical";import*as x from"react";import{useRef as g,useCallback as C,useEffect as v}from"react";function N({children:N,format:y,nodeKey:D,className:F}){const[L]=e(),[h,B,K]=t(D),b=g(null),j=C((e=>{if(h&&a(l())){e.preventDefault();const r=m(D);if(n(r))return r.remove(),!0}return!1}),[h,D]);return v((()=>o(L.registerCommand(c,(e=>{if(h){const t=l();if(a(t)){const t=m(D);r(t)&&t.setFormat(e)}else if(s(t)){const o=t.getNodes();for(const t of o)if(r(t))t.setFormat(e);else{i(t).setFormat(e)}}return!0}return!1}),f),L.registerCommand(u,(e=>e.target===b.current&&(e.preventDefault(),e.shiftKey||K(),B(!h),!0)),f),L.registerCommand(d,j,f),L.registerCommand(p,j,f))),[K,L,h,D,j,B]),x.createElement("div",{className:[F.base,h?F.focus:null].filter(Boolean).join(" "),ref:b,style:{textAlign:y||void 0}},N)}export{N as BlockWithAlignableContents};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$isDecoratorBlockNode as r}from"@lexical/react/LexicalDecoratorBlockNode";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as o,$getNearestBlockElementAncestorOrThrow as i}from"@lexical/utils";import{$isNodeSelection as l,$getSelection as a,$getNodeByKey as m,$isDecoratorNode as n,FORMAT_ELEMENT_COMMAND as c,$isRangeSelection as s,COMMAND_PRIORITY_LOW as f,CLICK_COMMAND as u,KEY_DELETE_COMMAND as d,KEY_BACKSPACE_COMMAND as x}from"lexical";import{useRef as p,useCallback as g,useEffect as C}from"react";import{jsx as v}from"react/jsx-runtime";function N({children:N,format:h,nodeKey:y,className:D}){const[F]=e(),[L,j,B]=t(y),K=p(null),b=g((e=>{if(L&&l(a())){e.preventDefault();const r=m(y);if(n(r))return r.remove(),!0}return!1}),[L,y]);return C((()=>o(F.registerCommand(c,(e=>{if(L){const t=a();if(l(t)){const t=m(y);r(t)&&t.setFormat(e)}else if(s(t)){const o=t.getNodes();for(const t of o)if(r(t))t.setFormat(e);else{i(t).setFormat(e)}}return!0}return!1}),f),F.registerCommand(u,(e=>e.target===K.current&&(e.preventDefault(),e.shiftKey||B(),j(!L),!0)),f),F.registerCommand(d,b,f),F.registerCommand(x,b,f))),[B,F,L,y,b,j]),v("div",{className:[D.base,L?D.focus:null].filter(Boolean).join(" "),ref:K,style:{textAlign:h||void 0},children:N})}export{N as BlockWithAlignableContents};
@@ -9,24 +9,12 @@
9
9
  'use strict';
10
10
 
11
11
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
- var React = require('react');
12
+ var react = require('react');
13
13
  var overflow = require('@lexical/overflow');
14
14
  var text = require('@lexical/text');
15
15
  var utils = require('@lexical/utils');
16
16
  var lexical = require('lexical');
17
-
18
- function _interopNamespaceDefault(e) {
19
- var n = Object.create(null);
20
- if (e) {
21
- for (var k in e) {
22
- n[k] = e[k];
23
- }
24
- }
25
- n.default = e;
26
- return n;
27
- }
28
-
29
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
17
+ var jsxRuntime = require('react/jsx-runtime');
30
18
 
31
19
  /**
32
20
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -44,14 +32,14 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
44
32
  return;
45
33
  }
46
34
  } = optional;
47
- React.useEffect(() => {
35
+ react.useEffect(() => {
48
36
  if (!editor.hasNodes([overflow.OverflowNode])) {
49
37
  {
50
38
  throw Error(`useCharacterLimit: OverflowNode not registered on editor`);
51
39
  }
52
40
  }
53
41
  }, [editor]);
54
- React.useEffect(() => {
42
+ react.useEffect(() => {
55
43
  let text$1 = editor.getEditorState().read(text.$rootTextContent);
56
44
  let lastComputedTextLength = 0;
57
45
  return utils.mergeRegister(editor.registerTextContentListener(currentText => {
@@ -82,7 +70,6 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
82
70
  }, [editor, maxCharacters, remainingCharacters, strlen]);
83
71
  }
84
72
  function findOffset(text, maxCharacters, strlen) {
85
- // @ts-ignore This is due to be added in a later version of TS
86
73
  const Segmenter = Intl.Segmenter;
87
74
  let offsetUtf16 = 0;
88
75
  let offset = 0;
@@ -258,9 +245,10 @@ function utf8Length(text) {
258
245
  function DefaultRenderer({
259
246
  remainingCharacters
260
247
  }) {
261
- return /*#__PURE__*/React__namespace.createElement("span", {
262
- className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`
263
- }, remainingCharacters);
248
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
249
+ className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`,
250
+ children: remainingCharacters
251
+ });
264
252
  }
265
253
  function CharacterLimitPlugin({
266
254
  charset = 'UTF-16',
@@ -268,8 +256,8 @@ function CharacterLimitPlugin({
268
256
  renderer = DefaultRenderer
269
257
  }) {
270
258
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
271
- const [remainingCharacters, setRemainingCharacters] = React.useState(maxLength);
272
- const characterLimitProps = React.useMemo(() => ({
259
+ const [remainingCharacters, setRemainingCharacters] = react.useState(maxLength);
260
+ const characterLimitProps = react.useMemo(() => ({
273
261
  remainingCharacters: setRemainingCharacters,
274
262
  strlen: text => {
275
263
  if (charset === 'UTF-8') {
@@ -7,12 +7,12 @@
7
7
  */
8
8
 
9
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import * as React from 'react';
11
10
  import { useEffect, useState, useMemo } from 'react';
12
11
  import { OverflowNode, $isOverflowNode, $createOverflowNode } from '@lexical/overflow';
13
12
  import { $rootTextContent } from '@lexical/text';
14
13
  import { mergeRegister, $dfs } from '@lexical/utils';
15
14
  import { $getSelection, $isRangeSelection, $isTextNode, $isLeafNode, $setSelection } from 'lexical';
15
+ import { jsx } from 'react/jsx-runtime';
16
16
 
17
17
  /**
18
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -68,7 +68,6 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
68
68
  }, [editor, maxCharacters, remainingCharacters, strlen]);
69
69
  }
70
70
  function findOffset(text, maxCharacters, strlen) {
71
- // @ts-ignore This is due to be added in a later version of TS
72
71
  const Segmenter = Intl.Segmenter;
73
72
  let offsetUtf16 = 0;
74
73
  let offset = 0;
@@ -244,9 +243,10 @@ function utf8Length(text) {
244
243
  function DefaultRenderer({
245
244
  remainingCharacters
246
245
  }) {
247
- return /*#__PURE__*/React.createElement("span", {
248
- className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`
249
- }, remainingCharacters);
246
+ return /*#__PURE__*/jsx("span", {
247
+ className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`,
248
+ children: remainingCharacters
249
+ });
250
250
  }
251
251
  function CharacterLimitPlugin({
252
252
  charset = 'UTF-16',
@@ -6,12 +6,12 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var p=require("@lexical/react/LexicalComposerContext"),q=require("react"),w=require("@lexical/overflow"),x=require("@lexical/text"),A=require("@lexical/utils"),C=require("lexical"),D=Object.create(null);if(q)for(var E in q)D[E]=q[E];D.default=q;var F;
10
- function H(a){let c=new URLSearchParams;c.append("code",a);for(let h=1;h<arguments.length;h++)c.append("v",arguments[h]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}F=H&&H.__esModule&&Object.prototype.hasOwnProperty.call(H,"default")?H["default"]:H;
11
- function I(a,c,h=Object.freeze({})){let {strlen:f=l=>l.length,remainingCharacters:r=()=>{}}=h;q.useEffect(()=>{a.hasNodes([w.OverflowNode])||F(57)},[a]);q.useEffect(()=>{let l=a.getEditorState().read(x.$rootTextContent),m=0;return A.mergeRegister(a.registerTextContentListener(d=>{l=d}),a.registerUpdateListener(({dirtyLeaves:d,dirtyElements:t})=>{var y=a.isComposing();d=0<d.size||0<t.size;if(!y&&d){y=f(l);d=y>c||null!==m&&m>c;r(c-y);if(null===m||d){let u=K(l,c,f);a.update(()=>{let G=A.$dfs(),O=G.length,
12
- z=0;for(let B=0;B<O;B+=1){var {node:b}=G[B];if(w.$isOverflowNode(b)){var e=z;if(z+b.getTextContentSize()<=u){var g=b.getParent();e=b.getPreviousSibling();var k=b.getNextSibling();L(b);b=C.$getSelection();!C.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(C.$isTextNode(e)?e.select():C.$isTextNode(k)?k.select():null!==g&&g.select())}else e<u&&(g=b.getFirstDescendant(),k=null!==g?g.getTextContentSize():0,e+=k,g=C.$isTextNode(g)&&g.isSimpleText(),e=e<=u,(g||e)&&
13
- L(b))}else if(C.$isLeafNode(b)&&(e=z,z+=b.getTextContentSize(),z>u&&!w.$isOverflowNode(b.getParent())&&(g=C.$getSelection(),e<u&&C.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(u-e),b=M(b)):b=M(b),null!==g&&C.$setSelection(g),e=b.getPreviousSibling(),w.$isOverflowNode(e)))){k=b.getFirstChild();var v=e.getChildren();g=v.length;if(null===k)b.append(...v);else for(var n=0;n<g;n++)k.insertBefore(v[n]);n=C.$getSelection();if(C.$isRangeSelection(n)){k=n.anchor;v=k.getNode();n=n.focus;let J=k.getNode();
14
- v.is(e)?k.set(b.getKey(),k.offset,"element"):v.is(b)&&k.set(b.getKey(),g+k.offset,"element");J.is(e)?n.set(b.getKey(),n.offset,"element"):J.is(b)&&n.set(b.getKey(),g+n.offset,"element")}e.remove()}}},{tag:"history-merge"})}m=y}}))},[a,c,r,f])}
15
- function K(a,c,h){var f=Intl.Segmenter;let r=0;var l=0;if("function"===typeof f){a=(new f).segment(a);for(var {segment:m}of a){l+=h(m);if(l>c)break;r+=m.length}}else for(m=Array.from(a),a=m.length,f=0;f<a;f++){let d=m[f];l+=h(d);if(l>c)break;r+=d.length}return r}function M(a){let c=w.$createOverflowNode();a.replace(c);c.append(a);return c}function L(a){let c=a.getChildren(),h=c.length;for(let f=0;f<h;f++)a.insertBefore(c[f]);a.remove();return 0<h?c[h-1]:null}let N=null;
16
- function P({remainingCharacters:a}){return D.createElement("span",{className:`characters-limit ${0>a?"characters-limit-exceeded":""}`},a)}
17
- exports.CharacterLimitPlugin=function({charset:a="UTF-16",maxLength:c=5,renderer:h=P}){let [f]=p.useLexicalComposerContext(),[r,l]=q.useState(c),m=q.useMemo(()=>({remainingCharacters:l,strlen:d=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var t=null;else null===N&&(N=new window.TextEncoder),t=N;null===t?(t=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(t?t.length:0)):d=t.encode(d).length;return d}if("UTF-16"===a)return d.length;throw Error("Unrecognized charset");}}),[a]);I(f,c,m);return h({remainingCharacters:r})}
9
+ 'use strict';var p=require("@lexical/react/LexicalComposerContext"),v=require("react"),w=require("@lexical/overflow"),z=require("@lexical/text"),B=require("@lexical/utils"),C=require("lexical"),D=require("react/jsx-runtime"),F;
10
+ function G(a){let c=new URLSearchParams;c.append("code",a);for(let h=1;h<arguments.length;h++)c.append("v",arguments[h]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}F=G&&G.__esModule&&Object.prototype.hasOwnProperty.call(G,"default")?G["default"]:G;
11
+ function I(a,c,h=Object.freeze({})){let {strlen:f=l=>l.length,remainingCharacters:q=()=>{}}=h;v.useEffect(()=>{a.hasNodes([w.OverflowNode])||F(57)},[a]);v.useEffect(()=>{let l=a.getEditorState().read(z.$rootTextContent),m=0;return B.mergeRegister(a.registerTextContentListener(d=>{l=d}),a.registerUpdateListener(({dirtyLeaves:d,dirtyElements:r})=>{var x=a.isComposing();d=0<d.size||0<r.size;if(!x&&d){x=f(l);d=x>c||null!==m&&m>c;q(c-x);if(null===m||d){let t=J(l,c,f);a.update(()=>{let E=B.$dfs(),N=E.length,
12
+ y=0;for(let A=0;A<N;A+=1){var {node:b}=E[A];if(w.$isOverflowNode(b)){var e=y;if(y+b.getTextContentSize()<=t){var g=b.getParent();e=b.getPreviousSibling();var k=b.getNextSibling();K(b);b=C.$getSelection();!C.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(C.$isTextNode(e)?e.select():C.$isTextNode(k)?k.select():null!==g&&g.select())}else e<t&&(g=b.getFirstDescendant(),k=null!==g?g.getTextContentSize():0,e+=k,g=C.$isTextNode(g)&&g.isSimpleText(),e=e<=t,(g||e)&&
13
+ K(b))}else if(C.$isLeafNode(b)&&(e=y,y+=b.getTextContentSize(),y>t&&!w.$isOverflowNode(b.getParent())&&(g=C.$getSelection(),e<t&&C.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(t-e),b=L(b)):b=L(b),null!==g&&C.$setSelection(g),e=b.getPreviousSibling(),w.$isOverflowNode(e)))){k=b.getFirstChild();var u=e.getChildren();g=u.length;if(null===k)b.append(...u);else for(var n=0;n<g;n++)k.insertBefore(u[n]);n=C.$getSelection();if(C.$isRangeSelection(n)){k=n.anchor;u=k.getNode();n=n.focus;let H=k.getNode();
14
+ u.is(e)?k.set(b.getKey(),k.offset,"element"):u.is(b)&&k.set(b.getKey(),g+k.offset,"element");H.is(e)?n.set(b.getKey(),n.offset,"element"):H.is(b)&&n.set(b.getKey(),g+n.offset,"element")}e.remove()}}},{tag:"history-merge"})}m=x}}))},[a,c,q,f])}
15
+ function J(a,c,h){var f=Intl.Segmenter;let q=0;var l=0;if("function"===typeof f){a=(new f).segment(a);for(var {segment:m}of a){l+=h(m);if(l>c)break;q+=m.length}}else for(m=Array.from(a),a=m.length,f=0;f<a;f++){let d=m[f];l+=h(d);if(l>c)break;q+=d.length}return q}function L(a){let c=w.$createOverflowNode();a.replace(c);c.append(a);return c}function K(a){let c=a.getChildren(),h=c.length;for(let f=0;f<h;f++)a.insertBefore(c[f]);a.remove();return 0<h?c[h-1]:null}let M=null;
16
+ function O({remainingCharacters:a}){return D.jsx("span",{className:`characters-limit ${0>a?"characters-limit-exceeded":""}`,children:a})}
17
+ exports.CharacterLimitPlugin=function({charset:a="UTF-16",maxLength:c=5,renderer:h=O}){let [f]=p.useLexicalComposerContext(),[q,l]=v.useState(c),m=v.useMemo(()=>({remainingCharacters:l,strlen:d=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var r=null;else null===M&&(M=new window.TextEncoder),r=M;null===r?(r=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(r?r.length:0)):d=r.encode(d).length;return d}if("UTF-16"===a)return d.length;throw Error("Unrecognized charset");}}),[a]);I(f,c,m);return h({remainingCharacters:q})}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import*as t from"react";import{useEffect as n,useState as r,useMemo as o}from"react";import{OverflowNode as i,$isOverflowNode as s,$createOverflowNode as l}from"@lexical/overflow";import{$rootTextContent as c}from"@lexical/text";import{mergeRegister as a,$dfs as f}from"@lexical/utils";import{$getSelection as g,$isRangeSelection as u,$isTextNode as d,$isLeafNode as m,$setSelection as h}from"lexical";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x=p((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function C(e,t,r=Object.freeze({})){const{strlen:o=(e=>e.length),remainingCharacters:l=(()=>{})}=r;n((()=>{e.hasNodes([i])||x(57)}),[e]),n((()=>{let n=e.getEditorState().read(c),r=0;return a(e.registerTextContentListener((e=>{n=e})),e.registerUpdateListener((({dirtyLeaves:i,dirtyElements:c})=>{const a=e.isComposing(),p=i.size>0||c.size>0;if(a||!p)return;const x=o(n),C=x>t||null!==r&&r>t;if(l(t-x),null===r||C){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(n,t,o);e.update((()=>{!function(e){const t=f(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(s(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();w(n);const o=g();!u(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(d(t)?t.select():d(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(d(r)&&r.isSimpleText()||o<=e)&&w(n)}}else if(m(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!s(n.getParent())){const r=g();let o;if(t<e&&d(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=v(r)}else o=v(n);null!==r&&h(r),T(o)}}}}(r)}),{tag:"history-merge"})}r=x})))}),[e,t,l,o])}function v(e){const t=l();return e.replace(t),t.append(e),t}function w(e){const t=e.getChildren(),n=t.length;for(let r=0;r<n;r++)e.insertBefore(t[r]);return e.remove(),n>0?t[n-1]:null}function T(e){const t=e.getPreviousSibling();if(!s(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const i=g();if(u(i)){const n=i.anchor,r=n.getNode(),s=i.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?s.set(e.getKey(),s.offset,"element"):l.is(e)&&s.set(e.getKey(),o+s.offset,"element")}t.remove()}let y=null;function S(e){const t=void 0===window.TextEncoder?null:(null===y&&(y=new window.TextEncoder),y);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function b({remainingCharacters:e}){return t.createElement("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":"")},e)}function z({charset:t="UTF-16",maxLength:n=5,renderer:i=b}){const[s]=e(),[l,c]=r(n);return C(s,n,o((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return S(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{z as CharacterLimitPlugin};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useEffect as t,useState as n,useMemo as r}from"react";import{OverflowNode as o,$isOverflowNode as i,$createOverflowNode as s}from"@lexical/overflow";import{$rootTextContent as l}from"@lexical/text";import{mergeRegister as c,$dfs as a}from"@lexical/utils";import{$getSelection as f,$isRangeSelection as g,$isTextNode as u,$isLeafNode as d,$setSelection as m}from"lexical";import{jsx as h}from"react/jsx-runtime";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x=p((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function C(e,n,r=Object.freeze({})){const{strlen:s=(e=>e.length),remainingCharacters:h=(()=>{})}=r;t((()=>{e.hasNodes([o])||x(57)}),[e]),t((()=>{let t=e.getEditorState().read(l),r=0;return c(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:o,dirtyElements:l})=>{const c=e.isComposing(),p=o.size>0||l.size>0;if(c||!p)return;const x=s(t),C=x>n||null!==r&&r>n;if(h(n-x),null===r||C){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(t,n,s);e.update((()=>{!function(e){const t=a(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(i(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();w(n);const o=f();!g(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(u(t)?t.select():u(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(u(r)&&r.isSimpleText()||o<=e)&&w(n)}}else if(d(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!i(n.getParent())){const r=f();let o;if(t<e&&u(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=v(r)}else o=v(n);null!==r&&m(r),T(o)}}}}(r)}),{tag:"history-merge"})}r=x})))}),[e,n,h,s])}function v(e){const t=s();return e.replace(t),t.append(e),t}function w(e){const t=e.getChildren(),n=t.length;for(let r=0;r<n;r++)e.insertBefore(t[r]);return e.remove(),n>0?t[n-1]:null}function T(e){const t=e.getPreviousSibling();if(!i(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const s=f();if(g(s)){const n=s.anchor,r=n.getNode(),i=s.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?i.set(e.getKey(),i.offset,"element"):l.is(e)&&i.set(e.getKey(),o+i.offset,"element")}t.remove()}let y=null;function S(e){const t=void 0===window.TextEncoder?null:(null===y&&(y=new window.TextEncoder),y);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function b({remainingCharacters:e}){return h("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}function z({charset:t="UTF-16",maxLength:o=5,renderer:i=b}){const[s]=e(),[l,c]=n(o);return C(s,o,r((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return S(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{z as CharacterLimitPlugin};
@@ -133,12 +133,14 @@ function handleClick(event) {
133
133
  });
134
134
  }
135
135
  });
136
+ event.stopPropagation(); // Prevents potential parent-editor listeners from firing, causing the checkbox toggle to be undone
136
137
  }
137
138
  function handlePointerDown(event) {
138
139
  handleCheckItemEvent(event, () => {
139
140
  // Prevents caret moving when clicking on check mark
140
141
  event.preventDefault();
141
142
  });
143
+ event.stopPropagation();
142
144
  }
143
145
  function findEditor(target) {
144
146
  let node = target;
@@ -131,12 +131,14 @@ function handleClick(event) {
131
131
  });
132
132
  }
133
133
  });
134
+ event.stopPropagation(); // Prevents potential parent-editor listeners from firing, causing the checkbox toggle to be undone
134
135
  }
135
136
  function handlePointerDown(event) {
136
137
  handleCheckItemEvent(event, () => {
137
138
  // Prevents caret moving when clicking on check mark
138
139
  event.preventDefault();
139
140
  });
141
+ event.stopPropagation();
140
142
  }
141
143
  function findEditor(target) {
142
144
  let node = target;
@@ -7,8 +7,8 @@
7
7
  */
8
8
 
9
9
  'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");function n(a,c){let b=a.target;if(null!==b&&k.isHTMLElement(b)){var d=b.firstChild;(null==d||!k.isHTMLElement(d)||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(d=b.getBoundingClientRect(),a=a.pageX/k.calculateZoomLevel(b),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}}
10
- function p(a){n(a,()=>{let c=a.target,b=q(c);null!=b&&b.isEditable()&&b.update(()=>{if(a.target){let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())}})})}function r(a){n(a,()=>{a.preventDefault()})}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
11
- function u(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
10
+ function p(a){n(a,()=>{let c=a.target,b=q(c);null!=b&&b.isEditable()&&b.update(()=>{if(a.target){let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())}})});a.stopPropagation()}function r(a){n(a,()=>{a.preventDefault()});a.stopPropagation()}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}
11
+ function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}function u(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
12
12
  function v(a,c,b){let d=t();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=u(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
13
13
  exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>v(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>v(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=t()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
14
14
  a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=t();return null!=b&&a.isEditable()?(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0):!1},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline());
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{INSERT_CHECK_LIST_COMMAND as e,insertList as t,$isListItemNode as n,$isListNode as r}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as l,$findMatchingParent as o,isHTMLElement as c,calculateZoomLevel as u}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as s,KEY_ARROW_DOWN_COMMAND as a,KEY_ARROW_UP_COMMAND as g,KEY_ESCAPE_COMMAND as f,KEY_SPACE_COMMAND as d,$getNearestNodeFromDOMNode as m,KEY_ARROW_LEFT_COMMAND as p,$getSelection as C,$isRangeSelection as h,$isElementNode as v}from"lexical";import{useEffect as E}from"react";function L(){const[c]=i();return E((()=>l(c.registerCommand(e,(()=>(t(c,"check"),!0)),s),c.registerCommand(a,(e=>N(e,c,!1)),s),c.registerCommand(g,(e=>N(e,c,!0)),s),c.registerCommand(f,(e=>{if(null!=y()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),s),c.registerCommand(d,(e=>{const t=y();return!(null==t||!c.isEditable())&&(c.update((()=>{const r=m(t);n(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),s),c.registerCommand(p,(e=>c.getEditorState().read((()=>{const t=C();if(h(t)&&t.isCollapsed()){const{anchor:i}=t,l="element"===i.type;if(l||0===i.offset){const t=i.getNode(),u=o(t,(e=>v(e)&&!e.isInline()));if(n(u)){const n=u.getParent();if(r(n)&&"check"===n.getListType()&&(l||u.getFirstDescendant()===t)){const t=c.getElementByKey(u.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),s),c.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",_),e.addEventListener("pointerdown",k)),null!==t&&(t.removeEventListener("click",_),t.removeEventListener("pointerdown",k))}))))),null}function x(e,t){const n=e.target;if(null===n||!c(n))return;const r=n.firstChild;if(null!=r&&c(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const l=n.getBoundingClientRect(),o=e.pageX/u(n);("rtl"===n.dir?o<l.right&&o>l.right-20:o>l.left&&o<l.left+20)&&t()}function _(e){x(e,(()=>{const t=e.target,r=function(e){let t=e;for(;t;){if(t.__lexicalEditor)return t.__lexicalEditor;t=t.parentNode}return null}(t);null!=r&&r.isEditable()&&r.update((()=>{if(e.target){const e=m(t);n(e)&&(t.focus(),e.toggleChecked())}}))}))}function k(e){x(e,(()=>{e.preventDefault()}))}function y(){const e=document.activeElement;return null!=e&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function N(e,t,i){const l=y();return null!=l&&t.update((()=>{const o=m(l);if(!n(o))return;const c=function(e,t){let i=t?e.getPreviousSibling():e.getNextSibling(),l=e;for(;null==i&&n(l);)l=l.getParentOrThrow().getParent(),null!=l&&(i=t?l.getPreviousSibling():l.getNextSibling());for(;n(i);){const e=t?i.getLastChild():i.getFirstChild();if(!r(e))return i;i=t?e.getLastChild():e.getFirstChild()}return null}(o,i);if(null!=c){c.selectStart();const n=t.getElementByKey(c.__key);null!=n&&(e.preventDefault(),setTimeout((()=>{n.focus()}),0))}})),!1}export{L as CheckListPlugin};
9
+ import{INSERT_CHECK_LIST_COMMAND as e,insertList as t,$isListItemNode as n,$isListNode as r}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as l,$findMatchingParent as o,isHTMLElement as c,calculateZoomLevel as s}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as u,KEY_ARROW_DOWN_COMMAND as a,KEY_ARROW_UP_COMMAND as g,KEY_ESCAPE_COMMAND as f,KEY_SPACE_COMMAND as d,$getNearestNodeFromDOMNode as m,KEY_ARROW_LEFT_COMMAND as p,$getSelection as C,$isRangeSelection as h,$isElementNode as v}from"lexical";import{useEffect as E}from"react";function L(){const[c]=i();return E((()=>l(c.registerCommand(e,(()=>(t(c,"check"),!0)),u),c.registerCommand(a,(e=>N(e,c,!1)),u),c.registerCommand(g,(e=>N(e,c,!0)),u),c.registerCommand(f,(e=>{if(null!=y()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),u),c.registerCommand(d,(e=>{const t=y();return!(null==t||!c.isEditable())&&(c.update((()=>{const r=m(t);n(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),u),c.registerCommand(p,(e=>c.getEditorState().read((()=>{const t=C();if(h(t)&&t.isCollapsed()){const{anchor:i}=t,l="element"===i.type;if(l||0===i.offset){const t=i.getNode(),s=o(t,(e=>v(e)&&!e.isInline()));if(n(s)){const n=s.getParent();if(r(n)&&"check"===n.getListType()&&(l||s.getFirstDescendant()===t)){const t=c.getElementByKey(s.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),u),c.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",_),e.addEventListener("pointerdown",k)),null!==t&&(t.removeEventListener("click",_),t.removeEventListener("pointerdown",k))}))))),null}function x(e,t){const n=e.target;if(null===n||!c(n))return;const r=n.firstChild;if(null!=r&&c(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const l=n.getBoundingClientRect(),o=e.pageX/s(n);("rtl"===n.dir?o<l.right&&o>l.right-20:o>l.left&&o<l.left+20)&&t()}function _(e){x(e,(()=>{const t=e.target,r=function(e){let t=e;for(;t;){if(t.__lexicalEditor)return t.__lexicalEditor;t=t.parentNode}return null}(t);null!=r&&r.isEditable()&&r.update((()=>{if(e.target){const e=m(t);n(e)&&(t.focus(),e.toggleChecked())}}))})),e.stopPropagation()}function k(e){x(e,(()=>{e.preventDefault()})),e.stopPropagation()}function y(){const e=document.activeElement;return null!=e&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function N(e,t,i){const l=y();return null!=l&&t.update((()=>{const o=m(l);if(!n(o))return;const c=function(e,t){let i=t?e.getPreviousSibling():e.getNextSibling(),l=e;for(;null==i&&n(l);)l=l.getParentOrThrow().getParent(),null!=l&&(i=t?l.getPreviousSibling():l.getNextSibling());for(;n(i);){const e=t?i.getLastChild():i.getFirstChild();if(!r(e))return i;i=t?e.getLastChild():e.getFirstChild()}return null}(o,i);if(null!=c){c.selectStart();const n=t.getElementByKey(c.__key);null!=n&&(e.preventDefault(),setTimeout((()=>{n.focus()}),0))}})),!1}export{L as CheckListPlugin};
@@ -30,6 +30,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
30
30
  *
31
31
  */
32
32
 
33
+
34
+ // This workaround is no longer necessary in React 19,
35
+ // but we currently support React >=17.x
36
+ // https://github.com/facebook/react/pull/26395
33
37
  const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
34
38
 
35
39
  /**
@@ -28,6 +28,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
28
28
  *
29
29
  */
30
30
 
31
+
32
+ // This workaround is no longer necessary in React 19,
33
+ // but we currently support React >=17.x
34
+ // https://github.com/facebook/react/pull/26395
31
35
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
32
36
 
33
37
  /**
@@ -5,7 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export default function LexicalClickableLinkPlugin({ newTab, disabled, }: {
8
+ export declare function ClickableLinkPlugin({ newTab, disabled, }: {
9
9
  newTab?: boolean;
10
10
  disabled?: boolean;
11
11
  }): null;
12
+ /** @deprecated use the named export {@link ClickableLinkPlugin} */
13
+ export default ClickableLinkPlugin;
@@ -32,7 +32,7 @@ function findMatchingDOM(startNode, predicate) {
32
32
  }
33
33
  return null;
34
34
  }
35
- function LexicalClickableLinkPlugin({
35
+ function ClickableLinkPlugin({
36
36
  newTab = true,
37
37
  disabled = false
38
38
  }) {
@@ -100,4 +100,5 @@ function LexicalClickableLinkPlugin({
100
100
  return null;
101
101
  }
102
102
 
103
- module.exports = LexicalClickableLinkPlugin;
103
+ exports.ClickableLinkPlugin = ClickableLinkPlugin;
104
+ exports.default = ClickableLinkPlugin;
@@ -30,7 +30,7 @@ function findMatchingDOM(startNode, predicate) {
30
30
  }
31
31
  return null;
32
32
  }
33
- function LexicalClickableLinkPlugin({
33
+ function ClickableLinkPlugin({
34
34
  newTab = true,
35
35
  disabled = false
36
36
  }) {
@@ -98,4 +98,4 @@ function LexicalClickableLinkPlugin({
98
98
  return null;
99
99
  }
100
100
 
101
- export { LexicalClickableLinkPlugin as default };
101
+ export { ClickableLinkPlugin, ClickableLinkPlugin as default };
@@ -7,6 +7,8 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare export function MLCClickableLinkPlugin({
10
+ declare export function ClickableLinkPlugin({
11
11
  newTab?: boolean,
12
12
  }): null;
13
+
14
+ declare export default typeof ClickableLinkPlugin;
@@ -9,4 +9,5 @@
9
9
  import * as modDev from './LexicalClickableLinkPlugin.dev.mjs';
10
10
  import * as modProd from './LexicalClickableLinkPlugin.prod.mjs';
11
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
12
+ export const ClickableLinkPlugin = mod.ClickableLinkPlugin;
12
13
  export default mod.default;
@@ -7,4 +7,5 @@
7
7
  */
8
8
 
9
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalClickableLinkPlugin.dev.mjs') : import('./LexicalClickableLinkPlugin.prod.mjs'));
10
+ export const ClickableLinkPlugin = mod.ClickableLinkPlugin;
10
11
  export default mod.default;