@usememos/editor 26.10.18 → 26.10.20
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 +26 -7
- package/dist/base.css +11 -3
- package/dist/index.js +228 -31
- package/dist/index.js.map +3 -3
- package/dist/style.css +17 -6
- package/dist/theme.css +2 -1
- package/dist/types/commands.d.ts +9 -0
- package/dist/types/editor.d.ts +25 -2
- package/dist/types/extension.d.ts +35 -3
- package/dist/types/extensions/tags.d.ts +15 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/theme.d.ts +2 -0
- package/dist/types/view/dom.d.ts +44 -1
- package/dist/types/view/reveal.d.ts +10 -5
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -294,7 +294,11 @@
|
|
|
294
294
|
padding: 0;
|
|
295
295
|
width: 12em;
|
|
296
296
|
}
|
|
297
|
-
:is(.mbe-root, .mbe-flow) > .mbe-code pre
|
|
297
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre {
|
|
298
|
+
white-space: pre;
|
|
299
|
+
overflow-x: auto;
|
|
300
|
+
tab-size: 2;
|
|
301
|
+
}
|
|
298
302
|
:is(.mbe-root, .mbe-flow) > pre.mbe-raw {
|
|
299
303
|
white-space: pre-wrap;
|
|
300
304
|
tab-size: 2;
|
|
@@ -317,6 +321,12 @@
|
|
|
317
321
|
:is(.mbe-root, .mbe-flow) > .mbe-view-block > * {
|
|
318
322
|
margin-block: 0;
|
|
319
323
|
}
|
|
324
|
+
.mbe-root > .mbe-block-view {
|
|
325
|
+
overflow: visible;
|
|
326
|
+
}
|
|
327
|
+
.mbe-root.mbe-readonly :is([data-mbe-tag], [data-mbe-mention]) {
|
|
328
|
+
cursor: pointer;
|
|
329
|
+
}
|
|
320
330
|
.mbe-root .mbe-view-block.mbe-view-html {
|
|
321
331
|
white-space: normal;
|
|
322
332
|
}
|
|
@@ -372,11 +382,13 @@
|
|
|
372
382
|
:is(.mbe-root, .mbe-flow) > .mbe-table th,
|
|
373
383
|
:is(.mbe-root, .mbe-flow) > .mbe-table td {
|
|
374
384
|
padding: 4px 8px;
|
|
375
|
-
min-width: 4em;
|
|
376
385
|
vertical-align: top;
|
|
377
386
|
text-align: start;
|
|
378
387
|
outline: none;
|
|
379
388
|
}
|
|
389
|
+
.mbe-root:not(.mbe-readonly) > .mbe-table :is(th, td).mbe-empty-content {
|
|
390
|
+
min-width: 4em;
|
|
391
|
+
}
|
|
380
392
|
:is(.mbe-root, .mbe-flow) > [data-in-section] {
|
|
381
393
|
margin-inline-start: calc(var(--mbe-section-depth, 0) * var(--mbe-indent-size));
|
|
382
394
|
}
|
|
@@ -817,6 +829,9 @@
|
|
|
817
829
|
.mbe-root.mbe-readonly .mbe-footnote-ref {
|
|
818
830
|
cursor: pointer;
|
|
819
831
|
}
|
|
832
|
+
.mbe-root.mbe-readonly [data-mbe-mention]:hover {
|
|
833
|
+
text-decoration: underline;
|
|
834
|
+
}
|
|
820
835
|
:is(.mbe-root, .mbe-flow) > .mbe-footnote {
|
|
821
836
|
font-size: 0.875em;
|
|
822
837
|
color: var(--mbe-muted);
|
|
@@ -1024,10 +1039,6 @@
|
|
|
1024
1039
|
border: 1px solid var(--mbe-border);
|
|
1025
1040
|
border-radius: var(--mbe-radius);
|
|
1026
1041
|
}
|
|
1027
|
-
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td) {
|
|
1028
|
-
padding: 6px 10px;
|
|
1029
|
-
min-width: 8em;
|
|
1030
|
-
}
|
|
1031
1042
|
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td):not(:first-child) {
|
|
1032
1043
|
border-inline-start: 1px solid var(--mbe-border);
|
|
1033
1044
|
}
|
package/dist/theme.css
CHANGED
|
@@ -110,6 +110,8 @@
|
|
|
110
110
|
/* Footnotes, rendered: a reference is a small raised label, a definition a small muted note. */
|
|
111
111
|
.mbe-root .mbe-footnote-ref { font-size: 0.75em; line-height: 0; color: var(--mbe-link); }
|
|
112
112
|
.mbe-root.mbe-readonly .mbe-footnote-ref { cursor: pointer; }
|
|
113
|
+
/* A mention with an onClick (tags.ts), read-only: underlined on hover, as a name that leads somewhere. */
|
|
114
|
+
.mbe-root.mbe-readonly [data-mbe-mention]:hover { text-decoration: underline; }
|
|
113
115
|
:is(.mbe-root, .mbe-flow) > .mbe-footnote { font-size: 0.875em; color: var(--mbe-muted); }
|
|
114
116
|
.mbe-root .mbe-footnote-label { margin-inline-end: 0.375em; color: var(--mbe-link); }
|
|
115
117
|
|
|
@@ -229,7 +231,6 @@
|
|
|
229
231
|
border: 1px solid var(--mbe-border);
|
|
230
232
|
border-radius: var(--mbe-radius);
|
|
231
233
|
}
|
|
232
|
-
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td) { padding: 6px 10px; min-width: 8em; }
|
|
233
234
|
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td):not(:first-child) { border-inline-start: 1px solid var(--mbe-border); }
|
|
234
235
|
:is(.mbe-root, .mbe-flow) > .mbe-table tr:not(:first-child) > * { border-top: 1px solid var(--mbe-border); }
|
|
235
236
|
:is(.mbe-root, .mbe-flow) > .mbe-table th { font-weight: 500; background: var(--mbe-block-code-bg); }
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -15,6 +15,15 @@ export declare function deleteBackward(state: EditorState): EditorState;
|
|
|
15
15
|
export declare function deleteForward(state: EditorState): EditorState;
|
|
16
16
|
/** Inserts text at the selection with the current format. "\n" is a hard line break. */
|
|
17
17
|
export declare function insertText(state: EditorState, text: string): EditorState;
|
|
18
|
+
/**
|
|
19
|
+
* Inserts a token such as `#tag` at the selection's focus, spaced as a word
|
|
20
|
+
* among words: a space before it unless the caret is at the start of the
|
|
21
|
+
* text or after whitespace, and a space after it unless one follows, which
|
|
22
|
+
* the caret moves past; either way the caret ends after that space. Selected
|
|
23
|
+
* text is kept, and the token takes the format at the caret as typed text
|
|
24
|
+
* would: plain in a code or raw block.
|
|
25
|
+
*/
|
|
26
|
+
export declare function insertToken(state: EditorState, token: string): EditorState;
|
|
18
27
|
/**
|
|
19
28
|
* ArrowDown on the last line of the last block, or ArrowUp on the first line
|
|
20
29
|
* of the first block, when that block is a code block, table or divider, or
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -221,6 +221,15 @@ export interface EditorCommands {
|
|
|
221
221
|
to: Position;
|
|
222
222
|
};
|
|
223
223
|
}): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Inserts a token such as `#tag` at the caret as a word of its own: with a
|
|
226
|
+
* space before it unless the caret is at the start of the text or after
|
|
227
|
+
* whitespace, and a space after it, reusing one that is already there; the
|
|
228
|
+
* caret ends after that space. Selected text is kept. The token is plain
|
|
229
|
+
* text in a code block or source mode, as typed text is. Does nothing, and
|
|
230
|
+
* returns false, while an input method is composing.
|
|
231
|
+
*/
|
|
232
|
+
insertToken(text: string): boolean;
|
|
224
233
|
insertMarkdown(markdown: string, options?: InsertMarkdownOptions): boolean;
|
|
225
234
|
insertTable(attrs?: {
|
|
226
235
|
rows?: number;
|
|
@@ -415,7 +424,7 @@ export declare class Editor {
|
|
|
415
424
|
on<K extends keyof EditorEvents>(type: K, handler: (payload: EditorEvents[K]) => void): () => void;
|
|
416
425
|
private emit;
|
|
417
426
|
private applyRuntime;
|
|
418
|
-
/** Sets the theme. Returns true when
|
|
427
|
+
/** Sets the theme. Returns true when every block must re-render, for new classes. */
|
|
419
428
|
private applyTheme;
|
|
420
429
|
/** Applies a command (a pure function of the state), records history, re-renders, and emits events. */
|
|
421
430
|
run(command: (state: EditorState) => EditorState | null, kind?: ChangeKind): boolean;
|
|
@@ -483,15 +492,29 @@ export declare class Editor {
|
|
|
483
492
|
* loading. Waits for an input method to finish composing.
|
|
484
493
|
*/
|
|
485
494
|
redecorate(): void;
|
|
495
|
+
/**
|
|
496
|
+
* Renders every view (`Extension.views`) again, or those of one syntax
|
|
497
|
+
* (`'math'`, `'code:mermaid'`), for when what a view shows depends on
|
|
498
|
+
* something besides its source that changed: a renderer that finished
|
|
499
|
+
* loading, or the font a diagram measured its text with. A view that
|
|
500
|
+
* failed is tried again. Only the blocks that show those views render
|
|
501
|
+
* again. The editor calls it itself when the theme's font tokens change.
|
|
502
|
+
* Waits for an input method to finish composing.
|
|
503
|
+
*/
|
|
504
|
+
refreshViews(syntax?: string): void;
|
|
505
|
+
/** Renders the given blocks again now, or when the composition in progress settles. */
|
|
506
|
+
private renderBlocksAgain;
|
|
486
507
|
/**
|
|
487
508
|
* Views that returned a promise settled: their blocks render again on the
|
|
488
509
|
* next frame, or when a composition settles, since rendering would end it.
|
|
489
510
|
*/
|
|
490
511
|
private viewsSettled;
|
|
491
|
-
/** A block rendered by a view (a formula block, a diagram), or null. */
|
|
512
|
+
/** A block rendered by a view (a formula block, a diagram, a block an extension's block view draws), or null. */
|
|
492
513
|
private viewBlock;
|
|
493
514
|
/** Re-renders if the views that show their source changed: after the selection, focus or editability changes. */
|
|
494
515
|
private refreshRevealed;
|
|
516
|
+
/** Whether an extension's block view draws `block` (see `BlockView`). */
|
|
517
|
+
private readonly hosted;
|
|
495
518
|
private onMouseUp;
|
|
496
519
|
/**
|
|
497
520
|
* When an arrow key at the edge of a block would move past a rendered raw
|
|
@@ -2,7 +2,7 @@ import type { Decoration, Decorator } from './decorations.js';
|
|
|
2
2
|
import type { Editor } from './editor.js';
|
|
3
3
|
import type { SuggestionConfig } from './extensions/suggestion.js';
|
|
4
4
|
import type { MarkdownSyntax } from './markdown/options.js';
|
|
5
|
-
import type { CodeBlock, Position } from './model.js';
|
|
5
|
+
import type { Block, CodeBlock, Position } from './model.js';
|
|
6
6
|
import type { ThemeClasses } from './theme.js';
|
|
7
7
|
export interface ExtensionContext {
|
|
8
8
|
readonly editor: Editor;
|
|
@@ -16,14 +16,40 @@ export type KeyHandler = (ctx: ExtensionContext) => boolean;
|
|
|
16
16
|
* Renders the Markdown source of a token (`kind` is `inline`, `element` a
|
|
17
17
|
* span), a raw block, or the code of a code block (`block`, a div) into
|
|
18
18
|
* `element`. Returns false, or throws, to show the source instead. Results
|
|
19
|
-
* are cached by source, so the output must depend on nothing else
|
|
19
|
+
* are cached by source, so the output must depend on nothing else; what a
|
|
20
|
+
* view reads from the editor instead (its font, for a layout that measures
|
|
21
|
+
* text) is current again after `editor.refreshViews()`, which the editor
|
|
22
|
+
* calls itself when the theme's font tokens change.
|
|
23
|
+
*
|
|
24
|
+
* `element` is not in the page yet, so it has no layout. A view that
|
|
25
|
+
* measures text uses the editor: `getComputedStyle(ctx.editor.root)` gives
|
|
26
|
+
* the font the view's text will have, for a canvas `measureText`.
|
|
20
27
|
*
|
|
21
28
|
* A view that finishes later (a diagram, a renderer that loads on demand)
|
|
22
29
|
* fills in what it can at once and returns a promise: the editor shows that
|
|
23
30
|
* meanwhile, and the finished element when the promise resolves. A promise
|
|
24
31
|
* that rejects or resolves to false shows the source.
|
|
25
32
|
*/
|
|
26
|
-
export type SyntaxView = (source: string, element: HTMLElement, kind: 'inline' | 'block') => void | false | PromiseLike<void | false>;
|
|
33
|
+
export type SyntaxView = (source: string, element: HTMLElement, kind: 'inline' | 'block', ctx: ExtensionContext) => void | false | PromiseLike<void | false>;
|
|
34
|
+
/**
|
|
35
|
+
* Draws whole blocks the app wants to show its own way, such as a paragraph
|
|
36
|
+
* that is one bare link shown as a preview card with data from a server.
|
|
37
|
+
* `match` picks the blocks; `render` draws one into `element`, a div the
|
|
38
|
+
* editor owns and keeps while the block is unchanged: typing elsewhere, a
|
|
39
|
+
* new selection or `redecorate()` never call `render` again, so app UI
|
|
40
|
+
* mounted into the element (a React portal) stays. The editor calls `render`
|
|
41
|
+
* again for a block whose content changed, and for a new block. It calls the
|
|
42
|
+
* function `render` returned when it lets the element go: the block was
|
|
43
|
+
* removed or changed, `editor.refreshViews()` ran, or the editor was
|
|
44
|
+
* destroyed. `render` returns false to leave the block as the editor draws
|
|
45
|
+
* it. While editing, the block shows as the editor draws it, editable, when
|
|
46
|
+
* the selection is in it, as a rendered formula shows its source; read-only
|
|
47
|
+
* always shows the view.
|
|
48
|
+
*/
|
|
49
|
+
export interface BlockView {
|
|
50
|
+
readonly match: (block: Block) => boolean;
|
|
51
|
+
readonly render: (block: Block, element: HTMLElement, ctx: ExtensionContext) => void | false | (() => void);
|
|
52
|
+
}
|
|
27
53
|
/** A code block's code, for decorations such as syntax highlighting. */
|
|
28
54
|
export interface CodeDecorationContext {
|
|
29
55
|
readonly block: CodeBlock;
|
|
@@ -78,6 +104,12 @@ export interface Extension {
|
|
|
78
104
|
* same. Read-only always shows the rendered view.
|
|
79
105
|
*/
|
|
80
106
|
readonly views?: Readonly<Record<string, SyntaxView>>;
|
|
107
|
+
/**
|
|
108
|
+
* Draws the blocks `match` picks with `render`, in place of the editor's
|
|
109
|
+
* own rendering; see `BlockView`. `editor.refreshViews(name)`, with this
|
|
110
|
+
* extension's name, draws them again.
|
|
111
|
+
*/
|
|
112
|
+
readonly blockView?: BlockView;
|
|
81
113
|
/**
|
|
82
114
|
* Theme classes for the elements this extension cares about, such as
|
|
83
115
|
* `token.math`. The editor's `theme` wins for the same key, and an earlier
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type TextRange } from '../decorations.js';
|
|
2
|
+
import type { Editor } from '../editor.js';
|
|
2
3
|
import type { Extension } from '../extension.js';
|
|
3
4
|
/** Finds tags or mentions in `text[from, to)`. `text` is the whole container, so a scanner can look before `from`. */
|
|
4
5
|
export type TagScanner = (text: string, from: number, to: number) => Iterable<TextRange>;
|
|
@@ -13,6 +14,20 @@ export interface TagsOptions {
|
|
|
13
14
|
readonly attributes?: Readonly<Record<string, string>> | ((match: string) => Readonly<Record<string, string>> | undefined);
|
|
14
15
|
/** Finds matches in a run of text. Default `scanTags` or `scanMentions`. */
|
|
15
16
|
readonly scan?: TagScanner;
|
|
17
|
+
/**
|
|
18
|
+
* Called when a match is clicked to be followed, as `onLinkClick` is for a
|
|
19
|
+
* link: a plain click while read-only, Mod+click while editing. `match` is
|
|
20
|
+
* the text as written (`#work/planning`). Return true to handle it: the
|
|
21
|
+
* click then goes no further, neither to the browser nor to the page's
|
|
22
|
+
* own listeners. With this option, read-only matches show a pointer
|
|
23
|
+
* cursor, and mentions underline on hover; the editor marks each match with
|
|
24
|
+
* `data-mbe-tag` or `data-mbe-mention`.
|
|
25
|
+
*/
|
|
26
|
+
readonly onClick?: (ctx: {
|
|
27
|
+
readonly editor: Editor;
|
|
28
|
+
readonly match: string;
|
|
29
|
+
readonly event: MouseEvent;
|
|
30
|
+
}) => boolean | void;
|
|
16
31
|
}
|
|
17
32
|
/**
|
|
18
33
|
* The default tag grammar, memos': `#` and one or more segments separated
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type { EditorMode } from './sourceMode.js';
|
|
|
12
12
|
export type { MarkdownOptions } from './markdown/options.js';
|
|
13
13
|
export { docToHtml } from './clipboard/toHtml.js';
|
|
14
14
|
export { htmlToDoc } from './clipboard/fromHtml.js';
|
|
15
|
-
export type { CodeDecorationContext, Extension, ExtensionContext, KeyHandler, SyntaxView } from './extension.js';
|
|
15
|
+
export type { BlockView, CodeDecorationContext, Extension, ExtensionContext, KeyHandler, SyntaxView } from './extension.js';
|
|
16
16
|
export type { ColorScheme, Theme, ThemeClasses, ThemeColors, ThemeTokens } from './theme.js';
|
|
17
17
|
export { defaultKeymap } from './extensions/keymap.js';
|
|
18
18
|
export { math, type MathOptions } from './extensions/math.js';
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -88,6 +88,8 @@ export interface Theme {
|
|
|
88
88
|
}
|
|
89
89
|
/** Merges class maps; a later map wins for the same key, and `heading` and `token` merge per entry. */
|
|
90
90
|
export declare function mergeClasses(maps: readonly (ThemeClasses | undefined)[]): ThemeClasses;
|
|
91
|
+
/** The token properties that change how text measures: a view that laid out text (a diagram) renders again when one changes. */
|
|
92
|
+
export declare const FONT_PROPERTIES: readonly string[];
|
|
91
93
|
/**
|
|
92
94
|
* The custom properties for `tokens`. Colors go in `--mbe-<name>-light` and
|
|
93
95
|
* `--mbe-<name>-dark`, which the stylesheet picks between with `light-dark()`.
|
package/dist/types/view/dom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Block, type Cell, type CalloutType, type CodeBlock, type Doc, type Inline, type Position } from '../model.js';
|
|
2
|
-
import type { SyntaxView } from '../extension.js';
|
|
2
|
+
import type { BlockView, ExtensionContext, SyntaxView } from '../extension.js';
|
|
3
3
|
import type { Labels } from '../labels.js';
|
|
4
4
|
import type { IconName } from '../icons.js';
|
|
5
5
|
import type { ThemeClasses } from '../theme.js';
|
|
@@ -34,6 +34,8 @@ 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`). */
|
|
38
|
+
readonly blockView?: (block: Block) => HTMLElement | null;
|
|
37
39
|
/** The document's Markdown options, for the Markdown inside an HTML section. */
|
|
38
40
|
readonly markdown?: MarkdownOptions;
|
|
39
41
|
/** Theme classes for rendered elements. */
|
|
@@ -65,6 +67,13 @@ export declare function calloutName(type: CalloutType): `callout${Capitalize<Cal
|
|
|
65
67
|
* `renderMarkdown`), and an extension's own `markdown` view replaces it.
|
|
66
68
|
*/
|
|
67
69
|
export declare const MARKDOWN_VIEW: SyntaxView;
|
|
70
|
+
/**
|
|
71
|
+
* Inline content with each tag or comment of raw HTML as its own span.
|
|
72
|
+
* Adjacent `html` spans are joined first, so several tags that
|
|
73
|
+
* `normalizeInline` merged (`</rt></ruby><ruby>`) come apart, and a tag an
|
|
74
|
+
* edit left in two spans is whole again. Everything else is unchanged.
|
|
75
|
+
*/
|
|
76
|
+
export declare function splitHtmlSpans(inline: Inline): Inline;
|
|
68
77
|
/**
|
|
69
78
|
* Runs of inline raw HTML that render as one piece: an opening tag through
|
|
70
79
|
* its closing tag, with the text between (`<kbd>Ctrl</kbd>`), or a single tag
|
|
@@ -103,6 +112,19 @@ export declare class BlockRenderer {
|
|
|
103
112
|
widgetsAfter?: (blockId: string) => readonly HTMLElement[] | undefined;
|
|
104
113
|
/** Views of extension syntaxes, by syntax name. */
|
|
105
114
|
views?: ReadonlyMap<string, SyntaxView>;
|
|
115
|
+
/** What a view gets besides its source: the editor. Set with `views`. */
|
|
116
|
+
viewContext?: ExtensionContext;
|
|
117
|
+
/** Block views of extensions, with the extension's name, in extension order. */
|
|
118
|
+
blockViews: readonly {
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly view: BlockView;
|
|
121
|
+
}[];
|
|
122
|
+
/**
|
|
123
|
+
* Per block drawn by a block view, the element the view drew into (null
|
|
124
|
+
* when every matching view declined), kept while the block object is the
|
|
125
|
+
* same, and the function to call when the element is let go.
|
|
126
|
+
*/
|
|
127
|
+
private readonly hosted;
|
|
106
128
|
/** The document's Markdown options, for the Markdown inside an HTML section. */
|
|
107
129
|
markdown?: MarkdownOptions;
|
|
108
130
|
/** Theme classes for rendered elements. Set before a full render. */
|
|
@@ -128,6 +150,8 @@ export declare class BlockRenderer {
|
|
|
128
150
|
private readonly pendingViews;
|
|
129
151
|
/** Views whose promise rejected or resolved to false: their source shows. */
|
|
130
152
|
private readonly failedViews;
|
|
153
|
+
/** Per cached or failed view, the blocks that showed it, to render again when `dropViews` forgets it. */
|
|
154
|
+
private readonly viewBlocks;
|
|
131
155
|
/** The block being rendered, so a pending view knows which blocks to render again. */
|
|
132
156
|
private renderingBlock;
|
|
133
157
|
/** During a render, the loaded images of the block elements it replaces, by `src`. */
|
|
@@ -135,11 +159,30 @@ export declare class BlockRenderer {
|
|
|
135
159
|
constructor(root: HTMLElement, labels: Labels);
|
|
136
160
|
private context;
|
|
137
161
|
private renderView;
|
|
162
|
+
/** Whether a block view draws `block`: its blocks show their editable form only while the selection is in them. */
|
|
163
|
+
isHosted(block: Block): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The element a block view drew `block` into: the one from the last render
|
|
166
|
+
* while the block object is the same, else a fresh one from the first
|
|
167
|
+
* matching view that does not decline. Null when none draws it.
|
|
168
|
+
*/
|
|
169
|
+
private renderBlockView;
|
|
170
|
+
private disposeHosted;
|
|
171
|
+
/** Lets every block view's element go: on destroy. */
|
|
172
|
+
destroy(): void;
|
|
173
|
+
private noteViewBlock;
|
|
138
174
|
/**
|
|
139
175
|
* A view that renders later (a diagram, a lazily loaded renderer) shows what
|
|
140
176
|
* it filled in at once, and its blocks render again when it settles.
|
|
141
177
|
*/
|
|
142
178
|
private awaitView;
|
|
179
|
+
/**
|
|
180
|
+
* Forgets rendered and failed views, of one syntax or all, so the next
|
|
181
|
+
* render runs the view again: for when what it shows depends on something
|
|
182
|
+
* besides its source that changed, such as the editor's font. Returns the
|
|
183
|
+
* rendered blocks that showed them, for the caller to render again.
|
|
184
|
+
*/
|
|
185
|
+
dropViews(syntax?: string): string[];
|
|
143
186
|
/**
|
|
144
187
|
* `force` re-renders every block. `lazy` (with a full render) lets blocks
|
|
145
188
|
* skip layout while off screen; use it only when loading a document.
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { SyntaxView } from '../extension.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Block, type EditorState, type Position } from '../model.js';
|
|
3
3
|
import { type BlockReveal } from './dom.js';
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Per block, the views that show their source. Empty when `active` is false
|
|
6
|
+
* (read-only or unfocused). `hosted` says whether an extension's block view
|
|
7
|
+
* draws a block, which then shows its editable form instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare function revealedViews(state: EditorState, views: ReadonlyMap<string, SyntaxView>, active: boolean, hosted?: (block: Block) => boolean): Map<string, BlockReveal>;
|
|
6
10
|
export declare function sameRevealed(a: ReadonlyMap<string, BlockReveal>, b: ReadonlyMap<string, BlockReveal>): boolean;
|
|
7
11
|
/**
|
|
8
12
|
* Where the caret goes in a rendered block's source. A raw block: past its
|
|
9
13
|
* opening line going forward (such as a `$$` fence), at the end of its
|
|
10
14
|
* next-to-last line going back or on a click. A code block holds only the
|
|
11
|
-
* code, and raw Markdown has no fence: their start or their end.
|
|
15
|
+
* code, and raw Markdown has no fence: their start or their end. So does any
|
|
16
|
+
* other block drawn by a block view; a table, its first or last cell.
|
|
12
17
|
*/
|
|
13
|
-
export declare function viewEntry(block:
|
|
18
|
+
export declare function viewEntry(block: Block, forward: boolean): Position;
|