@astryxdesign/richtext 0.7.17-canary.gffd1fc0 → 0.7.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @astryxdesign/richtext
2
2
 
3
+ # 0.7.17
4
+
5
+ #### New Features
6
+
7
+ - In `RichTextEditor`, a Markdown block marker typed at the start of a list item now re-marks it and keeps its text: `- `, `1. `, or `[ ] ` switches the item's list between bullets, numbers, and tasks, and `# ` or `> ` takes a top-level item out of its list as a heading or a quote, the rest of the list continuing after it. Each change is one undo step, back to the marker as typed.
8
+
9
+ #### Fixes
10
+
11
+ - In RichTextEditor and RichTextView, a code block's language label too long for its header wraps instead of being cut off, and the code starts below the taller header, as in Markdown, so a block is as tall in edit mode as in read mode.
12
+ - Apps that install the rich text package no longer see "Warning: @astryxdesign/richtext has N integration issue(s)" on `astryx search`, `component`, `template`, `theme`, `discover` and `upgrade`. The editor's internal plugins now live in a folder the CLI does not read as components, so the integration check reports no issues. The public components and imports are unchanged.
13
+ - RichText text reads the way it is written, in either document, and the shared first-strong classifier reads three Arabic marks, the Rumi numerals, and the digits of Devanagari, Bengali, Tamil, Thai and other scripts by their bidi class, which changes `Markdown` output too: a line opening `०१ שלום` now reads left-to-right where it read right-to-left before. `Badge`, `Token` and `InputGroupText` read the same strong set to decide whether their own text holds any right-to-left character, so the three Arabic marks — the semicolon, the question mark and tatweel — now count there too, wherever they sit in the label. A paragraph, heading, quote or list item takes the direction of its own text at any depth, so a Hebrew paragraph in an English document flushes right with its caret following the arrow keys instead of walking backwards, and an English paragraph, list item or table cell in a Hebrew document does the mirror. Each line of a fenced code block reads its own way too, so a Hebrew comment reads right-to-left while `const x = 1;` keeps its semicolon at the end. Top-level lists, tables and code blocks keep ordering their contents in the document's direction; a nested list follows the item that holds it. The stored value now drops a `dir` that arrives on them with pasted HTML or an older document.
14
+ - A line break typed with Shift+Enter at the end of a paragraph, list item or quote no longer saves as a backslash that comes back as a literal `\` the next time the Markdown loads. Markdown has no line break at the end of a block, so the editor leaves it out of the Markdown; a line break inside a block still saves and loads as a line break.
15
+
16
+ #### Documentation
17
+
18
+ - RichText: the README says that server rendering outputs no document content, because `RichTextView` and `RichTextEditor` fill their blocks on the client, and points server HTML at core `Markdown`, which renders the same Markdown document on the server (affordances only RichText draws appear in their Markdown form), or at `@astryxdesign/richtext/markdown`.
19
+
20
+ #### Other Changes
21
+
22
+ - Internal: the toolbar's link popover, its URL form, the link address rule, and the toolbar's inline-format helpers move into modules RichText shares internally. Apps see no change.
23
+
24
+ #### Contributors
25
+
26
+ Thanks to everyone who contributed to this release:
27
+
28
+ - @cixzhang
29
+ - @emilyhorsman
30
+ - @ernestt
31
+ - @josephfarina
32
+ - @potatowagon
33
+
34
+ ---
35
+
3
36
  # 0.7.16
4
37
 
5
38
  #### New Features
package/README.md CHANGED
@@ -22,6 +22,12 @@ editor required). The server-safe serializers are also available from
22
22
  Markdown imported into the editor exports back byte for byte when nothing was
23
23
  edited.
24
24
 
25
+ Server rendering outputs no document content: `RichTextView` and
26
+ `RichTextEditor` fill their blocks on the client. For content that must be in
27
+ the server HTML, render it with core `Markdown`, which renders the same
28
+ Markdown document on the server (affordances only RichText draws appear in
29
+ their Markdown form), or convert it with `@astryxdesign/richtext/markdown`.
30
+
25
31
  ## Built on Lexical
26
32
 
27
33
  RichText is built on [Lexical](https://lexical.dev) and does not hide it:
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AASf,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAIlD,OAAO,E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ClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC9D;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC5C,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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,cAAc;2ZAiCxB,mBAAmB;;CAqQrB,CAAC"}
@@ -54,6 +54,7 @@ import { CodeBackspacePlugin } from "./internal/CodeBackspacePlugin.js";
54
54
  import { CodeBlockHeaderPlugin } from "./internal/CodeBlockHeaderPlugin.js";
55
55
  import { CodePastePlugin } from "./internal/CodePastePlugin.js";
56
56
  import { CodeSyntaxPlugin } from "./internal/CodeSyntaxPlugin.js";
57
+ import { BlockDirectionPlugin } from "./internal/BlockDirectionPlugin.js";
57
58
  import { CodeTabPlugin } from "./internal/CodeTabPlugin.js";
58
59
  import { MarkdownExtensionsPlugin } from "./internal/MarkdownExtensionsPlugin.js";
59
60
  import { TaskCheckboxPlugin } from "./internal/TaskCheckboxPlugin.js";
@@ -337,7 +338,7 @@ export const RichTextEditor = function RichTextEditor({
337
338
  }[!!hasToolbar << 2 | !!!!statusIcon << 1 | !!(size === 'lg') << 0],
338
339
  children: [/*#__PURE__*/_jsxs("div", {
339
340
  ...{
340
- className: "x1n2onr6 xh8yej3 x9ynric xjm74w1 xf9zqsd xw6l6zx"
341
+ className: "xrjygrn xss4jc1 x1n2onr6 xh8yej3 x9ynric xjm74w1 xf9zqsd xw6l6zx"
341
342
  },
342
343
  dir: rest.dir,
343
344
  children: [/*#__PURE__*/_jsx(RichTextPlugin, {
@@ -370,7 +371,7 @@ export const RichTextEditor = function RichTextEditor({
370
371
  codeLanguages: codeLanguages
371
372
  }), /*#__PURE__*/_jsx(CodeSyntaxPlugin, {
372
373
  codeLanguages: codeLanguages
373
- }), /*#__PURE__*/_jsx(CodeBackspacePlugin, {}), /*#__PURE__*/_jsx(CodePastePlugin, {}), markdownExtensions != null && markdownExtensions.length > 0 ? /*#__PURE__*/_jsx(MarkdownExtensionsPlugin, {
374
+ }), /*#__PURE__*/_jsx(BlockDirectionPlugin, {}), /*#__PURE__*/_jsx(CodeBackspacePlugin, {}), /*#__PURE__*/_jsx(CodePastePlugin, {}), markdownExtensions != null && markdownExtensions.length > 0 ? /*#__PURE__*/_jsx(MarkdownExtensionsPlugin, {
374
375
  extensions: markdownExtensions,
375
376
  transformers: markdownTransformers
376
377
  }) : null, /*#__PURE__*/_jsx(CodeTabPlugin, {}), /*#__PURE__*/_jsx(TabIndentationPlugin, {}), /*#__PURE__*/_jsx(TabFocusEscapePlugin, {}), /*#__PURE__*/_jsx(SelectAllScopePlugin, {}), /*#__PURE__*/_jsx(ImageSourceCaretPlugin, {}), hasMarkdownShortcuts && /*#__PURE__*/_jsx(MarkdownShortcutPlugin, {
@@ -1 +1 @@
1
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in } from "./internal/TableScrollRegionPlugin.js";
33
33
  import { TableColumnFloorPlugin } from "./internal/TableColumnFloorPlugin.js";
34
34
  import { CodeBlockHeaderPlugin } from "./internal/CodeBlockHeaderPlugin.js";
35
35
  import { CodeSyntaxPlugin } from "./internal/CodeSyntaxPlugin.js";
36
+ import { BlockDirectionPlugin } from "./internal/BlockDirectionPlugin.js";
36
37
  import { MarkdownExtensionsPlugin } from "./internal/MarkdownExtensionsPlugin.js";
37
38
  import { TaskCheckboxPlugin } from "./internal/TaskCheckboxPlugin.js";
38
39
  import { defineExtension } from 'lexical';
@@ -42,6 +43,7 @@ import { DEFAULT_NODES } from "./editorNodes.js";
42
43
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
43
44
  const styles = {
44
45
  root: {
46
+ "--_richtext-document-direction": "xrjygrn xss4jc1",
45
47
  kzqmXN: "xh8yej3",
46
48
  kVAEAm: "x1n2onr6",
47
49
  kMv6JI: "x9ynric",
@@ -255,7 +257,7 @@ export function RichTextView({
255
257
  codeLanguages: codeLanguages
256
258
  }), /*#__PURE__*/_jsx(CodeSyntaxPlugin, {
257
259
  codeLanguages: codeLanguages
258
- }), markdownExtensions != null && markdownExtensions.length > 0 ? /*#__PURE__*/_jsx(MarkdownExtensionsPlugin, {
260
+ }), /*#__PURE__*/_jsx(BlockDirectionPlugin, {}), markdownExtensions != null && markdownExtensions.length > 0 ? /*#__PURE__*/_jsx(MarkdownExtensionsPlugin, {
259
261
  extensions: markdownExtensions,
260
262
  transformers: NO_TRANSFORMERS
261
263
  }) : null, /*#__PURE__*/_jsx(TaskCheckboxPlugin, {
@@ -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;AAschD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CAgEtD"}
1
+ {"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAmfhD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CAyEtD"}
@@ -39,16 +39,26 @@ const LIST_ROW_FLUSH = `calc(${spacingVars['--spacing-0']})`;
39
39
  const NESTED_LIST_SPACE = `calc(${spacingVars['--spacing-2']})`;
40
40
  const RULE_SPACE = `calc(${spacingVars['--spacing-6']})`;
41
41
  const CODE_SPACE = `calc(${spacingVars['--spacing-3']})`;
42
- // Core CodeBlock's header (8px, a small control, 8px) overlaps the code's
43
- // 12px top padding by 8px, so its code starts 8px + control + 12px down.
44
- const CODE_HEADER_SPACE = `calc(${spacingVars['--spacing-2']} + ${sizeVars['--size-element-sm']} + ${spacingVars['--spacing-3']})`;
42
+ // Core CodeBlock's header overlaps the code's 12px top padding by 8px. So the
43
+ // code starts 4px below the header. CodeBlockHeaderPlugin writes the header's
44
+ // drawn height; one row is the fallback.
45
+ const CODE_HEADER_SPACE = `calc(var(--_richtext-code-header-block-size, calc(2 * ${spacingVars['--spacing-2']} + ${sizeVars['--size-element-sm']})) + ${spacingVars['--spacing-3']} - ${spacingVars['--spacing-2']})`;
45
46
  // A block that names no language has no header: core CodeBlock puts its copy
46
47
  // button in a column of its own at the inline end (8px, a small control, 8px),
47
48
  // beside the code rather than over it, so the code ends that much earlier.
48
49
  const CODE_CORNER_SPACE = `calc(${spacingVars['--spacing-4']} + ${sizeVars['--size-element-sm']} + 2 * ${spacingVars['--spacing-2']})`;
49
50
  const editorTheme = {
50
- providerDirection: {
51
+ blockDirection: {
52
+ ksoyAI: "x2dh0mw xz38kqs",
53
+ $$css: true
54
+ },
55
+ surfaceDirection: {
56
+ ksoyAI: "x1epdd7z",
57
+ $$css: true
58
+ },
59
+ codeDirection: {
51
60
  ksoyAI: "x1epdd7z",
61
+ kQ0QjF: "xa7awgv",
52
62
  $$css: true
53
63
  },
54
64
  paragraph: {
@@ -135,7 +145,7 @@ const editorTheme = {
135
145
  keoZOQ: "x1ftnraw xnhvf09",
136
146
  k1K539: "x18pneqc xfo59cc",
137
147
  ks0D6T: "x7ep2pv",
138
- kZCmMZ: "x31w388",
148
+ kg3NbH: "x17a0aqu",
139
149
  kpqbRz: "x43c9pm",
140
150
  $$css: true
141
151
  },
@@ -143,7 +153,7 @@ const editorTheme = {
143
153
  keoZOQ: "x1ftnraw xnhvf09",
144
154
  k1K539: "x18pneqc xfo59cc",
145
155
  ks0D6T: "x7ep2pv",
146
- kZCmMZ: "x31w388",
156
+ kg3NbH: "x17a0aqu",
147
157
  kpqbRz: "x43c9pm",
148
158
  $$css: true
149
159
  },
@@ -171,6 +181,16 @@ const editorTheme = {
171
181
  kH6xsr: "x19k9dhg",
172
182
  $$css: true
173
183
  },
184
+ listItem: {
185
+ kLKAdn: "x1f3mx8c xmvvslv x1uerj9w",
186
+ kGO01o: "x13xdy6z",
187
+ keoZOQ: "x1wqhfsw xkuhcwz xsgnyjk",
188
+ k1K539: "x10j6jf0 xfo59cc",
189
+ kH6xsr: "x1sle589 x81k3mc xovwveo x2i8j16",
190
+ keTefX: "x1l10yog x1w4ozbb",
191
+ kZCmMZ: "xbj1ybn x1kuvm45",
192
+ $$css: true
193
+ },
174
194
  tableScrollableWrapper: {
175
195
  kXHlph: "xw2csxc",
176
196
  ks0D6T: "x193iq5w",
@@ -228,13 +248,13 @@ const editorTheme = {
228
248
  ksu8eU: "x1y0btm7",
229
249
  kVAM5u: "x14i3s5s",
230
250
  kaIpWk: "xh6dtrn",
231
- kLKAdn: "xekneqv x2w4pp4",
251
+ kLKAdn: "xekneqv xyyife3",
232
252
  kGO01o: "xvmdzux",
233
253
  kZCmMZ: "x1rey3nv",
234
254
  kwRFfy: "xza90q5 x18crcbm",
235
255
  kB7OPa: "x9f619",
236
256
  kzqmXN: "xeq5yr9",
237
- k7Eaqz: "xejm5pw",
257
+ k7Eaqz: "x1o973b8",
238
258
  ks0D6T: "x193iq5w",
239
259
  keoZOQ: "x1w2a574 xnhvf09",
240
260
  k1K539: "x1u2y747 xfo59cc",
@@ -250,8 +270,14 @@ const editorTheme = {
250
270
  * class-name strings, which `stylex.props(...).className` yields.
251
271
  */
252
272
  export function sharedEditorTheme() {
253
- // A class for a block Lexical may mark `dir="auto"`.
254
- const block = (...styles) => stylex.props(...styles, editorTheme.providerDirection).className ?? '';
273
+ // A class for a block Lexical can mark `dir="auto"`: it reads its own way
274
+ // once BlockDirectionPlugin has written a direction onto it, and follows
275
+ // the document while it still says `auto`.
276
+ const block = (...styles) => stylex.props(...styles, editorTheme.blockDirection).className ?? '';
277
+ // A class for a container — a list, a table and its parts — which orders
278
+ // its contents in its parent's direction: the document's at the top level,
279
+ // its wrapper item's when nested.
280
+ const container = (...styles) => stylex.props(...styles, editorTheme.surfaceDirection).className ?? '';
255
281
  const className = style => stylex.props(style).className ?? '';
256
282
  return {
257
283
  paragraph: block(editorTheme.paragraph),
@@ -268,15 +294,13 @@ export function sharedEditorTheme() {
268
294
  },
269
295
  quote: block(editorTheme.quote),
270
296
  list: {
271
- ul: block(editorTheme.ul),
272
- ol: block(editorTheme.ol),
273
- listitem: {
274
- className: "x1f3mx8c xmvvslv x1uerj9w x13xdy6z x1wqhfsw xkuhcwz xsgnyjk x10j6jf0 xfo59cc x1sle589 x81k3mc xovwveo x2i8j16 x8yim9t x1pvqllw xbj1ybn x1kuvm45"
275
- }.className,
297
+ ul: container(editorTheme.ul),
298
+ ol: container(editorTheme.ol),
299
+ // An item is prose: it reads the way its own text reads, and the
300
+ // document's way when its text decides nothing.
301
+ listitem: block(editorTheme.listItem),
276
302
  nested: {
277
- listitem: {
278
- className: "x1f3mx8c xmvvslv x1uerj9w x13xdy6z x1wqhfsw xkuhcwz xsgnyjk x10j6jf0 xfo59cc x1sle589 x81k3mc xovwveo x2i8j16 x8yim9t x1pvqllw xbj1ybn x1kuvm45"
279
- }.className
303
+ listitem: block(editorTheme.listItem)
280
304
  },
281
305
  // Lexical picks the class at `depth % 3` (spec:AST-061 DEC-6).
282
306
  ulDepth: [className(editorTheme.ulMarker0), className(editorTheme.ulMarker1), className(editorTheme.ulMarker2)],
@@ -303,7 +327,7 @@ export function sharedEditorTheme() {
303
327
  }.className
304
328
  },
305
329
  // The plain class lets CodeSyntaxPlugin's highlight rules find code blocks.
306
- code: `${block(editorTheme.code)} ${CODE_SYNTAX_CLASS}`,
330
+ code: `${container(editorTheme.code)} ${className(editorTheme.codeDirection)} ${CODE_SYNTAX_CLASS}`,
307
331
  hr: {
308
332
  className: "xc342km x11xkdxz x13fuv20 x1pc3f07 x13xmvwt xnhvf09 xe66n16 x1qaki06 xfo59cc x1vugyqv"
309
333
  }.className,
@@ -314,15 +338,15 @@ export function sharedEditorTheme() {
314
338
  markdownExtensionSelected: {
315
339
  className: "xak0ai5 x9ssot5 x19bwoy8 x1eqjuhu"
316
340
  }.className,
317
- table: block(editorTheme.table),
341
+ table: container(editorTheme.table),
318
342
  // Lexical stamps rows and cells `dir="auto"` too, which would set a cell
319
343
  // of English text left-to-right inside a right-to-left document.
320
- tableRow: block(editorTheme.tableRow),
321
- tableCell: block(editorTheme.tableCell),
322
- tableCellHeader: block(editorTheme.tableCellHeader),
344
+ tableRow: container(editorTheme.tableRow),
345
+ tableCell: container(editorTheme.tableCell),
346
+ tableCellHeader: container(editorTheme.tableCellHeader),
323
347
  // Added on top of the cell's own class by Lexical while the cell is in a
324
348
  // table selection, so it carries no direction of its own.
325
349
  tableCellSelected: className(editorTheme.tableCellSelected),
326
- tableScrollableWrapper: block(editorTheme.tableScrollableWrapper)
350
+ tableScrollableWrapper: container(editorTheme.tableScrollableWrapper)
327
351
  };
328
352
  }
@@ -0,0 +1,14 @@
1
+ import { type LexicalEditor } from 'lexical';
2
+ /**
3
+ * Keeps every prose container's `dir` equal to the direction of its own
4
+ * text. Returns the usual teardown.
5
+ */
6
+ export declare function registerBlockDirection(editor: LexicalEditor): () => void;
7
+ /**
8
+ * Gives each prose container — paragraph, heading, quote, list item, at any
9
+ * depth — an explicit `dir` taken from its own text, so a strongly
10
+ * directional one reads its own way in either document and one with no
11
+ * direction of its own follows the document.
12
+ */
13
+ export declare function BlockDirectionPlugin(): null;
14
+ //# sourceMappingURL=BlockDirectionPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockDirectionPlugin.d.ts","sourceRoot":"","sources":["../../src/internal/BlockDirectionPlugin.tsx"],"names":[],"mappings":"AA+BA,OAAO,EAUL,KAAK,aAAa,EAEnB,MAAM,SAAS,CAAC;AAuMjB;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI,CAkDxE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAqB3C"}
@@ -0,0 +1,283 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file BlockDirectionPlugin.tsx
7
+ * @input Uses @lexical/react (composer context) and the prose container
8
+ * classes, and classifies text with `firstStrongDirection`.
9
+ * @output Exports BlockDirectionPlugin, which gives each prose container an
10
+ * explicit `dir` taken from its own text, and registerBlockDirection for
11
+ * a caller driving a Lexical editor directly.
12
+ * @position Rendered by RichTextEditor and RichTextView inside the composer,
13
+ * so a document reads the same way in both.
14
+ *
15
+ * SYNC: RichTextEditor.tsx and RichTextView.tsx both mount this plugin and
16
+ * set `--_richtext-document-direction` on their own root.
17
+ */
18
+ import { useLayoutEffect } from 'react';
19
+ import { firstStrongDirection } from "./firstStrongDirection.js";
20
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
21
+ import { mergeRegister } from '@lexical/utils';
22
+ import { HeadingNode, QuoteNode } from '@lexical/rich-text';
23
+ import { $isListItemNode, $isListNode, ListItemNode, ListNode } from '@lexical/list';
24
+ import { CodeNode } from '@lexical/code';
25
+ import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
26
+ import { $getRoot, $isRootNode, $isDecoratorNode, $isElementNode, HISTORY_MERGE_TAG, ParagraphNode, TextNode } from 'lexical';
27
+
28
+ /**
29
+ * The containers read as one piece of prose, so one direction covers the
30
+ * whole of each, at any depth — a paragraph inside a table cell included.
31
+ *
32
+ * Lexical leaves a top-level block at `dir="auto"` and writes none below
33
+ * that, and neither state can say "this block has no direction of its own":
34
+ * under `auto`, digits, an image and an empty block all resolve
35
+ * left-to-right, exactly like English. Writing the direction out separates
36
+ * the two, and Lexical serializes it, so a stored document reopens the way
37
+ * it was written.
38
+ *
39
+ * A list, a fenced code block and a table are not here: they hold several
40
+ * items, lines or cells that are read on their own terms.
41
+ */
42
+ const PROSE_NODES = [ParagraphNode, HeadingNode, QuoteNode, ListItemNode];
43
+
44
+ /**
45
+ * The containers. They take their parent's direction from the theme whatever
46
+ * `dir` says, so an arriving one changes no pixels. It can still arrive from
47
+ * pasted HTML (`$setDirectionFromDOM`) or an older stored document; clearing
48
+ * it keeps the stored state saying what the document shows.
49
+ *
50
+ * A fenced code block has no per-line node to carry a direction, so the
51
+ * theme gives it `unicode-bidi: plaintext` and each line reads its own way.
52
+ * Core `Markdown` reaches the same rule through CodeBlock, which puts each
53
+ * line in its own `dir="auto"` element; `pnpm specs:for` finds the record.
54
+ */
55
+ const CONTAINER_NODES = [ListNode, CodeNode, TableNode, TableRowNode, TableCellNode];
56
+
57
+ /**
58
+ * Whether this node is a prose container that carries its own `dir`.
59
+ *
60
+ * A list item holding a nested list takes one too, from the item it hangs
61
+ * from. The nesting step is an inline margin on the item, so it resolves
62
+ * against that item's own direction: left unwritten it puts the step on the
63
+ * document's side while the items inside start on theirs, and every level of
64
+ * an English list in a right-to-left document then begins at
65
+ * the same edge, with only the marker shape showing the depth.
66
+ */
67
+ function $isOwnDirectionBlock(node) {
68
+ return $isElementNode(node) && PROSE_NODES.some(k => node instanceof k);
69
+ }
70
+
71
+ /**
72
+ * The direction this container's own text asks for; null when it has none.
73
+ *
74
+ * Only text a reader reads counts. A decorator — an image, a chart, an
75
+ * embed — shows no prose of its own, and `getTextContent` gives its
76
+ * alternative text, so a picture captioned in English would turn a Hebrew
77
+ * item left-to-right. Core Markdown skips the same nodes when it reads a
78
+ * block's direction. A fenced code block is skipped for its own reason:
79
+ * each of its lines reads on its own terms.
80
+ *
81
+ * Lexical puts a nested list in an item of its own after the item it hangs
82
+ * from. That holder shows no text and is not a block a reader sees: it
83
+ * belongs to the item above it, and a nested list is anchored on its parent
84
+ * item's text start. So it takes that item's direction, not the direction of
85
+ * the list inside it. Reading its own contents instead would anchor the
86
+ * nested list on whichever language its first item happened to use, which
87
+ * costs an item that reads the other way its nesting step, and leaves a
88
+ * neutral item — digits, an image — following that first item rather than
89
+ * the document.
90
+ */
91
+ function $ownDirection(node) {
92
+ const holds = $heldList(node);
93
+ if (holds !== null) {
94
+ const parentItem = $parentItemOf(node);
95
+ return parentItem === null ? null : $ownDirection(parentItem);
96
+ }
97
+ return firstStrongDirection($proseText(node));
98
+ }
99
+
100
+ /** The list a holder item exists to carry, or null when it carries prose. */
101
+ function $heldList(node) {
102
+ if (!$isListItemNode(node)) {
103
+ return null;
104
+ }
105
+ const children = node.getChildren();
106
+ const lists = children.filter($isListNode);
107
+ return lists.length === 1 && children.length === lists.length ? lists[0] : null;
108
+ }
109
+
110
+ /** The item a holder hangs from: the nearest prose item before it. */
111
+ function $parentItemOf(node) {
112
+ let sibling = node.getPreviousSibling();
113
+ while (sibling !== null) {
114
+ if ($isListItemNode(sibling) && $heldList(sibling) === null) {
115
+ return sibling;
116
+ }
117
+ sibling = sibling.getPreviousSibling();
118
+ }
119
+ return null;
120
+ }
121
+
122
+ /** The text of a node's prose descendants, decorators and code aside. */
123
+ function $proseText(node) {
124
+ let text = '';
125
+ for (const child of node.getChildren()) {
126
+ if ($isDecoratorNode(child) || child instanceof CodeNode) {
127
+ continue;
128
+ }
129
+ text += $isElementNode(child) ? $proseText(child) : child.getTextContent();
130
+ if (firstStrongDirection(text) !== null) {
131
+ break;
132
+ }
133
+ }
134
+ return text;
135
+ }
136
+
137
+ /** Whether this node is a container, which carries no direction of its own. */
138
+ function $isContainer(node) {
139
+ return $isElementNode(node) && CONTAINER_NODES.some(klass => node instanceof klass);
140
+ }
141
+
142
+ /** The direction this node should carry: its text's, or none at all. */
143
+ function $wantedDirection(node) {
144
+ return $isOwnDirectionBlock(node) ? $ownDirection(node) : null;
145
+ }
146
+
147
+ /** Whether this node's `dir` is already what it should be. */
148
+ function $isSettled(node) {
149
+ if ($isRootNode(node)) {
150
+ return node.getDirection() === null;
151
+ }
152
+ if (!$isOwnDirectionBlock(node) && !$isContainer(node)) {
153
+ return true;
154
+ }
155
+ return node.getDirection() === $wantedDirection(node);
156
+ }
157
+
158
+ /** Writes a node's direction onto it, if that is not what it says. */
159
+ function $writeOwnDirection(node) {
160
+ if (!$isSettled(node)) {
161
+ node.setDirection($wantedDirection(node));
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Every prose container at or above this node, nearest first.
167
+ *
168
+ * A keystroke deep in a list changes its own item, and a wrapper above it
169
+ * follows the item it hangs from, so both are written here.
170
+ * All of them have to be written inside the keystroke's own update: the
171
+ * sweep that follows is tagged `history-merge`, which `OnChangePlugin`
172
+ * does not report, so a wrapper left to the sweep would hold a stale
173
+ * direction in the value a caller stores until the next edit.
174
+ */
175
+ function $proseContainers(node) {
176
+ const found = [];
177
+ for (let current = node; current !== null; current = current.getParent()) {
178
+ if ($isOwnDirectionBlock(current)) {
179
+ found.push(current);
180
+ }
181
+ }
182
+ return found;
183
+ }
184
+
185
+ /** Every node whose direction this plugin owns, in document order. */
186
+ function $allProseContainers() {
187
+ const found = [];
188
+ const visit = node => {
189
+ if ($isOwnDirectionBlock(node) || $isContainer(node)) {
190
+ found.push(node);
191
+ }
192
+ if ($isElementNode(node)) {
193
+ node.getChildren().forEach(visit);
194
+ }
195
+ };
196
+ // The root is a container too. Lexical writes a stored root direction onto
197
+ // the editable element, and every container under it inherits, so a value
198
+ // saved in one document direction would lay its tables and code frames out
199
+ // that way in the other. It carries no text of its own, so it always gives
200
+ // the direction up and the surface decides.
201
+ found.push($getRoot());
202
+ $getRoot().getChildren().forEach(visit);
203
+ return found;
204
+ }
205
+
206
+ /**
207
+ * Keeps every prose container's `dir` equal to the direction of its own
208
+ * text. Returns the usual teardown.
209
+ */
210
+ export function registerBlockDirection(editor) {
211
+ return mergeRegister(
212
+ // Typing inside an existing paragraph dirties its text node, not the
213
+ // container, so the text node is where a keystroke can be caught.
214
+ // Running here keeps the direction in the update that changed the text,
215
+ // and so in that keystroke's own history entry: a later `editor.update`
216
+ // would be a history step of its own, and undo would bounce off it.
217
+ editor.registerNodeTransform(TextNode, node => {
218
+ $proseContainers(node).forEach($writeOwnDirection);
219
+ }),
220
+ // A container that gains or loses its text without a text node of its
221
+ // own being dirtied — a new empty paragraph, a heading conversion, a
222
+ // list item split, a deletion that empties a block.
223
+ ...PROSE_NODES.map(klass => editor.registerNodeTransform(klass, node => {
224
+ $proseContainers(node).forEach($writeOwnDirection);
225
+ })),
226
+ // A container that arrives carrying a direction — pasted HTML, or an
227
+ // older stored document — gives it up, so its contents are ordered by
228
+ // the document as they are everywhere else. Removing a node dirties its
229
+ // parent, so a removed list item reaches its list here; the walk settles
230
+ // the wrapper above it in the same update, which the sweep below would
231
+ // otherwise do a history step later.
232
+ ...CONTAINER_NODES.map(klass => editor.registerNodeTransform(klass, node => {
233
+ $writeOwnDirection(node);
234
+ $proseContainers(node).forEach($writeOwnDirection);
235
+ })),
236
+ // Replacing the whole state runs no transform at all, and RichTextView
237
+ // does exactly that whenever its `value` changes. Sweep the document
238
+ // when a container is left disagreeing with its text. The sweep merges
239
+ // into the update that caused it rather than taking an undo step of its
240
+ // own, and writing the direction settles the container, so this does
241
+ // not loop.
242
+ editor.registerUpdateListener(({
243
+ editorState
244
+ }) => {
245
+ const stale = editorState.read(() => $allProseContainers().some(node => !$isSettled(node)));
246
+ if (stale) {
247
+ editor.update(() => {
248
+ $allProseContainers().forEach($writeOwnDirection);
249
+ }, {
250
+ tag: HISTORY_MERGE_TAG
251
+ });
252
+ }
253
+ }));
254
+ }
255
+
256
+ /**
257
+ * Gives each prose container — paragraph, heading, quote, list item, at any
258
+ * depth — an explicit `dir` taken from its own text, so a strongly
259
+ * directional one reads its own way in either document and one with no
260
+ * direction of its own follows the document.
261
+ */
262
+ export function BlockDirectionPlugin() {
263
+ const [editor] = useLexicalComposerContext();
264
+ // A layout effect, not an ordinary one: it runs after Lexical has written
265
+ // the document into the DOM and before the browser paints, so the first
266
+ // frame a reader sees already has every block on its own side. An
267
+ // ordinary effect runs after that frame, which showed an English
268
+ // paragraph right-aligned in a right-to-left page for about one frame
269
+ // before it moved.
270
+ useLayoutEffect(() => {
271
+ const teardown = registerBlockDirection(editor);
272
+ // Registering only arms the transforms; a document already in the
273
+ // editor has run none of them. Settle it now, in this same frame.
274
+ editor.update(() => {
275
+ $allProseContainers().forEach($writeOwnDirection);
276
+ }, {
277
+ discrete: true,
278
+ tag: HISTORY_MERGE_TAG
279
+ });
280
+ return teardown;
281
+ }, [editor]);
282
+ return null;
283
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlockHeaderPlugin.d.ts","sourceRoot":"","sources":["../../src/internal/CodeBlockHeaderPlugin.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;AAQpD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AA4J/D;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,aAAa,GACd,GAAE;IACD,gFAAgF;IAChF,aAAa,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACxC,GAAG,GAAG,CAAC,OAAO,CAyFnB"}
1
+ {"version":3,"file":"CodeBlockHeaderPlugin.d.ts","sourceRoot":"","sources":["../../src/internal/CodeBlockHeaderPlugin.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAA2C,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;AASzE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAiP/D;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,aAAa,GACd,GAAE;IACD,gFAAgF;IAChF,aAAa,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACxC,GAAG,GAAG,CAAC,OAAO,CAqJnB"}