@astryxdesign/richtext 0.7.5-canary.f2dafed → 0.7.5-canary.f57df18

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.
@@ -1,7 +1,7 @@
1
1
  import type { Transformer } from '@lexical/markdown';
2
2
  import type { MarkdownExtensionNode, MarkdownPluginEntry } from '@astryxdesign/core/Markdown/plugins';
3
- import { type RichTextMarkdownExtension } from './markdownExtensions';
4
- import { type RichTextExtensionNodeFacts } from './markdownExtensionNode';
3
+ import { type RichTextMarkdownExtension } from './markdownExtensions.js';
4
+ import { type RichTextExtensionNodeFacts } from './markdownExtensionNode.js';
5
5
  /**
6
6
  * The node core derives from a stored node's source with `plugins`, or null
7
7
  * when no adopted plugin of the same protocol version reads that exact source
@@ -23,7 +23,7 @@ import { type ReactNode, type Ref } from 'react';
23
23
  import { type FieldStatusVariant } from '@astryxdesign/core/Field';
24
24
  import type { BaseProps } from '@astryxdesign/core';
25
25
  import { type SizeValue } from '@astryxdesign/core/utils';
26
- import type { RichTextMarkdownExtension } from './markdownExtensions';
26
+ import type { RichTextMarkdownExtension } from './markdownExtensions.js';
27
27
  import { type Transformer } from '@lexical/markdown';
28
28
  import { type EditorState, type Klass, type LexicalEditor, type LexicalNode } from 'lexical';
29
29
  export type RichTextEditorStatusType = 'warning' | 'error' | 'success';
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { type ReactNode } from 'react';
17
17
  import type { BaseProps } from '@astryxdesign/core';
18
- import type { RichTextMarkdownExtension } from './markdownExtensions';
18
+ import type { RichTextMarkdownExtension } from './markdownExtensions.js';
19
19
  import type { Klass, LexicalNode } from 'lexical';
20
20
  export interface RichTextViewProps extends BaseProps {
21
21
  /**
@@ -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;AA0bhD;;;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;AAqchD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CAgEtD"}
@@ -42,6 +42,10 @@ const CODE_SPACE = `calc(${spacingVars['--spacing-3']})`;
42
42
  // Core CodeBlock's header (8px, a small control, 8px) overlaps the code's
43
43
  // 12px top padding by 8px, so its code starts 8px + control + 12px down.
44
44
  const CODE_HEADER_SPACE = `calc(${spacingVars['--spacing-2']} + ${sizeVars['--size-element-sm']} + ${spacingVars['--spacing-3']})`;
45
+ // A block that names no language has no header: core CodeBlock puts its copy
46
+ // button in a column of its own at the inline end (8px, a small control, 8px),
47
+ // beside the code rather than over it, so the code ends that much earlier.
48
+ const CODE_CORNER_SPACE = `calc(${spacingVars['--spacing-4']} + ${sizeVars['--size-element-sm']} + 2 * ${spacingVars['--spacing-2']})`;
45
49
  const editorTheme = {
46
50
  providerDirection: {
47
51
  ksoyAI: "x1epdd7z",
@@ -226,7 +230,8 @@ const editorTheme = {
226
230
  kaIpWk: "xh6dtrn",
227
231
  kLKAdn: "xekneqv x2w4pp4",
228
232
  kGO01o: "xvmdzux",
229
- kg3NbH: "x1pzlopt",
233
+ kZCmMZ: "x1rey3nv",
234
+ kwRFfy: "xza90q5 x18crcbm",
230
235
  kB7OPa: "x9f619",
231
236
  kzqmXN: "xeq5yr9",
232
237
  k7Eaqz: "xejm5pw",
package/dist/index.d.ts CHANGED
@@ -15,17 +15,17 @@
15
15
  * /packages/richtext/src/publicSurface.test.ts, and the editor component doc
16
16
  * files.
17
17
  */
18
- export { RichTextEditor } from './RichTextEditor';
19
- export type { RichTextEditorProps, RichTextEditorRef, RichTextEditorStatus, RichTextEditorStatusType, RichTextEditorSize, } from './RichTextEditor';
20
- export { RichTextView } from './RichTextView';
21
- export type { RichTextViewProps } from './RichTextView';
22
- export { markdownToEditorStateJSON, editorStateJSONToMarkdown, } from './markdownSerializers';
23
- export type { MarkdownSerializerOptions } from './markdownSerializers';
24
- export { createRichTextExtension, RichTextExtensionError, } from './markdownExtensions';
25
- export type { RichTextMarkdownExtension } from './markdownExtensions';
26
- export { RichTextEditorToolbar, RICHTEXT_ICON_KEYS, } from './RichTextEditorToolbar';
27
- export type { RichTextEditorToolbarProps } from './RichTextEditorToolbar';
28
- export { RichTextEditorAutoLinkPlugin, DEFAULT_LINK_MATCHERS, NEW_TAB_LINK_ATTRIBUTES, } from './RichTextEditorAutoLinkPlugin';
29
- export type { RichTextEditorAutoLinkPluginProps } from './RichTextEditorAutoLinkPlugin';
30
- export { sanitizeUrl, validateUrl } from './linkUtils';
18
+ export { RichTextEditor } from './RichTextEditor.js';
19
+ export type { RichTextEditorProps, RichTextEditorRef, RichTextEditorStatus, RichTextEditorStatusType, RichTextEditorSize, } from './RichTextEditor.js';
20
+ export { RichTextView } from './RichTextView.js';
21
+ export type { RichTextViewProps } from './RichTextView.js';
22
+ export { markdownToEditorStateJSON, editorStateJSONToMarkdown, } from './markdownSerializers.js';
23
+ export type { MarkdownSerializerOptions } from './markdownSerializers.js';
24
+ export { createRichTextExtension, RichTextExtensionError, } from './markdownExtensions.js';
25
+ export type { RichTextMarkdownExtension } from './markdownExtensions.js';
26
+ export { RichTextEditorToolbar, RICHTEXT_ICON_KEYS, } from './RichTextEditorToolbar.js';
27
+ export type { RichTextEditorToolbarProps } from './RichTextEditorToolbar.js';
28
+ export { RichTextEditorAutoLinkPlugin, DEFAULT_LINK_MATCHERS, NEW_TAB_LINK_ATTRIBUTES, } from './RichTextEditorAutoLinkPlugin.js';
29
+ export type { RichTextEditorAutoLinkPluginProps } from './RichTextEditorAutoLinkPlugin.js';
30
+ export { sanitizeUrl, validateUrl } from './linkUtils.js';
31
31
  //# sourceMappingURL=index.d.ts.map
@@ -10,8 +10,8 @@
10
10
  * serializable: create the extensions a page passes to the surfaces in a
11
11
  * client module, and create your own for headless use.
12
12
  */
13
- export { markdownToEditorStateJSON, editorStateJSONToMarkdown, } from './markdownSerializers';
14
- export type { MarkdownSerializerOptions } from './markdownSerializers';
15
- export { createRichTextExtension, RichTextExtensionError, } from './markdownExtensions';
16
- export type { RichTextMarkdownExtension } from './markdownExtensions';
13
+ export { markdownToEditorStateJSON, editorStateJSONToMarkdown, } from './markdownSerializers.js';
14
+ export type { MarkdownSerializerOptions } from './markdownSerializers.js';
15
+ export { createRichTextExtension, RichTextExtensionError, } from './markdownExtensions.js';
16
+ export type { RichTextMarkdownExtension } from './markdownExtensions.js';
17
17
  //# sourceMappingURL=markdown.d.ts.map
@@ -24,7 +24,7 @@
24
24
  import type { Transformer } from '@lexical/markdown';
25
25
  import { TextNode, type ElementNode } from 'lexical';
26
26
  import { type MarkdownExtensionNode, type MarkdownPluginEntry } from '@astryxdesign/core/Markdown/plugins';
27
- import { RichTextExtensionNode } from './markdownExtensionNode';
27
+ import { RichTextExtensionNode } from './markdownExtensionNode.js';
28
28
  declare const extensionPlugin: unique symbol;
29
29
  /**
30
30
  * One Markdown plugin adopted by RichText. Opaque: create it with
@@ -1,5 +1,5 @@
1
1
  import { type Transformer } from '@lexical/markdown';
2
- import { type RichTextMarkdownExtension } from './markdownExtensions';
2
+ import { type RichTextMarkdownExtension } from './markdownExtensions.js';
3
3
  import type { Klass, LexicalNode } from 'lexical';
4
4
  /** Options shared by the Markdown serializer helpers. */
5
5
  export interface MarkdownSerializerOptions {
package/dist/richtext.css CHANGED
@@ -120,6 +120,7 @@
120
120
  .xak0ai5:not(#\#):not(#\#):not(#\#){outline-width:var(--focus-outline-width)}
121
121
  .x1mzt3pk:not(#\#):not(#\#):not(#\#){overflow-wrap:break-word}
122
122
  .xp74n0j:not(#\#):not(#\#):not(#\#){padding-inline-end:calc(var(--spacing-2) + var(--spacing-6))}
123
+ .xza90q5:not(#\#):not(#\#):not(#\#){padding-inline-end:calc(var(--spacing-4) + var(--size-element-sm) + 2 * var(--spacing-2))}
123
124
  .xbj1ybn:not(#\#):not(#\#):not(#\#){padding-inline-start:calc(var(--spacing-0))}
124
125
  .x1rey3nv:not(#\#):not(#\#):not(#\#){padding-inline-start:var(--spacing-4)}
125
126
  .x31w388:not(#\#):not(#\#):not(#\#){padding-inline-start:var(--spacing-6)}
@@ -139,6 +140,7 @@
139
140
  .x16khyan:is(:disabled,[aria-disabled="true"]):not(#\#):not(#\#):not(#\#){cursor:default}
140
141
  .x2i8j16:is([data-richtext-task]):not(#\#):not(#\#):not(#\#){list-style-type:none}
141
142
  .x1pvqllw:is([data-richtext-task]):not(#\#):not(#\#):not(#\#){margin-inline-start:calc(-1 * var(--spacing-6))}
143
+ .x18crcbm:is([data-language]:not([data-language="plaintext"])):not(#\#):not(#\#):not(#\#){padding-inline-end:var(--spacing-4)}
142
144
  .x1kuvm45:is([data-richtext-task]):not(#\#):not(#\#):not(#\#){padding-inline-start:calc(20px + var(--spacing-2))}
143
145
  .x81k3mc:has(ul):not(#\#):not(#\#):not(#\#){list-style-type:none}
144
146
  .xovwveo:has(ol):not(#\#):not(#\#):not(#\#){list-style-type:none}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astryxdesign/richtext",
3
3
  "displayName": "Rich Text",
4
- "version": "0.7.5-canary.f2dafed",
4
+ "version": "0.7.5-canary.f57df18",
5
5
  "description": "Astryx rich text — a Lexical-based rich text editor and viewer, styled with Astryx design tokens.",
6
6
  "author": "Meta Open Source",
7
7
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@stylexjs/stylex": ">=0.10.0",
56
- "@astryxdesign/core": "0.7.5-canary.f2dafed",
56
+ "@astryxdesign/core": "0.7.5-canary.f57df18",
57
57
  "react": ">=19.0.0",
58
58
  "react-dom": ">=19.0.0",
59
59
  "lexical": "^0.52.0",
@@ -112,8 +112,8 @@
112
112
  }
113
113
  },
114
114
  "devDependencies": {
115
- "@astryxdesign/a11y-spec": "0.7.5-canary.f2dafed",
116
- "@astryxdesign/cli": "0.7.5-canary.f2dafed",
115
+ "@astryxdesign/a11y-spec": "0.7.5-canary.f57df18",
116
+ "@astryxdesign/cli": "0.7.5-canary.f57df18",
117
117
  "@babel/cli": "^7.29.7",
118
118
  "@babel/core": "^7.29.7",
119
119
  "@babel/preset-react": "^7.29.7",
@@ -135,14 +135,14 @@
135
135
  "lexical": "^0.52.0"
136
136
  },
137
137
  "scripts": {
138
- "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",
139
- "build:esm": "babel src --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json",
138
+ "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && node ../../scripts/add-declaration-extensions.mjs && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",
139
+ "build:esm": "babel src --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.cjs",
140
140
  "build:css": "node ../../scripts/build-css.mjs --package richtext",
141
- "dev": "babel src --watch --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json",
141
+ "dev": "babel src --watch --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.cjs",
142
142
  "test": "vitest run --root ../..",
143
143
  "test:watch": "vitest --root ../..",
144
144
  "lint": "eslint src",
145
145
  "typecheck:docs": "tsc --project tsconfig.docs.json",
146
- "typecheck": "tsc --project tsconfig.json --noEmit"
146
+ "typecheck": "tsc --project tsconfig.json --noEmit && pnpm typecheck:docs"
147
147
  }
148
148
  }
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/src/
2
3
 
3
4
  /**
4
5
  * @file MarkdownParitySandbox.a11y.chromium.spec.ts
@@ -807,7 +808,7 @@ for (const viewport of [PHONE, DESKTOP, {width: 2200, height: 900}] as const) {
807
808
  // One header per fenced block; the first is the `ts` block's.
808
809
  await expect(
809
810
  page.locator(`${RICH_TEXT} [data-richtext-code-header]`),
810
- ).toHaveCount(6);
811
+ ).toHaveCount(7);
811
812
  const header = page
812
813
  .locator(`${RICH_TEXT} [data-richtext-code-header]`)
813
814
  .first();
@@ -890,6 +891,7 @@ for (const globals of [
890
891
  'code-plaintext': '',
891
892
  'code-unknown': 'notalanguage',
892
893
  'code-long': 'sh',
894
+ 'code-plain-long': '',
893
895
  } as const;
894
896
  const markdown = await surfaceGeometry(page, MARKDOWN);
895
897
  const richText = await surfaceGeometry(page, RICH_TEXT);
@@ -904,6 +906,42 @@ for (const globals of [
904
906
  `${key} height`,
905
907
  ).toBeLessThanOrEqual(2);
906
908
  }
909
+ // A fence that names no language keeps its corner copy button beside the
910
+ // code, never over it: the text ends as far from the frame's inline end
911
+ // on both surfaces.
912
+ const textInset = (surface: string, key: string) =>
913
+ page.evaluate(
914
+ ({selector}) => {
915
+ const block = document.querySelector<HTMLElement>(selector);
916
+ const frame = block?.matches('pre, code')
917
+ ? block
918
+ : block?.querySelector<HTMLElement>('pre, code');
919
+ if (frame == null) {
920
+ return -1;
921
+ }
922
+ const rect = frame.getBoundingClientRect();
923
+ const style = getComputedStyle(frame);
924
+ const rtl = style.direction === 'rtl';
925
+ const line = frame.querySelector('[data-line="1"]');
926
+ if (line != null) {
927
+ const text = line.getBoundingClientRect();
928
+ return rtl ? text.left - rect.left : rect.right - text.right;
929
+ }
930
+ return rtl
931
+ ? parseFloat(style.borderLeftWidth) + parseFloat(style.paddingLeft)
932
+ : parseFloat(style.borderRightWidth) +
933
+ parseFloat(style.paddingRight);
934
+ },
935
+ {selector: `${surface} [data-parity-block="${key}"]`},
936
+ );
937
+ for (const key of ['code-plain', 'code-plain-long']) {
938
+ const markdownInset = await textInset(MARKDOWN, key);
939
+ expect(markdownInset, `${key} markdown inset`).toBeGreaterThan(40);
940
+ expect(
941
+ Math.abs((await textInset(RICH_TEXT, key)) - markdownInset),
942
+ `${key} text inset`,
943
+ ).toBeLessThanOrEqual(2);
944
+ }
907
945
  // The label core Markdown shows for each fence.
908
946
  const markdownLabels = await page.evaluate(
909
947
  ({selector, names}) =>
@@ -926,14 +964,14 @@ for (const globals of [
926
964
  // RichText draws one header per fence, in order, each with a copy button
927
965
  // and the same label.
928
966
  const headers = page.locator(`${RICH_TEXT} [data-richtext-code-header]`);
929
- await expect(headers).toHaveCount(6);
967
+ await expect(headers).toHaveCount(7);
930
968
  const richTextLabels = await headers.evaluateAll(elements =>
931
969
  elements.map(element =>
932
970
  (element.textContent ?? '').replace('Copy code', '').trim(),
933
971
  ),
934
972
  );
935
973
  expect(richTextLabels).toEqual(Object.values(fences));
936
- for (const index of [0, 1, 2, 3, 4, 5]) {
974
+ for (const index of [0, 1, 2, 3, 4, 5, 6]) {
937
975
  await expect(
938
976
  headers.nth(index).getByRole('button', {name: 'Copy code'}),
939
977
  ).toBeVisible();
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y release-only
2
3
 
3
4
  /**
4
5
  * @file MarkdownPlugins.a11y.chromium.spec.ts
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y release-only
2
3
 
3
4
  /**
4
5
  * @file MarkdownPluginsImportExport.a11y.chromium.spec.ts
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y release-only
2
3
 
3
4
  /**
4
5
  * @file Playground.a11y.chromium.spec.ts
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/src/
2
3
 
3
4
  /**
4
5
  * @file RichTextEditorToolbar.a11y.chromium.spec.ts
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y scope core/Markdown richtext/* ^(apps/storybook/stories/RichTextEditor\.(markdownParity|stories)|packages/richtext/src/__tests__/(MarkdownParitySandbox|RichTextView|RichTextEditorToolbar)) ^packages/richtext/src/
2
3
 
3
4
  /**
4
5
  * @file RichTextView.a11y.chromium.spec.ts
@@ -1,4 +1,5 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // @pr-a11y release-only
2
3
 
3
4
  /**
4
5
  * @file TableCellSelection.a11y.chromium.spec.ts
@@ -53,6 +53,10 @@ const CODE_SPACE = `calc(${spacingVars['--spacing-3']})`;
53
53
  // Core CodeBlock's header (8px, a small control, 8px) overlaps the code's
54
54
  // 12px top padding by 8px, so its code starts 8px + control + 12px down.
55
55
  const CODE_HEADER_SPACE = `calc(${spacingVars['--spacing-2']} + ${sizeVars['--size-element-sm']} + ${spacingVars['--spacing-3']})`;
56
+ // A block that names no language has no header: core CodeBlock puts its copy
57
+ // button in a column of its own at the inline end (8px, a small control, 8px),
58
+ // beside the code rather than over it, so the code ends that much earlier.
59
+ const CODE_CORNER_SPACE = `calc(${spacingVars['--spacing-4']} + ${sizeVars['--size-element-sm']} + 2 * ${spacingVars['--spacing-2']})`;
56
60
 
57
61
  const editorTheme = stylex.create({
58
62
  // Lexical marks every top-level block `dir="auto"`, which picks each
@@ -443,7 +447,14 @@ const editorTheme = stylex.create({
443
447
  CODE_HEADER_SPACE,
444
448
  },
445
449
  paddingBlockEnd: spacingVars['--spacing-3'],
446
- paddingInline: spacingVars['--spacing-4'],
450
+ paddingInlineStart: spacingVars['--spacing-4'],
451
+ paddingInlineEnd: {
452
+ // Room for the corner copy button CodeBlockHeaderPlugin draws over a
453
+ // block that names no language, so no line runs under it.
454
+ default: CODE_CORNER_SPACE,
455
+ ':is([data-language]:not([data-language="plaintext"]))':
456
+ spacingVars['--spacing-4'],
457
+ },
447
458
  // Sized like core Markdown's code frame: as wide as its longest line, at
448
459
  // least the prose measure (or the whole width when that is narrower), and
449
460
  // never wider than the editor, where long lines wrap.