wysio 0.0.1 → 0.2.0-alpha.0
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 +25 -0
- package/LICENSE +21 -0
- package/README.md +241 -3
- package/dist/auto-init.d.ts +12 -0
- package/dist/auto-init.d.ts.map +1 -0
- package/dist/cdn-full.d.ts +3 -0
- package/dist/cdn-full.d.ts.map +1 -0
- package/dist/cdn.d.ts +2 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/commands.d.ts +19 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/content.d.ts +31 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/editor.d.ts +158 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/emitter.d.ts +9 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/format-html.d.ts +7 -0
- package/dist/format-html.d.ts.map +1 -0
- package/dist/i18n.d.ts +16 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/icons.d.ts +34 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/locales/nl.d.ts +81 -0
- package/dist/locales/nl.d.ts.map +1 -0
- package/dist/markdown/index.d.ts +17 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown.js +179 -0
- package/dist/markdown.js.map +1 -0
- package/dist/messages.d.ts +83 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/plugin.d.ts +94 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugins/alignment.d.ts +10 -0
- package/dist/plugins/alignment.d.ts.map +1 -0
- package/dist/plugins/base.d.ts +7 -0
- package/dist/plugins/base.d.ts.map +1 -0
- package/dist/plugins/blocks.d.ts +4 -0
- package/dist/plugins/blocks.d.ts.map +1 -0
- package/dist/plugins/clear-formatting.d.ts +10 -0
- package/dist/plugins/clear-formatting.d.ts.map +1 -0
- package/dist/plugins/color.d.ts +36 -0
- package/dist/plugins/color.d.ts.map +1 -0
- package/dist/plugins/heading.d.ts +3 -0
- package/dist/plugins/heading.d.ts.map +1 -0
- package/dist/plugins/history.d.ts +2 -0
- package/dist/plugins/history.d.ts.map +1 -0
- package/dist/plugins/image.d.ts +56 -0
- package/dist/plugins/image.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +29 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/link.d.ts +15 -0
- package/dist/plugins/link.d.ts.map +1 -0
- package/dist/plugins/lists.d.ts +2 -0
- package/dist/plugins/lists.d.ts.map +1 -0
- package/dist/plugins/marks.d.ts +7 -0
- package/dist/plugins/marks.d.ts.map +1 -0
- package/dist/plugins/paste.d.ts +9 -0
- package/dist/plugins/paste.d.ts.map +1 -0
- package/dist/plugins/placeholder.d.ts +3 -0
- package/dist/plugins/placeholder.d.ts.map +1 -0
- package/dist/plugins/source.d.ts +5 -0
- package/dist/plugins/source.d.ts.map +1 -0
- package/dist/plugins/table.d.ts +14 -0
- package/dist/plugins/table.d.ts.map +1 -0
- package/dist/registry-BfhH2s8N.js +19 -0
- package/dist/registry-BfhH2s8N.js.map +1 -0
- package/dist/registry.d.ts +10 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/schema.d.ts +5 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/style.css +824 -0
- package/dist/toolbar/toolbar.d.ts +56 -0
- package/dist/toolbar/toolbar.d.ts.map +1 -0
- package/dist/ui/menu.d.ts +20 -0
- package/dist/ui/menu.d.ts.map +1 -0
- package/dist/ui/popover.d.ts +29 -0
- package/dist/ui/popover.d.ts.map +1 -0
- package/dist/url.d.ts +23 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/web-component.d.ts +21 -0
- package/dist/web-component.d.ts.map +1 -0
- package/dist/wysio.full.iife.js +72 -0
- package/dist/wysio.iife.js +49 -0
- package/dist/wysio.js +2668 -0
- package/dist/wysio.js.map +1 -0
- package/package.json +68 -6
- package/index.js +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MarkType } from 'prosemirror-model';
|
|
2
|
+
import type { Command, EditorState } from 'prosemirror-state';
|
|
3
|
+
import { type WysioPlugin } from '../plugin';
|
|
4
|
+
export interface PaletteColor {
|
|
5
|
+
/**
|
|
6
|
+
* Identifier (`a-z`, digits, `-`): used in the class (`wysio-color-{name}`) and for the
|
|
7
|
+
* label (`color.{name}` message, or the name itself).
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/** Hex colour: `#rgb` or `#rrggbb`. */
|
|
11
|
+
value: string;
|
|
12
|
+
/** Label override. */
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ColorOptions {
|
|
16
|
+
/** The only colours that are accepted, in picker order. */
|
|
17
|
+
colors?: readonly PaletteColor[];
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_TEXT_COLORS: readonly PaletteColor[];
|
|
20
|
+
export declare const DEFAULT_HIGHLIGHT_COLORS: readonly PaletteColor[];
|
|
21
|
+
/** `#abc`, `#aabbcc` or `rgb(…)`/`rgba(…, 1)` → `#aabbcc`; anything else → `null`. */
|
|
22
|
+
export declare function normalizeColor(value: unknown): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* CSS rules for a custom palette, for pages that display editor content (and for the
|
|
25
|
+
* editor itself). The default palettes are already in `wysio/style.css`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function paletteCSS(kind: 'text' | 'highlight', colors: readonly PaletteColor[]): string;
|
|
28
|
+
export declare function setColorMark(type: MarkType, color: string): Command;
|
|
29
|
+
export declare function removeColorMark(type: MarkType): Command;
|
|
30
|
+
/** The colour name of `type` at the selection, when it is the same everywhere. */
|
|
31
|
+
export declare function activeColor(state: EditorState, type: MarkType): string | null;
|
|
32
|
+
/** Text colour, limited to a palette. Output: `<span class="wysio-color-{name}">`. */
|
|
33
|
+
export declare function textColor(options?: ColorOptions): WysioPlugin;
|
|
34
|
+
/** Highlight, limited to a palette. Output: `<mark class="wysio-highlight-{name}">`. */
|
|
35
|
+
export declare function highlight(options?: ColorOptions): WysioPlugin;
|
|
36
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/plugins/color.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAG3D,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,mBAAmB,EAAE,SAAS,YAAY,EAStD,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,SAAS,YAAY,EAS3D,CAAC;AAIF,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAY5D;AAiCD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAS9F;AAWD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAanE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAYvD;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAa7E;AA+FD,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,OAAO,GAAE,YAAiB,GAAG,WAAW,CA4DjE;AAED,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,OAAO,GAAE,YAAiB,GAAG,WAAW,CAiEjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/plugins/heading.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,uBAAwB,CAAC;AAIpD,eAAO,MAAM,OAAO,0BA+DlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/plugins/history.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO,0BAYlB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Editor } from '../editor';
|
|
2
|
+
import { type WysioPlugin } from '../plugin';
|
|
3
|
+
export declare const IMAGE_ALIGNMENTS: readonly ["left", "center", "right"];
|
|
4
|
+
export type ImageAlign = (typeof IMAGE_ALIGNMENTS)[number];
|
|
5
|
+
export interface ImageAttrs {
|
|
6
|
+
src: string;
|
|
7
|
+
alt?: string | null;
|
|
8
|
+
title?: string | null;
|
|
9
|
+
width?: number | null;
|
|
10
|
+
height?: number | null;
|
|
11
|
+
/** Rendered as the class `wysio-image-{align}`. */
|
|
12
|
+
align?: ImageAlign | null;
|
|
13
|
+
}
|
|
14
|
+
export interface ImageOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Allow base64 raster `data:image/*` URLs as `src` (pasted HTML, upload results).
|
|
17
|
+
* Off by default: they bloat the stored HTML.
|
|
18
|
+
*/
|
|
19
|
+
allowDataUrls?: boolean;
|
|
20
|
+
/** MIME types accepted for upload. Defaults to PNG, JPEG, GIF, WebP and AVIF. */
|
|
21
|
+
types?: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export interface UploadContext {
|
|
24
|
+
editor: Editor;
|
|
25
|
+
/** Aborted when the upload is cancelled (e.g. the editor is destroyed). */
|
|
26
|
+
signal: AbortSignal;
|
|
27
|
+
/** Report progress between 0 and 1. */
|
|
28
|
+
onProgress: (fraction: number) => void;
|
|
29
|
+
}
|
|
30
|
+
export type UploadResult = string | {
|
|
31
|
+
url: string;
|
|
32
|
+
alt?: string;
|
|
33
|
+
title?: string;
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
};
|
|
37
|
+
/** Uploads a file and resolves with its public URL. Rejecting removes the placeholder and emits `error`. */
|
|
38
|
+
export type UploadHandler = (file: File, context: UploadContext) => Promise<UploadResult>;
|
|
39
|
+
export declare const DEFAULT_IMAGE_TYPES: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* Uploads image files through the `upload` option and inserts them at `pos`
|
|
42
|
+
* (default: the selection), showing a placeholder while uploading.
|
|
43
|
+
*/
|
|
44
|
+
export declare function uploadImages(editor: Editor, files: Iterable<File>, pos?: number): Promise<void>[];
|
|
45
|
+
/**
|
|
46
|
+
* Inserts an image at the selection, or updates the selected image (only the
|
|
47
|
+
* attributes given). Returns false when `src` is unsafe.
|
|
48
|
+
*/
|
|
49
|
+
export declare function insertImage(editor: Editor, attrs: ImageAttrs): boolean;
|
|
50
|
+
/** Deletes the selected image. */
|
|
51
|
+
export declare function removeImage(editor: Editor): boolean;
|
|
52
|
+
/** Opens the image popover (insert, or edit the selected image). */
|
|
53
|
+
export declare function openImageDialog(editor: Editor): void;
|
|
54
|
+
/** Image support. Use `image({ ... })` in `plugins` to replace the default configuration. */
|
|
55
|
+
export declare function image(config?: ImageOptions): WysioPlugin;
|
|
56
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/plugins/image.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OA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FF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAsEjG;AA4DD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAiBtE;AAED,kCAAkC;AAClC,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOnD;AAID,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAGpD;AA6HD,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,MAAM,GAAE,YAAiB,GAAG,WAAW,CA8E5D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { alignment } from './alignment';
|
|
2
|
+
import { base } from './base';
|
|
3
|
+
import { blockquote, hardBreak, horizontalRule } from './blocks';
|
|
4
|
+
import { highlight, textColor } from './color';
|
|
5
|
+
import { heading } from './heading';
|
|
6
|
+
import { history } from './history';
|
|
7
|
+
import { image } from './image';
|
|
8
|
+
import { link } from './link';
|
|
9
|
+
import { lists } from './lists';
|
|
10
|
+
import { bold, code, italic, strike, underline } from './marks';
|
|
11
|
+
import { paste } from './paste';
|
|
12
|
+
import { placeholder } from './placeholder';
|
|
13
|
+
import { source } from './source';
|
|
14
|
+
import { table } from './table';
|
|
15
|
+
export { alignment, base, blockquote, bold, code, hardBreak, heading, highlight, history, horizontalRule, image, italic, link, lists, paste, placeholder, source, strike, table, textColor, underline, };
|
|
16
|
+
export { DEFAULT_IMAGE_TYPES, IMAGE_ALIGNMENTS, insertImage, openImageDialog, removeImage, uploadImages, type ImageAlign, type ImageAttrs, type ImageOptions, type UploadContext, type UploadHandler, type UploadResult, } from './image';
|
|
17
|
+
export { createTable, insertTable, MAX_TABLE_SIZE, openTableMenu, toggleHeaderRow } from './table';
|
|
18
|
+
export { cleanPastedHTML } from './paste';
|
|
19
|
+
export { toggleSourceView } from './source';
|
|
20
|
+
export { ALIGNMENTS, isAlignmentActive, openAlignmentMenu, setAlignment, type Alignment, } from './alignment';
|
|
21
|
+
export { activeColor, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_TEXT_COLORS, normalizeColor, paletteCSS, removeColorMark, setColorMark, type ColorOptions, type PaletteColor, } from './color';
|
|
22
|
+
export { clearFormatting, clearFormattingPlugin, FORMATTING_ATTRIBUTES } from './clear-formatting';
|
|
23
|
+
export { openLinkDialog, removeLink, setLink, type LinkAttrs } from './link';
|
|
24
|
+
/**
|
|
25
|
+
* Built-in plugins, in schema order. Mark order decides nesting in the output:
|
|
26
|
+
* link is outermost, code innermost.
|
|
27
|
+
*/
|
|
28
|
+
export declare const defaultPlugins: import("..").WysioPlugin[];
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EA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EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,cAAc,4BAuB1B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MarkType } from 'prosemirror-model';
|
|
2
|
+
import type { Command } from 'prosemirror-state';
|
|
3
|
+
import type { Editor } from '../editor';
|
|
4
|
+
export interface LinkAttrs {
|
|
5
|
+
href: string;
|
|
6
|
+
/** `'_blank'` to open in a new tab, otherwise `null`. */
|
|
7
|
+
target?: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** Sets a link on the selection (or the link around the cursor); inserts the URL as text when nothing is selected. */
|
|
10
|
+
export declare function setLink(type: MarkType, attrs: LinkAttrs): Command;
|
|
11
|
+
export declare function removeLink(type: MarkType): Command;
|
|
12
|
+
/** Opens the link popover for this editor. */
|
|
13
|
+
export declare function openLinkDialog(editor: Editor): void;
|
|
14
|
+
export declare const link: import("..").WysioPlugin;
|
|
15
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/plugins/link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAMxC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAUD,sHAAsH;AACtH,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAkBjE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAOlD;AAED,8CAA8C;AAC9C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAInD;AA6GD,eAAO,MAAM,IAAI,0BA4Df,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/plugins/lists.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,KAAK,0BA+EhB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type WysioPlugin } from '../plugin';
|
|
2
|
+
export declare const bold: WysioPlugin;
|
|
3
|
+
export declare const italic: WysioPlugin;
|
|
4
|
+
export declare const underline: WysioPlugin;
|
|
5
|
+
export declare const strike: WysioPlugin;
|
|
6
|
+
export declare const code: WysioPlugin;
|
|
7
|
+
//# sourceMappingURL=marks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.d.ts","sourceRoot":"","sources":["../../src/plugins/marks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAyB3D,eAAO,MAAM,IAAI,aAgBhB,CAAC;AAEF,eAAO,MAAM,MAAM,aAYlB,CAAC;AAEF,eAAO,MAAM,SAAS,aAWrB,CAAC;AAEF,eAAO,MAAM,MAAM,aAgBlB,CAAC;AAEF,eAAO,MAAM,IAAI,aAQhB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleans pasted HTML from Word, Google Docs and web pages before the schema parses it:
|
|
3
|
+
* removes comments, Office markup, scripts and styles; turns style-only bold/italic/
|
|
4
|
+
* underline/strike into tags; drops `style`, `class`, `id` and other attributes; unwraps
|
|
5
|
+
* `span`/`font`; removes empty paragraphs. The result is clean, not a faithful copy.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cleanPastedHTML(html: string, doc?: Document): string;
|
|
8
|
+
export declare const paste: import("..").WysioPlugin;
|
|
9
|
+
//# sourceMappingURL=paste.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paste.d.ts","sourceRoot":"","sources":["../../src/plugins/paste.ts"],"names":[],"mappings":"AA2GA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,QAAmB,GAAG,MAAM,CA6E9E;AAED,eAAO,MAAM,KAAK,0BAShB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placeholder.d.ts","sourceRoot":"","sources":["../../src/plugins/placeholder.ts"],"names":[],"mappings":"AAKA,+DAA+D;AAC/D,eAAO,MAAM,WAAW,0BAuBtB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Editor } from '../editor';
|
|
2
|
+
/** Switches between the WYSIWYG editor and the HTML source view. */
|
|
3
|
+
export declare function toggleSourceView(editor: Editor): void;
|
|
4
|
+
export declare const source: import("..").WysioPlugin;
|
|
5
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/plugins/source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA4FxC,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED,eAAO,MAAM,MAAM,0BAsBjB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { type Command } from 'prosemirror-state';
|
|
3
|
+
import type { Editor } from '../editor';
|
|
4
|
+
export declare const MAX_TABLE_SIZE = 10;
|
|
5
|
+
/** Builds a `rows` × `cols` table; the first row uses header cells when `header` is set. */
|
|
6
|
+
export declare function createTable(schema: Schema, rows: number, cols: number, header?: boolean): PMNode;
|
|
7
|
+
/** Inserts a table at the selection and puts the cursor in its first cell. */
|
|
8
|
+
export declare function insertTable(rows: number, cols: number, header?: boolean): Command;
|
|
9
|
+
/** Turns the table's first row into header cells, or back into normal cells. */
|
|
10
|
+
export declare const toggleHeaderRow: Command;
|
|
11
|
+
/** Opens the table popover: a size picker, or the table actions when the cursor is in a table. */
|
|
12
|
+
export declare function openTableMenu(editor: Editor): void;
|
|
13
|
+
export declare const table: import("..").WysioPlugin;
|
|
14
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/plugins/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,EAAY,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAiB,KAAK,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAclF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKxC,eAAO,MAAM,cAAc,KAAK,CAAC;AA4CjC,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,MAAM,CAa7F;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,CAwB9E;AAED,gFAAgF;AAChF,eAAO,MAAM,eAAe,EAAE,OAe7B,CAAC;AAoEF,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAGlD;AAiJD,eAAO,MAAM,KAAK,0BAgDhB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/plugin.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e;
|
|
4
|
+
}
|
|
5
|
+
// src/registry.ts
|
|
6
|
+
var t = /* @__PURE__ */ new Map();
|
|
7
|
+
function n(e, n) {
|
|
8
|
+
t.set(e, n);
|
|
9
|
+
}
|
|
10
|
+
function r(e) {
|
|
11
|
+
return e.flatMap((e) => {
|
|
12
|
+
if (typeof e != "string") return [e];
|
|
13
|
+
let n = t.get(e);
|
|
14
|
+
return n ? [n()] : (console.warn(`[wysio] Unknown plugin "${e}". Register it with registerPlugin() (wysio/markdown registers "markdown").`), []);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { r as n, e as r, n as t };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=registry-BfhH2s8N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-BfhH2s8N.js","names":["definePlugin","plugin","factories","registerPlugin","name","factory","resolvePluginNames","list","entry"],"sources":["../src/plugin.ts","../src/registry.ts"],"sourcesContent":["import type { InputRule } from 'prosemirror-inputrules';\nimport type { MarkSpec, Node as PMNode, NodeSpec, Schema } from 'prosemirror-model';\nimport type { Command, EditorState, Plugin } from 'prosemirror-state';\nimport type { Editor } from './editor';\n\nexport interface PluginContext {\n schema: Schema;\n editor: Editor;\n}\n\ninterface ToolbarItemBase {\n /** Accessible label and tooltip (already translated). Give this or `labelKey`. */\n label?: string;\n /** Message key for the label, translated by the toolbar (e.g. for custom items). */\n labelKey?: string;\n /** Whether the item can be used in the current state. Defaults to the command's dry run. */\n isEnabled?: (state: EditorState, editor: Editor) => boolean;\n /**\n * Keep the item usable in source mode and when the editor is read-only (e.g. the\n * source toggle itself). Other items are disabled then.\n */\n availableInSourceMode?: boolean;\n}\n\nexport interface ToolbarButton extends ToolbarItemBase {\n type?: 'button';\n /** Trusted HTML (usually an inline SVG). */\n icon: string;\n /** Keyboard shortcut in ProseMirror notation, shown in the tooltip, e.g. `Mod-b`. */\n shortcut?: string;\n /** ProseMirror command to run. Focus returns to the editor afterwards. */\n command?: Command;\n /** Custom action, for items that open UI (e.g. the link dialog). */\n run?: (editor: Editor) => void;\n /** When given, the button is a toggle and reflects this state through `aria-pressed`. */\n isActive?: (state: EditorState) => boolean;\n /**\n * Key of the popover this button opens (see `getPopover`). The button then gets\n * `aria-haspopup=\"dialog\"` and an `aria-expanded` that follows the popover.\n */\n popover?: string;\n /** Show a dropdown caret (for buttons that open a chooser). */\n dropdown?: boolean;\n /** Updates the button on every state change, e.g. to show the current colour. */\n render?: (state: EditorState, button: ToolbarButtonHandle) => void;\n}\n\n/** What `render` can change on a toolbar button. */\nexport interface ToolbarButtonHandle {\n readonly el: HTMLButtonElement;\n /** Replaces the icon (trusted HTML); a no-op when unchanged. */\n setIcon: (html: string) => void;\n}\n\nexport interface ToolbarSelect extends ToolbarItemBase {\n type: 'select';\n options: { value: string; label: string }[];\n /** Current value, or `''` when the selection does not match any option. */\n getValue: (state: EditorState) => string;\n onSelect: (editor: Editor, value: string) => void;\n}\n\nexport type ToolbarItem = ToolbarButton | ToolbarSelect;\n\n/** A text format a plugin can read and write (e.g. Markdown). */\nexport interface ContentFormatHandler {\n /** Parses text into a document. The editor sanitises the result like HTML input. */\n parse: (text: string, schema: Schema) => PMNode;\n serialize: (doc: PMNode) => string;\n}\n\nexport interface WysioPlugin {\n /** Unique name. */\n name: string;\n /** Nodes and marks this plugin adds to the schema. Order matters (see ProseMirror docs). */\n schema?: {\n nodes?: Record<string, NodeSpec>;\n marks?: Record<string, MarkSpec>;\n /**\n * Changes node specs defined by other plugins (e.g. adding an attribute to\n * `paragraph`). Applied after all nodes are collected; missing nodes are skipped.\n */\n extendNodes?: Record<string, (spec: NodeSpec) => NodeSpec>;\n };\n /** Toolbar items, keyed by the name used in the `toolbar` option. */\n toolbarItems?: (ctx: PluginContext) => Record<string, ToolbarItem>;\n /** Key bindings, in ProseMirror notation (`Mod-b`, `Shift-Enter`). */\n keymap?: (ctx: PluginContext) => Record<string, Command>;\n /** Markdown-style input rules. */\n inputRules?: (ctx: PluginContext) => InputRule[];\n /** Text formats this plugin adds, keyed by name (e.g. `markdown`). */\n formats?: (ctx: PluginContext) => Record<string, ContentFormatHandler>;\n /** Any other ProseMirror plugins. */\n prosemirrorPlugins?: (ctx: PluginContext) => Plugin[];\n}\n\n/** Identity helper that gives plugin definitions full type checking. */\nexport function definePlugin(plugin: WysioPlugin): WysioPlugin {\n return plugin;\n}\n","import type { WysioPlugin } from './plugin';\n\nconst factories = new Map<string, () => WysioPlugin>();\n\n/**\n * Makes a plugin available by name, so it can be enabled from JSON configuration\n * (`data-wysio-options`, `<wysio-editor plugins=\"…\">`) as `plugins: ['name']`.\n * `wysio/markdown` registers `markdown` when it is imported.\n */\nexport function registerPlugin(name: string, factory: () => WysioPlugin): void {\n factories.set(name, factory);\n}\n\n/** Turns plugin names into plugins; unknown names are skipped with a warning. */\nexport function resolvePluginNames(list: readonly (WysioPlugin | string)[]): WysioPlugin[] {\n return list.flatMap((entry) => {\n if (typeof entry !== 'string') return [entry];\n const factory = factories.get(entry);\n if (factory) return [factory()];\n console.warn(\n `[wysio] Unknown plugin \"${entry}\". Register it with registerPlugin() (wysio/markdown registers \"markdown\").`,\n );\n return [];\n });\n}\n"],"mappings":";AAiGA,SAAgBA,EAAaC,GAAkC;CAC7D,OAAOA;AACT;;ACjGA,IAAMC,oBAAY,IAAI,IAA+B;AAOrD,SAAgBC,EAAeC,GAAcC,GAAkC;CAC7EH,EAAU,IAAIE,GAAMC,CAAO;AAC7B;AAGA,SAAgBC,EAAmBC,GAAwD;CACzF,OAAOA,EAAK,SAASC,MAAU;EAC7B,IAAI,OAAOA,KAAU,UAAU,OAAO,CAACA,CAAK;EAC5C,IAAMH,IAAUH,EAAU,IAAIM,CAAK;EAKnC,OAJIH,IAAgB,CAACA,EAAQ,CAAC,KAC9B,QAAQ,KACN,2BAA2BG,EAAM,4EACnC,GACO,CAAC;CACV,CAAC;AACH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WysioPlugin } from './plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Makes a plugin available by name, so it can be enabled from JSON configuration
|
|
4
|
+
* (`data-wysio-options`, `<wysio-editor plugins="…">`) as `plugins: ['name']`.
|
|
5
|
+
* `wysio/markdown` registers `markdown` when it is imported.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerPlugin(name: string, factory: () => WysioPlugin): void;
|
|
8
|
+
/** Turns plugin names into plugins; unknown names are skipped with a warning. */
|
|
9
|
+
export declare function resolvePluginNames(list: readonly (WysioPlugin | string)[]): WysioPlugin[];
|
|
10
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,GAAG,IAAI,CAE7E;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,GAAG,WAAW,EAAE,CAUzF"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import type { WysioPlugin } from './plugin';
|
|
3
|
+
/** Builds a schema from the nodes and marks of all plugins, in plugin order. */
|
|
4
|
+
export declare function buildSchema(plugins: readonly WysioPlugin[]): Schema;
|
|
5
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgC,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAsBnE"}
|