@astryxdesign/richtext 0.6.5-canary.84fdbd1 → 0.6.5-canary.8a5b3fb
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/dist/CodeBlockHeaderPlugin.d.ts.map +1 -1
- package/dist/RichTextEditor.d.ts.map +1 -1
- package/dist/RichTextEditor.js +1 -1
- package/dist/TaskCheckboxPlugin.d.ts.map +1 -1
- package/dist/editorTheme.d.ts.map +1 -1
- package/dist/editorTheme.js +1 -1
- package/dist/markdownCharacterReferences.d.ts.map +1 -1
- package/dist/markdownCharacterReferences.js +6 -2
- package/dist/markdownCodeFence.d.ts.map +1 -1
- package/dist/markdownCodeFence.js +22 -9
- package/dist/markdownHeading.d.ts +20 -0
- package/dist/markdownHeading.d.ts.map +1 -0
- package/dist/markdownHeading.js +30 -0
- package/dist/markdownQuote.d.ts +22 -0
- package/dist/markdownQuote.d.ts.map +1 -0
- package/dist/markdownQuote.js +32 -0
- package/dist/markdownSource.d.ts.map +1 -1
- package/dist/markdownSource.js +17 -10
- package/dist/markdownTable.d.ts.map +1 -1
- package/dist/markdownTable.js +13 -7
- package/dist/richtext.css +2 -1
- package/package.json +4 -4
- package/src/CodeBlockHeaderPlugin.tsx +1 -0
- package/src/RichTextEditor.tsx +8 -1
- package/src/TaskCheckboxPlugin.tsx +5 -1
- package/src/editorTheme.ts +4 -1
- package/src/markdownAngleCodeSpans.test.ts +92 -0
- package/src/markdownCharacterReferences.ts +6 -2
- package/src/markdownCodeFence.ts +39 -15
- package/src/markdownHeading.ts +33 -0
- package/src/markdownHeadingMarkers.test.ts +132 -0
- package/src/markdownIndentedFences.test.ts +43 -0
- package/src/markdownIndentedTables.test.ts +43 -0
- package/src/markdownOpenFence.test.ts +35 -0
- package/src/markdownQuote.ts +35 -0
- package/src/markdownQuoteMarkers.test.ts +206 -0
- package/src/markdownSource.ts +19 -12
- package/src/markdownSpaceRuns.test.ts +42 -13
- package/src/markdownSpacedBlockStarts.test.ts +96 -0
- package/src/markdownTable.ts +18 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockHeaderPlugin.d.ts","sourceRoot":"","sources":["../src/CodeBlockHeaderPlugin.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeBlockHeaderPlugin.d.ts","sourceRoot":"","sources":["../src/CodeBlockHeaderPlugin.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;AA+JpD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,GAAG,CAAC,OAAO,CA+EnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AASf,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAyB,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAqBhF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAKnD,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,WAAW,EAEjB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAu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AC,yBAAyB,CAAC,CAAC;IAC9D,yEAAyE;IACzE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,cAAc,mHAkRzB,CAAC"}
|
package/dist/RichTextEditor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskCheckboxPlugin.d.ts","sourceRoot":"","sources":["../src/TaskCheckboxPlugin.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAA6B,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TaskCheckboxPlugin.d.ts","sourceRoot":"","sources":["../src/TaskCheckboxPlugin.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAA6B,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;AAmC3D,wDAAwD;AACxD,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAgDnD,wBAAgB,kBAAkB,CAAC,EACjC,UAAU,GACX,EAAE;IACD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B,GAAG,GAAG,CAAC,OAAO,CAmId"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAyXhD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CA6DtD"}
|
package/dist/editorTheme.js
CHANGED
|
@@ -264,7 +264,7 @@ export function sharedEditorTheme() {
|
|
|
264
264
|
olDepth: [className(editorTheme.olMarker0), className(editorTheme.olMarker1), className(editorTheme.olMarker2)]
|
|
265
265
|
},
|
|
266
266
|
link: {
|
|
267
|
-
className: "xjse4m1 x1bvjpef x1ypdohk"
|
|
267
|
+
className: "xjse4m1 x1bvjpef x1ypdohk x16khyan"
|
|
268
268
|
}.className,
|
|
269
269
|
text: {
|
|
270
270
|
bold: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownCharacterReferences.d.ts","sourceRoot":"","sources":["../src/markdownCharacterReferences.ts"],"names":[],"mappings":"AAiCA,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,SAAS,CAAC;AAMjB;;;GAGG;AACH,KAAK,OAAO,GACR;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GACrD;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAC,GAC5B;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GACrD;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAC,GAC5B;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjD;AAYD,oEAAoE;AACpE,wBAAiB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAUjE;AAkID;;;;;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gCN;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,GACf,iBAAiB,CA+EnB;AAmDD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,IAAI,CAsCN"}
|
|
@@ -617,8 +617,12 @@ function linkTargetRanges(markdown, code) {
|
|
|
617
617
|
}
|
|
618
618
|
const pair = pairedDelimiters(markdown, code);
|
|
619
619
|
for (let index = markdown.indexOf(']('); index !== -1; index = markdown.indexOf('](', index + 1)) {
|
|
620
|
-
|
|
621
|
-
|
|
620
|
+
// An angle-bracket destination ends where core ends it: a parenthesis
|
|
621
|
+
// inside the brackets pairs with nothing.
|
|
622
|
+
const angleClose = angleDestinationEnd(markdown, index + 1);
|
|
623
|
+
const close = typeof angleClose === 'number' ? angleClose : pair[index + 1];
|
|
624
|
+
if (pair[index] !== -1 && close !== -1) {
|
|
625
|
+
ranges.push([index + 1, close + 1]);
|
|
622
626
|
}
|
|
623
627
|
}
|
|
624
628
|
return ranges;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownCodeFence.d.ts","sourceRoot":"","sources":["../src/markdownCodeFence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdownCodeFence.d.ts","sourceRoot":"","sources":["../src/markdownCodeFence.ts"],"names":[],"mappings":"AAyBA,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,mBAAmB,CAAC;AAuJ3B,eAAO,MAAM,aAAa,EAAE,2BAqB3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,2BAYxB,CAAC"}
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
* spaces (so `~~~ c++` reads `c++`), as core and CommonMark read it. A
|
|
14
14
|
* block closes at
|
|
15
15
|
* a fence of its own character at least as long, or at the end of the
|
|
16
|
-
* document, and its code is exactly the lines between,
|
|
17
|
-
*
|
|
16
|
+
* document, and its code is exactly the lines between, blank lines
|
|
17
|
+
* included, each less as much indentation as the opening fence has (up to
|
|
18
|
+
* three spaces), as core reads it. Each keeps its fence and info
|
|
18
19
|
* string (spec:AST-062): an edited block exports them as written, with its
|
|
19
20
|
* language first when that was changed, and its fence lengthened when its
|
|
20
21
|
* code holds a run of the fence's character that long.
|
|
@@ -52,15 +53,21 @@ function languageOf(info) {
|
|
|
52
53
|
return /^\S+/.exec(info.trimStart())?.[0] ?? null;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
/** An opening fence line: its fence and the info string
|
|
56
|
+
/** An opening fence line: its indentation, its fence, and the info string. */
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Reads an opening fence line: up to three spaces of indentation, then the
|
|
60
|
+
* fence (CommonMark 0.31 §4.5), as core Markdown reads it.
|
|
61
|
+
*/
|
|
56
62
|
function readOpening(line) {
|
|
57
|
-
const match = /^
|
|
63
|
+
const match = /^( {0,3})(`{3,}|~{3,})(.*)$/.exec(line);
|
|
58
64
|
if (match == null) {
|
|
59
65
|
return null;
|
|
60
66
|
}
|
|
61
|
-
const [, fence, info] = match;
|
|
67
|
+
const [, indentation, fence, info] = match;
|
|
62
68
|
// A backtick fence's info string holds no backtick.
|
|
63
69
|
return fence.startsWith('`') && info.includes('`') ? null : {
|
|
70
|
+
indentation: indentation.length,
|
|
64
71
|
fence,
|
|
65
72
|
info
|
|
66
73
|
};
|
|
@@ -77,19 +84,25 @@ function longestFenceRun(text, character) {
|
|
|
77
84
|
*/
|
|
78
85
|
function $importFencedCode(rootNode, lines, startLineIndex, opening) {
|
|
79
86
|
const {
|
|
87
|
+
indentation,
|
|
80
88
|
fence,
|
|
81
89
|
info
|
|
82
90
|
} = opening;
|
|
83
|
-
const closing = new RegExp(`^
|
|
91
|
+
const closing = new RegExp(`^ {0,3}${fence[0] === '`' ? '`' : '~'}{${fence.length},}[ \\t]*$`);
|
|
92
|
+
// Each code line loses as much indentation as the opening fence has.
|
|
93
|
+
const fenceIndentation = new RegExp(`^ {0,${indentation}}`);
|
|
84
94
|
let end = startLineIndex + 1;
|
|
85
95
|
while (end < lines.length && !closing.test(lines[end])) {
|
|
86
96
|
end++;
|
|
87
97
|
}
|
|
98
|
+
// A fence left open runs to the end of the document, whose final line
|
|
99
|
+
// ending starts no line of code (CommonMark 0.31 §4.5), as core reads it.
|
|
100
|
+
const codeEnd = end === lines.length && end > startLineIndex + 1 && lines[end - 1] === '' ? end - 1 : end;
|
|
88
101
|
// The code is the lines between the fences, exactly: Lexical's own
|
|
89
102
|
// transformer trims a space from the first line and drops blank first and
|
|
90
103
|
// last lines, adjustments meant for its own reading of the opening line.
|
|
91
104
|
const block = $createCodeNode(languageOf(info) ?? undefined);
|
|
92
|
-
block.append($createTextNode(lines.slice(startLineIndex + 1,
|
|
105
|
+
block.append($createTextNode(lines.slice(startLineIndex + 1, codeEnd).map(line => line.replace(fenceIndentation, '')).join('\n')));
|
|
93
106
|
rootNode.append(block);
|
|
94
107
|
if (fence.startsWith('~')) {
|
|
95
108
|
$setState(block, tildeFence, fence);
|
|
@@ -137,10 +150,10 @@ export const BACKTICK_CODE = {
|
|
|
137
150
|
};
|
|
138
151
|
export const TILDE_CODE = {
|
|
139
152
|
...CODE,
|
|
140
|
-
regExpStart: /^(
|
|
153
|
+
regExpStart: /^( {0,3}~{3,})(.*)$/,
|
|
141
154
|
regExpEnd: {
|
|
142
155
|
optional: true,
|
|
143
|
-
regExp: /^
|
|
156
|
+
regExp: /^ {0,3}~{3,}[ \t]*$/
|
|
144
157
|
},
|
|
145
158
|
handleImportAfterStartMatch: ({
|
|
146
159
|
lines,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file markdownHeading.ts
|
|
3
|
+
* @input Uses @lexical/markdown (Lexical's HEADING element transformer).
|
|
4
|
+
* @output Exports HEADING_MARKERS, Lexical's heading transformer reading an
|
|
5
|
+
* ATX heading marker as CommonMark does.
|
|
6
|
+
* @position Part of DEFAULT_TRANSFORMERS (markdownTable.ts) in place of
|
|
7
|
+
* Lexical's HEADING, whose pattern allows no indentation. Matches core
|
|
8
|
+
* Markdown's ATX headings (CommonMark 0.31 §4.2). Typing shortcuts keep
|
|
9
|
+
* Lexical's own trigger: `# ` makes a heading. Text that starts like a
|
|
10
|
+
* marker is escaped on export by markdownSource.ts.
|
|
11
|
+
*/
|
|
12
|
+
import { type ElementTransformer } from '@lexical/markdown';
|
|
13
|
+
/**
|
|
14
|
+
* An ATX heading marker: up to three spaces of indentation, then one to six
|
|
15
|
+
* `#` and a space, so ` # h` imports as a heading, as in core Markdown. A
|
|
16
|
+
* typed line becomes a heading only at Lexical's own `# `, so typing
|
|
17
|
+
* ` # ` changes nothing new.
|
|
18
|
+
*/
|
|
19
|
+
export declare const HEADING_MARKERS: ElementTransformer;
|
|
20
|
+
//# sourceMappingURL=markdownHeading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownHeading.d.ts","sourceRoot":"","sources":["../src/markdownHeading.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,EAAU,KAAK,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAKnE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,kBAO7B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file markdownHeading.ts
|
|
5
|
+
* @input Uses @lexical/markdown (Lexical's HEADING element transformer).
|
|
6
|
+
* @output Exports HEADING_MARKERS, Lexical's heading transformer reading an
|
|
7
|
+
* ATX heading marker as CommonMark does.
|
|
8
|
+
* @position Part of DEFAULT_TRANSFORMERS (markdownTable.ts) in place of
|
|
9
|
+
* Lexical's HEADING, whose pattern allows no indentation. Matches core
|
|
10
|
+
* Markdown's ATX headings (CommonMark 0.31 §4.2). Typing shortcuts keep
|
|
11
|
+
* Lexical's own trigger: `# ` makes a heading. Text that starts like a
|
|
12
|
+
* marker is escaped on export by markdownSource.ts.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { HEADING } from '@lexical/markdown';
|
|
16
|
+
|
|
17
|
+
/** Lexical's own heading marker, which the typing shortcut keeps using. */
|
|
18
|
+
const SHORTCUT_MARKER = /^(#{1,6})\s/;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* An ATX heading marker: up to three spaces of indentation, then one to six
|
|
22
|
+
* `#` and a space, so ` # h` imports as a heading, as in core Markdown. A
|
|
23
|
+
* typed line becomes a heading only at Lexical's own `# `, so typing
|
|
24
|
+
* ` # ` changes nothing new.
|
|
25
|
+
*/
|
|
26
|
+
export const HEADING_MARKERS = {
|
|
27
|
+
...HEADING,
|
|
28
|
+
regExp: /^ {0,3}(#{1,6})\s/,
|
|
29
|
+
replace: (parentNode, children, match, isImport) => isImport || SHORTCUT_MARKER.test(match[0]) ? HEADING.replace(parentNode, children, match, isImport) : false
|
|
30
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file markdownQuote.ts
|
|
3
|
+
* @input Uses @lexical/markdown (Lexical's QUOTE element transformer).
|
|
4
|
+
* @output Exports QUOTE_MARKERS, Lexical's quote transformer reading a block
|
|
5
|
+
* quote marker as CommonMark does.
|
|
6
|
+
* @position Part of DEFAULT_TRANSFORMERS (markdownTable.ts) in place of
|
|
7
|
+
* Lexical's QUOTE, whose pattern needs a space after `>` and no indentation.
|
|
8
|
+
* Matches core Markdown's block quote marker (CommonMark 0.31 §5.1). Typing
|
|
9
|
+
* shortcuts keep Lexical's own trigger: `> ` makes a quote. Text that starts
|
|
10
|
+
* like a marker is escaped on export by markdownSource.ts.
|
|
11
|
+
*/
|
|
12
|
+
import { type ElementTransformer } from '@lexical/markdown';
|
|
13
|
+
/**
|
|
14
|
+
* A block quote marker: up to three spaces of indentation, then `>` and the
|
|
15
|
+
* one space or tab that may follow it, so `>a` and ` > a` import as quotes,
|
|
16
|
+
* as in core Markdown. A typed line becomes a quote only at Lexical's own
|
|
17
|
+
* `> `, so typing `>` and Enter, or ` > `, changes nothing new. RichText
|
|
18
|
+
* quotes do not nest: the marker of a quote inside a quote stays in the
|
|
19
|
+
* outer quote's text.
|
|
20
|
+
*/
|
|
21
|
+
export declare const QUOTE_MARKERS: ElementTransformer;
|
|
22
|
+
//# sourceMappingURL=markdownQuote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownQuote.d.ts","sourceRoot":"","sources":["../src/markdownQuote.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,EAAQ,KAAK,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAKjE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,kBAO3B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file markdownQuote.ts
|
|
5
|
+
* @input Uses @lexical/markdown (Lexical's QUOTE element transformer).
|
|
6
|
+
* @output Exports QUOTE_MARKERS, Lexical's quote transformer reading a block
|
|
7
|
+
* quote marker as CommonMark does.
|
|
8
|
+
* @position Part of DEFAULT_TRANSFORMERS (markdownTable.ts) in place of
|
|
9
|
+
* Lexical's QUOTE, whose pattern needs a space after `>` and no indentation.
|
|
10
|
+
* Matches core Markdown's block quote marker (CommonMark 0.31 §5.1). Typing
|
|
11
|
+
* shortcuts keep Lexical's own trigger: `> ` makes a quote. Text that starts
|
|
12
|
+
* like a marker is escaped on export by markdownSource.ts.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { QUOTE } from '@lexical/markdown';
|
|
16
|
+
|
|
17
|
+
/** Lexical's own quote marker, which the typing shortcut keeps using. */
|
|
18
|
+
const SHORTCUT_MARKER = /^>\s/;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A block quote marker: up to three spaces of indentation, then `>` and the
|
|
22
|
+
* one space or tab that may follow it, so `>a` and ` > a` import as quotes,
|
|
23
|
+
* as in core Markdown. A typed line becomes a quote only at Lexical's own
|
|
24
|
+
* `> `, so typing `>` and Enter, or ` > `, changes nothing new. RichText
|
|
25
|
+
* quotes do not nest: the marker of a quote inside a quote stays in the
|
|
26
|
+
* outer quote's text.
|
|
27
|
+
*/
|
|
28
|
+
export const QUOTE_MARKERS = {
|
|
29
|
+
...QUOTE,
|
|
30
|
+
regExp: /^ {0,3}>[ \t]?/,
|
|
31
|
+
replace: (parentNode, children, match, isImport) => isImport || SHORTCUT_MARKER.test(match[0]) ? QUOTE.replace(parentNode, children, match, isImport) : false
|
|
32
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownSource.d.ts","sourceRoot":"","sources":["../src/markdownSource.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAA6B,KAAK,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAUL,KAAK,WAAW,EAChB,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAC;AAsBjB,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,qCAAqC,CAAC;AAE7E,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AA0JD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CA4E1E;AA8CD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,aAAa,EACrB,QAAQ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AmB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAoB3D;AAsLD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBhD;AAyLD,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,GACvC,MAAM,CA0ER"}
|
package/dist/markdownSource.js
CHANGED
|
@@ -521,16 +521,23 @@ function $canonicalMarkdown(nodes, transformers) {
|
|
|
521
521
|
return entry;
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
/**
|
|
524
|
+
/**
|
|
525
|
+
* Line starts that would turn literal text into a block structure. Each match
|
|
526
|
+
* is the spaces before the marker, where the escape goes: block markers may
|
|
527
|
+
* follow up to three spaces (CommonMark 0.31), and a list item's continuation
|
|
528
|
+
* line adds its own indentation, so any spaces count.
|
|
529
|
+
*/
|
|
525
530
|
const LINE_START_SYNTAX = [
|
|
526
|
-
//
|
|
527
|
-
|
|
531
|
+
// Block quote or ATX heading marker.
|
|
532
|
+
/^ *(?=>|#{1,6}(?:[ \t]|$))/,
|
|
533
|
+
// Bullet list item.
|
|
534
|
+
/^ *(?=[-+](?:[ \t]|$))/,
|
|
528
535
|
// Setext underline or thematic break made of `=` or `-`.
|
|
529
|
-
/^[=-]
|
|
536
|
+
/^ *(?=[=-][=\- \t]*$)/,
|
|
530
537
|
// Table delimiter row.
|
|
531
|
-
/^[|:]
|
|
538
|
+
/^ *(?=[|:][|:\- \t]*-[|:\- \t]*$)/];
|
|
532
539
|
// An ordered list item escapes its delimiter, not its first character.
|
|
533
|
-
const ORDERED_LIST_START = /^(
|
|
540
|
+
const ORDERED_LIST_START = /^( *\d{1,9})(?=[.)](?:[ \t]|$))/;
|
|
534
541
|
|
|
535
542
|
// Inline syntax Lexical's export leaves unescaped: link and image brackets and
|
|
536
543
|
// character references.
|
|
@@ -588,10 +595,10 @@ function markedView(node, token, placeholders) {
|
|
|
588
595
|
const previous = node.getPreviousSibling();
|
|
589
596
|
if (previous == null || $isLineBreakNode(previous)) {
|
|
590
597
|
const ordered = ORDERED_LIST_START.exec(text);
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
text = token + text;
|
|
598
|
+
const start = LINE_START_SYNTAX.map(pattern => pattern.exec(text)).find(match => match != null);
|
|
599
|
+
const before = ordered?.[1] ?? start?.[0];
|
|
600
|
+
if (before != null) {
|
|
601
|
+
text = before + token + text.slice(before.length);
|
|
595
602
|
}
|
|
596
603
|
}
|
|
597
604
|
const view = Object.create(node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTable.d.ts","sourceRoot":"","sources":["../src/markdownTable.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"markdownTable.d.ts","sourceRoot":"","sources":["../src/markdownTable.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAUL,KAAK,2BAA2B,EAChC,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAkL3B;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,2BA8DnB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,WAAW,CAoB3D,CAAC"}
|
package/dist/markdownTable.js
CHANGED
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
* so the same source is a table on both surfaces. Keep the two in step.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { $convertFromMarkdownString, CODE, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, LINK, ORDERED_LIST, TRANSFORMERS } from '@lexical/markdown';
|
|
18
|
+
import { $convertFromMarkdownString, CODE, HEADING, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, LINK, ORDERED_LIST, QUOTE, TRANSFORMERS } from '@lexical/markdown';
|
|
19
19
|
import { $createTableCellNode, $createTableNode, $createTableRowNode, $isTableCellNode, $isTableNode, $isTableRowNode, TableCellHeaderStates, TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
20
20
|
import { HARD_LINE_BREAK } from "./markdownHardLineBreak.js";
|
|
21
21
|
import { THEMATIC_BREAK } from "./markdownThematicBreak.js";
|
|
22
|
+
import { HEADING_MARKERS } from "./markdownHeading.js";
|
|
23
|
+
import { QUOTE_MARKERS } from "./markdownQuote.js";
|
|
22
24
|
import { LIST_EXPORT } from "./markdownListExport.js";
|
|
23
25
|
import { TASK_LIST } from "./markdownTaskList.js";
|
|
24
26
|
import { ORDERED_LIST_KEEPING_START } from "./markdownOrderedList.js";
|
|
@@ -32,15 +34,19 @@ import { $convertToMarkdownKeepingTimeLinear } from "./markdownSpaceRuns.js";
|
|
|
32
34
|
*/
|
|
33
35
|
const CELL_TRANSFORMERS = [...TEXT_FORMAT_TRANSFORMERS, ...TEXT_MATCH_TRANSFORMERS.map(transformer => transformer === LINK ? LINK_KEEPING_DESTINATIONS : transformer)];
|
|
34
36
|
/**
|
|
35
|
-
* Splits a row into trimmed cell sources:
|
|
36
|
-
* and one trailing pipe are dropped, and the rest
|
|
37
|
-
* An escaped pipe stays escaped for the cell's
|
|
37
|
+
* Splits a row into trimmed cell sources: the row's indentation, one leading
|
|
38
|
+
* pipe, trailing spaces, and one trailing pipe are dropped, and the rest
|
|
39
|
+
* splits on unescaped pipes. An escaped pipe stays escaped for the cell's
|
|
40
|
+
* inline import.
|
|
38
41
|
*/
|
|
39
42
|
function splitTableRow(line) {
|
|
40
43
|
let start = 0;
|
|
41
44
|
let end = line.length;
|
|
42
|
-
|
|
43
|
-
start
|
|
45
|
+
while (start < end && (line[start] === ' ' || line[start] === '\t')) {
|
|
46
|
+
start++;
|
|
47
|
+
}
|
|
48
|
+
if (line[start] === '|') {
|
|
49
|
+
start++;
|
|
44
50
|
while (start < end && line[start] === ' ') {
|
|
45
51
|
start++;
|
|
46
52
|
}
|
|
@@ -218,4 +224,4 @@ export const TABLE = {
|
|
|
218
224
|
* rather than a list item, and task items before bullets so `- [ ] text` is a
|
|
219
225
|
* task rather than a bullet that starts with `[ ]`.
|
|
220
226
|
*/
|
|
221
|
-
export const DEFAULT_TRANSFORMERS = [THEMATIC_BREAK, LIST_EXPORT, TASK_LIST, TILDE_CODE, ...TRANSFORMERS.map(transformer => transformer === ORDERED_LIST ? ORDERED_LIST_KEEPING_START : transformer === LINK ? LINK_KEEPING_DESTINATIONS : transformer === CODE ? BACKTICK_CODE : transformer), HARD_LINE_BREAK, TABLE];
|
|
227
|
+
export const DEFAULT_TRANSFORMERS = [THEMATIC_BREAK, LIST_EXPORT, TASK_LIST, TILDE_CODE, ...TRANSFORMERS.map(transformer => transformer === ORDERED_LIST ? ORDERED_LIST_KEEPING_START : transformer === LINK ? LINK_KEEPING_DESTINATIONS : transformer === CODE ? BACKTICK_CODE : transformer === QUOTE ? QUOTE_MARKERS : transformer === HEADING ? HEADING_MARKERS : transformer), HARD_LINE_BREAK, TABLE];
|
package/dist/richtext.css
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
.xjse4m1:not(#\#):not(#\#):not(#\#){color:var(--color-text-accent)}
|
|
51
51
|
.x1tgivj0:not(#\#):not(#\#):not(#\#){color:var(--color-text-primary)}
|
|
52
52
|
.xv1l7n4:not(#\#):not(#\#):not(#\#){color:var(--color-text-secondary)}
|
|
53
|
-
.
|
|
53
|
+
.xt0e3qv:not(#\#):not(#\#):not(#\#){cursor:default}
|
|
54
54
|
.x1ypdohk:not(#\#):not(#\#):not(#\#){cursor:pointer}
|
|
55
55
|
.x1epdd7z:not(#\#):not(#\#):not(#\#){direction:inherit}
|
|
56
56
|
.x1lliihq:not(#\#):not(#\#):not(#\#){display:block}
|
|
@@ -124,6 +124,7 @@
|
|
|
124
124
|
.xuxw1ft:not(#\#):not(#\#):not(#\#){white-space:nowrap}
|
|
125
125
|
.x126k92a:not(#\#):not(#\#):not(#\#){white-space:pre-wrap}
|
|
126
126
|
.x1vjfegm:not(#\#):not(#\#):not(#\#){z-index:1}
|
|
127
|
+
.x16khyan:is(:disabled,[aria-disabled="true"]):not(#\#):not(#\#):not(#\#){cursor:default}
|
|
127
128
|
.x2i8j16:is([data-richtext-task]):not(#\#):not(#\#):not(#\#){list-style-type:none}
|
|
128
129
|
.x1pvqllw:is([data-richtext-task]):not(#\#):not(#\#):not(#\#){margin-inline-start:calc(-1 * var(--spacing-6))}
|
|
129
130
|
.x1kuvm45:is([data-richtext-task]):not(#\#):not(#\#):not(#\#){padding-inline-start:calc(20px + var(--spacing-2))}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/richtext",
|
|
3
3
|
"displayName": "Rich Text",
|
|
4
|
-
"version": "0.6.5-canary.
|
|
4
|
+
"version": "0.6.5-canary.8a5b3fb",
|
|
5
5
|
"description": "Astryx rich text — a Lexical-based rich text editor and viewer. Published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@stylexjs/stylex": ">=0.10.0",
|
|
58
|
-
"@astryxdesign/core": "0.6.5-canary.
|
|
58
|
+
"@astryxdesign/core": "0.6.5-canary.8a5b3fb",
|
|
59
59
|
"react": ">=19.0.0",
|
|
60
60
|
"react-dom": ">=19.0.0",
|
|
61
61
|
"lexical": "^0.46.0",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@astryxdesign/a11y-spec": "0.6.5-canary.
|
|
118
|
-
"@astryxdesign/cli": "0.6.5-canary.
|
|
117
|
+
"@astryxdesign/a11y-spec": "0.6.5-canary.8a5b3fb",
|
|
118
|
+
"@astryxdesign/cli": "0.6.5-canary.8a5b3fb",
|
|
119
119
|
"@babel/cli": "^7.29.7",
|
|
120
120
|
"@babel/core": "^7.29.7",
|
|
121
121
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -81,6 +81,7 @@ const styles = stylex.create({
|
|
|
81
81
|
},
|
|
82
82
|
placement: (top: number, left: number, width: number) => ({
|
|
83
83
|
top,
|
|
84
|
+
// eslint-disable-next-line @astryx/no-physical-properties -- intentional: `left` is a measured viewport coordinate (`box.left - origin.left + element.clientLeft`), not an authored edge. `insetInlineStart` would resolve to the right edge in RTL and place the header off the block.
|
|
84
85
|
left,
|
|
85
86
|
width,
|
|
86
87
|
}),
|
package/src/RichTextEditor.tsx
CHANGED
|
@@ -212,7 +212,14 @@ const styles = stylex.create({
|
|
|
212
212
|
alignItems: 'center',
|
|
213
213
|
},
|
|
214
214
|
disabled: {
|
|
215
|
-
|
|
215
|
+
// Per #5335: `default`, not `not-allowed`. A disabled control already
|
|
216
|
+
// carries its own visual treatment, and `not-allowed` is unpaintable on
|
|
217
|
+
// the part of the library sealed behind `pointer-events: none`, so the
|
|
218
|
+
// library cannot promise it consistently.
|
|
219
|
+
cursor: {
|
|
220
|
+
default: 'default',
|
|
221
|
+
':is(:disabled,[aria-disabled="true"])': 'default',
|
|
222
|
+
},
|
|
216
223
|
},
|
|
217
224
|
counter: {
|
|
218
225
|
display: 'flex',
|
|
@@ -49,7 +49,11 @@ const styles = stylex.create({
|
|
|
49
49
|
checkbox: {
|
|
50
50
|
position: 'absolute',
|
|
51
51
|
},
|
|
52
|
-
placement: (top: number, left: number) => ({
|
|
52
|
+
placement: (top: number, left: number) => ({
|
|
53
|
+
top,
|
|
54
|
+
// eslint-disable-next-line @astryx/no-physical-properties -- intentional: `left` is a measured viewport coordinate, already resolved for direction above (`isRightToLeft ? box.right - CHECKBOX_SIZE : box.left`). `insetInlineStart` would flip the anchor edge again in RTL and double-correct the offset.
|
|
55
|
+
left,
|
|
56
|
+
}),
|
|
53
57
|
});
|
|
54
58
|
|
|
55
59
|
/** The width of core CheckboxInput's small control. */
|
package/src/editorTheme.ts
CHANGED
|
@@ -271,7 +271,10 @@ const editorTheme = stylex.create({
|
|
|
271
271
|
link: {
|
|
272
272
|
color: colorVars['--color-text-accent'],
|
|
273
273
|
textDecoration: 'underline',
|
|
274
|
-
cursor:
|
|
274
|
+
cursor: {
|
|
275
|
+
default: 'pointer',
|
|
276
|
+
':is(:disabled,[aria-disabled="true"])': 'default',
|
|
277
|
+
},
|
|
275
278
|
},
|
|
276
279
|
textBold: {fontWeight: fontWeightVars['--font-weight-semibold']},
|
|
277
280
|
textItalic: {fontStyle: 'italic'},
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
import {createHeadlessEditor} from '@lexical/headless';
|
|
5
|
+
import {$createLinkNode} from '@lexical/link';
|
|
6
|
+
import {$createParagraphNode, $createTextNode, $getRoot} from 'lexical';
|
|
7
|
+
import {parseInlineAst} from '@astryxdesign/core/Markdown/parser';
|
|
8
|
+
import {DEFAULT_NODES} from './editorNodes';
|
|
9
|
+
import {DEFAULT_TRANSFORMERS} from './markdownTable';
|
|
10
|
+
import {$exportMarkdownKeepingSource} from './markdownSource';
|
|
11
|
+
import {markdownToEditorStateJSON} from './markdownSerializers';
|
|
12
|
+
|
|
13
|
+
type Json = {type: string; url?: string; children?: Json[]};
|
|
14
|
+
|
|
15
|
+
const urlsIn = (nodes: ReadonlyArray<Json>): string[] =>
|
|
16
|
+
nodes.flatMap(node => [
|
|
17
|
+
...(node.type === 'link' ? [node.url ?? ''] : []),
|
|
18
|
+
...urlsIn(node.children ?? []),
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const richUrls = (markdown: string): string[] =>
|
|
22
|
+
urlsIn([
|
|
23
|
+
(JSON.parse(markdownToEditorStateJSON(markdown)) as {root: Json}).root,
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const coreUrls = (markdown: string): string[] =>
|
|
27
|
+
urlsIn(parseInlineAst(markdown) as unknown as Json[]);
|
|
28
|
+
|
|
29
|
+
/** A link made in the editor to `url`, exported. */
|
|
30
|
+
function exportLinkTo(url: string): string {
|
|
31
|
+
const editor = createHeadlessEditor({
|
|
32
|
+
nodes: [...DEFAULT_NODES],
|
|
33
|
+
onError(error) {
|
|
34
|
+
throw error;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
editor.update(
|
|
38
|
+
() => {
|
|
39
|
+
$getRoot()
|
|
40
|
+
.clear()
|
|
41
|
+
.append(
|
|
42
|
+
$createParagraphNode().append(
|
|
43
|
+
$createLinkNode(url).append($createTextNode('x')),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
{discrete: true},
|
|
48
|
+
);
|
|
49
|
+
return editor
|
|
50
|
+
.getEditorState()
|
|
51
|
+
.read(() => $exportMarkdownKeepingSource([...DEFAULT_TRANSFORMERS]));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('backticks inside an angle-bracket destination with a parenthesis', () => {
|
|
55
|
+
it.each([
|
|
56
|
+
'[x](<https://e.com/* ([b`\\<`>)',
|
|
57
|
+
'[a](<b ([c`d`>)',
|
|
58
|
+
'`x` [a](<b (`c`>)',
|
|
59
|
+
])('stay in the address of %j, as core reads it', markdown => {
|
|
60
|
+
expect(richUrls(markdown)).toEqual(coreUrls(markdown));
|
|
61
|
+
expect(richUrls(markdown)).toHaveLength(1);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('read back from a link made in the editor', () => {
|
|
65
|
+
const url = 'https://e.com/* ([b`<`';
|
|
66
|
+
expect(richUrls(exportLinkTo(url))).toEqual([url]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('read back across 4,000 addresses made in the editor', () => {
|
|
70
|
+
let state = 7050;
|
|
71
|
+
const random = () => {
|
|
72
|
+
state = (state * 1103515245 + 12345) % 2147483648;
|
|
73
|
+
return state / 2147483648;
|
|
74
|
+
};
|
|
75
|
+
// Backslashes outside angle brackets are a separate gap (#7098).
|
|
76
|
+
const alphabet = [...'ab/. ()<>"\'#:_*[]&;`'];
|
|
77
|
+
const lost: string[] = [];
|
|
78
|
+
for (let round = 0; round < 4000; round++) {
|
|
79
|
+
let tail = '';
|
|
80
|
+
const length = 1 + Math.floor(random() * 8);
|
|
81
|
+
for (let index = 0; index < length; index++) {
|
|
82
|
+
tail += alphabet[Math.floor(random() * alphabet.length)];
|
|
83
|
+
}
|
|
84
|
+
const url = `https://e.com/${tail}`;
|
|
85
|
+
const read = richUrls(exportLinkTo(url));
|
|
86
|
+
if (read.length !== 1 || read[0] !== url) {
|
|
87
|
+
lost.push(url);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
expect(lost).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -635,8 +635,12 @@ function linkTargetRanges(
|
|
|
635
635
|
index !== -1;
|
|
636
636
|
index = markdown.indexOf('](', index + 1)
|
|
637
637
|
) {
|
|
638
|
-
|
|
639
|
-
|
|
638
|
+
// An angle-bracket destination ends where core ends it: a parenthesis
|
|
639
|
+
// inside the brackets pairs with nothing.
|
|
640
|
+
const angleClose = angleDestinationEnd(markdown, index + 1);
|
|
641
|
+
const close = typeof angleClose === 'number' ? angleClose : pair[index + 1];
|
|
642
|
+
if (pair[index] !== -1 && close !== -1) {
|
|
643
|
+
ranges.push([index + 1, close + 1]);
|
|
640
644
|
}
|
|
641
645
|
}
|
|
642
646
|
return ranges;
|