@usememos/editor 26.10.3 → 26.10.5

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
@@ -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); }
@@ -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;
@@ -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` */
@@ -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;
@@ -20,9 +20,9 @@ export declare function serializeInline(inline: Inline, options?: MarkdownOption
20
20
  * - Whitespace at the edges of a bold, italic or strike run moves outside it,
21
21
  * because `**foo **` is not valid emphasis.
22
22
  * - A "\n" in a code span is a hard break outside the code span.
23
- * - Spaces and tabs that end a line of text are dropped, because Markdown
24
- * strips them. Writing them as character references instead would leave
25
- * " " behind wherever someone typed a space last. A line of only
26
- * whitespace keeps it, so the line is not lost.
23
+ * - Spaces and tabs that start or end a line of text are dropped, because
24
+ * Markdown strips them. Writing them as character references instead would
25
+ * leave " " behind wherever someone typed a space first or last. A line
26
+ * of only whitespace keeps it, so the line is not lost.
27
27
  */
28
28
  export declare function representableInline(inline: Inline): Span[];
@@ -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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usememos/editor",
3
- "version": "26.10.3",
3
+ "version": "26.10.5",
4
4
  "description": "A block editor for standard Markdown. Zero runtime dependencies, with an optional React component.",
5
5
  "keywords": [
6
6
  "markdown",