@lexical/react 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalAutoLinkPlugin.d.ts +6 -0
- package/LexicalAutoLinkPlugin.dev.js +13 -0
- package/LexicalAutoLinkPlugin.js.flow +5 -0
- package/LexicalAutoLinkPlugin.prod.js +1 -1
- package/LexicalHorizontalRuleNode.d.ts +2 -2
- package/LexicalOnChangePlugin.d.ts +1 -1
- package/LexicalOnChangePlugin.dev.js +1 -1
- package/LexicalOnChangePlugin.prod.js +2 -2
- package/package.json +19 -19
|
@@ -16,6 +16,12 @@ declare type LinkMatcherResult = {
|
|
|
16
16
|
url: string;
|
|
17
17
|
};
|
|
18
18
|
export declare type LinkMatcher = (text: string) => LinkMatcherResult | null;
|
|
19
|
+
export declare function createLinkMatcherWithRegExp(regExp: RegExp, urlTransformer?: (text: string) => string): (text: string) => {
|
|
20
|
+
index: number;
|
|
21
|
+
length: number;
|
|
22
|
+
text: string;
|
|
23
|
+
url: string;
|
|
24
|
+
} | null;
|
|
19
25
|
export declare function AutoLinkPlugin({ matchers, onChange, }: {
|
|
20
26
|
matchers: Array<LinkMatcher>;
|
|
21
27
|
onChange?: ChangeHandler;
|
|
@@ -19,6 +19,18 @@ var react = require('react');
|
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
+
function createLinkMatcherWithRegExp(regExp, urlTransformer = text => text) {
|
|
23
|
+
return text => {
|
|
24
|
+
const match = regExp.exec(text);
|
|
25
|
+
if (match === null) return null;
|
|
26
|
+
return {
|
|
27
|
+
index: match.index,
|
|
28
|
+
length: match[0].length,
|
|
29
|
+
text: match[0],
|
|
30
|
+
url: urlTransformer(text)
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
function findFirstMatch(text, matchers) {
|
|
24
36
|
for (let i = 0; i < matchers.length; i++) {
|
|
@@ -244,3 +256,4 @@ function AutoLinkPlugin({
|
|
|
244
256
|
}
|
|
245
257
|
|
|
246
258
|
exports.AutoLinkPlugin = AutoLinkPlugin;
|
|
259
|
+
exports.createLinkMatcherWithRegExp = createLinkMatcherWithRegExp;
|
|
@@ -21,6 +21,11 @@ type LinkMatcherResult = {
|
|
|
21
21
|
|
|
22
22
|
export type LinkMatcher = (text: string) => LinkMatcherResult | null;
|
|
23
23
|
|
|
24
|
+
declare export function createLinkMatcherWithRegExp(
|
|
25
|
+
regExp: RegExp,
|
|
26
|
+
urlTransformer?: (text: string) => string,
|
|
27
|
+
): LinkMatcher;
|
|
28
|
+
|
|
24
29
|
declare export function AutoLinkPlugin(props: {
|
|
25
30
|
matchers: Array<LinkMatcher>,
|
|
26
31
|
onChange?: ChangeHandler,
|
|
@@ -10,4 +10,4 @@ function F(a,b,c){var d=a.getChildren();let e=d.length;for(let f=0;f<e;f++){let
|
|
|
10
10
|
null,d)))):(G(a),c(null,a.getURL()))}function G(a){let b=a.getChildren();var c=b.length;for(--c;0<=c;c--)a.insertAfter(b[c]);a.remove();return b.map(d=>d.getLatest())}
|
|
11
11
|
function H(a,b,c){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #77; visit https://lexical.dev/docs/error?code=77 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let d=(e,f)=>{c&&c(e,f)};return p.mergeRegister(a.registerNodeTransform(u.TextNode,e=>{var f=e.getParentOrThrow(),l=e.getPreviousSibling();if(h.$isAutoLinkNode(f))F(f,b,d);else if(!h.$isLinkNode(f)){if(e.isSimpleText()&&(B.test(e.getTextContent()[0])||
|
|
12
12
|
!h.$isAutoLinkNode(l))){l=f=e.getTextContent();let m=0,v=e;for(var g;(g=A(l,b))&&null!==g;){let r=g.index,x=g.length,y=r+x;var t=m+r,q=m+y,z=f,D=e;if((0<t?B.test(z[t-1]):C(D))&&(q<z.length?B.test(z[q]):E(D))){var k=void 0;0===m+r?[k,v]=v.splitText(m+x):[,k,v]=v.splitText(m+r,m+r+x);t=h.$createAutoLinkNode(g.url,g.attributes);q=u.$createTextNode(g.text);q.setFormat(k.getFormat());q.setDetail(k.getDetail());t.append(q);k.replace(t);c&&c(g.url,null);m=0}else m+=y;l=l.substring(y)}}f=e.getPreviousSibling();
|
|
13
|
-
g=e.getNextSibling();k=e.getTextContent();h.$isAutoLinkNode(f)&&!B.test(k[0])&&(f.append(e),F(f,b,d),e=f.getURL(),c&&c(null,e));h.$isAutoLinkNode(g)&&!B.test(k[k.length-1])&&(G(g),F(g,b,d),e=g.getURL(),c&&c(null,e))}}))},[a,b,c])}exports.AutoLinkPlugin=function({matchers:a,onChange:b}){let [c]=n.useLexicalComposerContext();H(c,a,b);return null}
|
|
13
|
+
g=e.getNextSibling();k=e.getTextContent();h.$isAutoLinkNode(f)&&!B.test(k[0])&&(f.append(e),F(f,b,d),e=f.getURL(),c&&c(null,e));h.$isAutoLinkNode(g)&&!B.test(k[k.length-1])&&(G(g),F(g,b,d),e=g.getURL(),c&&c(null,e))}}))},[a,b,c])}exports.AutoLinkPlugin=function({matchers:a,onChange:b}){let [c]=n.useLexicalComposerContext();H(c,a,b);return null};exports.createLinkMatcherWithRegExp=function(a,b=c=>c){return c=>{let d=a.exec(c);return null===d?null:{index:d.index,length:d[0].length,text:d[0],url:b(c)}}}
|
|
@@ -21,9 +21,9 @@ export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element> {
|
|
|
21
21
|
exportJSON(): SerializedLexicalNode;
|
|
22
22
|
exportDOM(): DOMExportOutput;
|
|
23
23
|
createDOM(): HTMLElement;
|
|
24
|
-
getTextContent():
|
|
24
|
+
getTextContent(): string;
|
|
25
25
|
isInline(): false;
|
|
26
|
-
updateDOM():
|
|
26
|
+
updateDOM(): boolean;
|
|
27
27
|
decorate(): JSX.Element;
|
|
28
28
|
}
|
|
29
29
|
export declare function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
@@ -9,5 +9,5 @@ import type { EditorState, LexicalEditor } from 'lexical';
|
|
|
9
9
|
export declare function OnChangePlugin({ ignoreHistoryMergeTagChange, ignoreSelectionChange, onChange, }: {
|
|
10
10
|
ignoreHistoryMergeTagChange?: boolean;
|
|
11
11
|
ignoreSelectionChange?: boolean;
|
|
12
|
-
onChange: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
12
|
+
onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void;
|
|
13
13
|
}): null;
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var c=require("@lexical/react/LexicalComposerContext"),
|
|
8
|
-
exports.OnChangePlugin=function({ignoreHistoryMergeTagChange:d=!0,ignoreSelectionChange:e=!1,onChange:a}){let [b]=c.useLexicalComposerContext();
|
|
7
|
+
'use strict';var c=require("@lexical/react/LexicalComposerContext"),g=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
|
|
8
|
+
exports.OnChangePlugin=function({ignoreHistoryMergeTagChange:d=!0,ignoreSelectionChange:e=!1,onChange:a}){let [b]=c.useLexicalComposerContext();h(()=>{if(a)return b.registerUpdateListener(({editorState:k,dirtyElements:l,dirtyLeaves:m,prevEditorState:n,tags:f})=>{e&&0===l.size&&0===m.size||d&&f.has("history-merge")||n.isEmpty()||a(k,b,f)})},[b,d,e,a]);return null}
|
package/package.json
CHANGED
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.9.
|
|
11
|
+
"version": "0.9.1",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.9.
|
|
14
|
-
"@lexical/code": "0.9.
|
|
15
|
-
"@lexical/dragon": "0.9.
|
|
16
|
-
"@lexical/hashtag": "0.9.
|
|
17
|
-
"@lexical/history": "0.9.
|
|
18
|
-
"@lexical/link": "0.9.
|
|
19
|
-
"@lexical/list": "0.9.
|
|
20
|
-
"@lexical/mark": "0.9.
|
|
21
|
-
"@lexical/markdown": "0.9.
|
|
22
|
-
"@lexical/overflow": "0.9.
|
|
23
|
-
"@lexical/plain-text": "0.9.
|
|
24
|
-
"@lexical/rich-text": "0.9.
|
|
25
|
-
"@lexical/selection": "0.9.
|
|
26
|
-
"@lexical/table": "0.9.
|
|
27
|
-
"@lexical/text": "0.9.
|
|
28
|
-
"@lexical/utils": "0.9.
|
|
29
|
-
"@lexical/yjs": "0.9.
|
|
13
|
+
"@lexical/clipboard": "0.9.1",
|
|
14
|
+
"@lexical/code": "0.9.1",
|
|
15
|
+
"@lexical/dragon": "0.9.1",
|
|
16
|
+
"@lexical/hashtag": "0.9.1",
|
|
17
|
+
"@lexical/history": "0.9.1",
|
|
18
|
+
"@lexical/link": "0.9.1",
|
|
19
|
+
"@lexical/list": "0.9.1",
|
|
20
|
+
"@lexical/mark": "0.9.1",
|
|
21
|
+
"@lexical/markdown": "0.9.1",
|
|
22
|
+
"@lexical/overflow": "0.9.1",
|
|
23
|
+
"@lexical/plain-text": "0.9.1",
|
|
24
|
+
"@lexical/rich-text": "0.9.1",
|
|
25
|
+
"@lexical/selection": "0.9.1",
|
|
26
|
+
"@lexical/table": "0.9.1",
|
|
27
|
+
"@lexical/text": "0.9.1",
|
|
28
|
+
"@lexical/utils": "0.9.1",
|
|
29
|
+
"@lexical/yjs": "0.9.1",
|
|
30
30
|
"react-error-boundary": "^3.1.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"lexical": "0.9.
|
|
33
|
+
"lexical": "0.9.1",
|
|
34
34
|
"react": ">=17.x",
|
|
35
35
|
"react-dom": ">=17.x"
|
|
36
36
|
},
|