wds-editor 0.0.0-stage → 1.0.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.
@@ -0,0 +1,128 @@
1
+ export declare const en: {
2
+ undo: string;
3
+ redo: string;
4
+ blockType: string;
5
+ paragraph: string;
6
+ heading1: string;
7
+ heading2: string;
8
+ heading3: string;
9
+ heading4: string;
10
+ codeBlock: string;
11
+ bold: string;
12
+ italic: string;
13
+ underline: string;
14
+ strike: string;
15
+ code: string;
16
+ link: string;
17
+ blockquote: string;
18
+ bulletList: string;
19
+ orderedList: string;
20
+ indent: string;
21
+ outdent: string;
22
+ alignLeft: string;
23
+ alignCenter: string;
24
+ alignRight: string;
25
+ alignJustify: string;
26
+ hr: string;
27
+ clear: string;
28
+ source: string;
29
+ fullscreen: string;
30
+ linkUrl: string;
31
+ linkText: string;
32
+ linkTitle: string;
33
+ linkNewTab: string;
34
+ linkInvalid: string;
35
+ save: string;
36
+ cancel: string;
37
+ remove: string;
38
+ close: string;
39
+ words: string;
40
+ characters: string;
41
+ poweredBy: string;
42
+ editorLabel: string;
43
+ toolbarLabel: string;
44
+ sourceLabel: string;
45
+ image: string;
46
+ file: string;
47
+ imageEdit: string;
48
+ imageUrl: string;
49
+ imageAlt: string;
50
+ imageAltHint: string;
51
+ imageWidth: string;
52
+ imageAlign: string;
53
+ alignNone: string;
54
+ alignLeftShort: string;
55
+ alignCenterShort: string;
56
+ alignRightShort: string;
57
+ imageInvalid: string;
58
+ insert: string;
59
+ fmTitle: string;
60
+ fmRoot: string;
61
+ fmBreadcrumb: string;
62
+ fmSearch: string;
63
+ fmSort: string;
64
+ fmSortNewest: string;
65
+ fmSortName: string;
66
+ fmSortLargest: string;
67
+ fmGrid: string;
68
+ fmList: string;
69
+ fmUpload: string;
70
+ fmDrop: string;
71
+ fmLoading: string;
72
+ fmEmpty: string;
73
+ fmNoResults: string;
74
+ fmLoadMore: string;
75
+ fmRetry: string;
76
+ fmDelete: string;
77
+ fmDeleteConfirm: string;
78
+ fmFromUrl: string;
79
+ fmLinkText: string;
80
+ fmFolder: string;
81
+ fmNoSelection: string;
82
+ fmNotAllowed: string;
83
+ fmUploadFailed: string;
84
+ fmListFailed: string;
85
+ fmDeleteFailed: string;
86
+ fmUploading: string;
87
+ table: string;
88
+ tableInsert: string;
89
+ tableSize: string;
90
+ rowAbove: string;
91
+ rowBelow: string;
92
+ colLeft: string;
93
+ colRight: string;
94
+ deleteRow: string;
95
+ deleteCol: string;
96
+ headerRow: string;
97
+ headerCol: string;
98
+ mergeCells: string;
99
+ splitCell: string;
100
+ deleteTable: string;
101
+ caption: string;
102
+ captionPlaceholder: string;
103
+ resizeImage: string;
104
+ pasteText: string;
105
+ textColor: string;
106
+ highlight: string;
107
+ removeColor: string;
108
+ removeHighlight: string;
109
+ colorRed: string;
110
+ colorOrange: string;
111
+ colorAmber: string;
112
+ colorYellow: string;
113
+ colorGreen: string;
114
+ colorTeal: string;
115
+ colorBlue: string;
116
+ colorPurple: string;
117
+ colorPink: string;
118
+ colorSlate: string;
119
+ colorGray: string;
120
+ };
121
+ export type Messages = typeof en;
122
+ export type MessageKey = keyof Messages;
123
+ export declare const tr: Messages;
124
+ /** Registers or extends a language, e.g. WDSEditor.addLanguage('de', { bold: 'Fett', ... }). Missing keys fall back to English. */
125
+ export declare function addLanguage(code: string, messages: Partial<Messages>): void;
126
+ export declare function resolveMessages(language: string | Partial<Messages> | undefined): Messages;
127
+ /** Fills {placeholders} in a message. */
128
+ export declare function format(message: string, values: Record<string, string>): string;
@@ -0,0 +1,8 @@
1
+ import './styles/wds-editor.css';
2
+ export { WDSEditor } from './editor';
3
+ export type { WDSEditorOptions, FileManagerOptions, FileItem, ImageAttrs, Theme, EditorEvent } from './editor';
4
+ export { normalizeList, matchesAccept, isImage } from './filemanager/api';
5
+ export { addLanguage, en, tr } from './i18n';
6
+ export type { Messages, MessageKey } from './i18n';
7
+ export { schema } from './schema';
8
+ export { toolbarItems, DEFAULT_TOOLBAR } from './toolbar';
@@ -0,0 +1,18 @@
1
+ import { Plugin, PluginKey, type EditorState } from 'prosemirror-state';
2
+ import { DecorationSet } from 'prosemirror-view';
3
+ import type { Command } from 'prosemirror-state';
4
+ /** Markdown-style shortcuts: "# " heading, "> " quote, "- " / "1. " lists, "```" code block, "---" rule. */
5
+ export declare function markdownShortcuts(): Plugin;
6
+ export declare function editorKeymap(actions: {
7
+ link: Command;
8
+ }): Plugin;
9
+ export declare const baseKeys: () => Plugin;
10
+ /** Shows the placeholder text while the document is a single empty paragraph. */
11
+ export declare function placeholder(text: string): Plugin;
12
+ /**
13
+ * Upload placeholders: a widget marks where a pasted / dropped file will land while it uploads.
14
+ * Positions are mapped through later edits, so typing during the upload is safe.
15
+ */
16
+ export declare const uploadKey: PluginKey<DecorationSet>;
17
+ export declare function uploadPlaceholders(): Plugin<DecorationSet>;
18
+ export declare function findUploadPlaceholder(state: EditorState, id: object): number | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * URL and pasted-HTML hygiene. The ProseMirror schema already drops every tag and attribute
3
+ * it does not know (scripts, event handlers, iframes, inline styles), so this file only has
4
+ * to deal with dangerous URL schemes and with the noise office suites put on the clipboard.
5
+ */
6
+ /** Returns the URL if it is safe to put in href/src, otherwise null. Relative URLs and anchors are allowed. */
7
+ export declare function safeUrl(value: string | null | undefined): string | null;
8
+ /** Makes a user-typed link usable: "example.com" -> "https://example.com", "a@b.com" -> "mailto:a@b.com". */
9
+ export declare function normalizeLinkInput(value: string): string | null;
10
+ /** Removes Microsoft Word / Google Docs clipboard noise before ProseMirror parses pasted HTML. */
11
+ export declare function cleanPastedHtml(html: string): string;
@@ -0,0 +1,8 @@
1
+ import { Schema, type NodeSpec, type MarkSpec, type Attrs } from 'prosemirror-model';
2
+ export type Align = 'left' | 'center' | 'right' | 'justify';
3
+ export type ImageAlign = 'left' | 'center' | 'right';
4
+ /** Inline styles keep alignment working on any site without extra CSS classes. */
5
+ export declare const IMAGE_ALIGN_STYLE: Record<ImageAlign, string>;
6
+ /** Attributes of the <img> element itself (shared by inline images and figures). */
7
+ export declare function imgDomAttrs(attrs: Attrs, withAlign: boolean): Record<string, string>;
8
+ export declare const schema: Schema<keyof import("orderedmap").default<NodeSpec>, keyof import("orderedmap").default<MarkSpec>>;
@@ -0,0 +1,31 @@
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { Messages, MessageKey } from './i18n';
3
+ import type { WDSEditor } from './editor';
4
+ export interface ToolbarButton {
5
+ type: 'button';
6
+ label: MessageKey;
7
+ icon: string;
8
+ run: (editor: WDSEditor, button: HTMLButtonElement) => void;
9
+ /** Opens a menu or picker (sets aria-haspopup). */
10
+ popup?: boolean;
11
+ /** Color shown in the icon's bar (CSS variable --wds-swatch). */
12
+ swatch?: (state: EditorState) => string | null;
13
+ active?: (state: EditorState, editor: WDSEditor) => boolean;
14
+ enabled?: (state: EditorState, editor: WDSEditor) => boolean;
15
+ /** Button stays usable in source mode (source toggle, fullscreen). */
16
+ inSource?: boolean;
17
+ shortcut?: string;
18
+ /** The button is left out of the toolbar when this returns false (e.g. "file" without a file manager). */
19
+ available?: (editor: WDSEditor) => boolean;
20
+ }
21
+ export interface ToolbarSelect {
22
+ type: 'blocks';
23
+ }
24
+ export type ToolbarItem = ToolbarButton | ToolbarSelect;
25
+ export declare const toolbarItems: Record<string, ToolbarItem>;
26
+ export declare const DEFAULT_TOOLBAR: string[];
27
+ /** Builds the toolbar element and returns an update function called on every state change. */
28
+ export declare function createToolbar(editor: WDSEditor, names: string[], t: Messages): {
29
+ element: HTMLElement;
30
+ update: (state: EditorState) => void;
31
+ };
@@ -0,0 +1,33 @@
1
+ export interface DialogField {
2
+ name: string;
3
+ label: string;
4
+ type: 'text' | 'url' | 'number' | 'checkbox' | 'select';
5
+ value?: string | boolean;
6
+ placeholder?: string;
7
+ /** Small help text under the field. */
8
+ hint?: string;
9
+ /** Options for type "select". */
10
+ options?: Array<{
11
+ value: string;
12
+ label: string;
13
+ }>;
14
+ }
15
+ export interface DialogOptions {
16
+ title: string;
17
+ fields: DialogField[];
18
+ submitLabel: string;
19
+ cancelLabel: string;
20
+ closeLabel: string;
21
+ /** Optional secondary action on the left, e.g. "Remove link". */
22
+ extraAction?: {
23
+ label: string;
24
+ onClick: () => void;
25
+ };
26
+ /** Returns an error message to block submit, or null. */
27
+ validate?: (values: Record<string, string | boolean>) => string | null;
28
+ onSubmit: (values: Record<string, string | boolean>) => void;
29
+ /** Called after the dialog closes for any reason (submit, cancel, Escape). */
30
+ onClose?: () => void;
31
+ }
32
+ /** Small modal form built on the native <dialog> element (focus trap, Escape and top layer come for free). */
33
+ export declare function openDialog(host: HTMLElement, options: DialogOptions): () => void;
@@ -0,0 +1 @@
1
+ export declare const icons: Record<string, string>;
@@ -0,0 +1,35 @@
1
+ import type { Node as PMNode } from 'prosemirror-model';
2
+ import type { EditorView, NodeView } from 'prosemirror-view';
3
+ export interface ImageViewHooks {
4
+ /** Double click: open the image dialog for the node at pos. */
5
+ onEdit: (pos: number) => void;
6
+ resizeLabel: string;
7
+ captionPlaceholder: string;
8
+ }
9
+ type GetPos = () => number | undefined;
10
+ export declare class ImageView implements NodeView {
11
+ dom: HTMLElement;
12
+ private node;
13
+ private parts;
14
+ constructor(node: PMNode, view: EditorView, getPos: GetPos, hooks: ImageViewHooks);
15
+ private render;
16
+ update(node: PMNode): boolean;
17
+ stopEvent(event: Event): boolean;
18
+ ignoreMutation(): boolean;
19
+ }
20
+ /** <figure> with a non-editable image and an editable <figcaption> (the node content). */
21
+ export declare class FigureView implements NodeView {
22
+ dom: HTMLElement;
23
+ contentDOM: HTMLElement;
24
+ private node;
25
+ private parts;
26
+ constructor(node: PMNode, view: EditorView, getPos: GetPos, hooks: ImageViewHooks);
27
+ private render;
28
+ update(node: PMNode): boolean;
29
+ stopEvent(event: Event): boolean;
30
+ ignoreMutation(mutation: MutationRecord | {
31
+ type: 'selection';
32
+ target: Node;
33
+ }): boolean;
34
+ }
35
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Small dropdown anchored to a toolbar button. It lives inside the editor root (theme variables
3
+ * apply), closes on Escape / outside click / item choice and gives focus back to the button's editor.
4
+ */
5
+ export interface MenuItem {
6
+ label: string;
7
+ icon?: string;
8
+ enabled?: boolean;
9
+ danger?: boolean;
10
+ run: () => void;
11
+ }
12
+ export type MenuEntry = MenuItem | '|';
13
+ export declare function closeMenus(): void;
14
+ /** A vertical list of actions (role="menu"), arrow keys move, Enter / Space run. */
15
+ export declare function showMenu(anchor: HTMLElement, host: HTMLElement, entries: MenuEntry[], label: string): void;
16
+ /** Grid picker for the size of a new table: hover / arrow keys choose, click / Enter inserts. */
17
+ export declare function showTablePicker(anchor: HTMLElement, host: HTMLElement, label: string, sizeLabel: (rows: number, cols: number) => string, onPick: (rows: number, cols: number) => void): void;
18
+ /** Swatch palette: arrow keys move, Enter / click applies, the first button removes the color. */
19
+ export declare function showColorPicker(anchor: HTMLElement, host: HTMLElement, options: {
20
+ label: string;
21
+ removeLabel: string;
22
+ swatches: Array<{
23
+ color: string;
24
+ label: string;
25
+ }>;
26
+ current: string | null;
27
+ columns: number;
28
+ onPick: (color: string | null) => void;
29
+ }): void;