@astryxdesign/richtext 0.7.5-canary.45b0afd → 0.7.5-canary.4bcd84f
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 +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.4bcd84f",
|
|
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.4bcd84f",
|
|
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.4bcd84f",
|
|
116
|
+
"@astryxdesign/cli": "0.7.5-canary.4bcd84f",
|
|
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
|
}
|
|
@@ -807,7 +807,7 @@ for (const viewport of [PHONE, DESKTOP, {width: 2200, height: 900}] as const) {
|
|
|
807
807
|
// One header per fenced block; the first is the `ts` block's.
|
|
808
808
|
await expect(
|
|
809
809
|
page.locator(`${RICH_TEXT} [data-richtext-code-header]`),
|
|
810
|
-
).toHaveCount(
|
|
810
|
+
).toHaveCount(7);
|
|
811
811
|
const header = page
|
|
812
812
|
.locator(`${RICH_TEXT} [data-richtext-code-header]`)
|
|
813
813
|
.first();
|
|
@@ -890,6 +890,7 @@ for (const globals of [
|
|
|
890
890
|
'code-plaintext': '',
|
|
891
891
|
'code-unknown': 'notalanguage',
|
|
892
892
|
'code-long': 'sh',
|
|
893
|
+
'code-plain-long': '',
|
|
893
894
|
} as const;
|
|
894
895
|
const markdown = await surfaceGeometry(page, MARKDOWN);
|
|
895
896
|
const richText = await surfaceGeometry(page, RICH_TEXT);
|
|
@@ -904,6 +905,42 @@ for (const globals of [
|
|
|
904
905
|
`${key} height`,
|
|
905
906
|
).toBeLessThanOrEqual(2);
|
|
906
907
|
}
|
|
908
|
+
// A fence that names no language keeps its corner copy button beside the
|
|
909
|
+
// code, never over it: the text ends as far from the frame's inline end
|
|
910
|
+
// on both surfaces.
|
|
911
|
+
const textInset = (surface: string, key: string) =>
|
|
912
|
+
page.evaluate(
|
|
913
|
+
({selector}) => {
|
|
914
|
+
const block = document.querySelector<HTMLElement>(selector);
|
|
915
|
+
const frame = block?.matches('pre, code')
|
|
916
|
+
? block
|
|
917
|
+
: block?.querySelector<HTMLElement>('pre, code');
|
|
918
|
+
if (frame == null) {
|
|
919
|
+
return -1;
|
|
920
|
+
}
|
|
921
|
+
const rect = frame.getBoundingClientRect();
|
|
922
|
+
const style = getComputedStyle(frame);
|
|
923
|
+
const rtl = style.direction === 'rtl';
|
|
924
|
+
const line = frame.querySelector('[data-line="1"]');
|
|
925
|
+
if (line != null) {
|
|
926
|
+
const text = line.getBoundingClientRect();
|
|
927
|
+
return rtl ? text.left - rect.left : rect.right - text.right;
|
|
928
|
+
}
|
|
929
|
+
return rtl
|
|
930
|
+
? parseFloat(style.borderLeftWidth) + parseFloat(style.paddingLeft)
|
|
931
|
+
: parseFloat(style.borderRightWidth) +
|
|
932
|
+
parseFloat(style.paddingRight);
|
|
933
|
+
},
|
|
934
|
+
{selector: `${surface} [data-parity-block="${key}"]`},
|
|
935
|
+
);
|
|
936
|
+
for (const key of ['code-plain', 'code-plain-long']) {
|
|
937
|
+
const markdownInset = await textInset(MARKDOWN, key);
|
|
938
|
+
expect(markdownInset, `${key} markdown inset`).toBeGreaterThan(40);
|
|
939
|
+
expect(
|
|
940
|
+
Math.abs((await textInset(RICH_TEXT, key)) - markdownInset),
|
|
941
|
+
`${key} text inset`,
|
|
942
|
+
).toBeLessThanOrEqual(2);
|
|
943
|
+
}
|
|
907
944
|
// The label core Markdown shows for each fence.
|
|
908
945
|
const markdownLabels = await page.evaluate(
|
|
909
946
|
({selector, names}) =>
|
|
@@ -926,14 +963,14 @@ for (const globals of [
|
|
|
926
963
|
// RichText draws one header per fence, in order, each with a copy button
|
|
927
964
|
// and the same label.
|
|
928
965
|
const headers = page.locator(`${RICH_TEXT} [data-richtext-code-header]`);
|
|
929
|
-
await expect(headers).toHaveCount(
|
|
966
|
+
await expect(headers).toHaveCount(7);
|
|
930
967
|
const richTextLabels = await headers.evaluateAll(elements =>
|
|
931
968
|
elements.map(element =>
|
|
932
969
|
(element.textContent ?? '').replace('Copy code', '').trim(),
|
|
933
970
|
),
|
|
934
971
|
);
|
|
935
972
|
expect(richTextLabels).toEqual(Object.values(fences));
|
|
936
|
-
for (const index of [0, 1, 2, 3, 4, 5]) {
|
|
973
|
+
for (const index of [0, 1, 2, 3, 4, 5, 6]) {
|
|
937
974
|
await expect(
|
|
938
975
|
headers.nth(index).getByRole('button', {name: 'Copy code'}),
|
|
939
976
|
).toBeVisible();
|
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.
|