autumnnote 2.7.0 → 2.7.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "autumnnote",
3
- "version": "2.7.0",
4
- "description": "WYSIWYG rich-text editor built with vanilla JavaScript \u2014 zero dependencies, no jQuery. Dark mode, @mention, markdown shortcuts, bubble toolbar. React and Vue\u00a03 wrappers included.",
3
+ "version": "2.7.1",
4
+ "description": "WYSIWYG rich-text editor built with vanilla JavaScript zero dependencies, no jQuery. Dark mode, @mention, markdown shortcuts, bubble toolbar. React and Vue 3 wrappers included.",
5
5
  "type": "module",
6
6
  "main": "dist/autumnnote.cjs",
7
7
  "module": "dist/autumnnote.es.js",
@@ -119,13 +119,13 @@
119
119
  "@vitest/browser-playwright": "^4.1.10",
120
120
  "@vitest/coverage-v8": "^4.1.8",
121
121
  "cross-env": "^10.1.0",
122
- "eslint": "^10.7.0",
123
- "jsdom": "^25.0.1",
124
- "playwright": "^1.61.1",
125
- "rollup-plugin-visualizer": "^7.0.1",
126
- "sass": "^1.101.0",
127
- "typescript": "^6.0.2",
128
- "vite": "^8.1.5",
122
+ "eslint": "^10.8.1",
123
+ "jsdom": "^30.0.1",
124
+ "playwright": "^1.62.1",
125
+ "rollup-plugin-visualizer": "^7.1.1",
126
+ "sass": "^1.102.0",
127
+ "typescript": "^7.0.2",
128
+ "vite": "^8.2.1",
129
129
  "vitest": "^4.1.8"
130
130
  },
131
131
  "packageManager": "pnpm@11.1.3",
@@ -108,9 +108,14 @@ export function isFunction(val) {
108
108
  * mutations to the merged result do not bleed back into the source object
109
109
  * (e.g. mutating `instance.options.fontFamilies` should not affect
110
110
  * `AutumnNote.defaults.fontFamilies`).
111
- * @param {object} target
112
- * @param {object} source
113
- * @returns {object}
111
+ *
112
+ * The result starts as a copy of `target`, so it carries `target`'s shape —
113
+ * `source` only overwrites values. Typing the return as `T` rather than
114
+ * `object` is what lets callers read properties off the merged result.
115
+ * @template {object} T
116
+ * @param {T} target
117
+ * @param {object} [source]
118
+ * @returns {T}
114
119
  */
115
120
  export function mergeDeep(target, source) {
116
121
  // Start with a shallow copy of target; clone any arrays to avoid shared refs
@@ -133,7 +138,8 @@ export function mergeDeep(target, source) {
133
138
  }
134
139
  }
135
140
  }
136
- return output;
141
+ // `output` is built key by key from `target`, which no inference can follow.
142
+ return /** @type {T} */ (output);
137
143
  }
138
144
 
139
145
  /**
package/types/index.d.ts CHANGED
@@ -29,6 +29,40 @@ export interface AutoSaveAdapter {
29
29
  remove?(payload: { key: string; context: Context }): void | Promise<void>;
30
30
  }
31
31
 
32
+ /**
33
+ * One entry in the right-click menu. Most entries are a labelled row with an
34
+ * `action`; the remaining fields each select a different kind of row, and an
35
+ * entry that sets one of them ignores `action`.
36
+ */
37
+ export interface ContextMenuItem {
38
+ /** Unique identifier. Omitted on separators and other non-interactive rows. */
39
+ name?: string;
40
+ label?: string;
41
+ /** Icon markup (SVG or HTML). */
42
+ icon?: string;
43
+ /** Key into `locale.contextMenu`; preferred over `label` when it resolves. */
44
+ localeKey?: string;
45
+ action?: (context: Context) => void;
46
+ /** Greys the row out and blocks the click. A function is evaluated per open. */
47
+ disabled?: boolean | ((context: Context) => boolean);
48
+ /** Opens a submenu instead of firing `action`. */
49
+ navigate?: ContextMenuItem[] | ((context: Context) => ContextMenuItem[]);
50
+ /** A horizontal rule. `sep` is an accepted alias. */
51
+ separator?: boolean;
52
+ /** @see separator */
53
+ sep?: boolean;
54
+ /** Renders as the submenu's "back" row rather than a command. */
55
+ back?: boolean;
56
+ /** Renders a row of quick colour swatches for `colorType`. */
57
+ colorStrip?: 'foreColor' | 'hiliteColor';
58
+ /** Renders the full palette plus a native colour input, for `colorType`. */
59
+ colorPalette?: boolean;
60
+ /** Which command `colorStrip` / `colorPalette` applies. */
61
+ colorType?: 'foreColor' | 'hiliteColor';
62
+ /** Renders the drag-to-size table picker. */
63
+ tableGrid?: boolean;
64
+ }
65
+
32
66
  export interface SlashCommand {
33
67
  id: string;
34
68
  label?: string;
@@ -237,6 +271,14 @@ export interface AsnOptions {
237
271
  /** @mention autocomplete configuration. Activated when mention.onSearch is provided. */
238
272
  mention?: MentionOptions | null;
239
273
 
274
+ // ---- Right-click menu ------------------------------------------------------
275
+
276
+ /**
277
+ * Replaces the built-in right-click menu. Omit it, or omit `items`, to keep
278
+ * the default list.
279
+ */
280
+ contextMenu?: { items?: ContextMenuItem[] } | null;
281
+
240
282
  // ---- Slash command menu ----------------------------------------------------
241
283
 
242
284
  /** Show a "/" command palette for quick block insertion (headings, lists, table, image, ...). Default: true. */