@astl/editor-tiptap 0.2.3 → 0.3.1

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/src/nodes.ts CHANGED
@@ -21,12 +21,19 @@
21
21
  */
22
22
  import {
23
23
  CAPTION_TAG,
24
+ CHECK_FOR_ATTRIBUTE,
25
+ CHECK_LABEL_ATTRIBUTE,
26
+ CHECK_TAG,
27
+ type CheckTree,
24
28
  type ChildSpec,
25
29
  CLASS_ATTRIBUTE,
26
30
  COLUMN_TAG,
27
31
  COLUMNS_TAG,
28
32
  CONTENT_ATTRIBUTES,
29
33
  type ComponentManifest,
34
+ checkFor,
35
+ checkNodes,
36
+ checkParts,
30
37
  childTagConflict,
31
38
  directionOf,
32
39
  type EditorDescriptor,
@@ -39,11 +46,13 @@ import {
39
46
  HINT_TAG,
40
47
  INERT_STYLE,
41
48
  inertStyles,
49
+ isCheckable,
42
50
  isSourceId,
43
51
  MAX_COLUMNS,
44
52
  type MessageParams,
45
53
  MIN_COLUMNS,
46
54
  PAGE_CHECK_ATTRIBUTE,
55
+ planChecks,
47
56
  TAG_ATTRIBUTES,
48
57
  } from '@astl/core';
49
58
  import { cleanClass, cleanStyle, isStyleName } from '@astl/core/declarations';
@@ -81,10 +90,11 @@ import {
81
90
  TextSelection,
82
91
  type Transaction,
83
92
  } from '@tiptap/pm/state';
84
- import { Decoration, DecorationSet } from '@tiptap/pm/view';
93
+ import { Decoration, DecorationSet, type EditorView } from '@tiptap/pm/view';
85
94
  import { StarterKit } from '@tiptap/starter-kit';
86
95
  import {
87
96
  blocksExtension,
97
+ CHECK_NODE,
88
98
  historyKey,
89
99
  LAYOUT,
90
100
  LAYOUT_COLUMN,
@@ -945,6 +955,243 @@ function helpPlaceholderExtension(authoring: Authoring): Extension {
945
955
  });
946
956
  }
947
957
 
958
+ /** The group of `<astl-check>`: directly on a page or in a column, never in text or in a component. */
959
+ const CHECK = 'check';
960
+
961
+ /** The decoration spec key a Check element's view reads how many questions it checks from (`checksExtension`). */
962
+ const CHECK_COUNT = 'astlCheckCount';
963
+
964
+ /** The class of the questions the selected Check element checks. */
965
+ const CHECK_TARGET = 'astl-check-target';
966
+
967
+ /** A Check element's count among its view's decorations, or null before the plugin has given it. */
968
+ const countIn = (decorations: readonly { spec: Record<string, unknown> }[]): number | null => {
969
+ for (const decoration of decorations) {
970
+ const count = decoration.spec[CHECK_COUNT];
971
+ if (typeof count === 'number') return count;
972
+ }
973
+ return null;
974
+ };
975
+
976
+ /**
977
+ * `<astl-check>`, a Check for several questions: a block atom kept as data, drawn as the compact button it puts in the
978
+ * player (`astl-check-button`: its `label`, else "Check") with a tag saying how many questions it checks
979
+ * (`astl-check-tag`: "3 questions"; without any, "No questions" and `data-empty` on `astl-check`). Its card ticks them.
980
+ */
981
+ function checkNode(authoring: Authoring): Node {
982
+ const t = (key: string, params?: MessageParams) => authoring.t(EDITOR_NAMESPACE, key, params);
983
+ const ui = { lang: authoring.locale, dir: directionOf(authoring.locale) };
984
+ return Node.create({
985
+ name: CHECK_NODE,
986
+ group: CHECK,
987
+ atom: true,
988
+ selectable: true,
989
+ addAttributes: () => sourceAttributes,
990
+ parseHTML: () => [{ tag: CHECK_TAG }],
991
+ renderHTML: ({ node }) => [CHECK_TAG, { ...node.attrs.attributes }],
992
+ addNodeView:
993
+ () =>
994
+ ({ node, decorations }) => {
995
+ const dom = document.createElement('div');
996
+ dom.className = 'astl-check';
997
+ const button = dom.appendChild(document.createElement('span'));
998
+ button.className = 'astl-check-button';
999
+ button.append(lineIcon('check', 'astl-icon'));
1000
+ const label = button.appendChild(document.createElement('span'));
1001
+ const tag = dom.appendChild(Object.assign(document.createElement('span'), ui));
1002
+ tag.className = 'astl-check-tag';
1003
+ const render = (attrs: Record<string, unknown>, count: number | null) => {
1004
+ const own = ((attrs.attributes as Attributes)[CHECK_LABEL_ATTRIBUTE] ?? '').trim();
1005
+ label.textContent = own === '' ? t('check.button') : own;
1006
+ // The default words are the editor's, the author's the exercise's.
1007
+ if (own === '') Object.assign(label, ui);
1008
+ else {
1009
+ label.removeAttribute('lang');
1010
+ label.removeAttribute('dir');
1011
+ }
1012
+ tag.textContent =
1013
+ count === null ? '' : count === 0 ? t('check.none') : t('check.count', { n: count });
1014
+ dom.toggleAttribute('data-empty', count === 0);
1015
+ };
1016
+ render(node.attrs, countIn(decorations));
1017
+ return {
1018
+ dom,
1019
+ update: (next: NodeLike, nextDecorations: readonly { spec: Record<string, unknown> }[]) => {
1020
+ if (next.type.name !== CHECK_NODE) return false;
1021
+ render(next.attrs, countIn(nextDecorations));
1022
+ return true;
1023
+ },
1024
+ ignoreMutation: () => true,
1025
+ };
1026
+ },
1027
+ });
1028
+ }
1029
+
1030
+ /**
1031
+ * Each Check element's questions, by the rule the engine and the player use (`planChecks`) over the editor's nodes: its
1032
+ * view says how many (a node decoration's spec), and while it is selected its questions are marked (`astl-check-target`
1033
+ * on each), inline ones and blocks alike. Where two or more questions of a run of text have none, the automatic Check
1034
+ * the player puts there shows after the block of the last of them (`astl-check astl-check-auto`: "automatic · 3
1035
+ * questions"), with "Make it a button" (`astl-check-make`), which writes a Check element for them in its place.
1036
+ */
1037
+ function checksExtension(authoring: Authoring, manifests: readonly ComponentManifest[]): Extension {
1038
+ const t = (key: string, params?: MessageParams) => authoring.t(EDITOR_NAMESPACE, key, params);
1039
+ const ui = { lang: authoring.locale, dir: directionOf(authoring.locale) };
1040
+ const types = new Map(manifests.map((m) => [nodeName(m.tag), m]));
1041
+ const idOf = (node: PMNode): string | null => (node.attrs.attributes as Attributes | undefined)?.id || null;
1042
+ const childrenOf = (node: PMNode): PMNode[] => {
1043
+ const out: PMNode[] = [];
1044
+ node.forEach((child) => {
1045
+ out.push(child);
1046
+ });
1047
+ return out;
1048
+ };
1049
+ /** The positions of the Check elements directly in `node` and in its layouts' columns, as `checkNodes` meets them. */
1050
+ const checkPositions = (node: PMNode, start: number): number[] => {
1051
+ const out: number[] = [];
1052
+ node.forEach((child, offset) => {
1053
+ const pos = start + offset;
1054
+ if (child.type.name === CHECK_NODE) out.push(pos);
1055
+ else if (child.type.name === LAYOUT) {
1056
+ child.forEach((column, at) => {
1057
+ if (column.type.name === LAYOUT_COLUMN) out.push(...checkPositions(column, pos + 1 + at + 1));
1058
+ });
1059
+ }
1060
+ });
1061
+ return out;
1062
+ };
1063
+ /** A Check element for `run` at `pos` (after the block of its last question), selected, as one undo step. */
1064
+ const make = (view: EditorView, pos: number, run: readonly string[]): void => {
1065
+ const type = view.state.schema.nodes[CHECK_NODE];
1066
+ if (type === undefined) return;
1067
+ const used = idsIn(view.state.doc);
1068
+ let n = 1;
1069
+ while (used.has(`check-${n}`)) n++;
1070
+ const node = type.create({ attributes: { id: `check-${n}`, [CHECK_FOR_ATTRIBUTE]: run.join(' ') } });
1071
+ const tr = closeHistory(view.state.tr).insert(pos, node);
1072
+ view.dispatch(tr.setSelection(NodeSelection.create(tr.doc, pos)).scrollIntoView());
1073
+ view.focus();
1074
+ };
1075
+ /** The automatic Check of `run`: the button it is, its tag, and "Make it a button". */
1076
+ const automaticDom = (view: EditorView, run: readonly string[], getPos: () => number | undefined) => {
1077
+ const dom = Object.assign(document.createElement('div'), ui);
1078
+ dom.className = 'astl-check astl-check-auto';
1079
+ dom.contentEditable = 'false';
1080
+ const button = dom.appendChild(document.createElement('span'));
1081
+ button.className = 'astl-check-button';
1082
+ button.append(lineIcon('check', 'astl-icon'));
1083
+ button.appendChild(document.createElement('span')).textContent = t('check.button');
1084
+ const tag = dom.appendChild(document.createElement('span'));
1085
+ tag.className = 'astl-check-tag';
1086
+ tag.textContent = t('check.auto', { n: run.length });
1087
+ const press = dom.appendChild(document.createElement('button'));
1088
+ Object.assign(press, { type: 'button', tabIndex: -1, title: t('check.makeHelp') });
1089
+ press.className = 'astl-check-make';
1090
+ press.textContent = t('check.make');
1091
+ press.addEventListener('click', (event) => {
1092
+ event.preventDefault();
1093
+ const pos = getPos();
1094
+ if (pos !== undefined) make(view, pos, run);
1095
+ });
1096
+ return dom;
1097
+ };
1098
+ const decorate = (state: EditorState): DecorationSet => {
1099
+ const { doc, selection } = state;
1100
+ const selected =
1101
+ selection instanceof NodeSelection && selection.node.type.name === CHECK_NODE ? selection.from : null;
1102
+ const decorations: Decoration[] = [];
1103
+ const containers: { node: PMNode; start: number }[] = [];
1104
+ if (doc.firstChild?.type.name === PAGE) {
1105
+ doc.forEach((page, offset) => {
1106
+ containers.push({ node: page, start: offset + 1 });
1107
+ });
1108
+ } else containers.push({ node: doc, start: 0 });
1109
+ for (const container of containers) {
1110
+ // The page's graded questions by id, where they are.
1111
+ const questions = new Map<string, { readonly pos: number; readonly node: PMNode }>();
1112
+ container.node.descendants((node, offset) => {
1113
+ const manifest = types.get(node.type.name);
1114
+ if (manifest === undefined) return true;
1115
+ const id = idOf(node);
1116
+ if (isCheckable(manifest) && id !== null) questions.set(id, { pos: container.start + offset, node });
1117
+ return false;
1118
+ });
1119
+ const tree: CheckTree<PMNode> = {
1120
+ tag: (node) => {
1121
+ const name = node.type.name;
1122
+ if (node.isText) return null;
1123
+ if (name === CHECK_NODE) return CHECK_TAG;
1124
+ if (name === LAYOUT) return COLUMNS_TAG;
1125
+ if (name === LAYOUT_COLUMN) return COLUMN_TAG;
1126
+ return name === 'heading' ? `h${node.attrs.level as number}` : name;
1127
+ },
1128
+ children: childrenOf,
1129
+ component: (node) => {
1130
+ const manifest = types.get(node.type.name);
1131
+ if (manifest === undefined) return null;
1132
+ return { id: idOf(node), graded: isCheckable(manifest), block: manifest.display === 'block' };
1133
+ },
1134
+ checkFor: (node) => {
1135
+ const attributes = node.attrs.attributes as Attributes;
1136
+ return Object.hasOwn(attributes, CHECK_FOR_ATTRIBUTE)
1137
+ ? checkFor(attributes[CHECK_FOR_ATTRIBUTE]).filter((id) => questions.has(id))
1138
+ : null;
1139
+ },
1140
+ };
1141
+ const content = childrenOf(container.node);
1142
+ const { targets, uncovered } = planChecks(checkParts(content, tree));
1143
+ const positions = checkPositions(container.node, container.start);
1144
+ checkNodes(content, tree).forEach((check, k) => {
1145
+ const pos = positions[k];
1146
+ if (pos === undefined) return;
1147
+ const own = targets[k] ?? [];
1148
+ decorations.push(Decoration.node(pos, pos + check.nodeSize, {}, { [CHECK_COUNT]: own.length }));
1149
+ if (pos !== selected) return;
1150
+ for (const id of own) {
1151
+ const question = questions.get(id);
1152
+ if (question !== undefined)
1153
+ decorations.push(
1154
+ Decoration.node(question.pos, question.pos + question.node.nodeSize, { class: CHECK_TARGET }),
1155
+ );
1156
+ }
1157
+ });
1158
+ // After the block, directly in the page or its column, that holds the last question of the run.
1159
+ for (const run of uncovered) {
1160
+ const last = questions.get(run.at(-1) ?? '');
1161
+ if (run.length < 2 || last === undefined) continue;
1162
+ const $last = doc.resolve(last.pos);
1163
+ let depth = $last.depth;
1164
+ while (depth > 0 && ![PAGE, LAYOUT_COLUMN].includes($last.node(depth).type.name)) depth--;
1165
+ const at = $last.after(depth + 1);
1166
+ decorations.push(
1167
+ // Before the tab and the notes of a block framed right there (sides -2 and -1): it ends the run above.
1168
+ Decoration.widget(at, (view, getPos) => automaticDom(view, run, getPos), {
1169
+ key: `auto\n${run.join(' ')}`,
1170
+ side: -3,
1171
+ stopEvent: () => true,
1172
+ ignoreSelection: true,
1173
+ }),
1174
+ );
1175
+ }
1176
+ }
1177
+ return DecorationSet.create(doc, decorations);
1178
+ };
1179
+ const key = new PluginKey<DecorationSet>('astlChecks');
1180
+ return Extension.create({
1181
+ name: 'astlChecks',
1182
+ addProseMirrorPlugins: () => [
1183
+ new Plugin<DecorationSet>({
1184
+ key,
1185
+ state: {
1186
+ init: (_, state) => decorate(state),
1187
+ apply: (tr, previous, _, state) => (tr.docChanged || tr.selectionSet ? decorate(state) : previous),
1188
+ },
1189
+ props: { decorations: (state) => key.getState(state) },
1190
+ }),
1191
+ ],
1192
+ });
1193
+ }
1194
+
948
1195
  /**
949
1196
  * A block with rich children, or with rich content (`content: 'flow'`), framed and labelled in the editor, with its
950
1197
  * picture when it has picture fields.
@@ -1811,8 +2058,8 @@ function figureNode(authoring: Authoring, hooks: PictureHooks | undefined): Node
1811
2058
  /** The node name of `<astl-page>`. */
1812
2059
  const PAGE = 'astlPage';
1813
2060
 
1814
- /** What a page or a document without pages holds: blocks and layouts. */
1815
- const PAGE_CONTENT = `(block | ${LAYOUT} | ${HELP})+`;
2061
+ /** What a page or a document without pages holds: blocks, layouts, help for students and Check elements. */
2062
+ const PAGE_CONTENT = `(block | ${LAYOUT} | ${HELP} | ${CHECK})+`;
1816
2063
 
1817
2064
  /**
1818
2065
  * A layout: `<astl-columns>` with its `<astl-column>`s, under their real tags (nothing in them asks for a node view).
@@ -1848,7 +2095,7 @@ const layoutNodes: readonly Node[] = [
1848
2095
  }),
1849
2096
  Node.create({
1850
2097
  name: LAYOUT_COLUMN,
1851
- content: 'block+',
2098
+ content: `(block | ${CHECK})+`,
1852
2099
  isolating: true,
1853
2100
  selectable: false,
1854
2101
  addAttributes: () => sourceAttributes,
@@ -2762,7 +3009,8 @@ function pastedIdsExtension(
2762
3009
  manifests: readonly ComponentManifest[],
2763
3010
  hooks: PictureHooks | undefined,
2764
3011
  ): Extension {
2765
- const tags = new Map(manifests.map((m) => [nodeName(m.tag), m.tag]));
3012
+ // Check elements share the namespace: a pasted one whose id is taken gets `check-<n>`.
3013
+ const tags = new Map([...manifests.map((m) => [nodeName(m.tag), m.tag] as const), [CHECK_NODE, CHECK_TAG]]);
2766
3014
  const prefixOf = (name: string): string => {
2767
3015
  const tag = tags.get(name);
2768
3016
  if (tag === undefined) return 'page';
@@ -3171,6 +3419,8 @@ export function astrolabeExtensions(
3171
3419
  currentFigureExtension,
3172
3420
  ...componentNodes(manifests, label, zonesView(authoring), authoring),
3173
3421
  ...helpNodes(authoring),
3422
+ checkNode(authoring),
3423
+ checksExtension(authoring, manifests),
3174
3424
  referencesExtension(authoring, manifests),
3175
3425
  childrenExtension(manifests),
3176
3426
  richBlocksExtension(authoring, manifests),
package/src/styles.ts CHANGED
@@ -149,9 +149,12 @@ const baseSurfaceStyles: CSSResult = css`
149
149
  letter-spacing: var(--astl-editor-page-number-letter-spacing, normal);
150
150
  text-transform: var(--astl-editor-page-number-text-transform, none);
151
151
  }
152
+ /* The title and "Remove title" share a row while the title keeps 6rem; narrower (a phone with larger text) the button
153
+ goes under the title, its words wrapping only where it is wider than the row alone. */
152
154
  .astl-surface .astl-page-field {
153
155
  flex: 1 0 100%;
154
156
  display: flex;
157
+ flex-wrap: wrap;
155
158
  align-items: center;
156
159
  gap: var(--astl-space-2);
157
160
  min-inline-size: 0;
@@ -161,7 +164,7 @@ const baseSurfaceStyles: CSSResult = css`
161
164
  }
162
165
  .astl-surface .astl-page-label {
163
166
  box-sizing: border-box;
164
- flex: 1 1 auto;
167
+ flex: 1 1 6rem;
165
168
  min-inline-size: 0;
166
169
  min-block-size: var(--astl-target-min);
167
170
  margin: 0;
@@ -203,7 +206,8 @@ const baseSurfaceStyles: CSSResult = css`
203
206
  .astl-page-remove-title,
204
207
  .astl-page-check,
205
208
  .astl-help-remove,
206
- .astl-help-free
209
+ .astl-help-free,
210
+ .astl-check-make
207
211
  ) {
208
212
  box-sizing: border-box;
209
213
  display: inline-flex;
@@ -242,7 +246,8 @@ const baseSurfaceStyles: CSSResult = css`
242
246
  .astl-page-remove-title,
243
247
  .astl-page-check,
244
248
  .astl-help-remove,
245
- .astl-help-free
249
+ .astl-help-free,
250
+ .astl-check-make
246
251
  ):hover {
247
252
  background: var(--astl-accent-soft);
248
253
  color: var(--astl-ink);
@@ -267,6 +272,8 @@ const baseSurfaceStyles: CSSResult = css`
267
272
  /* Beside the title the button keeps its words whole (it broke "Remove" at 320 px): the title gives way instead. */
268
273
  .astl-surface .astl-page-remove-title {
269
274
  flex: none;
275
+ max-inline-size: 100%;
276
+ white-space: normal;
270
277
  }
271
278
 
272
279
  /* A component in text (a gap): a chip with an icon, its answer and a badge counting the other answers, a long word
@@ -323,6 +330,102 @@ const baseSurfaceStyles: CSSResult = css`
323
330
  color: var(--astl-danger);
324
331
  }
325
332
 
333
+ /* A Check element (astl-check): the compact button it puts in the player, the accent's outline, then a tag saying how
334
+ many questions it checks; without any, the tag says so, dashed in the warning colour: never by colour alone. While
335
+ it is selected, the questions it checks have a dashed accent outline (astl-check-target), apart from the solid
336
+ focus ring. */
337
+ .astl-surface .astl-check {
338
+ box-sizing: border-box;
339
+ display: flex;
340
+ flex-wrap: wrap;
341
+ align-items: center;
342
+ gap: var(--astl-space-2);
343
+ inline-size: fit-content;
344
+ max-inline-size: 100%;
345
+ margin-block: var(--astl-space-2);
346
+ border-radius: var(--astl-radius-s);
347
+ font-family: var(--astl-font-body);
348
+ cursor: pointer;
349
+ }
350
+ .astl-surface .astl-check-button {
351
+ box-sizing: border-box;
352
+ display: inline-flex;
353
+ align-items: center;
354
+ gap: 0.25rem;
355
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
356
+ max-inline-size: 100%;
357
+ padding-inline: var(--astl-space-3);
358
+ border: var(--astl-outline-width) solid var(--astl-accent);
359
+ border-radius: var(--astl-radius-s);
360
+ background: var(--astl-surface);
361
+ color: var(--astl-ink);
362
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
363
+ font-weight: 600;
364
+ line-height: 1.2;
365
+ overflow-wrap: anywhere;
366
+ }
367
+ .astl-surface .astl-check-button .astl-icon {
368
+ flex: none;
369
+ inline-size: var(--astl-editor-control-icon-size, 0.875rem);
370
+ block-size: var(--astl-editor-control-icon-size, 0.875rem);
371
+ fill: none;
372
+ stroke: var(--astl-accent);
373
+ stroke-width: 2.2;
374
+ stroke-linecap: round;
375
+ stroke-linejoin: round;
376
+ }
377
+ .astl-surface .astl-check-tag {
378
+ padding-inline: 0.5em;
379
+ border: 1px solid transparent;
380
+ border-radius: var(--astl-radius-pill);
381
+ background: var(--astl-accent-soft);
382
+ color: var(--astl-ink);
383
+ font-size: var(--astl-size-small);
384
+ font-weight: 600;
385
+ line-height: 1.4;
386
+ }
387
+ .astl-surface .astl-check-tag:empty {
388
+ display: none;
389
+ }
390
+ .astl-surface .astl-check[data-empty] .astl-check-tag {
391
+ border-style: dashed;
392
+ border-color: var(--astl-warning);
393
+ background: var(--astl-warning-soft);
394
+ }
395
+ .astl-surface .astl-check-target {
396
+ outline: var(--astl-editor-focus-width, 2px) dashed var(--astl-accent);
397
+ outline-offset: 2px;
398
+ }
399
+ /* A chip sits in running text: its outline hugs it, never over the words beside it. */
400
+ .astl-surface .astl-chip.astl-check-target {
401
+ outline-offset: 0;
402
+ }
403
+ /* An automatic Check is the player's, not the exercise's: in a dashed box, its button dashed and muted, with "Make it
404
+ a button" after its tag. */
405
+ .astl-surface .astl-check-auto {
406
+ padding-block: var(--astl-space-1);
407
+ padding-inline: var(--astl-space-2);
408
+ border: 1px dashed var(--astl-outline);
409
+ cursor: default;
410
+ }
411
+ .astl-surface .astl-check-auto .astl-check-button {
412
+ border-style: dashed;
413
+ border-color: var(--astl-outline);
414
+ color: var(--astl-ink-muted);
415
+ }
416
+ .astl-surface .astl-check-make:focus-visible {
417
+ outline: var(--astl-editor-focus-width, 2px) solid var(--astl-focus);
418
+ outline-offset: var(--astl-editor-focus-offset, 1px);
419
+ }
420
+ @media (forced-colors: active) {
421
+ .astl-surface .astl-check-target {
422
+ outline-color: Highlight;
423
+ }
424
+ .astl-surface .astl-check-button .astl-icon {
425
+ stroke: CanvasText;
426
+ }
427
+ }
428
+
326
429
  /* The page is one flowing text; a block component on it is framed, with a label tab at the frame's top start (its
327
430
  type's icon, its label, a summary). The tab sits on the frame's top border, covering it. The frame with the cursor
328
431
  is the accent, its tab filled; one with an error or a warning is dashed in that colour and says its issues under
@@ -769,7 +872,8 @@ const baseSurfaceStyles: CSSResult = css`
769
872
  .astl-surface .astl-block-add:not(:has(button:not([hidden]))) {
770
873
  display: none;
771
874
  }
772
- /* A small text button under the last child, as the page heads' are. */
875
+ /* A small text button under the last child, as the page heads' are. Its words wrap only where it is wider than its
876
+ row alone (larger text on a phone), not to run past the frame. */
773
877
  .astl-surface .astl-block-add button {
774
878
  box-sizing: border-box;
775
879
  display: inline-flex;
@@ -789,7 +893,7 @@ const baseSurfaceStyles: CSSResult = css`
789
893
  font-size: var(--astl-editor-control-font-size, 0.8125rem);
790
894
  font-weight: 600;
791
895
  line-height: 1.2;
792
- white-space: nowrap;
896
+ text-align: start;
793
897
  cursor: pointer;
794
898
  }
795
899
  .astl-surface .astl-block-add button:disabled {