@usememos/editor 26.10.19 → 26.10.21

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
@@ -275,6 +275,10 @@
275
275
  cursor: pointer;
276
276
  opacity: 0;
277
277
  }
278
+ .mbe-root .mbe-code-copy .mbe-icon {
279
+ width: 12px;
280
+ height: 12px;
281
+ }
278
282
  .mbe-root .mbe-code:hover .mbe-code-copy,
279
283
  .mbe-root .mbe-code-copy:focus-visible,
280
284
  .mbe-root .mbe-code-copy.mbe-copied {
@@ -294,7 +298,11 @@
294
298
  padding: 0;
295
299
  width: 12em;
296
300
  }
297
- :is(.mbe-root, .mbe-flow) > .mbe-code pre,
301
+ :is(.mbe-root, .mbe-flow) > .mbe-code pre {
302
+ white-space: pre;
303
+ overflow-x: auto;
304
+ tab-size: 2;
305
+ }
298
306
  :is(.mbe-root, .mbe-flow) > pre.mbe-raw {
299
307
  white-space: pre-wrap;
300
308
  tab-size: 2;
@@ -320,6 +328,10 @@
320
328
  .mbe-root > .mbe-block-view {
321
329
  overflow: visible;
322
330
  }
331
+ .mbe-root > .mbe-block-after {
332
+ cursor: default;
333
+ white-space: normal;
334
+ }
323
335
  .mbe-root.mbe-readonly :is([data-mbe-tag], [data-mbe-mention]) {
324
336
  cursor: pointer;
325
337
  }
@@ -378,11 +390,13 @@
378
390
  :is(.mbe-root, .mbe-flow) > .mbe-table th,
379
391
  :is(.mbe-root, .mbe-flow) > .mbe-table td {
380
392
  padding: 4px 8px;
381
- min-width: 4em;
382
393
  vertical-align: top;
383
394
  text-align: start;
384
395
  outline: none;
385
396
  }
397
+ .mbe-root:not(.mbe-readonly) > .mbe-table :is(th, td).mbe-empty-content {
398
+ min-width: 4em;
399
+ }
386
400
  :is(.mbe-root, .mbe-flow) > [data-in-section] {
387
401
  margin-inline-start: calc(var(--mbe-section-depth, 0) * var(--mbe-indent-size));
388
402
  }
@@ -1033,10 +1047,6 @@
1033
1047
  border: 1px solid var(--mbe-border);
1034
1048
  border-radius: var(--mbe-radius);
1035
1049
  }
1036
- :is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td) {
1037
- padding: 6px 10px;
1038
- min-width: 8em;
1039
- }
1040
1050
  :is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td):not(:first-child) {
1041
1051
  border-inline-start: 1px solid var(--mbe-border);
1042
1052
  }
package/dist/theme.css CHANGED
@@ -231,7 +231,6 @@
231
231
  border: 1px solid var(--mbe-border);
232
232
  border-radius: var(--mbe-radius);
233
233
  }
234
- :is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td) { padding: 6px 10px; min-width: 8em; }
235
234
  :is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td):not(:first-child) { border-inline-start: 1px solid var(--mbe-border); }
236
235
  :is(.mbe-root, .mbe-flow) > .mbe-table tr:not(:first-child) > * { border-top: 1px solid var(--mbe-border); }
237
236
  :is(.mbe-root, .mbe-flow) > .mbe-table th { font-weight: 500; background: var(--mbe-block-code-bg); }
@@ -45,10 +45,18 @@ export type SyntaxView = (source: string, element: HTMLElement, kind: 'inline' |
45
45
  * it. While editing, the block shows as the editor draws it, editable, when
46
46
  * the selection is in it, as a rendered formula shows its source; read-only
47
47
  * always shows the view.
48
+ *
49
+ * `placement` says where the element goes. `replace` (the default) draws it
50
+ * in place of the block. `after` keeps the block as the editor draws it and
51
+ * places the element after it, like a widget, for UI that adds to the text
52
+ * instead of standing in for it: a preview card for a link that sits on its
53
+ * own line of a paragraph. The element is still withheld while the selection
54
+ * is in the block, so a link being typed is not previewed on every keystroke.
48
55
  */
49
56
  export interface BlockView {
50
57
  readonly match: (block: Block) => boolean;
51
58
  readonly render: (block: Block, element: HTMLElement, ctx: ExtensionContext) => void | false | (() => void);
59
+ readonly placement?: 'replace' | 'after';
52
60
  }
53
61
  /** A code block's code, for decorations such as syntax highlighting. */
54
62
  export interface CodeDecorationContext {
@@ -248,6 +248,13 @@ export declare function sameMarks(a: readonly Mark[], b: readonly Mark[]): boole
248
248
  export declare function sameLink(a: Pick<Span, 'link' | 'linkTitle'>, b: Pick<Span, 'link' | 'linkTitle'> | undefined): boolean;
249
249
  export declare function inlineText(inline: Inline): string;
250
250
  export declare function inlineLength(inline: Inline): number;
251
+ /**
252
+ * The lines of inline content: the spans between its line breaks (`"\n"`),
253
+ * without the breaks, each line keeping its spans' format. Content with no
254
+ * break is one line; an empty line is an empty array. With the `breaks`
255
+ * Markdown option a line is what the user wrote on one line.
256
+ */
257
+ export declare function inlineLines(inline: Inline): Inline[];
251
258
  export declare function normalizeInline(inline: Inline): Span[];
252
259
  export declare function sliceInline(inline: Inline, from: number, to?: number): Span[];
253
260
  export declare function concatInline(...parts: Inline[]): Span[];
@@ -34,7 +34,12 @@ export interface RenderContext {
34
34
  readonly views?: ReadonlyMap<string, SyntaxView>;
35
35
  /** A token or raw block of an extension syntax, rendered; null shows its source. */
36
36
  readonly view?: (syntax: string, source: string, kind: 'inline' | 'block') => HTMLElement | null;
37
- /** The element an extension's block view draws a block of the document into, or null for none (see `BlockView`). */
37
+ /**
38
+ * The element an extension's block view draws a block of the document
39
+ * into, in place of the block, or null for none (see `BlockView`). A view
40
+ * placed after its block draws the block as usual: the renderer places
41
+ * its element itself.
42
+ */
38
43
  readonly blockView?: (block: Block) => HTMLElement | null;
39
44
  /** The document's Markdown options, for the Markdown inside an HTML section. */
40
45
  readonly markdown?: MarkdownOptions;
@@ -67,6 +72,13 @@ export declare function calloutName(type: CalloutType): `callout${Capitalize<Cal
67
72
  * `renderMarkdown`), and an extension's own `markdown` view replaces it.
68
73
  */
69
74
  export declare const MARKDOWN_VIEW: SyntaxView;
75
+ /**
76
+ * Inline content with each tag or comment of raw HTML as its own span.
77
+ * Adjacent `html` spans are joined first, so several tags that
78
+ * `normalizeInline` merged (`</rt></ruby><ruby>`) come apart, and a tag an
79
+ * edit left in two spans is whole again. Everything else is unchanged.
80
+ */
81
+ export declare function splitHtmlSpans(inline: Inline): Inline;
70
82
  /**
71
83
  * Runs of inline raw HTML that render as one piece: an opening tag through
72
84
  * its closing tag, with the text between (`<kbd>Ctrl</kbd>`), or a single tag
@@ -115,7 +127,9 @@ export declare class BlockRenderer {
115
127
  /**
116
128
  * Per block drawn by a block view, the element the view drew into (null
117
129
  * when every matching view declined), kept while the block object is the
118
- * same, and the function to call when the element is let go.
130
+ * same, and the function to call when the element is let go. A view placed
131
+ * after its block has `after`: the editor's wrapper around that element,
132
+ * placed after the block's element.
119
133
  */
120
134
  private readonly hosted;
121
135
  /** The document's Markdown options, for the Markdown inside an HTML section. */
@@ -155,11 +169,15 @@ export declare class BlockRenderer {
155
169
  /** Whether a block view draws `block`: its blocks show their editable form only while the selection is in them. */
156
170
  isHosted(block: Block): boolean;
157
171
  /**
158
- * The element a block view drew `block` into: the one from the last render
159
- * while the block object is the same, else a fresh one from the first
160
- * matching view that does not decline. Null when none draws it.
172
+ * The element a block view drew `block` into, to show in place of the
173
+ * block: the one from the last render while the block object is the same,
174
+ * else a fresh one from the first matching view that does not decline.
175
+ * Null when none draws it, and for a view placed after the block, whose
176
+ * element `afterView` gives.
161
177
  */
162
178
  private renderBlockView;
179
+ /** The element of a block view placed after `block`, while the block shows the view (not its editable form). */
180
+ private afterView;
163
181
  private disposeHosted;
164
182
  /** Lets every block view's element go: on destroy. */
165
183
  destroy(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usememos/editor",
3
- "version": "26.10.19",
3
+ "version": "26.10.21",
4
4
  "description": "A block editor for Markdown. Zero runtime dependencies, with an optional React component.",
5
5
  "keywords": [
6
6
  "markdown",