@usememos/editor 26.10.3 → 26.10.4
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 +1 -0
- package/dist/base.css +20 -0
- package/dist/index.js +72 -1
- package/dist/index.js.map +2 -2
- package/dist/style.css +34 -0
- package/dist/theme.css +3 -0
- package/dist/types/editor.d.ts +4 -0
- package/dist/types/icons.d.ts +11 -0
- package/dist/types/labels.d.ts +4 -0
- package/dist/types/view/dom.d.ts +9 -0
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -115,6 +115,29 @@
|
|
|
115
115
|
display: flex;
|
|
116
116
|
align-items: center;
|
|
117
117
|
}
|
|
118
|
+
.mbe-root .mbe-code-copy {
|
|
119
|
+
margin-inline-start: auto;
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
border: 0;
|
|
124
|
+
background: none;
|
|
125
|
+
padding: 2px;
|
|
126
|
+
font: inherit;
|
|
127
|
+
color: inherit;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
opacity: 0;
|
|
130
|
+
}
|
|
131
|
+
.mbe-root .mbe-code:hover .mbe-code-copy,
|
|
132
|
+
.mbe-root .mbe-code-copy:focus-visible,
|
|
133
|
+
.mbe-root .mbe-code-copy.mbe-copied {
|
|
134
|
+
opacity: 1;
|
|
135
|
+
}
|
|
136
|
+
@media (hover: none) {
|
|
137
|
+
.mbe-root .mbe-code-copy {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
118
141
|
.mbe-root .mbe-code-lang {
|
|
119
142
|
font: inherit;
|
|
120
143
|
color: inherit;
|
|
@@ -498,6 +521,17 @@
|
|
|
498
521
|
color: var(--mbe-muted);
|
|
499
522
|
opacity: 1;
|
|
500
523
|
}
|
|
524
|
+
.mbe-root .mbe-code-copy {
|
|
525
|
+
color: var(--mbe-muted);
|
|
526
|
+
border-radius: 4px;
|
|
527
|
+
}
|
|
528
|
+
.mbe-root .mbe-code-copy:hover {
|
|
529
|
+
color: var(--mbe-text);
|
|
530
|
+
background: var(--mbe-hover);
|
|
531
|
+
}
|
|
532
|
+
.mbe-root .mbe-code-copy.mbe-copied {
|
|
533
|
+
color: var(--mbe-accent);
|
|
534
|
+
}
|
|
501
535
|
.mbe-root > .mbe-code pre,
|
|
502
536
|
.mbe-root > pre.mbe-raw {
|
|
503
537
|
font: 14px/22px var(--mbe-mono);
|
package/dist/theme.css
CHANGED
|
@@ -131,6 +131,9 @@
|
|
|
131
131
|
.mbe-root .mbe-code-bar { padding: 6px 12px 0; }
|
|
132
132
|
.mbe-root .mbe-code-lang { font: 12px/16px var(--mbe-font); color: var(--mbe-muted); }
|
|
133
133
|
.mbe-root .mbe-code-lang::placeholder { color: var(--mbe-muted); opacity: 1; }
|
|
134
|
+
.mbe-root .mbe-code-copy { color: var(--mbe-muted); border-radius: 4px; }
|
|
135
|
+
.mbe-root .mbe-code-copy:hover { color: var(--mbe-text); background: var(--mbe-hover); }
|
|
136
|
+
.mbe-root .mbe-code-copy.mbe-copied { color: var(--mbe-accent); }
|
|
134
137
|
/* Block source text: code blocks and raw blocks. */
|
|
135
138
|
.mbe-root > .mbe-code pre,
|
|
136
139
|
.mbe-root > pre.mbe-raw { font: 14px/22px var(--mbe-mono); }
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface EditorOptions {
|
|
|
36
36
|
resolveUrl?: ResolveUrl;
|
|
37
37
|
/** `referrerpolicy` for images, such as `no-referrer`. Fixed for the editor's lifetime. */
|
|
38
38
|
referrerPolicy?: ReferrerPolicy;
|
|
39
|
+
/** A copy button on code blocks, which copies the code. Default true. Fixed for the editor's lifetime. */
|
|
40
|
+
codeCopy?: boolean;
|
|
39
41
|
/**
|
|
40
42
|
* Element ids for the document's headings, for in-page links and an
|
|
41
43
|
* outline: called with every heading in order, returns an id (or
|
|
@@ -498,6 +500,8 @@ export declare class Editor {
|
|
|
498
500
|
*/
|
|
499
501
|
private clickBelowLastBlock;
|
|
500
502
|
private onClick;
|
|
503
|
+
/** Copies the code of the code block holding `button`, and shows that it did for a moment. */
|
|
504
|
+
private copyCode;
|
|
501
505
|
/** The code block language input. */
|
|
502
506
|
private onControlChange;
|
|
503
507
|
private onFocusIn;
|
package/dist/types/icons.d.ts
CHANGED
|
@@ -66,6 +66,17 @@ declare const ICONS: {
|
|
|
66
66
|
rx: string;
|
|
67
67
|
ry: string;
|
|
68
68
|
}])[];
|
|
69
|
+
/** `copy` */
|
|
70
|
+
copyCode: (string | [string, {
|
|
71
|
+
width: string;
|
|
72
|
+
height: string;
|
|
73
|
+
x: string;
|
|
74
|
+
y: string;
|
|
75
|
+
rx: string;
|
|
76
|
+
ry: string;
|
|
77
|
+
}])[];
|
|
78
|
+
/** `check` */
|
|
79
|
+
copied: string[];
|
|
69
80
|
/** `trash` */
|
|
70
81
|
delete: readonly IconChild[];
|
|
71
82
|
/** `arrow-up` */
|
package/dist/types/labels.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export declare const DEFAULT_LABELS: {
|
|
|
35
35
|
language: string;
|
|
36
36
|
/** Shown in a code block's language field when it has none. */
|
|
37
37
|
plainText: string;
|
|
38
|
+
/** The copy button of a code block. */
|
|
39
|
+
copyCode: string;
|
|
40
|
+
/** The copy button of a code block, just after copying. */
|
|
41
|
+
copied: string;
|
|
38
42
|
addRowAbove: string;
|
|
39
43
|
addRowBelow: string;
|
|
40
44
|
addColumnLeft: string;
|
package/dist/types/view/dom.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Block, type Cell, type CodeBlock, type Doc, type Inline, type Position } from '../model.js';
|
|
2
2
|
import type { SyntaxView } from '../extension.js';
|
|
3
3
|
import type { Labels } from '../labels.js';
|
|
4
|
+
import type { IconName } from '../icons.js';
|
|
4
5
|
import type { ThemeClasses } from '../theme.js';
|
|
5
6
|
import { type Decoration } from '../decorations.js';
|
|
6
7
|
export declare const BLOCK_ATTR = "data-block-id";
|
|
@@ -34,6 +35,10 @@ export interface RenderContext {
|
|
|
34
35
|
readonly view?: (syntax: string, source: string, kind: 'inline' | 'block') => HTMLElement | null;
|
|
35
36
|
/** Theme classes for rendered elements. */
|
|
36
37
|
readonly classes: ThemeClasses;
|
|
38
|
+
/** The icon of a UI control, or null for none. */
|
|
39
|
+
readonly icon?: (name: IconName) => Node | null;
|
|
40
|
+
/** Code blocks get a copy button. */
|
|
41
|
+
readonly codeCopy?: boolean;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* Which views of one block show their source: `REVEAL_BLOCK` for a whole raw
|
|
@@ -83,6 +88,10 @@ export declare class BlockRenderer {
|
|
|
83
88
|
views?: ReadonlyMap<string, SyntaxView>;
|
|
84
89
|
/** Theme classes for rendered elements. Set before a full render. */
|
|
85
90
|
classes: ThemeClasses;
|
|
91
|
+
/** The icon of a UI control. */
|
|
92
|
+
icon?: (name: IconName) => Node | null;
|
|
93
|
+
/** Code blocks get a copy button. */
|
|
94
|
+
codeCopy: boolean;
|
|
86
95
|
/** Per block, the views that show their source. A block re-renders when its entry changes. */
|
|
87
96
|
revealed: ReadonlyMap<string, BlockReveal>;
|
|
88
97
|
/**
|