@crewlethq/ui 0.156.0 → 0.157.0

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/README.md CHANGED
@@ -208,6 +208,39 @@ places:
208
208
  - A surface that pans or zooms dispatches `LAYER_REPOSITION_EVENT` on its host
209
209
  when the content beneath it moves, and every panel anchored inside follows.
210
210
 
211
+ ## Changes in 0.157.0
212
+
213
+ ### A list item holds blocks
214
+
215
+ **The Markdown grammar reads a list item's lines as blocks**, as CommonMark does: each line indented to the item's content (the marker's width and the spaces after it, so three for `1. ` and four for `10. `) is the item's, with that indent taken off, and the item's lines are read like a document of their own. A fenced block (backticks or tildes), a table, a quote, a heading or a nested list inside an item is that block. The grammar read every later line of an item as paragraph text, so a fence in a numbered step drew as three backticks inline in every renderer, and `RichEditor`, saving it, turned an indented `- name:` line inside the fence into a list item that took the next paragraph's first word and a link's bracket with it.
216
+
217
+ The grammar reads a body in one pass over its lines, with the open quotes, lists and items on a stack, so the work is linear in the body however deeply its lists nest. Its block rules now follow CommonMark (and GitHub's tables) where a body could read two ways:
218
+
219
+ - A blank line belongs to an item when the next line that is not blank does, so blank lines inside a fence or between two of an item's paragraphs keep it open. Blank lines before the next item keep the list, loose, however many there are.
220
+ - A line less indented than an item's content continues a paragraph left open at the item's end (a lazy line) and otherwise ends the item, so `1. a` over ` - b`, or a paragraph indented two spaces under a three-wide marker after a blank line, reads outside the item, as GitHub draws it. A quote's paragraph takes lazy lines too: `> a` over `b` is one quote.
221
+ - A heading, a fence, a quote, a rule, a list that could start a document, or a line that opens an HTML block (`<!--`, `<div>` and CommonMark's other block-level kinds) ends a paragraph, a lazy line and a table's rows. An HTML block's line is still read as text, as all raw HTML is.
222
+ - Only a list that could start a document interrupts a paragraph: an item with text, numbered from 1 if numbered. A wrapped line that begins `365) ` or `2. ` is the paragraph's next line.
223
+ - A change of bullet character or ordered delimiter starts a new list. A marker, a rule or any other block start indented four or more columns starts nothing: it is text.
224
+ - A list is loose when a blank line separates two of its items or two blocks of one item.
225
+ - A table opens only where its header and delimiter rows hold as many cells, and its rows run until a blank line or another block, so a line with no pipe under a table is a row of one cell. A table's header on a lazy line is the paragraph's text, as it is to GitHub.
226
+ - A fence opens on three or more backticks or tildes and closes only on a run of the same character at least as long, indented up to three spaces. A tab is the columns it fills from the start of its line, after a quote's `>` and before a fence's close as everywhere else.
227
+ - In a code span, a backtick string is a whole run, so three backticks alone are text; a line ending is a space; and one space comes off each end only when both ends have one.
228
+ - A run of emphasis or strikethrough delimiters with nothing between them (`***`, `~~~~~`) is text.
229
+ - Strikethrough is GitHub's: a run of one or two tildes opens when it is followed by text and closes when it follows text, so `~~ ~~` and `a ~~ b ~~ c` are text, and `~one~` is struck.
230
+ - Quotes and list items nest 100 deep at most, and a marker past that is its line's text, as markdown-it reads it: a hundred is a twelfth of the depth at which the editor and the canonical spelling run out of stack, and fifty times the deepest nesting in Crewlet's own documentation.
231
+ - A line that opens containers one inside another (`> - > - x`) opens them however many there are.
232
+
233
+ **The line readers answer differently**, so an application that walks lines with them sees the same blocks the grammar does:
234
+
235
+ - `markdownHeadingOf` reads a heading indented up to three spaces (it read only one at the line's start).
236
+ - `markdownFenceOf` reads a fence indented up to three spaces and of three or more backticks or tildes, and answers its `indent` and `length` as well as its `marker` and `lang`.
237
+ - **Breaking:** `markdownClosesFence` takes the opening's `length` as a required third argument, and only a run at least that long closes. It accepts a close indented up to three spaces.
238
+ - `markdownCodeText` reads a line ending in a span as a space, and takes one space off each end only when both ends have one.
239
+
240
+ `RichEditor`'s list item holds any block, a code block and a heading after its first block included, and its writer puts every block back at the item's content indent. A tight list stays tight where the next block starts a block of its own, and is written loose where two blocks need a blank line between them; a rule right under a paragraph is written `***`. Two lists of one kind next to each other are written with alternating bullets (`-` and `*`) or delimiters (`.` and `)`), not two blank lines. A code span is written on one line and its text exactly, padded only where CommonMark needs it, and a fence one longer than the longest run of its character in the code. In a code block inside an item, Enter, Tab and Shift-Tab act on the code, not the item. The editor's corpus holds the shapes (`list-item-blocks.md`).
241
+
242
+ What to change: pass `markdownClosesFence` the opening fence's `length`, as `markdownFenceOf` answered it for the opening line; a call without it no longer type-checks. A body whose list items are indented less than their marker's width, or that relied on two blank lines or a change of bullet to keep one list, reads as CommonMark reads it.
243
+
211
244
  ## Changes in 0.153.0
212
245
 
213
246
  ### Every line diff is tinted, compared honestly and written on
@@ -1,5 +1,5 @@
1
- export { ARTIFACT_REF_KIND_LABELS, ArtifactRef } from '../chunk-QNSAFNGT.js';
2
- import '../chunk-6KCQXKFQ.js';
3
- import '../chunk-KBZO4B33.js';
1
+ export { ARTIFACT_REF_KIND_LABELS, ArtifactRef } from '../chunk-PZPLTFWX.js';
2
+ import '../chunk-WTV24BFB.js';
3
+ import '../chunk-KMTOGF6T.js';
4
4
  import '../chunk-RSKW25Y5.js';
5
5
  import '../chunk-ODEQTPFM.js';
@@ -1,8 +1,8 @@
1
- import { richEditorLabels } from './chunk-2DMTW2Y3.js';
2
- import { schema, readMarkdown, writeMarkdown } from './chunk-7CSTEH5I.js';
1
+ import { richEditorLabels } from './chunk-DGXHQMNP.js';
2
+ import { schema, readMarkdown, writeMarkdown } from './chunk-7XGDMXC5.js';
3
3
  import './chunk-KOJPDCGQ.js';
4
4
  import { Toolbar } from './chunk-NPEI2QAN.js';
5
- import { safeHref, MARKDOWN_CALLOUT_TONES } from './chunk-KBZO4B33.js';
5
+ import { safeHref, MARKDOWN_CALLOUT_TONES } from './chunk-KMTOGF6T.js';
6
6
  import { Menu } from './chunk-ZMZNKDPO.js';
7
7
  import { FormField, Input } from './chunk-XQMRSL7Z.js';
8
8
  import './chunk-NICEDVZM.js';
@@ -184,6 +184,7 @@ function setList(kind) {
184
184
  }
185
185
  var splitItem = (state, dispatch) => {
186
186
  const { $from } = state.selection;
187
+ if ($from.parent.type.spec.code) return false;
187
188
  if ($from.depth < 2 || $from.node(-1).type !== N.list_item) return false;
188
189
  const checked = $from.node(-1).attrs.checked;
189
190
  return splitListItem(N.list_item, checked === null ? void 0 : { checked: false })(state, dispatch);
@@ -568,8 +569,10 @@ function buildKeymap(hooks) {
568
569
  "Mod-Enter": () => hooks.submit(),
569
570
  "Shift-Enter": softBreak,
570
571
  Enter: chainCommands(moveCell("down"), fenceToCode, exitCodeOnBlankLines, splitItem),
571
- Tab: chainCommands(moveCell("next"), sinkListItem(N2.list_item), indentCode),
572
- "Shift-Tab": chainCommands(moveCell("previous"), liftListItem(N2.list_item), outdentCode),
572
+ // THE CODE BLOCK FIRST: a code block can sit inside a list item, and Tab
573
+ // there indents the code line rather than nesting the item it is in.
574
+ Tab: chainCommands(moveCell("next"), indentCode, sinkListItem(N2.list_item)),
575
+ "Shift-Tab": chainCommands(moveCell("previous"), outdentCode, liftListItem(N2.list_item)),
573
576
  "Alt-F10": () => hooks.toolbar()
574
577
  };
575
578
  for (let level = 1; level <= 6; level++) {
@@ -1,3 +1,3 @@
1
- export { InlineRef } from '../chunk-6KCQXKFQ.js';
2
- import '../chunk-KBZO4B33.js';
1
+ export { InlineRef } from '../chunk-WTV24BFB.js';
2
+ import '../chunk-KMTOGF6T.js';
3
3
  import '../chunk-ODEQTPFM.js';
@@ -1,5 +1,5 @@
1
- export { LinkCard } from '../chunk-346EXHOR.js';
1
+ export { LinkCard } from '../chunk-PVMDBNZ5.js';
2
2
  import '../chunk-KOJPDCGQ.js';
3
- import '../chunk-KBZO4B33.js';
3
+ import '../chunk-KMTOGF6T.js';
4
4
  import '../chunk-RRRK2KB6.js';
5
5
  import '../chunk-ODEQTPFM.js';
@@ -19,8 +19,14 @@
19
19
  * (`> [!NOTE]`, GitHub's alert syntax), tables, thematic breaks and hard line
20
20
  * breaks.
21
21
  *
22
+ * A LIST ITEM IS A CONTAINER, as in CommonMark: its lines, with the item's
23
+ * content indent taken off, are read as blocks by this same grammar, so a
24
+ * fence, a table, a quote, a heading or a list inside an item is that block
25
+ * and never the text of a paragraph (see [BlockReader]).
26
+ *
22
27
  * WHAT IT DELIBERATELY DOES NOT: raw HTML (read as its own text, never
23
- * parsed), reference links, footnotes, bare autolink literals, setext
28
+ * parsed, though a line that would open an HTML block ends the paragraph
29
+ * above it, as it does to CommonMark; see [htmlBlockStart]), reference links, footnotes, bare autolink literals, setext
24
30
  * headings and indented code. Each is a shape these documents do not use, and
25
31
  * every one of them is a place a parser grows a branch nobody exercises.
26
32
  */
@@ -98,12 +104,40 @@ export interface MarkdownSpan {
98
104
  * serves the page and mean nothing to a reader.
99
105
  */
100
106
  export declare function safeHref(raw: string): string | null;
101
- /** Whether `line` closes a fence opened with `marker`. */
102
- export declare function markdownClosesFence(line: string, marker: MarkdownFence): boolean;
103
- /** The fence `line` opens, with its info string, or null when it opens none. */
107
+ /**
108
+ * Whether `line` closes a fence opened with `length` of `marker`'s character,
109
+ * by CommonMark's rule (4.5): a run of the SAME character AT LEAST AS LONG as
110
+ * the opening's, indented up to three spaces, and nothing after it but
111
+ * whitespace.
112
+ *
113
+ * THE LENGTH IS REQUIRED: it is the opening's, which [markdownFenceOf]
114
+ * answers. A default of three answered wrongly for every longer fence, and a
115
+ * caller that walked a body's lines with it ended a ```` block on its first
116
+ * ``` line.
117
+ *
118
+ * NOT `line.startsWith(marker)`. A closing fence carries NO INFO STRING, so a
119
+ * literal ```` ```ts ```` line inside a ```` ```sh ```` sample is content, and
120
+ * reading it as a close ended the block on its first line. A page teaching
121
+ * somebody how to write a fenced block is exactly that input, and one that
122
+ * shows a fence of three inside a block opened on four is the other half.
123
+ *
124
+ * A CLOSE MAY BE INDENTED UP TO THREE SPACES, whatever the opening's indent:
125
+ * a fence in a list item whose closing line sits a space further in than its
126
+ * opening still ends there.
127
+ */
128
+ export declare function markdownClosesFence(line: string, marker: MarkdownFence, length: number): boolean;
129
+ /**
130
+ * The fence `line` opens: its character (as `marker`), its `length` (three or
131
+ * more), its info string and the spaces it is indented by, or null when it
132
+ * opens none. Each line of the block loses up to that many spaces of its own,
133
+ * which is how CommonMark reads an indented fence, and only a run of the same
134
+ * character at least `length` long closes it ([markdownClosesFence]).
135
+ */
104
136
  export declare function markdownFenceOf(line: string): {
105
137
  marker: MarkdownFence;
138
+ length: number;
106
139
  lang: string;
140
+ indent: number;
107
141
  } | null;
108
142
  /** The ATX heading `line` is, or null. Closing hashes are decoration, not content. */
109
143
  export declare function markdownHeadingOf(line: string): {
@@ -122,6 +156,63 @@ export declare function parseMarkdownSpans(source: string): {
122
156
  lines: string[];
123
157
  spans: MarkdownSpan[];
124
158
  };
159
+ /**
160
+ * Whether `line` opens an HTML block of a kind that interrupts a paragraph.
161
+ *
162
+ * THIS GRAMMAR HAS NO HTML BLOCK: the line is read as text, as all raw HTML
163
+ * is. But CommonMark ends the paragraph above it there, and a lazy line or a
164
+ * table row ends there too, so a `<!-- marker -->` under a list item is a
165
+ * paragraph of its own rather than the item's last words, as every other
166
+ * reader draws it.
167
+ */
168
+ export declare function htmlBlockStart(line: string): boolean;
169
+ /**
170
+ * The block reader: ONE PASS over the document's lines, in order, with the
171
+ * containers still open (quotes, lists and their items) on a stack, as
172
+ * CommonMark's reference parser reads.
173
+ *
174
+ * EACH LINE IS MATCHED AGAINST THE OPEN CONTAINERS from the outside in: a
175
+ * quote takes a line that starts with `>`, with that marker off; a list item
176
+ * takes one indented to its content ([ItemStart.content]), with that indent
177
+ * off, and a blank line when the next line that is not blank is indented that
178
+ * far (so a blank line inside a fence or between two of an item's paragraphs
179
+ * keeps the item open). What is left of the line goes to the innermost
180
+ * container that took it: to its open fence or table, or as the start of a
181
+ * block, or as the next line of its paragraph. A container the line does not
182
+ * reach is closed, unless the line is a LAZY line: one that continues the
183
+ * paragraph left open at the innermost tip, through items and quotes alike
184
+ * (CommonMark 5.1 and 5.2), and starts no block of its own.
185
+ *
186
+ * WHY ONE PASS. A list item's blocks can only be read as blocks, so whether a
187
+ * lazy line continues a paragraph depends on what the item holds so far. An
188
+ * item read by collecting its lines and parsing them answered that by parsing
189
+ * the lines collected so far, once a lazy line, and a nested item did the
190
+ * same inside every one of those parses: n to the power depth + 1, twenty
191
+ * seconds for five kilobytes three items deep. Here the answer is the stack's
192
+ * own state, and every line is matched once against containers that are as
193
+ * deep as the document: the work is linear in the document for any nesting
194
+ * the document has, and the grammar's tests count it.
195
+ *
196
+ * LOOKING AHEAD reads a later line through the same containers ([peel]): the
197
+ * delimiter row under a table's header, the line after a blank one between
198
+ * two items, and the first line that is not blank after a run of them inside
199
+ * an item, which is answered once for the whole run.
200
+ */
201
+ /**
202
+ * How deep quotes and list items nest, at most. A line's markers past it are
203
+ * read as the line's text, as markdown-it's maxNesting reads them.
204
+ *
205
+ * WHY A CAP, AND WHY 100. The reader opens any depth in constant stack, but
206
+ * every consumer of the blocks walks them by recursion: the editor's read
207
+ * and write, the canonical spelling, and an application's renderer. Measured
208
+ * under Node's default stack in jsdom, `canonicalMarkdown` and the editor's
209
+ * read overflow at 1,250 nested list items (1,875 quotes), and a save after
210
+ * an edit at 1,407; the deepest nesting in crewlet's documentation, skills
211
+ * and examples is 2. A hundred is markdown-it's own default, a twelfth of
212
+ * the smallest overflow, and fifty times the deepest real page, so no page
213
+ * anybody writes meets it and no body anybody sends can take a reader down.
214
+ */
215
+ export declare const MAX_NESTING = 100;
125
216
  /** What one inline construct captured, by name. */
126
217
  export interface MarkdownInlineGroups {
127
218
  /** An escaped ASCII punctuation character, without its backslash. */
@@ -139,6 +230,8 @@ export interface MarkdownInlineGroups {
139
230
  strongUnder?: string;
140
231
  em?: string;
141
232
  emUnder?: string;
233
+ /** A strikethrough's run, one tilde or two. */
234
+ tilde?: string;
142
235
  del?: string;
143
236
  }
144
237
  /** One inline construct: where it starts and ends in the text, and what it captured. */
@@ -158,8 +251,16 @@ export interface MarkdownInlineMatch {
158
251
  */
159
252
  export declare function markdownInline(text: string): Generator<MarkdownInlineMatch>;
160
253
  /**
161
- * A code span's content as it reads: ONE leading and one trailing space go,
162
- * which is how CommonMark lets a span start with a backtick of its own.
254
+ * A code span's content as it reads, by CommonMark's rules (6.1).
255
+ *
256
+ * A LINE ENDING INSIDE IT IS A SPACE: a span wrapped across two lines of a
257
+ * paragraph is one run of code, and a reader that kept the line ending handed
258
+ * a writer a line that starts inside the span, where no escape can stop it
259
+ * reading as a block (an escape inside a span is a literal backslash).
260
+ *
261
+ * ONE SPACE GOES FROM EACH END when both ends have one and the content is not
262
+ * all spaces, which is how a span starts or ends with a backtick of its own
263
+ * (`` `` `a` `` `` holds `` `a` ``). A space at one end only is content.
163
264
  */
164
265
  export declare function markdownCodeText(code: string): string;
165
266
  /**
@@ -1,2 +1,2 @@
1
1
  import '../chunk-KOJPDCGQ.js';
2
- export { MARKDOWN_CALLOUT_NAMES, MARKDOWN_CALLOUT_TONES, markdownBreaks, markdownClosesFence, markdownCodeText, markdownFenceOf, markdownHeadingOf, markdownInline, markdownLines, parseMarkdown, parseMarkdownSpans, safeHref } from '../chunk-KBZO4B33.js';
2
+ export { MARKDOWN_CALLOUT_NAMES, MARKDOWN_CALLOUT_TONES, markdownBreaks, markdownClosesFence, markdownCodeText, markdownFenceOf, markdownHeadingOf, markdownInline, markdownLines, parseMarkdown, parseMarkdownSpans, safeHref } from '../chunk-KMTOGF6T.js';
@@ -1,9 +1,9 @@
1
- export { OPEN_IN_APP_CARD_LABELS, OpenInAppCard } from '../chunk-AH7R777J.js';
1
+ export { OPEN_IN_APP_CARD_LABELS, OpenInAppCard } from '../chunk-OBNOJ6IM.js';
2
2
  import '../chunk-KOJPDCGQ.js';
3
3
  import '../chunk-VRVNLJUA.js';
4
4
  import '../chunk-OAD4AXYJ.js';
5
5
  import '../chunk-NWKH5FF7.js';
6
- import '../chunk-KBZO4B33.js';
6
+ import '../chunk-KMTOGF6T.js';
7
7
  import '../chunk-SJ3EUCFD.js';
8
8
  import '../chunk-E7KRB77B.js';
9
9
  import '../chunk-AV2DXAEL.js';
@@ -67,7 +67,7 @@ export declare function writeMarkdown(doc: PMNode, source?: MarkdownSource): str
67
67
  * One block in the canonical spelling, checked: the first spelling that reads
68
68
  * back as what the writer sees, or the plainest when none does.
69
69
  */
70
- export declare function writeBlock(node: PMNode): string;
70
+ export declare function writeBlock(node: PMNode, marker?: string): string;
71
71
  /**
72
72
  * What a block SAYS: its structure and the attributes a reader sees, and its
73
73
  * text character by character with the marks each carries. The spelling (a
@@ -1,8 +1,8 @@
1
- export { RichEditor, preloadRichEditor } from '../chunk-GFNCMSYS.js';
2
- export { RICH_EDITOR_LABELS, richEditorLabels } from '../chunk-2DMTW2Y3.js';
1
+ export { RichEditor, preloadRichEditor } from '../chunk-LVHAGF4R.js';
2
+ export { RICH_EDITOR_LABELS, richEditorLabels } from '../chunk-DGXHQMNP.js';
3
3
  import '../chunk-KOJPDCGQ.js';
4
4
  import '../chunk-CWACQEPP.js';
5
- import '../chunk-KBZO4B33.js';
5
+ import '../chunk-KMTOGF6T.js';
6
6
  import '../chunk-WFAJYBLX.js';
7
7
  import '../chunk-IMF3CPTY.js';
8
8
  import '../chunk-XSPCITPN.js';
@@ -1,4 +1,4 @@
1
- export { canonicalMarkdown, roundTripMarkdown } from '../chunk-GBASM5EV.js';
2
- import '../chunk-7CSTEH5I.js';
1
+ export { canonicalMarkdown, roundTripMarkdown } from '../chunk-W5JAJJZO.js';
2
+ import '../chunk-7XGDMXC5.js';
3
3
  import '../chunk-KOJPDCGQ.js';
4
- import '../chunk-KBZO4B33.js';
4
+ import '../chunk-KMTOGF6T.js';