@usememos/editor 26.10.9 → 26.10.11
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 +13 -10
- package/dist/base.css +43 -20
- package/dist/index.js +896 -179
- package/dist/index.js.map +4 -4
- package/dist/style.css +135 -27
- package/dist/theme.css +29 -10
- package/dist/types/commands.d.ts +20 -7
- package/dist/types/editor.d.ts +48 -9
- package/dist/types/icons.d.ts +37 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/labels.d.ts +14 -1
- package/dist/types/markdown/ast.d.ts +26 -7
- package/dist/types/model.d.ts +17 -0
- package/dist/types/ui/{handle.d.ts → blockHandle.d.ts} +2 -2
- package/dist/types/ui/popup.d.ts +34 -0
- package/dist/types/ui/{image.d.ts → resizeHandles.d.ts} +3 -3
- package/dist/types/ui/toolbar.d.ts +47 -6
- package/dist/types/view/dom.d.ts +4 -0
- package/package.json +2 -2
package/dist/style.css
CHANGED
|
@@ -106,11 +106,21 @@
|
|
|
106
106
|
cursor: pointer;
|
|
107
107
|
}
|
|
108
108
|
.mbe-root .mbe-image {
|
|
109
|
+
display: inline-block;
|
|
109
110
|
max-width: 100%;
|
|
110
111
|
height: auto;
|
|
111
112
|
margin: 8px 0;
|
|
112
113
|
vertical-align: bottom;
|
|
113
114
|
}
|
|
115
|
+
.mbe-root .mbe-image-block[data-align=left] {
|
|
116
|
+
text-align: left;
|
|
117
|
+
}
|
|
118
|
+
.mbe-root .mbe-image-block[data-align=center] {
|
|
119
|
+
text-align: center;
|
|
120
|
+
}
|
|
121
|
+
.mbe-root .mbe-image-block[data-align=right] {
|
|
122
|
+
text-align: right;
|
|
123
|
+
}
|
|
114
124
|
.mbe-root .mbe-image-unavailable {
|
|
115
125
|
display: inline-flex;
|
|
116
126
|
align-items: center;
|
|
@@ -260,7 +270,7 @@
|
|
|
260
270
|
}
|
|
261
271
|
.mbe-menu,
|
|
262
272
|
.mbe-toolbar,
|
|
263
|
-
.mbe-
|
|
273
|
+
.mbe-input-popover {
|
|
264
274
|
position: fixed;
|
|
265
275
|
background: Canvas;
|
|
266
276
|
color: CanvasText;
|
|
@@ -324,35 +334,92 @@
|
|
|
324
334
|
padding: 6px 8px;
|
|
325
335
|
}
|
|
326
336
|
.mbe-toolbar {
|
|
337
|
+
box-sizing: border-box;
|
|
327
338
|
display: flex;
|
|
328
339
|
align-items: center;
|
|
329
340
|
gap: 2px;
|
|
330
|
-
padding:
|
|
341
|
+
padding: 4px;
|
|
342
|
+
overflow-x: auto;
|
|
343
|
+
scrollbar-width: none;
|
|
344
|
+
}
|
|
345
|
+
.mbe-toolbar::-webkit-scrollbar {
|
|
346
|
+
display: none;
|
|
331
347
|
}
|
|
332
348
|
.mbe-tool {
|
|
349
|
+
flex: none;
|
|
333
350
|
font: inherit;
|
|
334
351
|
color: inherit;
|
|
335
352
|
background: none;
|
|
336
353
|
border: none;
|
|
337
|
-
padding: 4px
|
|
338
|
-
min-width:
|
|
339
|
-
min-height:
|
|
354
|
+
padding: 4px 7px;
|
|
355
|
+
min-width: 32px;
|
|
356
|
+
min-height: 32px;
|
|
340
357
|
display: inline-flex;
|
|
341
358
|
align-items: center;
|
|
342
359
|
justify-content: center;
|
|
343
360
|
cursor: pointer;
|
|
344
361
|
}
|
|
362
|
+
.mbe-tool[hidden],
|
|
363
|
+
.mbe-tool-sep[hidden] {
|
|
364
|
+
display: none;
|
|
365
|
+
}
|
|
366
|
+
.mbe-tool .mbe-icon {
|
|
367
|
+
width: 18px;
|
|
368
|
+
height: 18px;
|
|
369
|
+
}
|
|
370
|
+
.mbe-tool-menu {
|
|
371
|
+
gap: 1px;
|
|
372
|
+
padding-inline: 7px 4px;
|
|
373
|
+
}
|
|
374
|
+
.mbe-tool-icon,
|
|
375
|
+
.mbe-tool-chevron {
|
|
376
|
+
display: inline-flex;
|
|
377
|
+
}
|
|
378
|
+
.mbe-tool .mbe-tool-chevron .mbe-icon {
|
|
379
|
+
width: 13px;
|
|
380
|
+
height: 13px;
|
|
381
|
+
}
|
|
345
382
|
.mbe-tool.mbe-active {
|
|
346
383
|
background: Highlight;
|
|
347
384
|
color: HighlightText;
|
|
348
385
|
}
|
|
349
386
|
.mbe-tool-sep {
|
|
387
|
+
flex: none;
|
|
350
388
|
width: 1px;
|
|
351
|
-
|
|
352
|
-
margin: 3px
|
|
389
|
+
height: 18px;
|
|
390
|
+
margin: 0 3px;
|
|
353
391
|
background: GrayText;
|
|
354
392
|
}
|
|
355
|
-
.mbe-
|
|
393
|
+
.mbe-menu-check {
|
|
394
|
+
flex: none;
|
|
395
|
+
display: inline-flex;
|
|
396
|
+
margin-inline-start: auto;
|
|
397
|
+
}
|
|
398
|
+
.mbe-menu-submenu {
|
|
399
|
+
flex: none;
|
|
400
|
+
display: inline-flex;
|
|
401
|
+
margin-inline-start: auto;
|
|
402
|
+
}
|
|
403
|
+
.mbe-menu-submenu .mbe-icon {
|
|
404
|
+
width: 14px;
|
|
405
|
+
height: 14px;
|
|
406
|
+
}
|
|
407
|
+
.mbe-submenu {
|
|
408
|
+
min-width: 160px;
|
|
409
|
+
}
|
|
410
|
+
.mbe-menu-item[aria-expanded=true] {
|
|
411
|
+
background: Highlight;
|
|
412
|
+
color: HighlightText;
|
|
413
|
+
}
|
|
414
|
+
.mbe-tooltip {
|
|
415
|
+
position: fixed;
|
|
416
|
+
pointer-events: none;
|
|
417
|
+
white-space: nowrap;
|
|
418
|
+
padding: 4px 8px;
|
|
419
|
+
background: CanvasText;
|
|
420
|
+
color: Canvas;
|
|
421
|
+
}
|
|
422
|
+
.mbe-input-popover {
|
|
356
423
|
display: flex;
|
|
357
424
|
gap: 4px;
|
|
358
425
|
padding: 4px;
|
|
@@ -361,7 +428,7 @@
|
|
|
361
428
|
position: fixed;
|
|
362
429
|
pointer-events: none;
|
|
363
430
|
}
|
|
364
|
-
.mbe-
|
|
431
|
+
.mbe-resize-handle {
|
|
365
432
|
position: absolute;
|
|
366
433
|
top: 50%;
|
|
367
434
|
width: 6px;
|
|
@@ -377,34 +444,34 @@
|
|
|
377
444
|
border: 1px solid CanvasText;
|
|
378
445
|
border-radius: 3px;
|
|
379
446
|
}
|
|
380
|
-
.mbe-
|
|
447
|
+
.mbe-resize-handle::before {
|
|
381
448
|
content: "";
|
|
382
449
|
position: absolute;
|
|
383
450
|
inset: -6px -8px;
|
|
384
451
|
}
|
|
385
|
-
.mbe-
|
|
452
|
+
.mbe-resize-handle-left {
|
|
386
453
|
left: 8px;
|
|
387
454
|
}
|
|
388
|
-
.mbe-
|
|
455
|
+
.mbe-resize-handle-right {
|
|
389
456
|
left: calc(100% - 8px);
|
|
390
457
|
}
|
|
391
|
-
.mbe-image-frame-small .mbe-
|
|
458
|
+
.mbe-image-frame-small .mbe-resize-handle-left {
|
|
392
459
|
left: 0;
|
|
393
460
|
}
|
|
394
|
-
.mbe-image-frame-small .mbe-
|
|
461
|
+
.mbe-image-frame-small .mbe-resize-handle-right {
|
|
395
462
|
left: 100%;
|
|
396
463
|
}
|
|
397
464
|
.mbe-image-resizing,
|
|
398
|
-
.mbe-image-resizing .mbe-
|
|
465
|
+
.mbe-image-resizing .mbe-resize-handle {
|
|
399
466
|
cursor: ew-resize;
|
|
400
467
|
}
|
|
401
|
-
.mbe-
|
|
468
|
+
.mbe-popover-input {
|
|
402
469
|
font: inherit;
|
|
403
470
|
color: inherit;
|
|
404
471
|
width: 260px;
|
|
405
472
|
padding: 5px 8px;
|
|
406
473
|
}
|
|
407
|
-
.mbe-handle {
|
|
474
|
+
.mbe-block-handle {
|
|
408
475
|
position: fixed;
|
|
409
476
|
width: 20px;
|
|
410
477
|
height: 22px;
|
|
@@ -673,7 +740,7 @@
|
|
|
673
740
|
}
|
|
674
741
|
.mbe-menu,
|
|
675
742
|
.mbe-toolbar,
|
|
676
|
-
.mbe-
|
|
743
|
+
.mbe-input-popover {
|
|
677
744
|
color: var(--mbe-text);
|
|
678
745
|
background: var(--mbe-popup-bg);
|
|
679
746
|
border: 1px solid var(--mbe-popup-border);
|
|
@@ -714,16 +781,23 @@
|
|
|
714
781
|
font-size: 12px;
|
|
715
782
|
color: var(--mbe-muted);
|
|
716
783
|
}
|
|
784
|
+
.mbe-toolbar {
|
|
785
|
+
border-radius: calc(var(--mbe-radius) + 2px);
|
|
786
|
+
}
|
|
717
787
|
.mbe-tool {
|
|
718
|
-
border-radius:
|
|
788
|
+
border-radius: 7px;
|
|
719
789
|
}
|
|
720
|
-
.mbe-tool:hover
|
|
790
|
+
.mbe-tool:hover,
|
|
791
|
+
.mbe-tool.mbe-open {
|
|
721
792
|
background: var(--mbe-hover);
|
|
722
793
|
}
|
|
723
794
|
.mbe-tool.mbe-active {
|
|
724
795
|
color: var(--mbe-accent);
|
|
725
796
|
background: var(--mbe-hover);
|
|
726
797
|
}
|
|
798
|
+
.mbe-tool-chevron {
|
|
799
|
+
color: var(--mbe-muted);
|
|
800
|
+
}
|
|
727
801
|
.mbe-tool-bold {
|
|
728
802
|
font-weight: 700;
|
|
729
803
|
}
|
|
@@ -741,30 +815,64 @@
|
|
|
741
815
|
.mbe-tool-sep {
|
|
742
816
|
background: var(--mbe-popup-border);
|
|
743
817
|
}
|
|
744
|
-
.mbe-
|
|
818
|
+
.mbe-tooltip {
|
|
819
|
+
font-size: 12px;
|
|
820
|
+
border-radius: 6px;
|
|
821
|
+
color: var(--mbe-popup-bg);
|
|
822
|
+
background: var(--mbe-text);
|
|
823
|
+
}
|
|
824
|
+
.mbe-text-style-menu .mbe-menu-item,
|
|
825
|
+
.mbe-list-menu .mbe-menu-item {
|
|
826
|
+
min-height: 32px;
|
|
827
|
+
font-size: 14px;
|
|
828
|
+
line-height: 24px;
|
|
829
|
+
}
|
|
830
|
+
.mbe-menu-check {
|
|
831
|
+
color: var(--mbe-accent);
|
|
832
|
+
}
|
|
833
|
+
.mbe-menu-submenu {
|
|
834
|
+
color: var(--mbe-muted);
|
|
835
|
+
}
|
|
836
|
+
.mbe-menu-item[aria-expanded=true] {
|
|
837
|
+
background: var(--mbe-hover);
|
|
838
|
+
color: inherit;
|
|
839
|
+
}
|
|
840
|
+
.mbe-menu-heading1 {
|
|
841
|
+
font-size: 19px;
|
|
842
|
+
font-weight: 650;
|
|
843
|
+
}
|
|
844
|
+
.mbe-menu-heading2 {
|
|
845
|
+
font-size: 17px;
|
|
846
|
+
font-weight: 650;
|
|
847
|
+
}
|
|
848
|
+
.mbe-menu-heading3 {
|
|
849
|
+
font-size: 15px;
|
|
850
|
+
font-weight: 650;
|
|
851
|
+
}
|
|
852
|
+
.mbe-popover-input {
|
|
745
853
|
border: 1px solid var(--mbe-popup-border);
|
|
746
854
|
border-radius: 6px;
|
|
747
855
|
background: transparent;
|
|
748
856
|
outline: none;
|
|
749
857
|
}
|
|
750
|
-
.mbe-
|
|
858
|
+
.mbe-popover-input:focus {
|
|
751
859
|
border-color: var(--mbe-accent);
|
|
752
860
|
}
|
|
753
|
-
.mbe-
|
|
861
|
+
.mbe-resize-handle {
|
|
754
862
|
background: rgb(0 0 0 / 0.6);
|
|
755
863
|
border-color: rgb(255 255 255 / 0.85);
|
|
756
864
|
box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
|
|
757
865
|
}
|
|
758
|
-
.mbe-
|
|
759
|
-
.mbe-image-resizing .mbe-
|
|
866
|
+
.mbe-resize-handle:hover,
|
|
867
|
+
.mbe-image-resizing .mbe-resize-handle {
|
|
760
868
|
background: var(--mbe-accent);
|
|
761
869
|
}
|
|
762
|
-
.mbe-handle {
|
|
870
|
+
.mbe-block-handle {
|
|
763
871
|
border-radius: 4px;
|
|
764
872
|
color: var(--mbe-muted);
|
|
765
873
|
opacity: 0.7;
|
|
766
874
|
}
|
|
767
|
-
.mbe-handle:hover {
|
|
875
|
+
.mbe-block-handle:hover {
|
|
768
876
|
background: var(--mbe-hover);
|
|
769
877
|
opacity: 1;
|
|
770
878
|
}
|
package/dist/theme.css
CHANGED
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
}
|
|
191
191
|
.mbe-menu,
|
|
192
192
|
.mbe-toolbar,
|
|
193
|
-
.mbe-
|
|
193
|
+
.mbe-input-popover {
|
|
194
194
|
color: var(--mbe-text);
|
|
195
195
|
background: var(--mbe-popup-bg);
|
|
196
196
|
border: 1px solid var(--mbe-popup-border);
|
|
@@ -207,34 +207,53 @@
|
|
|
207
207
|
.mbe-menu-loading { color: var(--mbe-muted); }
|
|
208
208
|
.mbe-menu-detail { font-size: 12px; color: var(--mbe-muted); }
|
|
209
209
|
|
|
210
|
-
.mbe-
|
|
211
|
-
.mbe-tool
|
|
210
|
+
.mbe-toolbar { border-radius: calc(var(--mbe-radius) + 2px); }
|
|
211
|
+
.mbe-tool { border-radius: 7px; }
|
|
212
|
+
.mbe-tool:hover,
|
|
213
|
+
.mbe-tool.mbe-open { background: var(--mbe-hover); }
|
|
212
214
|
.mbe-tool.mbe-active { color: var(--mbe-accent); background: var(--mbe-hover); }
|
|
215
|
+
.mbe-tool-chevron { color: var(--mbe-muted); }
|
|
213
216
|
.mbe-tool-bold { font-weight: 700; }
|
|
214
217
|
.mbe-tool-italic { font-style: italic; font-family: Georgia, serif; }
|
|
215
218
|
.mbe-tool-strike { text-decoration: line-through; }
|
|
216
219
|
.mbe-tool-code { font-family: var(--mbe-mono); font-size: 12px; }
|
|
217
220
|
.mbe-tool-sep { background: var(--mbe-popup-border); }
|
|
221
|
+
.mbe-tooltip {
|
|
222
|
+
font-size: 12px;
|
|
223
|
+
border-radius: 6px;
|
|
224
|
+
color: var(--mbe-popup-bg);
|
|
225
|
+
background: var(--mbe-text);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* The text style and list menus: roomier rows, and each style shown as itself. */
|
|
229
|
+
.mbe-text-style-menu .mbe-menu-item,
|
|
230
|
+
.mbe-list-menu .mbe-menu-item { min-height: 32px; font-size: 14px; line-height: 24px; }
|
|
231
|
+
.mbe-menu-check { color: var(--mbe-accent); }
|
|
232
|
+
.mbe-menu-submenu { color: var(--mbe-muted); }
|
|
233
|
+
.mbe-menu-item[aria-expanded="true"] { background: var(--mbe-hover); color: inherit; }
|
|
234
|
+
.mbe-menu-heading1 { font-size: 19px; font-weight: 650; }
|
|
235
|
+
.mbe-menu-heading2 { font-size: 17px; font-weight: 650; }
|
|
236
|
+
.mbe-menu-heading3 { font-size: 15px; font-weight: 650; }
|
|
218
237
|
|
|
219
|
-
.mbe-
|
|
238
|
+
.mbe-popover-input {
|
|
220
239
|
border: 1px solid var(--mbe-popup-border);
|
|
221
240
|
border-radius: 6px;
|
|
222
241
|
background: transparent;
|
|
223
242
|
outline: none;
|
|
224
243
|
}
|
|
225
|
-
.mbe-
|
|
244
|
+
.mbe-popover-input:focus { border-color: var(--mbe-accent); }
|
|
226
245
|
|
|
227
|
-
.mbe-
|
|
246
|
+
.mbe-resize-handle {
|
|
228
247
|
background: rgb(0 0 0 / 0.6);
|
|
229
248
|
border-color: rgb(255 255 255 / 0.85);
|
|
230
249
|
box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
|
|
231
250
|
}
|
|
232
|
-
.mbe-
|
|
233
|
-
.mbe-image-resizing .mbe-
|
|
251
|
+
.mbe-resize-handle:hover,
|
|
252
|
+
.mbe-image-resizing .mbe-resize-handle { background: var(--mbe-accent); }
|
|
234
253
|
|
|
235
|
-
.mbe-handle {
|
|
254
|
+
.mbe-block-handle {
|
|
236
255
|
border-radius: 4px;
|
|
237
256
|
color: var(--mbe-muted);
|
|
238
257
|
opacity: 0.7;
|
|
239
258
|
}
|
|
240
|
-
.mbe-handle:hover { background: var(--mbe-hover); opacity: 1; }
|
|
259
|
+
.mbe-block-handle:hover { background: var(--mbe-hover); opacity: 1; }
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Block, type EditorState, type HeadingLevel, type ImageAtom, type ListType, type Mark, type Position, type Selection, type TableBlock, type Align } from './model.js';
|
|
1
|
+
import { type Block, type EditorState, type HeadingLevel, type ImageAlign, type ImageAtom, type ListType, type Mark, type Position, type Selection, type TableBlock, type RawBlock, type TextBlock, type Align } from './model.js';
|
|
2
2
|
import type { InlineSyntax } from './markdown/options.js';
|
|
3
3
|
export type Command = (state: EditorState) => EditorState;
|
|
4
4
|
/** A copy of a block with a new ID. */
|
|
@@ -17,10 +17,10 @@ export declare function deleteForward(state: EditorState): EditorState;
|
|
|
17
17
|
export declare function insertText(state: EditorState, text: string): EditorState;
|
|
18
18
|
/**
|
|
19
19
|
* ArrowDown on the last line of the last block, or ArrowUp on the first line
|
|
20
|
-
* of the first block, when that block is a code block, table or divider
|
|
21
|
-
* an empty paragraph past it, so the caret is
|
|
22
|
-
* the last (or first) row. Lines are lines of
|
|
23
|
-
* one.
|
|
20
|
+
* of the first block, when that block is a code block, table or divider, or
|
|
21
|
+
* a selected image block: adds an empty paragraph past it, so the caret is
|
|
22
|
+
* never stuck. In a table that is the last (or first) row. Lines are lines of
|
|
23
|
+
* text; a wrapped line counts as one.
|
|
24
24
|
*/
|
|
25
25
|
export declare function exitBlock(state: EditorState, dir: 1 | -1): EditorState;
|
|
26
26
|
/** Shift+Enter: a hard line break. A newline in code; nothing in a table cell. */
|
|
@@ -47,12 +47,22 @@ export declare function selectedImage(state: EditorState): {
|
|
|
47
47
|
pos: Position;
|
|
48
48
|
image: ImageAtom;
|
|
49
49
|
} | null;
|
|
50
|
+
/** The selected image when it is an image block's (see `isImageBlock`), else null. */
|
|
51
|
+
export declare function selectedImageBlock(state: EditorState): {
|
|
52
|
+
pos: Position;
|
|
53
|
+
image: ImageAtom;
|
|
54
|
+
} | null;
|
|
50
55
|
/** Selects the image after `pos` as one unit. */
|
|
51
56
|
export declare function selectImage(state: EditorState, pos: Position): EditorState;
|
|
52
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* What `updateImage` changes. `null` removes a title, an alignment or a size;
|
|
59
|
+
* a new width drops the height, so the image keeps its aspect ratio.
|
|
60
|
+
*/
|
|
53
61
|
export interface ImageChange {
|
|
54
62
|
readonly alt?: string;
|
|
55
63
|
readonly title?: string | null;
|
|
64
|
+
/** Shown on image blocks only (see `isImageBlock`). */
|
|
65
|
+
readonly align?: ImageAlign | null;
|
|
56
66
|
readonly width?: number | null;
|
|
57
67
|
}
|
|
58
68
|
/** Changes the image after `pos` and selects it. */
|
|
@@ -79,9 +89,12 @@ export type BlockTypeSpec = {
|
|
|
79
89
|
};
|
|
80
90
|
/**
|
|
81
91
|
* Changes the type of every text block touched by the selection. Text and IDs
|
|
82
|
-
* are kept. Tables and dividers are inserted instead (see insertBlock).
|
|
92
|
+
* are kept. Tables and dividers are inserted instead (see insertBlock). Code
|
|
93
|
+
* is the exception: adjacent blocks become one code block, a line per block.
|
|
83
94
|
*/
|
|
84
95
|
export declare function setBlockType(state: EditorState, spec: BlockTypeSpec): EditorState;
|
|
96
|
+
/** The blocks the selection touches whose type the block type commands change. */
|
|
97
|
+
export declare function convertibleBlocks(state: EditorState): Exclude<TextBlock, RawBlock>[];
|
|
85
98
|
/**
|
|
86
99
|
* Sets the type of the selected text blocks, or turns them back into
|
|
87
100
|
* paragraphs when they all have that type already.
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { Extension } from './extension.js';
|
|
|
7
7
|
import { type SuggestionState } from './suggest/controller.js';
|
|
8
8
|
import { type Widget, type WidgetRender } from './widgets.js';
|
|
9
9
|
import { type Block, type EditorState, type HeadingLevel, type Position, type Selection } from './model.js';
|
|
10
|
+
import { type ToolbarItem } from './ui/toolbar.js';
|
|
10
11
|
import { type ResolveUrl } from './view/dom.js';
|
|
11
12
|
import { type Theme } from './theme.js';
|
|
12
13
|
export interface EditorOptions {
|
|
@@ -65,8 +66,13 @@ export interface EditorOptions {
|
|
|
65
66
|
labels?: Partial<Labels>;
|
|
66
67
|
/** Replaces built-in icons, by the `labels` key of the same control. A string is shown as text; an element is cloned. */
|
|
67
68
|
icons?: Icons;
|
|
68
|
-
/**
|
|
69
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Shows the formatting toolbar on selection. Default true. `items` picks
|
|
71
|
+
* its controls; they always appear in the built-in order.
|
|
72
|
+
*/
|
|
73
|
+
toolbar?: boolean | {
|
|
74
|
+
items?: readonly ToolbarItem[];
|
|
75
|
+
};
|
|
70
76
|
/**
|
|
71
77
|
* The element menus, the toolbar and other popups are appended to.
|
|
72
78
|
* Default: the nearest open `<dialog>` or `aria-modal` ancestor of
|
|
@@ -177,7 +183,8 @@ export interface EditorCommands {
|
|
|
177
183
|
unsetLink(): boolean;
|
|
178
184
|
/**
|
|
179
185
|
* Changes the selected image (see `isActive('image')`): its alt text, its
|
|
180
|
-
* title,
|
|
186
|
+
* title, its alignment (shown on image blocks), or its width in CSS pixels.
|
|
187
|
+
* `null` removes the title, the alignment or the width.
|
|
181
188
|
*/
|
|
182
189
|
updateImage(attrs: cmd.ImageChange): boolean;
|
|
183
190
|
/** Inserts plain text at the selection, or in place of `range` (for example a suggestion's range). */
|
|
@@ -228,6 +235,12 @@ export declare class Editor {
|
|
|
228
235
|
private composition;
|
|
229
236
|
/** When the last composition ended (Safari only): the next key may be the Enter that committed it. */
|
|
230
237
|
private compositionEndedAt;
|
|
238
|
+
/**
|
|
239
|
+
* The last Markdown shortcut that typing applied: the state with the typed
|
|
240
|
+
* characters, and the state the shortcut made. Backspace right after it
|
|
241
|
+
* goes back to the typed characters.
|
|
242
|
+
*/
|
|
243
|
+
private shortcut;
|
|
231
244
|
/** Blocks the browser edited during a composition that ended, rendered again on the next frame. */
|
|
232
245
|
private readonly unsettled;
|
|
233
246
|
private settleFrame;
|
|
@@ -267,9 +280,10 @@ export declare class Editor {
|
|
|
267
280
|
private readonly suggestions;
|
|
268
281
|
private readonly blockMenu;
|
|
269
282
|
private readonly toolbar;
|
|
270
|
-
|
|
271
|
-
private readonly
|
|
272
|
-
private readonly
|
|
283
|
+
/** The link popover, and the field for an image's alt text. */
|
|
284
|
+
private readonly inputPopover;
|
|
285
|
+
private readonly blockHandle;
|
|
286
|
+
private readonly resizeHandles;
|
|
273
287
|
/** The selected image's element, which carries the selected class. */
|
|
274
288
|
private selectedImageEl;
|
|
275
289
|
private hintEl;
|
|
@@ -309,7 +323,7 @@ export declare class Editor {
|
|
|
309
323
|
get isDestroyed(): boolean;
|
|
310
324
|
/** True if `name` applies at the selection: a mark on the selected text, or the type of the block with the caret. */
|
|
311
325
|
isActive(name: ActiveName, attrs?: Readonly<Record<string, unknown>>): boolean;
|
|
312
|
-
/** Attributes of `name` at the selection: `src`, `alt`, `title`, `width` and `
|
|
326
|
+
/** Attributes of `name` at the selection: `src`, `alt`, `title`, `align`, `width`, `height` and `block` (true for an image block) for a selected image, `href` for a link, `level` for a heading, `language` for a code block, `checked` for a task, `syntax` for a raw block. */
|
|
313
327
|
getAttributes(name: ActiveName): Record<string, unknown>;
|
|
314
328
|
getSelection(): Selection;
|
|
315
329
|
/**
|
|
@@ -388,6 +402,8 @@ export declare class Editor {
|
|
|
388
402
|
private toDom;
|
|
389
403
|
private readDomSelection;
|
|
390
404
|
private onSelectionChange;
|
|
405
|
+
/** The selection of an image block's image, when `sel` is a caret in that block. */
|
|
406
|
+
private imageBlockAt;
|
|
391
407
|
/**
|
|
392
408
|
* After the browser moved the caret from block `from` with ArrowDown
|
|
393
409
|
* (`dir` 1) or ArrowUp to `to`: the position in the first block it passed
|
|
@@ -432,6 +448,13 @@ export declare class Editor {
|
|
|
432
448
|
* column.
|
|
433
449
|
*/
|
|
434
450
|
private blockPast;
|
|
451
|
+
/**
|
|
452
|
+
* An arrow key next to an image block: from the edge of the block before
|
|
453
|
+
* or after it, the selection of its image; from a selected image block, a
|
|
454
|
+
* caret in the next block that holds one, or the same selection when there
|
|
455
|
+
* is none. Null when no image block is involved.
|
|
456
|
+
*/
|
|
457
|
+
private imageBlockStep;
|
|
435
458
|
/**
|
|
436
459
|
* ArrowUp or ArrowDown on the first or last line of a table cell: the
|
|
437
460
|
* position in the cell above or below (same column), or past the table in
|
|
@@ -464,6 +487,12 @@ export declare class Editor {
|
|
|
464
487
|
private browserApplies;
|
|
465
488
|
/** Markdown shortcuts and suggestion menus that typing `text` triggers. */
|
|
466
489
|
private afterTyping;
|
|
490
|
+
/**
|
|
491
|
+
* Backspace right after a Markdown shortcut, with no edit or caret move since,
|
|
492
|
+
* restores the characters that were typed: `**a**` stays text. It is its
|
|
493
|
+
* own undo step.
|
|
494
|
+
*/
|
|
495
|
+
private undoShortcut;
|
|
467
496
|
private onCompositionStart;
|
|
468
497
|
private onCompositionEnd;
|
|
469
498
|
private settleComposition;
|
|
@@ -505,7 +534,7 @@ export declare class Editor {
|
|
|
505
534
|
private moveMenu;
|
|
506
535
|
private onMouseDown;
|
|
507
536
|
/**
|
|
508
|
-
* A click in the empty space below a final code block, table or
|
|
537
|
+
* A click in the empty space below a final code block, table, divider or image block
|
|
509
538
|
* adds a paragraph there. The browser would put the caret inside the
|
|
510
539
|
* block, or in the block above a table.
|
|
511
540
|
*/
|
|
@@ -551,14 +580,24 @@ export declare class Editor {
|
|
|
551
580
|
*/
|
|
552
581
|
private onBlockKey;
|
|
553
582
|
private blockMenuSections;
|
|
583
|
+
/** The Align row of the block menu: a submenu of Left, Center and Right with the current one checked. */
|
|
584
|
+
private alignMenuItem;
|
|
554
585
|
private closeBlockMenu;
|
|
555
|
-
/**
|
|
586
|
+
/**
|
|
587
|
+
* A press anywhere but the block menu or the block handle closes the block menu,
|
|
588
|
+
* in the editor's text too. The same goes for a toolbar menu and the toolbar.
|
|
589
|
+
*/
|
|
556
590
|
private onDocumentPointerDown;
|
|
557
591
|
private updateUi;
|
|
558
592
|
/** Marks the selected image's element, and hides the browser's selection highlight over it. */
|
|
559
593
|
private paintSelectedImage;
|
|
560
594
|
/** The selected image of `state` and its element, or null. */
|
|
561
595
|
private imageTargetAt;
|
|
596
|
+
/**
|
|
597
|
+
* Opens the alt text field under the image after `pos`. Enter saves the text,
|
|
598
|
+
* Escape keeps the old one. Either way the image stays selected.
|
|
599
|
+
*/
|
|
600
|
+
private editAltText;
|
|
562
601
|
private syncActiveDescendant;
|
|
563
602
|
private hideUi;
|
|
564
603
|
/** Wraps an input event handler so the changes it makes keep the caret in view. */
|
package/dist/types/icons.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export type Icon = string | Element;
|
|
16
16
|
/** One SVG child: a path's `d`, or a tag and its attributes. */
|
|
17
17
|
type IconChild = string | readonly [tag: string, attrs: Readonly<Record<string, string>>];
|
|
18
|
-
/** The built-in icons, by the `labels` key of the control that shows them. The comment names the Lucide icon. */
|
|
18
|
+
/** The built-in icons, by the `labels` key of the control that shows them (see IconName). The comment names the Lucide icon. */
|
|
19
19
|
declare const ICONS: {
|
|
20
20
|
/** `type` */
|
|
21
21
|
text: string[];
|
|
@@ -87,12 +87,36 @@ declare const ICONS: {
|
|
|
87
87
|
addColumnLeft: string[];
|
|
88
88
|
/** `arrow-right` */
|
|
89
89
|
addColumnRight: string[];
|
|
90
|
+
/** `text-align-start`, the table menu's Align row */
|
|
91
|
+
align: string[];
|
|
90
92
|
/** `text-align-start` */
|
|
91
93
|
alignLeft: string[];
|
|
92
94
|
/** `text-align-center` */
|
|
93
95
|
alignCenter: string[];
|
|
94
96
|
/** `text-align-end` */
|
|
95
97
|
alignRight: string[];
|
|
98
|
+
/** `align-start-vertical`, an image block's Align row and its Left item */
|
|
99
|
+
imageAlignLeft: (string | [string, {
|
|
100
|
+
width: string;
|
|
101
|
+
height: string;
|
|
102
|
+
x: string;
|
|
103
|
+
y: string;
|
|
104
|
+
rx: string;
|
|
105
|
+
}])[];
|
|
106
|
+
/** `align-center-vertical` */
|
|
107
|
+
imageAlignCenter: string[];
|
|
108
|
+
/** `align-end-vertical` */
|
|
109
|
+
imageAlignRight: (string | [string, {
|
|
110
|
+
width: string;
|
|
111
|
+
height: string;
|
|
112
|
+
x: string;
|
|
113
|
+
y: string;
|
|
114
|
+
rx: string;
|
|
115
|
+
}])[];
|
|
116
|
+
/** `rotate-ccw` */
|
|
117
|
+
resetImageSize: string[];
|
|
118
|
+
/** `text-cursor-input` */
|
|
119
|
+
altText: string[];
|
|
96
120
|
/** `trash` */
|
|
97
121
|
deleteRow: readonly IconChild[];
|
|
98
122
|
/** `trash` */
|
|
@@ -124,6 +148,12 @@ declare const ICONS: {
|
|
|
124
148
|
y1: string;
|
|
125
149
|
y2: string;
|
|
126
150
|
}])[];
|
|
151
|
+
/** `chevron-down`, after the icon of a toolbar button that opens a menu */
|
|
152
|
+
chevronDown: string[];
|
|
153
|
+
/** `check`, after the current item of a menu */
|
|
154
|
+
selected: string[];
|
|
155
|
+
/** `chevron-right`, at the end of a menu row that opens a submenu */
|
|
156
|
+
chevronRight: string[];
|
|
127
157
|
/** `grip-vertical` */
|
|
128
158
|
blockHandle: [string, {
|
|
129
159
|
cx: string;
|
|
@@ -131,7 +161,12 @@ declare const ICONS: {
|
|
|
131
161
|
r: string;
|
|
132
162
|
}][];
|
|
133
163
|
};
|
|
134
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Names of the built-in icons. Each is the `labels` key of the control that
|
|
166
|
+
* shows it, except `chevronDown`, `chevronRight` and `selected`, which are
|
|
167
|
+
* parts of controls, and `imageAlignLeft`, `imageAlignCenter` and
|
|
168
|
+
* `imageAlignRight`, an image block's Align choices.
|
|
169
|
+
*/
|
|
135
170
|
export type IconName = keyof typeof ICONS;
|
|
136
171
|
export type Icons = Partial<Record<IconName, Icon>>;
|
|
137
172
|
/** Builds the built-in icon `name` as a new `<svg class="mbe-icon">`. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Editor, type ActiveName, type EditorCommands, type EditorEvents, type EditorOptions, type InsertMarkdownOptions, type InsertTarget, type PositionJSON, type RuntimeOptions, type SelectionJSON, type SuggestionApi, SLASH_ITEM_IDS, type SlashItemId, } from './editor.js';
|
|
2
2
|
export { DEFAULT_LABELS, type Labels } from './labels.js';
|
|
3
|
+
export { TOOLBAR_ITEMS, type ToolbarItem } from './ui/toolbar.js';
|
|
3
4
|
export type { Icon, IconName, Icons } from './icons.js';
|
|
4
5
|
export * from './model.js';
|
|
5
6
|
export * as commands from './commands.js';
|
package/dist/types/labels.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export declare const DEFAULT_LABELS: {
|
|
|
26
26
|
strike: string;
|
|
27
27
|
inlineCode: string;
|
|
28
28
|
link: string;
|
|
29
|
+
/** The formatting toolbar's menu of paragraph and heading styles. */
|
|
30
|
+
textStyle: string;
|
|
31
|
+
/** The formatting toolbar's menu of list types. */
|
|
32
|
+
list: string;
|
|
29
33
|
linkPlaceholder: string;
|
|
30
34
|
removeLink: string;
|
|
31
35
|
slashHint: string;
|
|
@@ -45,13 +49,22 @@ export declare const DEFAULT_LABELS: {
|
|
|
45
49
|
addColumnRight: string;
|
|
46
50
|
deleteRow: string;
|
|
47
51
|
deleteColumn: string;
|
|
52
|
+
/** The block menu row that opens the Align submenu, and the submenu's title. */
|
|
53
|
+
align: string;
|
|
48
54
|
alignLeft: string;
|
|
49
55
|
alignCenter: string;
|
|
50
56
|
alignRight: string;
|
|
51
57
|
tableSection: string;
|
|
58
|
+
/** The title of the block menu's section of image block actions. */
|
|
59
|
+
imageSection: string;
|
|
60
|
+
/** Removes an image's width, so it shows at its own size. */
|
|
61
|
+
resetImageSize: string;
|
|
62
|
+
/** Edits an image's alt text, and names the field that edits it. */
|
|
63
|
+
altText: string;
|
|
64
|
+
altTextPlaceholder: string;
|
|
52
65
|
/** Shown in place of an image that did not load and has no alt text. */
|
|
53
66
|
imageUnavailable: string;
|
|
54
|
-
/** Accessible name of
|
|
67
|
+
/** Accessible name of an image's resize handles. */
|
|
55
68
|
resizeImage: string;
|
|
56
69
|
};
|
|
57
70
|
export type Labels = typeof DEFAULT_LABELS;
|