@astryxdesign/richtext 0.7.5-canary.a8ef89f → 0.7.5-canary.b7ea471
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/editorTheme.d.ts.map +1 -1
- package/dist/editorTheme.js +6 -1
- package/dist/richtext.css +2 -0
- package/package.json +7 -7
- package/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.ts +41 -3
- package/src/__tests__/MarkdownPlugins.a11y.chromium.spec.ts +1 -0
- package/src/__tests__/MarkdownPluginsImportExport.a11y.chromium.spec.ts +1 -0
- package/src/__tests__/Playground.a11y.chromium.spec.ts +1 -0
- package/src/__tests__/RichTextEditorToolbar.a11y.chromium.spec.ts +1 -0
- package/src/__tests__/RichTextView.a11y.chromium.spec.ts +1 -0
- package/src/__tests__/TableCellSelection.a11y.chromium.spec.ts +1 -0
- package/src/editorTheme.ts +12 -1
|
@@ -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;AAqchD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CAgEtD"}
|
package/dist/editorTheme.js
CHANGED
|
@@ -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
|
-
|
|
233
|
+
kZCmMZ: "x1rey3nv",
|
|
234
|
+
kwRFfy: "xza90q5 x18crcbm",
|
|
230
235
|
kB7OPa: "x9f619",
|
|
231
236
|
kzqmXN: "xeq5yr9",
|
|
232
237
|
k7Eaqz: "xejm5pw",
|
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.
|
|
4
|
+
"version": "0.7.5-canary.b7ea471",
|
|
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.
|
|
56
|
+
"@astryxdesign/core": "0.7.5-canary.b7ea471",
|
|
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.
|
|
116
|
-
"@astryxdesign/cli": "0.7.5-canary.
|
|
115
|
+
"@astryxdesign/a11y-spec": "0.7.5-canary.b7ea471",
|
|
116
|
+
"@astryxdesign/cli": "0.7.5-canary.b7ea471",
|
|
117
117
|
"@babel/cli": "^7.29.7",
|
|
118
118
|
"@babel/core": "^7.29.7",
|
|
119
119
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -136,13 +136,13 @@
|
|
|
136
136
|
},
|
|
137
137
|
"scripts": {
|
|
138
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.
|
|
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.
|
|
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(
|
|
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(
|
|
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 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
|
package/src/editorTheme.ts
CHANGED
|
@@ -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
|
-
|
|
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.
|