@usememos/editor 26.10.14 → 26.10.15

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/style.css CHANGED
@@ -39,21 +39,52 @@
39
39
  margin-top: 16px;
40
40
  margin-bottom: 4px;
41
41
  }
42
+ :is(.mbe-root, .mbe-flow) > blockquote[data-quote-continued] {
43
+ margin-bottom: 0;
44
+ }
42
45
  :is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] {
43
- margin-top: calc(-1 * var(--mbe-block-gap));
46
+ margin-top: 0;
47
+ padding-top: var(--mbe-block-gap);
48
+ }
49
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-quote-joined] {
50
+ margin-top: 0;
51
+ }
52
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-quote-joined]:not([data-list-start]) {
53
+ padding-top: 2px;
54
+ }
55
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
56
+ --mbe-callout-pad: 12px;
57
+ position: relative;
58
+ padding-block: var(--mbe-callout-pad);
59
+ padding-inline: calc(var(--mbe-callout-pad) + 28px) 16px;
60
+ }
61
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] {
44
62
  padding-top: var(--mbe-block-gap);
45
63
  }
46
- .mbe-root .mbe-callout-title {
64
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] {
65
+ padding-bottom: 0;
66
+ }
67
+ .mbe-root .mbe-callout-icon {
68
+ position: absolute;
69
+ top: var(--mbe-callout-pad);
70
+ inset-inline-start: calc(var(--mbe-callout-pad) - 2px);
47
71
  display: flex;
48
72
  align-items: center;
49
- gap: 8px;
73
+ justify-content: center;
74
+ width: 24px;
75
+ height: 1.5em;
76
+ height: 1lh;
50
77
  user-select: none;
51
78
  -webkit-user-select: none;
52
79
  }
53
- :is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] > .mbe-callout-title {
80
+ .mbe-root .mbe-callout-icon > .mbe-icon {
81
+ width: 18px;
82
+ height: 18px;
83
+ }
84
+ :is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] > .mbe-callout-icon {
54
85
  display: none;
55
86
  }
56
- .mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-title {
87
+ .mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon {
57
88
  cursor: pointer;
58
89
  }
59
90
  :is(.mbe-root, .mbe-flow) > .mbe-details {
@@ -113,21 +144,36 @@
113
144
  :is(.mbe-root, .mbe-flow) > .mbe-list-item[data-list-start] {
114
145
  margin-top: var(--mbe-block-gap);
115
146
  }
116
- :is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="1"] {
147
+ :is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="1"] {
117
148
  padding-inline-start: var(--mbe-indent-size);
118
149
  }
119
- :is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="2"] {
150
+ :is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="2"] {
120
151
  padding-inline-start: calc(2 * var(--mbe-indent-size));
121
152
  }
122
- :is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="3"] {
153
+ :is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="3"] {
123
154
  padding-inline-start: calc(3 * var(--mbe-indent-size));
124
155
  }
125
- :is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="4"] {
156
+ :is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="4"] {
126
157
  padding-inline-start: calc(4 * var(--mbe-indent-size));
127
158
  }
128
- :is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="5"] {
159
+ :is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="5"] {
129
160
  padding-inline-start: calc(5 * var(--mbe-indent-size));
130
161
  }
162
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="1"] > .mbe-marker {
163
+ margin-inline-start: var(--mbe-indent-size);
164
+ }
165
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="2"] > .mbe-marker {
166
+ margin-inline-start: calc(2 * var(--mbe-indent-size));
167
+ }
168
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="3"] > .mbe-marker {
169
+ margin-inline-start: calc(3 * var(--mbe-indent-size));
170
+ }
171
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="4"] > .mbe-marker {
172
+ margin-inline-start: calc(4 * var(--mbe-indent-size));
173
+ }
174
+ :is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="5"] > .mbe-marker {
175
+ margin-inline-start: calc(5 * var(--mbe-indent-size));
176
+ }
131
177
  .mbe-root .mbe-marker {
132
178
  flex: none;
133
179
  box-sizing: border-box;
@@ -337,7 +383,7 @@
337
383
  }
338
384
  .mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
339
385
  .mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
340
- .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
386
+ .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
341
387
  .mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
342
388
  .mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
343
389
  opacity: 0.5;
@@ -350,7 +396,7 @@
350
396
  .mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before {
351
397
  content: var(--mbe-slash-hint, "");
352
398
  }
353
- .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
399
+ .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
354
400
  .mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
355
401
  .mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
356
402
  content: attr(data-hint);
@@ -771,7 +817,17 @@
771
817
  }
772
818
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
773
819
  color: inherit;
774
- border-inline-start-color: var(--mbe-callout);
820
+ border-inline-start: 0;
821
+ border-radius: var(--mbe-radius);
822
+ background: color-mix(in oklab, var(--mbe-callout) 10%, transparent);
823
+ }
824
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] {
825
+ border-start-start-radius: 0;
826
+ border-start-end-radius: 0;
827
+ }
828
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] {
829
+ border-end-start-radius: 0;
830
+ border-end-end-radius: 0;
775
831
  }
776
832
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout=note] {
777
833
  --mbe-callout: var(--mbe-callout-note);
@@ -788,9 +844,12 @@
788
844
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout=caution] {
789
845
  --mbe-callout: var(--mbe-callout-caution);
790
846
  }
791
- .mbe-root .mbe-callout-title {
847
+ .mbe-root .mbe-callout-icon {
792
848
  color: var(--mbe-callout);
793
- font-weight: 500;
849
+ border-radius: 4px;
850
+ }
851
+ .mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon:hover {
852
+ background: color-mix(in oklab, var(--mbe-callout) 14%, transparent);
794
853
  }
795
854
  .mbe-root .mbe-marker {
796
855
  color: var(--mbe-muted);
@@ -972,7 +1031,7 @@
972
1031
  }
973
1032
  .mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
974
1033
  .mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
975
- .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
1034
+ .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
976
1035
  .mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
977
1036
  .mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
978
1037
  color: var(--mbe-muted);
package/dist/theme.css CHANGED
@@ -41,7 +41,7 @@
41
41
  0 2px 4px -2px light-dark(rgb(0 0 0 / 0.1), transparent);
42
42
  --mbe-block-code-bg: color-mix(in oklab, var(--mbe-code-bg) 45%, transparent);
43
43
  --mbe-quote-border: color-mix(in oklab, var(--mbe-muted) 25%, transparent);
44
- /* Callout colors, close to GitHub's alerts. */
44
+ /* Callout colors: the icon, and a tint of it behind the text. */
45
45
  --mbe-callout-note: light-dark(var(--mbe-callout-note-light, oklch(0.55 0.17 255)), var(--mbe-callout-note-dark, oklch(0.68 0.15 255)));
46
46
  --mbe-callout-tip: light-dark(var(--mbe-callout-tip-light, oklch(0.52 0.13 150)), var(--mbe-callout-tip-dark, oklch(0.72 0.17 150)));
47
47
  --mbe-callout-important: light-dark(var(--mbe-callout-important-light, oklch(0.52 0.2 295)), var(--mbe-callout-important-dark, oklch(0.7 0.15 295)));
@@ -120,14 +120,24 @@
120
120
  color: var(--mbe-muted);
121
121
  }
122
122
 
123
- /* Callouts: the type's color on the border and the title; the text keeps the body color. */
124
- :is(.mbe-root, .mbe-flow) > blockquote[data-callout] { color: inherit; border-inline-start-color: var(--mbe-callout); }
123
+ /* Callouts: a soft tint of the type's color behind body-colored text, with
124
+ the icon in the type's color and no border. Only the outer corners of a
125
+ callout are rounded. */
126
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
127
+ color: inherit;
128
+ border-inline-start: 0;
129
+ border-radius: var(--mbe-radius);
130
+ background: color-mix(in oklab, var(--mbe-callout) 10%, transparent);
131
+ }
132
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] { border-start-start-radius: 0; border-start-end-radius: 0; }
133
+ :is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] { border-end-start-radius: 0; border-end-end-radius: 0; }
125
134
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout='note'] { --mbe-callout: var(--mbe-callout-note); }
126
135
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout='tip'] { --mbe-callout: var(--mbe-callout-tip); }
127
136
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout='important'] { --mbe-callout: var(--mbe-callout-important); }
128
137
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout='warning'] { --mbe-callout: var(--mbe-callout-warning); }
129
138
  :is(.mbe-root, .mbe-flow) > blockquote[data-callout='caution'] { --mbe-callout: var(--mbe-callout-caution); }
130
- .mbe-root .mbe-callout-title { color: var(--mbe-callout); font-weight: 500; }
139
+ .mbe-root .mbe-callout-icon { color: var(--mbe-callout); border-radius: 4px; }
140
+ .mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon:hover { background: color-mix(in oklab, var(--mbe-callout) 14%, transparent); }
131
141
 
132
142
  /* Lists */
133
143
  .mbe-root .mbe-marker { color: var(--mbe-muted); }
@@ -230,7 +240,7 @@
230
240
  /* Placeholders and hints */
231
241
  .mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
232
242
  .mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
233
- .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
243
+ .mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
234
244
  .mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
235
245
  .mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
236
246
  color: var(--mbe-muted);
@@ -121,14 +121,14 @@ export type BlockTypeSpec = {
121
121
  */
122
122
  export declare function setBlockType(state: EditorState, spec: BlockTypeSpec): EditorState;
123
123
  /**
124
- * The quote blocks that form one blockquote with the quote `blockId`: its
125
- * neighbours with the same callout. Null when the block is not a quote.
124
+ * The blocks that form one blockquote with the block `blockId`: its
125
+ * neighbours in the same quote or callout. Null when the block is not in a quote.
126
126
  */
127
127
  export declare function quoteRun(state: EditorState, blockId: string): {
128
128
  start: number;
129
129
  end: number;
130
130
  } | null;
131
- /** Sets the callout of the whole blockquote with the quote `blockId`; null makes it a plain quote. */
131
+ /** Sets the callout of the whole blockquote with the block `blockId`; null makes it a plain quote. */
132
132
  export declare function setCallout(state: EditorState, blockId: string, callout: CalloutType | null): EditorState;
133
133
  /** The blocks the selection touches whose type the block type commands change. */
134
134
  export declare function convertibleBlocks(state: EditorState): Exclude<TextBlock, RawBlock>[];
@@ -1,4 +1,4 @@
1
- import { type Block, type Span } from '../model.js';
1
+ import { type Block, type CalloutType, type Span } from '../model.js';
2
2
  import { type BlockNode, type InlineNode } from './ast.js';
3
3
  import { type MarkdownOptions } from './options.js';
4
4
  /**
@@ -6,4 +6,14 @@ import { type MarkdownOptions } from './options.js';
6
6
  * one raw Markdown block holding `source`, the node's Markdown.
7
7
  */
8
8
  export declare function lowerTopLevel(node: BlockNode, options: MarkdownOptions, source: string): Block[];
9
+ /** Lowers one block node, or returns null when the model cannot hold its structure (see `fitsModel`). */
10
+ export declare function lowerIfFits(node: BlockNode, options: MarkdownOptions): Block[] | null;
9
11
  export declare function lowerInlines(nodes: readonly InlineNode[], options?: MarkdownOptions): Span[];
12
+ /**
13
+ * A GitHub alert: the first paragraph starts with a marker such as `[!NOTE]`
14
+ * alone on its line. Returns its type and the paragraph's content after the marker line.
15
+ */
16
+ export declare function calloutOf(children: readonly BlockNode[]): {
17
+ type: CalloutType;
18
+ rest: readonly InlineNode[];
19
+ } | null;
@@ -70,14 +70,18 @@ export interface ListItemBlock {
70
70
  readonly checked: boolean;
71
71
  /** Ordered items only: the number of the first item of a list. Ignored on later items. */
72
72
  readonly start?: number;
73
+ /** The item is inside a blockquote, with the quote blocks and quoted items around it (see `quoteKind`). */
74
+ readonly quote?: true;
75
+ /** Quoted items only: the item is inside a callout of this type. */
76
+ readonly callout?: CalloutType;
73
77
  readonly content: Inline;
74
78
  }
75
79
  /** The kinds of callout, as in GitHub's alert syntax (`> [!NOTE]`). */
76
80
  export declare const CALLOUT_TYPES: readonly ["note", "tip", "important", "warning", "caution"];
77
81
  export type CalloutType = (typeof CALLOUT_TYPES)[number];
78
82
  /**
79
- * One paragraph of a block quote. Adjacent quotes with the same `callout`
80
- * form one blockquote.
83
+ * One paragraph of a block quote. Adjacent quotes and quoted list items with
84
+ * the same `callout` form one blockquote (see `quoteKind`).
81
85
  */
82
86
  export interface QuoteBlock {
83
87
  readonly id: string;
@@ -165,11 +169,13 @@ export interface EditorState {
165
169
  export declare function createId(): string;
166
170
  export declare function paragraph(content?: Inline, id?: string): ParagraphBlock;
167
171
  export declare function heading(level: HeadingLevel, content?: Inline, id?: string): HeadingBlock;
172
+ /** `quote` puts the item inside a blockquote: `'quote'` for a plain quote, or a callout's type. */
168
173
  export declare function listItem(listType: ListType, content?: Inline, opts?: {
169
174
  indent?: number;
170
175
  checked?: boolean;
171
176
  start?: number;
172
177
  id?: string;
178
+ quote?: QuoteKind | null;
173
179
  }): ListItemBlock;
174
180
  export declare function quote(content?: Inline, id?: string, callout?: CalloutType): QuoteBlock;
175
181
  export declare function codeBlock(language?: string, text?: string, id?: string): CodeBlock;
@@ -186,6 +192,20 @@ export declare function details(content?: Inline, opts?: {
186
192
  }): DetailsBlock;
187
193
  export declare function detailsEnd(id?: string): DetailsEndBlock;
188
194
  export declare function plain(text: string): Span[];
195
+ /**
196
+ * Which blockquote a block is part of: `'quote'` for a plain quote, or the
197
+ * type of a callout. Quote blocks and quoted list items are the only blocks
198
+ * in quotes; adjacent ones of the same kind form one blockquote.
199
+ */
200
+ export type QuoteKind = 'quote' | CalloutType;
201
+ /** The blockquote a block is part of, or null for a block outside quotes. */
202
+ export declare function quoteKind(block: Block | undefined): QuoteKind | null;
203
+ /** True if `a` and `b` are parts of one blockquote when they are neighbours. */
204
+ export declare function sameQuote(a: Block | undefined, b: Block | undefined): boolean;
205
+ /** A list item moved into a blockquote of `kind`, or out of any with null. Keeps its ID. */
206
+ export declare function withQuote(item: ListItemBlock, kind: QuoteKind | null): ListItemBlock;
207
+ /** A block as it is inside its blockquote: a quote block is a paragraph there, and a quoted list item a plain one. */
208
+ export declare function unquote(block: Block): Block;
189
209
  export declare function isTextBlock(block: Block): block is TextBlock;
190
210
  /** Blocks with no text and no cells: dividers and the ends of collapsible sections. */
191
211
  export declare function isTextless(block: Block): block is DividerBlock | DetailsEndBlock;
@@ -54,7 +54,7 @@ export interface ThemeColors {
54
54
  /** Highlighted menu items and toolbar buttons. */
55
55
  readonly hover?: string;
56
56
  readonly danger?: string;
57
- /** The border and title of each callout type. */
57
+ /** The icon of each callout type, and a light tint of it behind the text. */
58
58
  readonly calloutNote?: string;
59
59
  readonly calloutTip?: string;
60
60
  readonly calloutImportant?: string;
@@ -4,7 +4,7 @@ import type { Labels } from '../labels.js';
4
4
  import type { IconName } from '../icons.js';
5
5
  import type { ThemeClasses } from '../theme.js';
6
6
  import { type Decoration } from '../decorations.js';
7
- import type { MarkdownOptions } from '../markdown/options.js';
7
+ import { type MarkdownOptions } from '../markdown/options.js';
8
8
  export declare const BLOCK_ATTR = "data-block-id";
9
9
  /** The view name for code blocks of a language: `code:mermaid`. */
10
10
  export declare function codeViewName(language: string): string;
@@ -57,6 +57,12 @@ export declare function tokenKey(cell: Cell | undefined, from: number): string;
57
57
  export declare function sameReveal(a: BlockReveal | undefined, b: BlockReveal | undefined): boolean;
58
58
  /** The label and icon name of a callout type, such as `calloutNote`. */
59
59
  export declare function calloutName(type: CalloutType): `callout${Capitalize<CalloutType>}`;
60
+ /**
61
+ * Marks the built-in view of raw Markdown blocks in `RenderContext.views`.
62
+ * It is never called: the renderer draws those blocks itself (see
63
+ * `renderMarkdown`), and an extension's own `markdown` view replaces it.
64
+ */
65
+ export declare const MARKDOWN_VIEW: SyntaxView;
60
66
  /**
61
67
  * Runs of inline raw HTML that render as one piece: an opening tag through
62
68
  * its closing tag, with the text between (`<kbd>Ctrl</kbd>`), or a single tag
@@ -8,6 +8,6 @@ export declare function sameRevealed(a: ReadonlyMap<string, BlockReveal>, b: Rea
8
8
  * Where the caret goes in a rendered block's source. A raw block: past its
9
9
  * opening line going forward (such as a `$$` fence), at the end of its
10
10
  * next-to-last line going back or on a click. A code block holds only the
11
- * code: its start or its end.
11
+ * code, and raw Markdown has no fence: their start or their end.
12
12
  */
13
13
  export declare function viewEntry(block: RawBlock | CodeBlock, forward: boolean): Position;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usememos/editor",
3
- "version": "26.10.14",
3
+ "version": "26.10.15",
4
4
  "description": "A block editor for Markdown. Zero runtime dependencies, with an optional React component.",
5
5
  "keywords": [
6
6
  "markdown",