@usememos/editor 26.10.20 → 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/README.md +18 -0
- package/dist/base.css +4 -0
- package/dist/index.js +62 -21
- package/dist/index.js.map +2 -2
- package/dist/style.css +8 -0
- package/dist/types/extension.d.ts +8 -0
- package/dist/types/model.d.ts +7 -0
- package/dist/types/view/dom.d.ts +16 -5
- package/package.json +1 -1
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 {
|
|
@@ -324,6 +328,10 @@
|
|
|
324
328
|
.mbe-root > .mbe-block-view {
|
|
325
329
|
overflow: visible;
|
|
326
330
|
}
|
|
331
|
+
.mbe-root > .mbe-block-after {
|
|
332
|
+
cursor: default;
|
|
333
|
+
white-space: normal;
|
|
334
|
+
}
|
|
327
335
|
.mbe-root.mbe-readonly :is([data-mbe-tag], [data-mbe-mention]) {
|
|
328
336
|
cursor: pointer;
|
|
329
337
|
}
|
|
@@ -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 {
|
package/dist/types/model.d.ts
CHANGED
|
@@ -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[];
|
package/dist/types/view/dom.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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;
|
|
@@ -122,7 +127,9 @@ export declare class BlockRenderer {
|
|
|
122
127
|
/**
|
|
123
128
|
* Per block drawn by a block view, the element the view drew into (null
|
|
124
129
|
* 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.
|
|
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.
|
|
126
133
|
*/
|
|
127
134
|
private readonly hosted;
|
|
128
135
|
/** The document's Markdown options, for the Markdown inside an HTML section. */
|
|
@@ -162,11 +169,15 @@ export declare class BlockRenderer {
|
|
|
162
169
|
/** Whether a block view draws `block`: its blocks show their editable form only while the selection is in them. */
|
|
163
170
|
isHosted(block: Block): boolean;
|
|
164
171
|
/**
|
|
165
|
-
* The element a block view drew `block` into
|
|
166
|
-
*
|
|
167
|
-
* matching view that does not decline.
|
|
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.
|
|
168
177
|
*/
|
|
169
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;
|
|
170
181
|
private disposeHosted;
|
|
171
182
|
/** Lets every block view's element go: on destroy. */
|
|
172
183
|
destroy(): void;
|