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,56 @@
|
|
|
1
|
+
import type { EditorState } from 'prosemirror-state';
|
|
2
|
+
import type { Editor } from '../editor';
|
|
3
|
+
import type { ToolbarItem } from '../plugin';
|
|
4
|
+
export declare const SEPARATOR = "|";
|
|
5
|
+
/** `overflow`: items that don't fit go into a "More" panel. `wrap`: items wrap to more rows. */
|
|
6
|
+
export type ToolbarMode = 'overflow' | 'wrap';
|
|
7
|
+
/** `Mod-Shift-z` → `Ctrl+Shift+Z` (or `⌘⇧Z` on macOS). */
|
|
8
|
+
export declare function formatShortcut(shortcut: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* How many items fit in a row: the number of leading items whose right edge
|
|
11
|
+
* (offsetLeft + offsetWidth) is within `limit`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fitCount(rightEdges: readonly number[], limit: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* Accessible toolbar: role="toolbar", a single tab stop with arrow-key navigation
|
|
16
|
+
* (roving tabindex), aria-pressed on toggles, aria-disabled on unavailable items and
|
|
17
|
+
* aria-expanded on buttons that open popovers. In `overflow` mode, items that don't
|
|
18
|
+
* fit move into a "More" disclosure panel.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Toolbar {
|
|
21
|
+
private editor;
|
|
22
|
+
readonly dom: HTMLElement;
|
|
23
|
+
private controls;
|
|
24
|
+
/** Controls and separators in configured order. */
|
|
25
|
+
private entries;
|
|
26
|
+
private more;
|
|
27
|
+
private panel;
|
|
28
|
+
private observer;
|
|
29
|
+
constructor(editor: Editor, names: readonly string[], registry: ReadonlyMap<string, ToolbarItem>, { warnUnknown, mode }?: {
|
|
30
|
+
warnUnknown?: boolean | undefined;
|
|
31
|
+
mode?: ToolbarMode | undefined;
|
|
32
|
+
});
|
|
33
|
+
private label;
|
|
34
|
+
private createButton;
|
|
35
|
+
private createSelect;
|
|
36
|
+
update(state: EditorState): void;
|
|
37
|
+
/** Moves focus into the toolbar (Alt+F10 from the editor). */
|
|
38
|
+
focus(): void;
|
|
39
|
+
destroy(): void;
|
|
40
|
+
private setUpOverflow;
|
|
41
|
+
/** Moves the items that don't fit into the "More" panel. Runs on every resize. */
|
|
42
|
+
layout(): void;
|
|
43
|
+
private openPanel;
|
|
44
|
+
private closePanel;
|
|
45
|
+
private panelItems;
|
|
46
|
+
private onOutside;
|
|
47
|
+
private onPanelKey;
|
|
48
|
+
/** Row items plus the "More" button, in order. */
|
|
49
|
+
private focusable;
|
|
50
|
+
/** Keeps exactly one tab stop in the row, also after items moved into the panel. */
|
|
51
|
+
private ensureTabStop;
|
|
52
|
+
private onFocusIn;
|
|
53
|
+
private onKeyDown;
|
|
54
|
+
private onPopover;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=toolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAiB,WAAW,EAAiB,MAAM,WAAW,CAAC;AAE3E,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B,gGAAgG;AAChG,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAS9C,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiBvD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI7E;AAOD;;;;;GAKG;AACH,qBAAa,OAAO;IAUhB,OAAO,CAAC,MAAM;IAThB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAiB;IACjC,mDAAmD;IACnD,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,IAAI,CAAkC;IAC9C,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,QAAQ,CAA+B;gBAGrC,MAAM,EAAE,MAAM,EACtB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAC1C,EAAE,WAAkB,EAAE,IAAgC,EAAE;;;KAAK;IA8C/D,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,YAAY;IA0BpB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAgChC,8DAA8D;IAC9D,KAAK,IAAI,IAAI;IAKb,OAAO,IAAI,IAAI;IASf,OAAO,CAAC,aAAa;IAyCrB,kFAAkF;IAClF,MAAM,IAAI,IAAI;IA2Bd,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,SAAS,CAGf;IAEF,OAAO,CAAC,UAAU,CAqBhB;IAIF,kDAAkD;IAClD,OAAO,CAAC,SAAS;IASjB,oFAAoF;IACpF,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,SAAS,CAKf;IAEF,OAAO,CAAC,SAAS,CAkBf;IAEF,OAAO,CAAC,SAAS,CAOf;CACH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EditorState } from 'prosemirror-state';
|
|
2
|
+
import type { Editor } from '../editor';
|
|
3
|
+
import { Popover } from './popover';
|
|
4
|
+
export interface MenuItem {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** Trusted HTML. */
|
|
8
|
+
icon?: string;
|
|
9
|
+
run: (editor: Editor) => void;
|
|
10
|
+
isActive?: (state: EditorState) => boolean;
|
|
11
|
+
isEnabled?: (state: EditorState) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A vertical list of actions in a popover, navigable with the arrow keys. */
|
|
14
|
+
export declare class MenuPopover extends Popover {
|
|
15
|
+
private buttons;
|
|
16
|
+
constructor(editor: Editor, label: string, items: MenuItem[]);
|
|
17
|
+
open(): void;
|
|
18
|
+
private onKey;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/ui/menu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;IAC3C,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;CAC7C;AAED,8EAA8E;AAC9E,qBAAa,WAAY,SAAQ,OAAO;IACtC,OAAO,CAAC,OAAO,CAAuD;gBAE1D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;IAwB5D,IAAI,IAAI,IAAI;IAYZ,OAAO,CAAC,KAAK,CAWX;CACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Editor } from '../editor';
|
|
2
|
+
/**
|
|
3
|
+
* Small dialog anchored to a document position inside the editor. Handles Escape,
|
|
4
|
+
* clicks outside, focus restore and positioning; subclasses provide the content.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Popover {
|
|
7
|
+
protected readonly editor: Editor;
|
|
8
|
+
readonly dom: HTMLElement;
|
|
9
|
+
/** Set by `getPopover`; toolbar buttons with the same `popover` key track it. */
|
|
10
|
+
key: string;
|
|
11
|
+
/** Unique prefix for element ids inside this popover. */
|
|
12
|
+
protected readonly uid: string;
|
|
13
|
+
constructor(editor: Editor, label: string);
|
|
14
|
+
get isOpen(): boolean;
|
|
15
|
+
/** Shows the popover below document position `pos` and focuses `focus`. */
|
|
16
|
+
protected show(pos: number, focus: HTMLElement): void;
|
|
17
|
+
close(restoreFocus?: boolean): void;
|
|
18
|
+
/** Announces open/close on the editor root (`wysio:popover`), e.g. for aria-expanded. */
|
|
19
|
+
private notify;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
private position;
|
|
22
|
+
private onOutside;
|
|
23
|
+
}
|
|
24
|
+
/** One popover instance per editor and key, destroyed together with the editor. */
|
|
25
|
+
export declare function getPopover<T extends Popover>(editor: Editor, key: string, create: () => T): T;
|
|
26
|
+
/** Builds a form from trusted markup; `{id}` in the template is replaced by the popover uid. */
|
|
27
|
+
export declare function createForm(doc: Document, uid: string, template: string): HTMLFormElement;
|
|
28
|
+
export declare function query<T extends Element>(root: ParentNode, selector: string): T;
|
|
29
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/ui/popover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIxC;;;GAGG;AACH,qBAAa,OAAO;IAQhB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAPnC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,iFAAiF;IACjF,GAAG,SAAM;IACT,yDAAyD;IACzD,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAiC;gBAGlC,MAAM,EAAE,MAAM,EACjC,KAAK,EAAE,MAAM;IAuBf,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,2EAA2E;IAC3E,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI;IAQrD,KAAK,CAAC,YAAY,UAAO,GAAG,IAAI;IAShC,yFAAyF;IACzF,OAAO,CAAC,MAAM;IAMd,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,SAAS,CAEf;CACH;AAID,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAiB7F;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAKxF;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAI9E"}
|
package/dist/url.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a URL that is safe to put in an `href`, or `null` when it is not.
|
|
3
|
+
*
|
|
4
|
+
* Only http(s), mailto and tel are allowed, plus scheme-less (relative, `#fragment`,
|
|
5
|
+
* `?query`, `//host`) URLs. Everything else, including `javascript:`, `data:` and
|
|
6
|
+
* `vbscript:`, is rejected.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sanitizeUrl(raw: unknown): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Turns what a user typed into a link dialog into a URL: adds `https://` to bare
|
|
11
|
+
* domains and `mailto:` to e-mail addresses. Returns `null` when the result is unsafe
|
|
12
|
+
* or clearly not a URL.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeUserUrl(input: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Like {@link sanitizeUrl} for image sources: http(s) and scheme-less URLs.
|
|
17
|
+
* Base64 raster `data:image/*` URLs only with `allowDataUrls`; SVG data URLs,
|
|
18
|
+
* `mailto:` and `tel:` are always rejected.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sanitizeImageUrl(raw: unknown, { allowDataUrls }?: {
|
|
21
|
+
allowDataUrls?: boolean | undefined;
|
|
22
|
+
}): string | null;
|
|
23
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAkBvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoB7D;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,aAAqB,EAAE;;CAAK,GAAG,MAAM,GAAG,IAAI,CAS5F"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Editor } from './editor';
|
|
2
|
+
/** Public shape of the `<wysio-editor>` element. */
|
|
3
|
+
export interface WysioEditorElement extends HTMLElement {
|
|
4
|
+
/**
|
|
5
|
+
* Current content, sanitised, in the `format` attribute's format (default HTML).
|
|
6
|
+
* Setting it replaces the content without emitting `change`.
|
|
7
|
+
*/
|
|
8
|
+
value: string;
|
|
9
|
+
/** The underlying editor, available while the element is connected. */
|
|
10
|
+
readonly editor: Editor | null;
|
|
11
|
+
readonly form: HTMLFormElement | null;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
/** Registers the `<wysio-editor>` custom element (no-op when already defined or outside a browser). */
|
|
15
|
+
export declare function defineWysioElement(tagName?: string): void;
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'wysio-editor': WysioEditorElement;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=web-component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-component.d.ts","sourceRoot":"","sources":["../src/web-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAErD,oDAAoD;AACpD,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAiID,uGAAuG;AACvG,wBAAgB,kBAAkB,CAAC,OAAO,SAAiB,GAAG,IAAI,CAGjE;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,kBAAkB,CAAC;KACpC;CACF"}
|