wysiwygido 0.2.1 → 0.2.2
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/CHANGELOG.md +7 -0
- package/README.md +24 -0
- package/dist/adapter.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/plugins/context-menu.d.ts +19 -0
- package/dist/plugins/helpers.d.ts +6 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/react.js +1 -1
- package/dist/{src-BRR721LM.js → src-DFClH3tv.js} +883 -8
- package/dist/src-DFClH3tv.js.map +1 -0
- package/dist/style.css +14 -0
- package/dist/types.d.ts +51 -1
- package/dist/vue.js +1 -1
- package/dist/wysiwygido.js +2 -2
- package/package.json +1 -1
- package/dist/src-BRR721LM.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/). Until 1.0, minor versions may contain breaking changes; they are listed under "Changed" or "Removed".
|
|
4
4
|
|
|
5
|
+
## 0.2.2
|
|
6
|
+
|
|
7
|
+
- Added: right-click menu (`ContextMenu`, in the default set) with table, list, link, picture and text-format items, and a `contextMenu(context)` hook for plugins to add their own.
|
|
8
|
+
- Added: `addRowBefore`, `addColumnBefore`, `toggleHeaderColumn`, `selectTable`, `selectRow`, `selectColumn`, `distributeColumns`, `listStyle` and `restartNumbering` commands.
|
|
9
|
+
- Fixed: a table reduced to one row, one column or one empty cell could not be deleted. Deleting its last row or column now removes the table, and Backspace/Delete in an empty single cell does too.
|
|
10
|
+
- Changed: `bulletList` / `orderedList` inside a list of the other kind now convert it instead of lifting out.
|
|
11
|
+
|
|
5
12
|
## [Unreleased]
|
|
6
13
|
|
|
7
14
|
## [0.2.1] - 2026-10-11
|
package/README.md
CHANGED
|
@@ -461,6 +461,30 @@ returns an unsubscribe function, and `editor.emit('my-event', payload)` tells ot
|
|
|
461
461
|
`registerIcon(name, svgInner)` adds an icon for ribbon buttons. See `demo/custom-plugin` for a complete third-party plugin, and `src/plugins/` for the built-in ones.
|
|
462
462
|
Plugins are fixed when the editor is created (the schema cannot change afterwards); commands, toolbar layout and listeners can change at any time.
|
|
463
463
|
|
|
464
|
+
## Right-click menu
|
|
465
|
+
|
|
466
|
+
`ContextMenu` is in `defaultPlugins`. Right-click shows cut/copy/paste and then what applies at the click: table tools in a table (insert/delete
|
|
467
|
+
rows and columns, merge/split, header row/column, cell colour, select, even column widths), list tools in a list (bulleted/numbered/checklist,
|
|
468
|
+
indent, numbering style, restart numbering), link tools on a link (open, copy address, edit, remove), picture tools on a picture (alt text, caption,
|
|
469
|
+
size, crop, edit, delete), and text formatting on a selection. It opens from the keyboard with the Menu key or Shift+F10, works with the arrow keys,
|
|
470
|
+
Escape closes it, and Shift + right-click gives the browser's own menu. A read-only editor only gets copy, open link and select all.
|
|
471
|
+
Deleting the last row or column of a table now removes the table, and Backspace/Delete in an empty one-cell table removes it too.
|
|
472
|
+
|
|
473
|
+
Add your own lines from any plugin:
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
definePlugin({
|
|
477
|
+
name: 'my-menu',
|
|
478
|
+
contextMenu({ closest, readonly }) {
|
|
479
|
+
if (readonly || !closest('blockquote')) return [];
|
|
480
|
+
return ['-', { label: 'Remove quote', command: 'blockQuote' }, { label: 'Say hi', run: (editor) => alert('hi') }];
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Items take `label`, `command`/`args` or `run`, `icon`, `shortcut`, `disabled`, `checked`, `danger`, `readOnly` and `items` (a submenu); `'-'` is a separator.
|
|
486
|
+
Leave the plugin out of `plugins` to have no custom menu.
|
|
487
|
+
|
|
464
488
|
## Known limitations
|
|
465
489
|
|
|
466
490
|
- **Pagination is visual.** The document stays one ProseMirror doc; blocks are measured in the browser and spaced across
|
package/dist/adapter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createEditor } from "./src-
|
|
1
|
+
import { t as createEditor } from "./src-DFClH3tv.js";
|
|
2
2
|
//#region src/adapter.ts
|
|
3
3
|
/**
|
|
4
4
|
* Framework-neutral binding for anything that needs a "value in, value out" control: Angular's `ControlValueAccessor`, Svelte, Solid,
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Editor, type EditorConfig } from './editor.js';
|
|
|
2
2
|
import { type PageOptions } from './plugins/index.js';
|
|
3
3
|
export { Editor } from './editor.js';
|
|
4
4
|
export type { EditorConfig, DocxExportOptions } from './editor.js';
|
|
5
|
-
export type { EditorPlugin, ToolbarItem, ToolbarEntry, ToolbarGroup, ToolbarOptions, Command, RibbonContribution, EditorEvent } from './types.js';
|
|
5
|
+
export type { EditorPlugin, ToolbarItem, ToolbarEntry, ToolbarGroup, ToolbarOptions, Command, ContextMenuContext, ContextMenuEntry, ContextMenuItem, RibbonContribution, EditorEvent } from './types.js';
|
|
6
6
|
export { definePlugin } from './types.js';
|
|
7
7
|
export * from './plugins/index.js';
|
|
8
8
|
export declare const defaultPlugins: import("./types.js").EditorPlugin[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Editor } from '../editor.js';
|
|
2
|
+
import type { ContextMenuContext, ContextMenuEntry, ContextMenuItem, EditorPlugin } from '../types.js';
|
|
3
|
+
export interface ContextMenuOptions {
|
|
4
|
+
/** Extra items added at the top, for this editor only (plugins add theirs with the `contextMenu` hook). */
|
|
5
|
+
extra?: (context: ContextMenuContext) => ContextMenuEntry[];
|
|
6
|
+
}
|
|
7
|
+
/** Remove what a read-only editor must not offer, then tidy the separators: none first, last or doubled, and no empty fly-outs. */
|
|
8
|
+
export declare function tidyEntries(entries: ContextMenuEntry[], readOnlyEditor: boolean): ContextMenuEntry[];
|
|
9
|
+
/** Everything a plugin offers for the current selection, grouped by plugin order. */
|
|
10
|
+
export declare function buildContextMenu(editor: Editor, event: MouseEvent | null, extra?: ContextMenuOptions['extra']): ContextMenuEntry[];
|
|
11
|
+
/**
|
|
12
|
+
* The right-click menu. It shows what applies at the click: clipboard actions, then the items each plugin adds for the
|
|
13
|
+
* selection (table tools in a table, list tools in a list, link tools on a link, picture tools on a picture…). Plugins add
|
|
14
|
+
* items with the `contextMenu(context)` hook. Hold Shift while right-clicking to get the browser's own menu (spelling
|
|
15
|
+
* suggestions from the browser's spell checker live there). It opens from the keyboard with the Menu key or Shift+F10.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ContextMenu(options?: ContextMenuOptions): EditorPlugin;
|
|
18
|
+
/** Select everything: an item other plugins can reuse. */
|
|
19
|
+
export declare const selectAllItem: ContextMenuItem;
|
|
@@ -70,3 +70,9 @@ export declare function docIndex<T>(name: string, match: (n: PMNode) => boolean,
|
|
|
70
70
|
rev: number;
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
+
/** Where the link (or any mark) at the selection starts and ends: the whole run of text that carries the same mark. */
|
|
74
|
+
export declare function markRunAt(state: EditorState, markName: string): {
|
|
75
|
+
mark: import('prosemirror-model').Mark;
|
|
76
|
+
from: number;
|
|
77
|
+
to: number;
|
|
78
|
+
} | null;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { List } from './list.js';
|
|
|
5
5
|
export { Blocks } from './blocks.js';
|
|
6
6
|
export { Link } from './link.js';
|
|
7
7
|
export { Image } from './image.js';
|
|
8
|
+
export { ContextMenu, buildContextMenu, tidyEntries } from './context-menu.js';
|
|
9
|
+
export type { ContextMenuOptions } from './context-menu.js';
|
|
8
10
|
export { Table } from './table.js';
|
|
9
11
|
export { Autoformat } from './autoformat.js';
|
|
10
12
|
export { Alignment } from './alignment.js';
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createEditor } from "./src-
|
|
1
|
+
import { t as createEditor } from "./src-DFClH3tv.js";
|
|
2
2
|
import { createElement, forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
|
|
3
3
|
//#region src/react.ts
|
|
4
4
|
/** React wrapper (needs the optional `react` peer dependency). */
|