@lexical/react 0.8.1 → 0.9.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.
- package/LexicalAutoEmbedPlugin.d.ts +1 -0
- package/LexicalAutoEmbedPlugin.dev.js +11 -0
- package/LexicalAutoFocusPlugin.dev.js +1 -0
- package/LexicalAutoLinkPlugin.d.ts +1 -0
- package/LexicalAutoLinkPlugin.dev.js +50 -7
- package/LexicalBlockWithAlignableContents.dev.js +13 -2
- package/LexicalBlockWithAlignableContents.prod.js +4 -4
- package/LexicalCharacterLimitPlugin.d.ts +1 -0
- package/LexicalCharacterLimitPlugin.dev.js +46 -7
- package/LexicalCheckListPlugin.dev.js +48 -10
- package/LexicalClearEditorPlugin.d.ts +1 -0
- package/LexicalClearEditorPlugin.dev.js +1 -1
- package/LexicalCollaborationContext.dev.js +3 -0
- package/LexicalCollaborationPlugin.d.ts +3 -2
- package/LexicalCollaborationPlugin.dev.js +35 -6
- package/LexicalComposer.d.ts +1 -0
- package/LexicalComposer.dev.js +10 -6
- package/LexicalComposerContext.dev.js +6 -0
- package/LexicalContentEditable.dev.js +0 -1
- package/LexicalDecoratorBlockNode.d.ts +1 -0
- package/LexicalDecoratorBlockNode.dev.js +5 -0
- package/LexicalErrorBoundary.d.ts +1 -0
- package/LexicalHashtagPlugin.d.ts +1 -0
- package/LexicalHashtagPlugin.dev.js +43 -73
- package/LexicalHorizontalRuleNode.d.ts +1 -0
- package/LexicalHorizontalRuleNode.dev.js +22 -0
- package/LexicalHorizontalRulePlugin.dev.js +4 -0
- package/LexicalLinkPlugin.dev.js +10 -4
- package/LexicalListPlugin.dev.js +2 -0
- package/LexicalMarkdownShortcutPlugin.dev.js +2 -2
- package/LexicalNestedComposer.dev.js +12 -6
- package/LexicalNestedComposer.prod.js +2 -2
- package/LexicalNodeEventPlugin.dev.js +3 -5
- package/LexicalOnChangePlugin.dev.js +1 -1
- package/LexicalPlainTextPlugin.d.ts +1 -0
- package/LexicalPlainTextPlugin.dev.js +12 -8
- package/LexicalRichTextPlugin.d.ts +1 -0
- package/LexicalRichTextPlugin.dev.js +12 -8
- package/LexicalTabIndentationPlugin.dev.js +3 -1
- package/{LexicalTableOfContents__EXPERIMENTAL.d.ts → LexicalTableOfContents.d.ts} +1 -0
- package/{LexicalTableOfContents__EXPERIMENTAL.dev.js → LexicalTableOfContents.dev.js} +33 -5
- package/{DEPRECATED_useLexical.js → LexicalTableOfContents.js} +2 -2
- package/LexicalTablePlugin.d.ts +1 -0
- package/LexicalTablePlugin.dev.js +19 -5
- package/LexicalTreeView.d.ts +1 -0
- package/LexicalTreeView.dev.js +113 -21
- package/LexicalTreeView.prod.js +16 -15
- package/LexicalTypeaheadMenuPlugin.dev.js +123 -17
- package/LexicalTypeaheadMenuPlugin.prod.js +18 -18
- package/package.json +19 -19
- package/shared/useYjsCollaboration.d.ts +3 -4
- package/useLexicalEditable.dev.js +5 -1
- package/useLexicalIsTextContentEmpty.dev.js +0 -1
- package/useLexicalNodeSelection.dev.js +7 -0
- package/useLexicalSubscription.dev.js +3 -1
- package/DEPRECATED_useLexical.d.ts +0 -18
- package/DEPRECATED_useLexical.dev.js +0 -104
- package/DEPRECATED_useLexical.js.flow +0 -25
- package/DEPRECATED_useLexical.prod.js +0 -8
- package/DEPRECATED_useLexicalCanShowPlaceholder.d.ts +0 -9
- package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +0 -72
- package/DEPRECATED_useLexicalCanShowPlaceholder.js +0 -9
- package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +0 -15
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +0 -8
- package/DEPRECATED_useLexicalCharacterLimit.d.ts +0 -8
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +0 -213
- package/DEPRECATED_useLexicalCharacterLimit.js +0 -9
- package/DEPRECATED_useLexicalCharacterLimit.js.flow +0 -31
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +0 -13
- package/DEPRECATED_useLexicalEditor.d.ts +0 -9
- package/DEPRECATED_useLexicalEditor.dev.js +0 -87
- package/DEPRECATED_useLexicalEditor.js +0 -9
- package/DEPRECATED_useLexicalEditor.prod.js +0 -8
- package/DEPRECATED_useLexicalHistory.d.ts +0 -12
- package/DEPRECATED_useLexicalHistory.dev.js +0 -38
- package/DEPRECATED_useLexicalHistory.js +0 -9
- package/DEPRECATED_useLexicalHistory.js.flow +0 -34
- package/DEPRECATED_useLexicalHistory.prod.js +0 -7
- package/DEPRECATED_useLexicalPlainText.d.ts +0 -10
- package/DEPRECATED_useLexicalPlainText.dev.js +0 -88
- package/DEPRECATED_useLexicalPlainText.js +0 -9
- package/DEPRECATED_useLexicalPlainText.js.flow +0 -17
- package/DEPRECATED_useLexicalPlainText.prod.js +0 -8
- package/DEPRECATED_useLexicalRichText.d.ts +0 -10
- package/DEPRECATED_useLexicalRichText.dev.js +0 -88
- package/DEPRECATED_useLexicalRichText.js +0 -9
- package/DEPRECATED_useLexicalRichText.js.flow +0 -17
- package/DEPRECATED_useLexicalRichText.prod.js +0 -8
- package/LexicalTableOfContents__EXPERIMENTAL.js +0 -9
- /package/{LexicalTableOfContents__EXPERIMENTAL.js.flow → LexicalTableOfContents.js.flow} +0 -0
- /package/{LexicalTableOfContents__EXPERIMENTAL.prod.js → LexicalTableOfContents.prod.js} +0 -0
|
@@ -18,97 +18,64 @@ var react = require('react');
|
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
+
|
|
21
22
|
function getHashtagRegexStringChars() {
|
|
22
23
|
// Latin accented characters
|
|
23
24
|
// Excludes 0xd7 from the range
|
|
24
25
|
// (the multiplication sign, confusable with "x").
|
|
25
26
|
// Also excludes 0xf7, the division sign
|
|
26
|
-
const latinAccents = '\xc0-\xd6' + '\xd8-\xf6' + '\xf8-\xff' + '\u0100-\u024f' + '\u0253-\u0254' + '\u0256-\u0257' + '\u0259' + '\u025b' + '\u0263' + '\u0268' + '\u026f' + '\u0272' + '\u0289' + '\u028b' + '\u02bb' + '\u0300-\u036f' + '\u1e00-\u1eff';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Cyrillic
|
|
31
|
-
'\
|
|
32
|
-
//
|
|
33
|
-
'\
|
|
34
|
-
|
|
35
|
-
'\
|
|
36
|
-
//
|
|
37
|
-
'\
|
|
38
|
-
//
|
|
39
|
-
'\
|
|
40
|
-
|
|
41
|
-
'\
|
|
42
|
-
//
|
|
43
|
-
'\
|
|
44
|
-
//
|
|
45
|
-
'\
|
|
46
|
-
//
|
|
47
|
-
'\u08a2-\u08ac' + '\u08e4-\u08fe' + '\ufb50-\ufbb1' +
|
|
48
|
-
// Arabic Pres. Forms A
|
|
49
|
-
'\ufbd3-\ufd3d' + '\ufd50-\ufd8f' + '\ufd92-\ufdc7' + '\ufdf0-\ufdfb' + '\ufe70-\ufe74' +
|
|
50
|
-
// Arabic Pres. Forms B
|
|
51
|
-
'\ufe76-\ufefc' + '\u200c-\u200c' +
|
|
52
|
-
// Zero-Width Non-Joiner
|
|
53
|
-
'\u0e01-\u0e3a' +
|
|
54
|
-
// Thai
|
|
55
|
-
'\u0e40-\u0e4e' +
|
|
56
|
-
// Hangul (Korean)
|
|
57
|
-
'\u1100-\u11ff' +
|
|
58
|
-
// Hangul Jamo
|
|
59
|
-
'\u3130-\u3185' +
|
|
60
|
-
// Hangul Compatibility Jamo
|
|
61
|
-
'\uA960-\uA97F' +
|
|
62
|
-
// Hangul Jamo Extended-A
|
|
63
|
-
'\uAC00-\uD7AF' +
|
|
64
|
-
// Hangul Syllables
|
|
65
|
-
'\uD7B0-\uD7FF' +
|
|
66
|
-
// Hangul Jamo Extended-B
|
|
27
|
+
const latinAccents = '\xc0-\xd6' + '\xd8-\xf6' + '\xf8-\xff' + '\u0100-\u024f' + '\u0253-\u0254' + '\u0256-\u0257' + '\u0259' + '\u025b' + '\u0263' + '\u0268' + '\u026f' + '\u0272' + '\u0289' + '\u028b' + '\u02bb' + '\u0300-\u036f' + '\u1e00-\u1eff'; // Cyrillic (Russian, Ukrainian, etc.)
|
|
28
|
+
|
|
29
|
+
const nonLatinChars = '\u0400-\u04ff' + // Cyrillic
|
|
30
|
+
'\u0500-\u0527' + // Cyrillic Supplement
|
|
31
|
+
'\u2de0-\u2dff' + // Cyrillic Extended A
|
|
32
|
+
'\ua640-\ua69f' + // Cyrillic Extended B
|
|
33
|
+
'\u0591-\u05bf' + // Hebrew
|
|
34
|
+
'\u05c1-\u05c2' + '\u05c4-\u05c5' + '\u05c7' + '\u05d0-\u05ea' + '\u05f0-\u05f4' + '\ufb12-\ufb28' + // Hebrew Presentation Forms
|
|
35
|
+
'\ufb2a-\ufb36' + '\ufb38-\ufb3c' + '\ufb3e' + '\ufb40-\ufb41' + '\ufb43-\ufb44' + '\ufb46-\ufb4f' + '\u0610-\u061a' + // Arabic
|
|
36
|
+
'\u0620-\u065f' + '\u066e-\u06d3' + '\u06d5-\u06dc' + '\u06de-\u06e8' + '\u06ea-\u06ef' + '\u06fa-\u06fc' + '\u06ff' + '\u0750-\u077f' + // Arabic Supplement
|
|
37
|
+
'\u08a0' + // Arabic Extended A
|
|
38
|
+
'\u08a2-\u08ac' + '\u08e4-\u08fe' + '\ufb50-\ufbb1' + // Arabic Pres. Forms A
|
|
39
|
+
'\ufbd3-\ufd3d' + '\ufd50-\ufd8f' + '\ufd92-\ufdc7' + '\ufdf0-\ufdfb' + '\ufe70-\ufe74' + // Arabic Pres. Forms B
|
|
40
|
+
'\ufe76-\ufefc' + '\u200c-\u200c' + // Zero-Width Non-Joiner
|
|
41
|
+
'\u0e01-\u0e3a' + // Thai
|
|
42
|
+
'\u0e40-\u0e4e' + // Hangul (Korean)
|
|
43
|
+
'\u1100-\u11ff' + // Hangul Jamo
|
|
44
|
+
'\u3130-\u3185' + // Hangul Compatibility Jamo
|
|
45
|
+
'\uA960-\uA97F' + // Hangul Jamo Extended-A
|
|
46
|
+
'\uAC00-\uD7AF' + // Hangul Syllables
|
|
47
|
+
'\uD7B0-\uD7FF' + // Hangul Jamo Extended-B
|
|
67
48
|
'\uFFA1-\uFFDC'; // Half-width Hangul
|
|
68
49
|
|
|
69
50
|
const charCode = String.fromCharCode;
|
|
70
|
-
const cjkChars = '\u30A1-\u30FA\u30FC-\u30FE' +
|
|
71
|
-
// Katakana (
|
|
72
|
-
'\
|
|
73
|
-
//
|
|
74
|
-
'\
|
|
75
|
-
//
|
|
76
|
-
'\u3041-\u3096\u3099-\u309E' +
|
|
77
|
-
// Hiragana
|
|
78
|
-
'\u3400-\u4DBF' +
|
|
79
|
-
// Kanji (CJK Extension A)
|
|
80
|
-
'\u4E00-\u9FFF' +
|
|
81
|
-
// Kanji (Unified)
|
|
51
|
+
const cjkChars = '\u30A1-\u30FA\u30FC-\u30FE' + // Katakana (full-width)
|
|
52
|
+
'\uFF66-\uFF9F' + // Katakana (half-width)
|
|
53
|
+
'\uFF10-\uFF19\uFF21-\uFF3A' + '\uFF41-\uFF5A' + // Latin (full-width)
|
|
54
|
+
'\u3041-\u3096\u3099-\u309E' + // Hiragana
|
|
55
|
+
'\u3400-\u4DBF' + // Kanji (CJK Extension A)
|
|
56
|
+
'\u4E00-\u9FFF' + // Kanji (Unified)
|
|
82
57
|
// Disabled as it breaks the Regex.
|
|
83
58
|
// charCode(0x20000) + '-' + charCode(0x2A6DF) + // Kanji (CJK Extension B)
|
|
84
|
-
charCode(0x2a700) + '-' + charCode(0x2b73f) +
|
|
85
|
-
// Kanji (CJK Extension
|
|
86
|
-
charCode(0x2b740) + '-' + charCode(0x2b81f) +
|
|
87
|
-
// Kanji (CJK Extension D)
|
|
59
|
+
charCode(0x2a700) + '-' + charCode(0x2b73f) + // Kanji (CJK Extension C)
|
|
60
|
+
charCode(0x2b740) + '-' + charCode(0x2b81f) + // Kanji (CJK Extension D)
|
|
88
61
|
charCode(0x2f800) + '-' + charCode(0x2fa1f) + '\u3003\u3005\u303B'; // Kanji (CJK supplement)
|
|
89
62
|
|
|
90
|
-
const otherChars = latinAccents + nonLatinChars + cjkChars;
|
|
91
|
-
// equivalent of \p{L}
|
|
92
|
-
|
|
93
|
-
const unicodeLetters = '\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6' + '\u00F8-\u0241\u0250-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EE\u037A\u0386' + '\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03F5\u03F7-\u0481' + '\u048A-\u04CE\u04D0-\u04F9\u0500-\u050F\u0531-\u0556\u0559\u0561-\u0587' + '\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0640-\u064A\u066E-\u066F' + '\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710' + '\u0712-\u072F\u074D-\u076D\u0780-\u07A5\u07B1\u0904-\u0939\u093D\u0950' + '\u0958-\u0961\u097D\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0' + '\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D' + '\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD' + '\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30' + '\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83' + '\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F' + '\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C' + '\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE' + '\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39' + '\u0D60-\u0D61\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6' + '\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0EDC-\u0EDD\u0F00\u0F40-\u0F47\u0F49-\u0F6A\u0F88-\u0F8B\u1000-\u1021' + '\u1023-\u1027\u1029-\u102A\u1050-\u1055\u10A0-\u10C5\u10D0-\u10FA\u10FC' + '\u1100-\u1159\u115F-\u11A2\u11A8-\u11F9\u1200-\u1248\u124A-\u124D' + '\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0' + '\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310' + '\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C' + '\u166F-\u1676\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711' + '\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7' + '\u17DC\u1820-\u1877\u1880-\u18A8\u1900-\u191C\u1950-\u196D\u1970-\u1974' + '\u1980-\u19A9\u19C1-\u19C7\u1A00-\u1A16\u1D00-\u1DBF\u1E00-\u1E9B' + '\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D' + '\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC' + '\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC' + '\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u2094\u2102\u2107' + '\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D' + '\u212F-\u2131\u2133-\u2139\u213C-\u213F\u2145-\u2149\u2C00-\u2C2E' + '\u2C30-\u2C5E\u2C80-\u2CE4\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96' + '\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6' + '\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3006\u3031-\u3035' + '\u303B-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF' + '\u3105-\u312C\u3131-\u318E\u31A0-\u31B7\u31F0-\u31FF\u3400-\u4DB5' + '\u4E00-\u9FBB\uA000-\uA48C\uA800-\uA801\uA803-\uA805\uA807-\uA80A' + '\uA80C-\uA822\uAC00-\uD7A3\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C' + '\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F' + '\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A' + '\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7' + '\uFFDA-\uFFDC';
|
|
63
|
+
const otherChars = latinAccents + nonLatinChars + cjkChars; // equivalent of \p{L}
|
|
94
64
|
|
|
95
|
-
// equivalent of \p{Mn}\p{Mc}
|
|
96
|
-
const unicodeAccents = '\u0300-\u036F\u0483-\u0486\u0591-\u05B9\u05BB-\u05BD\u05BF' + '\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u0615\u064B-\u065E\u0670' + '\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0711\u0730-\u074A' + '\u07A6-\u07B0\u0901-\u0903\u093C\u093E-\u094D\u0951-\u0954\u0962-\u0963' + '\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7-\u09C8\u09CB-\u09CD\u09D7' + '\u09E2-\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D' + '\u0A70-\u0A71\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD' + '\u0AE2-\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B43\u0B47-\u0B48\u0B4B-\u0B4D' + '\u0B56-\u0B57\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7' + '\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56' + '\u0C82-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5-\u0CD6' + '\u0D02-\u0D03\u0D3E-\u0D43\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D82-\u0D83' + '\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2-\u0DF3\u0E31\u0E34-\u0E3A' + '\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19' + '\u0F35\u0F37\u0F39\u0F3E-\u0F3F\u0F71-\u0F84\u0F86-\u0F87\u0F90-\u0F97' + '\u0F99-\u0FBC\u0FC6\u102C-\u1032\u1036-\u1039\u1056-\u1059\u135F' + '\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17B6-\u17D3\u17DD' + '\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8-\u19C9' + '\u1A17-\u1A1B\u1DC0-\u1DC3\u20D0-\u20DC\u20E1\u20E5-\u20EB\u302A-\u302F' + '\u3099-\u309A\uA802\uA806\uA80B\uA823-\uA827\uFB1E\uFE00-\uFE0F' + '\uFE20-\uFE23';
|
|
65
|
+
const unicodeLetters = '\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6' + '\u00F8-\u0241\u0250-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EE\u037A\u0386' + '\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03F5\u03F7-\u0481' + '\u048A-\u04CE\u04D0-\u04F9\u0500-\u050F\u0531-\u0556\u0559\u0561-\u0587' + '\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0640-\u064A\u066E-\u066F' + '\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710' + '\u0712-\u072F\u074D-\u076D\u0780-\u07A5\u07B1\u0904-\u0939\u093D\u0950' + '\u0958-\u0961\u097D\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0' + '\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D' + '\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD' + '\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30' + '\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83' + '\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F' + '\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C' + '\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE' + '\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39' + '\u0D60-\u0D61\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6' + '\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0EDC-\u0EDD\u0F00\u0F40-\u0F47\u0F49-\u0F6A\u0F88-\u0F8B\u1000-\u1021' + '\u1023-\u1027\u1029-\u102A\u1050-\u1055\u10A0-\u10C5\u10D0-\u10FA\u10FC' + '\u1100-\u1159\u115F-\u11A2\u11A8-\u11F9\u1200-\u1248\u124A-\u124D' + '\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0' + '\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310' + '\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C' + '\u166F-\u1676\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711' + '\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7' + '\u17DC\u1820-\u1877\u1880-\u18A8\u1900-\u191C\u1950-\u196D\u1970-\u1974' + '\u1980-\u19A9\u19C1-\u19C7\u1A00-\u1A16\u1D00-\u1DBF\u1E00-\u1E9B' + '\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D' + '\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC' + '\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC' + '\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u2094\u2102\u2107' + '\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D' + '\u212F-\u2131\u2133-\u2139\u213C-\u213F\u2145-\u2149\u2C00-\u2C2E' + '\u2C30-\u2C5E\u2C80-\u2CE4\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96' + '\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6' + '\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3006\u3031-\u3035' + '\u303B-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF' + '\u3105-\u312C\u3131-\u318E\u31A0-\u31B7\u31F0-\u31FF\u3400-\u4DB5' + '\u4E00-\u9FBB\uA000-\uA48C\uA800-\uA801\uA803-\uA805\uA807-\uA80A' + '\uA80C-\uA822\uAC00-\uD7A3\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C' + '\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F' + '\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A' + '\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7' + '\uFFDA-\uFFDC'; // equivalent of \p{Mn}\p{Mc}
|
|
97
66
|
|
|
98
|
-
// equivalent of \p{Dn}
|
|
99
|
-
const unicodeDigits = '\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF' + '\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F' + '\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29' + '\u1040-\u1049\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9' + '\uFF10-\uFF19';
|
|
67
|
+
const unicodeAccents = '\u0300-\u036F\u0483-\u0486\u0591-\u05B9\u05BB-\u05BD\u05BF' + '\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u0615\u064B-\u065E\u0670' + '\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0711\u0730-\u074A' + '\u07A6-\u07B0\u0901-\u0903\u093C\u093E-\u094D\u0951-\u0954\u0962-\u0963' + '\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7-\u09C8\u09CB-\u09CD\u09D7' + '\u09E2-\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D' + '\u0A70-\u0A71\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD' + '\u0AE2-\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B43\u0B47-\u0B48\u0B4B-\u0B4D' + '\u0B56-\u0B57\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7' + '\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56' + '\u0C82-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5-\u0CD6' + '\u0D02-\u0D03\u0D3E-\u0D43\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D82-\u0D83' + '\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2-\u0DF3\u0E31\u0E34-\u0E3A' + '\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19' + '\u0F35\u0F37\u0F39\u0F3E-\u0F3F\u0F71-\u0F84\u0F86-\u0F87\u0F90-\u0F97' + '\u0F99-\u0FBC\u0FC6\u102C-\u1032\u1036-\u1039\u1056-\u1059\u135F' + '\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17B6-\u17D3\u17DD' + '\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8-\u19C9' + '\u1A17-\u1A1B\u1DC0-\u1DC3\u20D0-\u20DC\u20E1\u20E5-\u20EB\u302A-\u302F' + '\u3099-\u309A\uA802\uA806\uA80B\uA823-\uA827\uFB1E\uFE00-\uFE0F' + '\uFE20-\uFE23'; // equivalent of \p{Dn}
|
|
100
68
|
|
|
101
|
-
// An alpha char is a unicode chars including unicode marks or
|
|
69
|
+
const unicodeDigits = '\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF' + '\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F' + '\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29' + '\u1040-\u1049\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9' + '\uFF10-\uFF19'; // An alpha char is a unicode chars including unicode marks or
|
|
102
70
|
// letter or char in otherChars range
|
|
103
|
-
const alpha = unicodeLetters + unicodeAccents + otherChars;
|
|
104
71
|
|
|
105
|
-
// A numeric character is any with the number digit property, or
|
|
72
|
+
const alpha = unicodeLetters + unicodeAccents + otherChars; // A numeric character is any with the number digit property, or
|
|
106
73
|
// underscore. These characters can be included in hashtags, but a hashtag
|
|
107
74
|
// cannot have only these characters.
|
|
108
|
-
const numeric = unicodeDigits + '_';
|
|
109
75
|
|
|
110
|
-
// Alphanumeric char is any alpha char or a unicode char with decimal
|
|
76
|
+
const numeric = unicodeDigits + '_'; // Alphanumeric char is any alpha char or a unicode char with decimal
|
|
111
77
|
// number property \p{Nd}
|
|
78
|
+
|
|
112
79
|
const alphanumeric = alpha + numeric;
|
|
113
80
|
const hashChars = '#\\uFF03'; // normal '#' or full-width '#'
|
|
114
81
|
|
|
@@ -118,6 +85,7 @@ function getHashtagRegexStringChars() {
|
|
|
118
85
|
hashChars
|
|
119
86
|
};
|
|
120
87
|
}
|
|
88
|
+
|
|
121
89
|
function getHashtagRegexString() {
|
|
122
90
|
const {
|
|
123
91
|
alpha,
|
|
@@ -127,13 +95,13 @@ function getHashtagRegexString() {
|
|
|
127
95
|
const hashtagAlpha = '[' + alpha + ']';
|
|
128
96
|
const hashtagAlphanumeric = '[' + alphanumeric + ']';
|
|
129
97
|
const hashtagBoundary = '^|$|[^&/' + alphanumeric + ']';
|
|
130
|
-
const hashCharList = '[' + hashChars + ']';
|
|
131
|
-
|
|
132
|
-
// A hashtag contains characters, numbers and underscores,
|
|
98
|
+
const hashCharList = '[' + hashChars + ']'; // A hashtag contains characters, numbers and underscores,
|
|
133
99
|
// but not all numbers.
|
|
100
|
+
|
|
134
101
|
const hashtag = '(' + hashtagBoundary + ')(' + hashCharList + ')(' + hashtagAlphanumeric + '*' + hashtagAlpha + hashtagAlphanumeric + '*)';
|
|
135
102
|
return hashtag;
|
|
136
103
|
}
|
|
104
|
+
|
|
137
105
|
const REGEX = new RegExp(getHashtagRegexString(), 'i');
|
|
138
106
|
function HashtagPlugin() {
|
|
139
107
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
@@ -147,9 +115,11 @@ function HashtagPlugin() {
|
|
|
147
115
|
}, []);
|
|
148
116
|
const getHashtagMatch = react.useCallback(text => {
|
|
149
117
|
const matchArr = REGEX.exec(text);
|
|
118
|
+
|
|
150
119
|
if (matchArr === null) {
|
|
151
120
|
return null;
|
|
152
121
|
}
|
|
122
|
+
|
|
153
123
|
const hashtagLength = matchArr[3].length + 1;
|
|
154
124
|
const startOffset = matchArr.index + matchArr[1].length;
|
|
155
125
|
const endOffset = startOffset + hashtagLength;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
+
/// <reference types="react" />
|
|
8
9
|
import type { DOMConversionMap, DOMExportOutput, LexicalCommand, LexicalNode, SerializedLexicalNode } from 'lexical';
|
|
9
10
|
import { DecoratorNode } from 'lexical';
|
|
10
11
|
export declare type SerializedHorizontalRuleNode = SerializedLexicalNode & {
|
|
@@ -20,6 +20,7 @@ var React = require('react');
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
const INSERT_HORIZONTAL_RULE_COMMAND = lexical.createCommand('INSERT_HORIZONTAL_RULE_COMMAND');
|
|
23
|
+
|
|
23
24
|
function HorizontalRuleComponent({
|
|
24
25
|
nodeKey
|
|
25
26
|
}) {
|
|
@@ -30,44 +31,55 @@ function HorizontalRuleComponent({
|
|
|
30
31
|
const event = payload;
|
|
31
32
|
event.preventDefault();
|
|
32
33
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
34
|
+
|
|
33
35
|
if ($isHorizontalRuleNode(node)) {
|
|
34
36
|
node.remove();
|
|
35
37
|
}
|
|
38
|
+
|
|
36
39
|
setSelected(false);
|
|
37
40
|
}
|
|
41
|
+
|
|
38
42
|
return false;
|
|
39
43
|
}, [isSelected, nodeKey, setSelected]);
|
|
40
44
|
React.useEffect(() => {
|
|
41
45
|
return utils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, event => {
|
|
42
46
|
const hrElem = editor.getElementByKey(nodeKey);
|
|
47
|
+
|
|
43
48
|
if (event.target === hrElem) {
|
|
44
49
|
if (!event.shiftKey) {
|
|
45
50
|
clearSelection();
|
|
46
51
|
}
|
|
52
|
+
|
|
47
53
|
setSelected(!isSelected);
|
|
48
54
|
return true;
|
|
49
55
|
}
|
|
56
|
+
|
|
50
57
|
return false;
|
|
51
58
|
}, 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));
|
|
52
59
|
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
53
60
|
React.useEffect(() => {
|
|
54
61
|
const hrElem = editor.getElementByKey(nodeKey);
|
|
62
|
+
|
|
55
63
|
if (hrElem !== null) {
|
|
56
64
|
hrElem.className = isSelected ? 'selected' : '';
|
|
57
65
|
}
|
|
58
66
|
}, [editor, isSelected, nodeKey]);
|
|
59
67
|
return null;
|
|
60
68
|
}
|
|
69
|
+
|
|
61
70
|
class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
62
71
|
static getType() {
|
|
63
72
|
return 'horizontalrule';
|
|
64
73
|
}
|
|
74
|
+
|
|
65
75
|
static clone(node) {
|
|
66
76
|
return new HorizontalRuleNode(node.__key);
|
|
67
77
|
}
|
|
78
|
+
|
|
68
79
|
static importJSON(serializedNode) {
|
|
69
80
|
return $createHorizontalRuleNode();
|
|
70
81
|
}
|
|
82
|
+
|
|
71
83
|
static importDOM() {
|
|
72
84
|
return {
|
|
73
85
|
hr: () => ({
|
|
@@ -76,40 +88,50 @@ class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
|
76
88
|
})
|
|
77
89
|
};
|
|
78
90
|
}
|
|
91
|
+
|
|
79
92
|
exportJSON() {
|
|
80
93
|
return {
|
|
81
94
|
type: 'horizontalrule',
|
|
82
95
|
version: 1
|
|
83
96
|
};
|
|
84
97
|
}
|
|
98
|
+
|
|
85
99
|
exportDOM() {
|
|
86
100
|
return {
|
|
87
101
|
element: document.createElement('hr')
|
|
88
102
|
};
|
|
89
103
|
}
|
|
104
|
+
|
|
90
105
|
createDOM() {
|
|
91
106
|
return document.createElement('hr');
|
|
92
107
|
}
|
|
108
|
+
|
|
93
109
|
getTextContent() {
|
|
94
110
|
return '\n';
|
|
95
111
|
}
|
|
112
|
+
|
|
96
113
|
isInline() {
|
|
97
114
|
return false;
|
|
98
115
|
}
|
|
116
|
+
|
|
99
117
|
updateDOM() {
|
|
100
118
|
return false;
|
|
101
119
|
}
|
|
120
|
+
|
|
102
121
|
decorate() {
|
|
103
122
|
return /*#__PURE__*/React.createElement(HorizontalRuleComponent, {
|
|
104
123
|
nodeKey: this.__key
|
|
105
124
|
});
|
|
106
125
|
}
|
|
126
|
+
|
|
107
127
|
}
|
|
128
|
+
|
|
108
129
|
function convertHorizontalRuleElement() {
|
|
109
130
|
return {
|
|
110
131
|
node: $createHorizontalRuleNode()
|
|
111
132
|
};
|
|
112
133
|
}
|
|
134
|
+
|
|
113
135
|
function $createHorizontalRuleNode() {
|
|
114
136
|
return lexical.$applyNodeReplacement(new HorizontalRuleNode());
|
|
115
137
|
}
|
|
@@ -24,14 +24,18 @@ function HorizontalRulePlugin() {
|
|
|
24
24
|
react.useEffect(() => {
|
|
25
25
|
return editor.registerCommand(LexicalHorizontalRuleNode.INSERT_HORIZONTAL_RULE_COMMAND, type => {
|
|
26
26
|
const selection = lexical.$getSelection();
|
|
27
|
+
|
|
27
28
|
if (!lexical.$isRangeSelection(selection)) {
|
|
28
29
|
return false;
|
|
29
30
|
}
|
|
31
|
+
|
|
30
32
|
const focusNode = selection.focus.getNode();
|
|
33
|
+
|
|
31
34
|
if (focusNode !== null) {
|
|
32
35
|
const horizontalRuleNode = LexicalHorizontalRuleNode.$createHorizontalRuleNode();
|
|
33
36
|
utils.$insertNodeToNearestRoot(horizontalRuleNode);
|
|
34
37
|
}
|
|
38
|
+
|
|
35
39
|
return true;
|
|
36
40
|
}, lexical.COMMAND_PRIORITY_EDITOR);
|
|
37
41
|
}, [editor]);
|
package/LexicalLinkPlugin.dev.js
CHANGED
|
@@ -27,6 +27,7 @@ function LinkPlugin({
|
|
|
27
27
|
if (!editor.hasNodes([link.LinkNode])) {
|
|
28
28
|
throw new Error('LinkPlugin: LinkNode not registered on editor');
|
|
29
29
|
}
|
|
30
|
+
|
|
30
31
|
return utils.mergeRegister(editor.registerCommand(link.TOGGLE_LINK_COMMAND, payload => {
|
|
31
32
|
if (payload === null) {
|
|
32
33
|
link.toggleLink(payload);
|
|
@@ -36,6 +37,7 @@ function LinkPlugin({
|
|
|
36
37
|
link.toggleLink(payload);
|
|
37
38
|
return true;
|
|
38
39
|
}
|
|
40
|
+
|
|
39
41
|
return false;
|
|
40
42
|
} else {
|
|
41
43
|
const {
|
|
@@ -51,22 +53,26 @@ function LinkPlugin({
|
|
|
51
53
|
}
|
|
52
54
|
}, lexical.COMMAND_PRIORITY_LOW), validateUrl !== undefined ? editor.registerCommand(lexical.PASTE_COMMAND, event => {
|
|
53
55
|
const selection = lexical.$getSelection();
|
|
56
|
+
|
|
54
57
|
if (!lexical.$isRangeSelection(selection) || selection.isCollapsed() || !(event instanceof ClipboardEvent) || event.clipboardData == null) {
|
|
55
58
|
return false;
|
|
56
59
|
}
|
|
60
|
+
|
|
57
61
|
const clipboardText = event.clipboardData.getData('text');
|
|
62
|
+
|
|
58
63
|
if (!validateUrl(clipboardText)) {
|
|
59
64
|
return false;
|
|
60
|
-
}
|
|
61
|
-
|
|
65
|
+
} // If we select nodes that are elements then avoid applying the link.
|
|
66
|
+
|
|
67
|
+
|
|
62
68
|
if (!selection.getNodes().some(node => lexical.$isElementNode(node))) {
|
|
63
69
|
editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, clipboardText);
|
|
64
70
|
event.preventDefault();
|
|
65
71
|
return true;
|
|
66
72
|
}
|
|
73
|
+
|
|
67
74
|
return false;
|
|
68
|
-
}, lexical.COMMAND_PRIORITY_LOW) : () => {
|
|
69
|
-
// Don't paste arbritrary text as a link when there's no validate function
|
|
75
|
+
}, lexical.COMMAND_PRIORITY_LOW) : () => {// Don't paste arbritrary text as a link when there's no validate function
|
|
70
76
|
});
|
|
71
77
|
}, [editor, validateUrl]);
|
|
72
78
|
return null;
|
package/LexicalListPlugin.dev.js
CHANGED
|
@@ -32,9 +32,11 @@ function useList(editor) {
|
|
|
32
32
|
return true;
|
|
33
33
|
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
|
|
34
34
|
const hasHandledInsertParagraph = list.$handleListInsertParagraph();
|
|
35
|
+
|
|
35
36
|
if (hasHandledInsertParagraph) {
|
|
36
37
|
return true;
|
|
37
38
|
}
|
|
39
|
+
|
|
38
40
|
return false;
|
|
39
41
|
}, lexical.COMMAND_PRIORITY_LOW));
|
|
40
42
|
}, [editor]);
|
|
@@ -25,14 +25,14 @@ const HR = {
|
|
|
25
25
|
},
|
|
26
26
|
regExp: /^(---|\*\*\*|___)\s?$/,
|
|
27
27
|
replace: (parentNode, _1, _2, isImport) => {
|
|
28
|
-
const line = LexicalHorizontalRuleNode.$createHorizontalRuleNode();
|
|
28
|
+
const line = LexicalHorizontalRuleNode.$createHorizontalRuleNode(); // TODO: Get rid of isImport flag
|
|
29
29
|
|
|
30
|
-
// TODO: Get rid of isImport flag
|
|
31
30
|
if (isImport || parentNode.getNextSibling() != null) {
|
|
32
31
|
parentNode.replace(line);
|
|
33
32
|
} else {
|
|
34
33
|
parentNode.insertBefore(line);
|
|
35
34
|
}
|
|
35
|
+
|
|
36
36
|
line.selectNext();
|
|
37
37
|
},
|
|
38
38
|
type: 'element'
|
|
@@ -26,23 +26,29 @@ function LexicalNestedComposer({
|
|
|
26
26
|
}) {
|
|
27
27
|
const wasCollabPreviouslyReadyRef = React.useRef(false);
|
|
28
28
|
const parentContext = React.useContext(LexicalComposerContext.LexicalComposerContext);
|
|
29
|
+
|
|
29
30
|
if (parentContext == null) {
|
|
30
31
|
{
|
|
31
32
|
throw Error(`Unexpected parent context null on a nested composer`);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
|
|
34
36
|
const [parentEditor, {
|
|
35
37
|
getTheme: getParentTheme
|
|
36
38
|
}] = parentContext;
|
|
37
39
|
const composerContext = React.useMemo(() => {
|
|
38
40
|
const composerTheme = initialTheme || getParentTheme() || undefined;
|
|
39
41
|
const context = LexicalComposerContext.createLexicalComposerContext(parentContext, composerTheme);
|
|
42
|
+
|
|
40
43
|
if (composerTheme !== undefined) {
|
|
41
44
|
initialEditor._config.theme = composerTheme;
|
|
42
45
|
}
|
|
46
|
+
|
|
43
47
|
initialEditor._parentEditor = parentEditor;
|
|
48
|
+
|
|
44
49
|
if (!initialNodes) {
|
|
45
50
|
const parentNodes = initialEditor._nodes = new Map(parentEditor._nodes);
|
|
51
|
+
|
|
46
52
|
for (const [type, entry] of parentNodes) {
|
|
47
53
|
initialEditor._nodes.set(type, {
|
|
48
54
|
klass: entry.klass,
|
|
@@ -54,6 +60,7 @@ function LexicalNestedComposer({
|
|
|
54
60
|
} else {
|
|
55
61
|
for (const klass of initialNodes) {
|
|
56
62
|
const type = klass.getType();
|
|
63
|
+
|
|
57
64
|
initialEditor._nodes.set(type, {
|
|
58
65
|
klass,
|
|
59
66
|
replace: null,
|
|
@@ -62,14 +69,14 @@ function LexicalNestedComposer({
|
|
|
62
69
|
});
|
|
63
70
|
}
|
|
64
71
|
}
|
|
72
|
+
|
|
65
73
|
initialEditor._config.namespace = parentEditor._config.namespace;
|
|
74
|
+
initialEditor._editable = parentEditor._editable;
|
|
66
75
|
return [initialEditor, context];
|
|
67
|
-
},
|
|
68
|
-
// We only do this for init
|
|
76
|
+
}, // We only do this for init
|
|
69
77
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
-
[]);
|
|
78
|
+
[]); // If collaboration is enabled, make sure we don't render the children until the collaboration subdocument is ready.
|
|
71
79
|
|
|
72
|
-
// If collaboration is enabled, make sure we don't render the children until the collaboration subdocument is ready.
|
|
73
80
|
const {
|
|
74
81
|
isCollabActive,
|
|
75
82
|
yjsDocMap
|
|
@@ -79,9 +86,8 @@ function LexicalNestedComposer({
|
|
|
79
86
|
if (isCollabReady) {
|
|
80
87
|
wasCollabPreviouslyReadyRef.current = true;
|
|
81
88
|
}
|
|
82
|
-
}, [isCollabReady]);
|
|
89
|
+
}, [isCollabReady]); // Update `isEditable` state of nested editor in response to the same change on parent editor.
|
|
83
90
|
|
|
84
|
-
// Update `isEditable` state of nested editor in response to the same change on parent editor.
|
|
85
91
|
React.useEffect(() => {
|
|
86
92
|
return parentEditor.registerEditableListener(editable => {
|
|
87
93
|
initialEditor.setEditable(editable);
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var c=require("@lexical/react/LexicalCollaborationContext"),f=require("@lexical/react/LexicalComposerContext"),n=require("react");
|
|
8
8
|
exports.LexicalNestedComposer=function({initialEditor:a,children:p,initialNodes:l,initialTheme:q,skipCollabChecks:r}){let m=n.useRef(!1),g=n.useContext(f.LexicalComposerContext);if(null==g)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let [d,{getTheme:t}]=g,w=n.useMemo(()=>{var b=q||t()||void 0;const u=f.createLexicalComposerContext(g,b);void 0!==b&&
|
|
9
|
-
(a._config.theme=b);a._parentEditor=d;if(l)for(var e of l)b=e.getType(),a._nodes.set(b,{klass:e,replace:null,replaceWithKlass:null,transforms:new Set});else{e=a._nodes=new Map(d._nodes);for(const [v,h]of e)a._nodes.set(v,{klass:h.klass,replace:h.replace,replaceWithKlass:h.replaceWithKlass,transforms:new Set})}a._config.namespace=d._config.namespace;return[a,u]},[]),{isCollabActive:x,yjsDocMap:y}=c.useCollaborationContext(),k=r||m.current||y.has(a.getKey());n.useEffect(()=>
|
|
10
|
-
n.useEffect(()=>d.registerEditableListener(b=>{a.setEditable(b)}),[a,d]);return n.createElement(f.LexicalComposerContext.Provider,{value:w},!x||k?p:null)}
|
|
9
|
+
(a._config.theme=b);a._parentEditor=d;if(l)for(var e of l)b=e.getType(),a._nodes.set(b,{klass:e,replace:null,replaceWithKlass:null,transforms:new Set});else{e=a._nodes=new Map(d._nodes);for(const [v,h]of e)a._nodes.set(v,{klass:h.klass,replace:h.replace,replaceWithKlass:h.replaceWithKlass,transforms:new Set})}a._config.namespace=d._config.namespace;a._editable=d._editable;return[a,u]},[]),{isCollabActive:x,yjsDocMap:y}=c.useCollaborationContext(),k=r||m.current||y.has(a.getKey());n.useEffect(()=>
|
|
10
|
+
{k&&(m.current=!0)},[k]);n.useEffect(()=>d.registerEditableListener(b=>{a.setEditable(b)}),[a,d]);return n.createElement(f.LexicalComposerContext.Provider,{value:w},!x||k?p:null)}
|
|
@@ -16,7 +16,6 @@ var react = require('react');
|
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -50,8 +49,8 @@ function NodeEventPlugin({
|
|
|
50
49
|
editor.getEditorState().read(() => {
|
|
51
50
|
for (const [key, mutation] of mutations) {
|
|
52
51
|
const element = editor.getElementByKey(key);
|
|
53
|
-
|
|
54
|
-
// Updated might be a move, so that might mean a new DOM element
|
|
52
|
+
|
|
53
|
+
if ( // Updated might be a move, so that might mean a new DOM element
|
|
55
54
|
// is created. In this case, we need to add and event listener too.
|
|
56
55
|
(mutation === 'created' || mutation === 'updated') && element !== null && !registedElements.has(element)) {
|
|
57
56
|
registedElements.add(element);
|
|
@@ -61,8 +60,7 @@ function NodeEventPlugin({
|
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
});
|
|
64
|
-
});
|
|
65
|
-
// wW intentionally don't respect changes to eventType.
|
|
63
|
+
}); // wW intentionally don't respect changes to eventType.
|
|
66
64
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
65
|
}, [editor, nodeType]);
|
|
68
66
|
return null;
|
|
@@ -16,7 +16,6 @@ var react = require('react');
|
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -54,6 +53,7 @@ function OnChangePlugin({
|
|
|
54
53
|
if (ignoreSelectionChange && dirtyElements.size === 0 && dirtyLeaves.size === 0 || ignoreHistoryMergeTagChange && tags.has('history-merge') || prevEditorState.isEmpty()) {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
56
|
+
|
|
57
57
|
onChange(editorState, editor);
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
+
/// <reference types="react" />
|
|
8
9
|
import { ErrorBoundaryType } from './shared/useDecorators';
|
|
9
10
|
export declare function PlainTextPlugin({ contentEditable, placeholder, ErrorBoundary, }: {
|
|
10
11
|
contentEditable: JSX.Element;
|
|
@@ -22,7 +22,6 @@ var plainText = require('@lexical/plain-text');
|
|
|
22
22
|
* LICENSE file in the root directory of this source tree.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
25
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
27
26
|
|
|
28
27
|
/**
|
|
@@ -42,10 +41,12 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
42
41
|
* LICENSE file in the root directory of this source tree.
|
|
43
42
|
*
|
|
44
43
|
*/
|
|
44
|
+
|
|
45
45
|
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
46
46
|
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
|
|
47
47
|
return currentCanShowPlaceholder;
|
|
48
48
|
}
|
|
49
|
+
|
|
49
50
|
function useCanShowPlaceholder(editor) {
|
|
50
51
|
const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
51
52
|
useLayoutEffect(() => {
|
|
@@ -53,6 +54,7 @@ function useCanShowPlaceholder(editor) {
|
|
|
53
54
|
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
54
55
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
55
56
|
}
|
|
57
|
+
|
|
56
58
|
resetCanShowPlaceholder();
|
|
57
59
|
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
58
60
|
resetCanShowPlaceholder();
|
|
@@ -71,9 +73,8 @@ function useCanShowPlaceholder(editor) {
|
|
|
71
73
|
*
|
|
72
74
|
*/
|
|
73
75
|
function useDecorators(editor, ErrorBoundary) {
|
|
74
|
-
const [decorators, setDecorators] = React.useState(() => editor.getDecorators());
|
|
76
|
+
const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
|
|
75
77
|
|
|
76
|
-
// Subscribe to changes
|
|
77
78
|
useLayoutEffect(() => {
|
|
78
79
|
return editor.registerDecoratorListener(nextDecorators => {
|
|
79
80
|
reactDom.flushSync(() => {
|
|
@@ -86,12 +87,12 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
86
87
|
// nothing will be rendered on initial pass. We can get around that by
|
|
87
88
|
// ensuring that we set the value.
|
|
88
89
|
setDecorators(editor.getDecorators());
|
|
89
|
-
}, [editor]);
|
|
90
|
+
}, [editor]); // Return decorators defined as React Portals
|
|
90
91
|
|
|
91
|
-
// Return decorators defined as React Portals
|
|
92
92
|
return React.useMemo(() => {
|
|
93
93
|
const decoratedPortals = [];
|
|
94
94
|
const decoratorKeys = Object.keys(decorators);
|
|
95
|
+
|
|
95
96
|
for (let i = 0; i < decoratorKeys.length; i++) {
|
|
96
97
|
const nodeKey = decoratorKeys[i];
|
|
97
98
|
const reactDecorator = /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
@@ -100,10 +101,12 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
100
101
|
fallback: null
|
|
101
102
|
}, decorators[nodeKey]));
|
|
102
103
|
const element = editor.getElementByKey(nodeKey);
|
|
104
|
+
|
|
103
105
|
if (element !== null) {
|
|
104
106
|
decoratedPortals.push( /*#__PURE__*/reactDom.createPortal(reactDecorator, element));
|
|
105
107
|
}
|
|
106
108
|
}
|
|
109
|
+
|
|
107
110
|
return decoratedPortals;
|
|
108
111
|
}, [ErrorBoundary, decorators, editor]);
|
|
109
112
|
}
|
|
@@ -117,9 +120,7 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
117
120
|
*/
|
|
118
121
|
function usePlainTextSetup(editor) {
|
|
119
122
|
useLayoutEffect(() => {
|
|
120
|
-
return utils.mergeRegister(plainText.registerPlainText(editor), dragon.registerDragonSupport(editor));
|
|
121
|
-
|
|
122
|
-
// We only do this for init
|
|
123
|
+
return utils.mergeRegister(plainText.registerPlainText(editor), dragon.registerDragonSupport(editor)); // We only do this for init
|
|
123
124
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
125
|
}, [editor]);
|
|
125
126
|
}
|
|
@@ -143,15 +144,18 @@ function PlainTextPlugin({
|
|
|
143
144
|
content: placeholder
|
|
144
145
|
}), decorators);
|
|
145
146
|
}
|
|
147
|
+
|
|
146
148
|
function Placeholder({
|
|
147
149
|
content
|
|
148
150
|
}) {
|
|
149
151
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
150
152
|
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
151
153
|
const editable = useLexicalEditable();
|
|
154
|
+
|
|
152
155
|
if (!showPlaceholder) {
|
|
153
156
|
return null;
|
|
154
157
|
}
|
|
158
|
+
|
|
155
159
|
if (typeof content === 'function') {
|
|
156
160
|
return content(editable);
|
|
157
161
|
} else {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
+
/// <reference types="react" />
|
|
8
9
|
import { ErrorBoundaryType } from './shared/useDecorators';
|
|
9
10
|
export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary, }: {
|
|
10
11
|
contentEditable: JSX.Element;
|