ccms-wysiwyg-editor 0.0.0-stage → 0.2.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/README.md +86 -2
- package/dist/core/ChangeQueue.d.ts +24 -0
- package/dist/core/ChangeQueue.d.ts.map +1 -0
- package/dist/core/CommandRegistry.d.ts +40 -0
- package/dist/core/CommandRegistry.d.ts.map +1 -0
- package/dist/core/EditorEngine.d.ts +55 -0
- package/dist/core/EditorEngine.d.ts.map +1 -0
- package/dist/core/FontLoader.d.ts +10 -0
- package/dist/core/FontLoader.d.ts.map +1 -0
- package/dist/core/HistoryManager.d.ts +28 -0
- package/dist/core/HistoryManager.d.ts.map +1 -0
- package/dist/core/HtmlSerializer.d.ts +8 -0
- package/dist/core/HtmlSerializer.d.ts.map +1 -0
- package/dist/core/PasteSanitizer.d.ts +12 -0
- package/dist/core/PasteSanitizer.d.ts.map +1 -0
- package/dist/core/SelectionManager.d.ts +31 -0
- package/dist/core/SelectionManager.d.ts.map +1 -0
- package/dist/core/TableController.d.ts +81 -0
- package/dist/core/TableController.d.ts.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4007 -0
- package/dist/style.css +1 -0
- package/dist/toolbar/ToolbarCoordinator.d.ts +17 -0
- package/dist/toolbar/ToolbarCoordinator.d.ts.map +1 -0
- package/dist/toolbar/ToolbarPositioner.d.ts +22 -0
- package/dist/toolbar/ToolbarPositioner.d.ts.map +1 -0
- package/dist/toolbar/toolbarPresets.d.ts +7 -0
- package/dist/toolbar/toolbarPresets.d.ts.map +1 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vue/WysiwygEditor.vue.d.ts +133 -0
- package/dist/vue/WysiwygEditor.vue.d.ts.map +1 -0
- package/dist/vue/WysiwygToolbar.vue.d.ts +57 -0
- package/dist/vue/WysiwygToolbar.vue.d.ts.map +1 -0
- package/dist/vue/components/ColorPickerDropdown.vue.d.ts +20 -0
- package/dist/vue/components/ColorPickerDropdown.vue.d.ts.map +1 -0
- package/dist/vue/components/FontDropdown.vue.d.ts +20 -0
- package/dist/vue/components/FontDropdown.vue.d.ts.map +1 -0
- package/dist/vue/components/SourceCodeDialog.vue.d.ts +13 -0
- package/dist/vue/components/SourceCodeDialog.vue.d.ts.map +1 -0
- package/dist/vue/components/SvgIcon.vue.d.ts +9 -0
- package/dist/vue/components/SvgIcon.vue.d.ts.map +1 -0
- package/dist/vue/components/TablePickerDropdown.vue.d.ts +10 -0
- package/dist/vue/components/TablePickerDropdown.vue.d.ts.map +1 -0
- package/dist/vue/components/TableToolsPanel.vue.d.ts +13 -0
- package/dist/vue/components/TableToolsPanel.vue.d.ts.map +1 -0
- package/dist/vue/composables/useWysiwygEditor.d.ts +98 -0
- package/dist/vue/composables/useWysiwygEditor.d.ts.map +1 -0
- package/package.json +66 -4
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ccms-wysiwyg-editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-agnostic TypeScript WYSIWYG core + Vue 3 editor components featuring toolbar-driven table creation/modification and configurable screen or editor-snapped toolbar placement.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install ccms-wysiwyg-editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Import the styles once in your entry file or component:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import "ccms-wysiwyg-editor/style.css";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start (Vue 3)
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<WysiwygEditor
|
|
22
|
+
v-model="html"
|
|
23
|
+
:toolbar="toolbarConfig"
|
|
24
|
+
:fonts="fonts"
|
|
25
|
+
:font-sizes="[8, 10, 11, 12, 14, 16, 18, 24, 32]"
|
|
26
|
+
@save="handleSave"
|
|
27
|
+
/>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import { ref } from "vue";
|
|
32
|
+
import {
|
|
33
|
+
WysiwygEditor,
|
|
34
|
+
GUEST_DIRECTORY_TOOLBAR_ITEMS,
|
|
35
|
+
DEFAULT_SNAPPED_PLACEMENT,
|
|
36
|
+
} from "ccms-wysiwyg-editor";
|
|
37
|
+
import "ccms-wysiwyg-editor/style.css";
|
|
38
|
+
|
|
39
|
+
const html = ref("<p>Hello World</p>");
|
|
40
|
+
const fonts = ref([{ text: "Liberation Sans", value: "Liberation Sans" }]);
|
|
41
|
+
|
|
42
|
+
const toolbarConfig = {
|
|
43
|
+
items: GUEST_DIRECTORY_TOOLBAR_ITEMS,
|
|
44
|
+
placement: DEFAULT_SNAPPED_PLACEMENT,
|
|
45
|
+
visibility: "on-focus" as const,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function handleSave(content: string) {
|
|
49
|
+
console.log("Saved HTML:", content);
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Toolbar Placement Modes
|
|
55
|
+
|
|
56
|
+
Configure `toolbar.placement.mode`:
|
|
57
|
+
|
|
58
|
+
- **`snapped`** (default): Teleported to `body`, anchored to `top | bottom | left | right` edge of the editor with `align`, `offset`, `autoFlip`, and `clampToViewport`. Supports `allowModeSwitch: true` to detach/drag and snap back.
|
|
59
|
+
- **`screen-fixed`**: Pinned to screen anchors (`top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right`, or `custom` `{ x, y }`).
|
|
60
|
+
- **`floating-draggable`**: Freely draggable anywhere on screen via the grip handle with viewport clamping and optional `localStorage` persistence (`storageKey`).
|
|
61
|
+
- **`portal`**: Teleported into an external `target` CSS selector or `HTMLElement`.
|
|
62
|
+
- **`inline`**: Rendered statically inside the editor flow.
|
|
63
|
+
|
|
64
|
+
## Table Features (from Toolbar)
|
|
65
|
+
|
|
66
|
+
- **Insert Table:** 10×10 interactive hover grid + custom rows/columns + optional `<thead>` header row + initial border preset (`solid`, `dashed`, `none`).
|
|
67
|
+
- **Modify Table:** Insert row above/below, delete row, toggle header row, insert column left/right, delete column, distribute columns evenly, multi-cell selection + merge/split (`colspan`/`rowspan`), border presets (all/outer/inner/dashed/**None / Remove Borders** with editor-only guide stripped on save), cell background, horizontal & vertical alignment, cell padding presets, and delete table.
|
|
68
|
+
|
|
69
|
+
## Scripts
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm test # Run Vitest unit & component tests
|
|
73
|
+
npm run typecheck # Run vue-tsc strict typecheck
|
|
74
|
+
npm run build # Build dist/index.js, dist/index.cjs, dist/style.css, dist/*.d.ts
|
|
75
|
+
npm run release:prepare # Run tests and rebuild dist/ before tagging a release
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Publishing to Public npm
|
|
79
|
+
|
|
80
|
+
Source code is hosted on Bitbucket (`https://bitbucket.org/guesttek/ccms-wysiwyg-editor.git`), and releases are published to the public npm registry (`https://registry.npmjs.org/`):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm login
|
|
84
|
+
npm version patch # or minor / major
|
|
85
|
+
npm publish # runs prepublishOnly (test + build) automatically
|
|
86
|
+
git push origin main --follow-tags
|
|
87
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { QueueEntry } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Queues editor content edits and batches them until explicit flush triggers
|
|
4
|
+
* (Save click, blur, unmount, or beforeunload) while deduplicating unchanged content.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ChangeQueue {
|
|
7
|
+
private queue;
|
|
8
|
+
private lastSavedContent;
|
|
9
|
+
constructor(initialContent?: string);
|
|
10
|
+
getLastSavedContent(): string;
|
|
11
|
+
getEntries(): readonly QueueEntry[];
|
|
12
|
+
isDirty(): boolean;
|
|
13
|
+
enqueue(content: string, source?: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the content to persist if it differs from lastSavedContent; otherwise null.
|
|
16
|
+
*/
|
|
17
|
+
flush(_trigger?: string, fallbackContent?: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Synchronizes external prop changes without clobbering unsaved user edits.
|
|
20
|
+
*/
|
|
21
|
+
syncExternal(content: string): boolean;
|
|
22
|
+
markSaved(content: string): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=ChangeQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangeQueue.d.ts","sourceRoot":"","sources":["../../src/core/ChangeQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,gBAAgB,CAAS;gBAErB,cAAc,SAAK;IAI/B,mBAAmB,IAAI,MAAM;IAI7B,UAAU,IAAI,SAAS,UAAU,EAAE;IAInC,OAAO,IAAI,OAAO;IAIlB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAW,GAAG,OAAO;IAoBpD;;OAEG;IACH,KAAK,CAAC,QAAQ,SAAW,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAgBnE;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAWtC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAIjC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FormatState } from "../types";
|
|
2
|
+
import { SelectionManager } from "./SelectionManager";
|
|
3
|
+
export type TextCaseMode = "upper" | "lower";
|
|
4
|
+
export type TextAlignMode = "left" | "center" | "right" | "justify";
|
|
5
|
+
/**
|
|
6
|
+
* Pure DOM/Range formatting command engine producing semantic HTML + inline CSS
|
|
7
|
+
* without relying on deprecated document.execCommand behavior.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CommandRegistry {
|
|
10
|
+
private readonly selection;
|
|
11
|
+
constructor(selection: SelectionManager);
|
|
12
|
+
private getRootOrThrow;
|
|
13
|
+
private ensureRange;
|
|
14
|
+
private insertCaretWrapper;
|
|
15
|
+
private selectNodesRange;
|
|
16
|
+
toggleInline(kind: "bold" | "italic" | "underline" | "strikethrough"): boolean;
|
|
17
|
+
applySpanStyle(styleProp: "fontFamily" | "fontSize" | "color" | "backgroundColor", value: string): boolean;
|
|
18
|
+
private withRangeMarkers;
|
|
19
|
+
private isBlockNode;
|
|
20
|
+
/**
|
|
21
|
+
* Wraps loose inline runs directly inside `root` into `<p>` lines split on `<br>`,
|
|
22
|
+
* leaving existing block elements untouched.
|
|
23
|
+
*/
|
|
24
|
+
private splitLooseRootLines;
|
|
25
|
+
/**
|
|
26
|
+
* Splits a block element containing `<br>`-separated lines into sibling blocks of the same tag.
|
|
27
|
+
*/
|
|
28
|
+
private splitBlockOnBr;
|
|
29
|
+
private prepareBlocksForLineAction;
|
|
30
|
+
private expandSelectionOutOfInlineWrappers;
|
|
31
|
+
formatBlock(tagName: string): boolean;
|
|
32
|
+
setAlign(align: TextAlignMode): boolean;
|
|
33
|
+
toggleList(listTag: "ol" | "ul"): boolean;
|
|
34
|
+
indent(delta: 1 | -1): boolean;
|
|
35
|
+
insertHorizontalRule(): boolean;
|
|
36
|
+
transformCase(mode: TextCaseMode): boolean;
|
|
37
|
+
clearFormat(): boolean;
|
|
38
|
+
queryFormatState(): FormatState;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=CommandRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandRegistry.d.ts","sourceRoot":"","sources":["../../src/core/CommandRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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EditorEvents, EditorOptions, FormatState, TableState } from "../types";
|
|
2
|
+
import { CommandRegistry } from "./CommandRegistry";
|
|
3
|
+
import { HistoryManager } from "./HistoryManager";
|
|
4
|
+
import { HtmlSerializer } from "./HtmlSerializer";
|
|
5
|
+
import { SelectionManager } from "./SelectionManager";
|
|
6
|
+
import { TableController } from "./TableController";
|
|
7
|
+
/**
|
|
8
|
+
* Headless rich-text editor core orchestrating selection, history, commands,
|
|
9
|
+
* table manipulation, paste cleanup, font loading, and clean HTML serialization.
|
|
10
|
+
*/
|
|
11
|
+
export declare class EditorEngine {
|
|
12
|
+
readonly selection: SelectionManager;
|
|
13
|
+
readonly history: HistoryManager;
|
|
14
|
+
readonly commands: CommandRegistry;
|
|
15
|
+
readonly table: TableController;
|
|
16
|
+
readonly serializer: HtmlSerializer;
|
|
17
|
+
private root;
|
|
18
|
+
private options;
|
|
19
|
+
private pasteConfig;
|
|
20
|
+
private listeners;
|
|
21
|
+
private readonly onInputBound;
|
|
22
|
+
private readonly onPasteBound;
|
|
23
|
+
private readonly onKeyDownBound;
|
|
24
|
+
private readonly onMouseDownBound;
|
|
25
|
+
private readonly onMouseMoveBound;
|
|
26
|
+
private readonly onMouseUpBound;
|
|
27
|
+
private readonly onFocusBound;
|
|
28
|
+
private readonly onBlurBound;
|
|
29
|
+
private readonly onSelectionChangeBound;
|
|
30
|
+
constructor(options?: EditorOptions);
|
|
31
|
+
mount(el: HTMLElement): void;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
setReadonly(readonly: boolean): void;
|
|
34
|
+
updateFonts(fonts: EditorOptions["fonts"]): void;
|
|
35
|
+
on<K extends keyof EditorEvents>(event: K, callback: EditorEvents[K]): () => void;
|
|
36
|
+
private emit;
|
|
37
|
+
getHtml(): string;
|
|
38
|
+
setHtml(html: string, recordHistory?: boolean): void;
|
|
39
|
+
clear(recordHistory?: boolean): void;
|
|
40
|
+
focus(): void;
|
|
41
|
+
blur(): void;
|
|
42
|
+
undo(): boolean;
|
|
43
|
+
redo(): boolean;
|
|
44
|
+
execCommand(command: string, value?: unknown): boolean;
|
|
45
|
+
execTableAction(action: string, payload?: unknown): boolean;
|
|
46
|
+
getFormatState(): FormatState;
|
|
47
|
+
getTableState(): TableState;
|
|
48
|
+
private markBorderlessTables;
|
|
49
|
+
private handleDomMutation;
|
|
50
|
+
private emitHistoryState;
|
|
51
|
+
private emitSelectionState;
|
|
52
|
+
private handlePaste;
|
|
53
|
+
private handleKeyDown;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=EditorEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorEngine.d.ts","sourceRoot":"","sources":["../../src/core/EditorEngine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EAIX,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAyC,MAAM,mBAAmB,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD;;;GAGG;AACH,qBAAa,YAAY;IACvB,QAAQ,CAAC,SAAS,mBAA0B;IAC5C,QAAQ,CAAC,OAAO,iBAAwB;IACxC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,UAAU,iBAAwB;IAE3C,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAMf;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY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;IAIxB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,WAAW;IAgCnB,OAAO,CAAC,aAAa;CAoDtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FontDefinition } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Registers dynamic @font-face rules in a deduplicated document stylesheet.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FontLoader {
|
|
6
|
+
private static registered;
|
|
7
|
+
static registerFonts(fonts?: FontDefinition[]): void;
|
|
8
|
+
static resetForTests(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=FontLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontLoader.d.ts","sourceRoot":"","sources":["../../src/core/FontLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAoB/C;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,UAAU,CAA6B;IAEtD,MAAM,CAAC,aAAa,CAAC,KAAK,GAAE,cAAc,EAAO,GAAG,IAAI;IAiCxD,MAAM,CAAC,aAAa,IAAI,IAAI;CAM7B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface HistorySnapshot {
|
|
2
|
+
html: string;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Snapshot-based Undo/Redo history stack with typing coalescing.
|
|
7
|
+
*/
|
|
8
|
+
export declare class HistoryManager {
|
|
9
|
+
private stack;
|
|
10
|
+
private index;
|
|
11
|
+
private readonly maxSize;
|
|
12
|
+
private readonly coalesceMs;
|
|
13
|
+
constructor(maxSize?: number, coalesceMs?: number);
|
|
14
|
+
reset(initialHtml: string): void;
|
|
15
|
+
current(): string | null;
|
|
16
|
+
canUndo(): boolean;
|
|
17
|
+
canRedo(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Pushes a new HTML snapshot onto the stack.
|
|
20
|
+
* When `force` is false and the previous snapshot occurred within `coalesceMs`,
|
|
21
|
+
* the current tip snapshot is updated in place to avoid character-by-character spam.
|
|
22
|
+
*/
|
|
23
|
+
push(html: string, force?: boolean): boolean;
|
|
24
|
+
undo(): string | null;
|
|
25
|
+
redo(): string | null;
|
|
26
|
+
size(): number;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=HistoryManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HistoryManager.d.ts","sourceRoot":"","sources":["../../src/core/HistoryManager.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,OAAO,SAAM,EAAE,UAAU,SAAM;IAK3C,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKhC,OAAO,IAAI,MAAM,GAAG,IAAI;IAKxB,OAAO,IAAI,OAAO;IAIlB,OAAO,IAAI,OAAO;IAIlB;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO;IAyB1C,IAAI,IAAI,MAAM,GAAG,IAAI;IAMrB,IAAI,IAAI,MAAM,GAAG,IAAI;IAMrB,IAAI,IAAI,MAAM;CAGf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes the editor DOM into clean, self-contained HTML with inline styles
|
|
3
|
+
* and zero editor-specific UI artifacts.
|
|
4
|
+
*/
|
|
5
|
+
export declare class HtmlSerializer {
|
|
6
|
+
serialize(root: HTMLElement | null): string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=HtmlSerializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HtmlSerializer.d.ts","sourceRoot":"","sources":["../../src/core/HtmlSerializer.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM;CAqD5C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PasteConfig } from "../types";
|
|
2
|
+
export declare const DEFAULT_DENIED_TAGS: string[];
|
|
3
|
+
export declare const DEFAULT_DENIED_ATTRS: string[];
|
|
4
|
+
/**
|
|
5
|
+
* Converts plain text into safe HTML paragraphs/line breaks.
|
|
6
|
+
*/
|
|
7
|
+
export declare function plainTextToHtml(text: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Sanitizes untrusted or pasted HTML markup using DOMParser while keeping safe formatting and tables.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sanitizeHtml(html: string, config?: PasteConfig): string;
|
|
12
|
+
//# sourceMappingURL=PasteSanitizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasteSanitizer.d.ts","sourceRoot":"","sources":["../../src/core/PasteSanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,mBAAmB,UA6C/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAiBhC,CAAC;AAkBF;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD;AA4BD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,WAAgB,GAAG,MAAM,CA+E3E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages DOM Selection/Range queries, preservation, and restoration scoped to an editor root.
|
|
3
|
+
*/
|
|
4
|
+
export declare class SelectionManager {
|
|
5
|
+
private root;
|
|
6
|
+
private savedRange;
|
|
7
|
+
attach(root: HTMLElement): void;
|
|
8
|
+
detach(): void;
|
|
9
|
+
getRoot(): HTMLElement | null;
|
|
10
|
+
isInsideEditor(node: Node | null): boolean;
|
|
11
|
+
getActiveRange(): Range | null;
|
|
12
|
+
/**
|
|
13
|
+
* Saves the current selection range if it lies within the editor root.
|
|
14
|
+
*/
|
|
15
|
+
save(): Range | null;
|
|
16
|
+
getSavedRange(): Range | null;
|
|
17
|
+
/**
|
|
18
|
+
* Restores the previously saved selection range (or ensures an active range exists).
|
|
19
|
+
*/
|
|
20
|
+
restore(): Range | null;
|
|
21
|
+
setRange(range: Range): void;
|
|
22
|
+
placeCaretAtEnd(target?: Node): Range | null;
|
|
23
|
+
placeCaretInElement(el: HTMLElement, atStart?: boolean): Range | null;
|
|
24
|
+
getClosestElement(node: Node | null): HTMLElement | null;
|
|
25
|
+
getClosestBlock(node: Node | null): HTMLElement | null;
|
|
26
|
+
getClosestCell(node: Node | null): HTMLTableCellElement | null;
|
|
27
|
+
getClosestTable(node: Node | null): HTMLTableElement | null;
|
|
28
|
+
getSelectedBlocks(range: Range): HTMLElement[];
|
|
29
|
+
hasSelectionText(): boolean;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=SelectionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../src/core/SelectionManager.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,UAAU,CAAsB;IAExC,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAI/B,MAAM,IAAI,IAAI;IAKd,OAAO,IAAI,WAAW,GAAG,IAAI;IAI7B,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO;IAK1C,cAAc,IAAI,KAAK,GAAG,IAAI;IAU9B;;OAEG;IACH,IAAI,IAAI,KAAK,GAAG,IAAI;IASpB,aAAa,IAAI,KAAK,GAAG,IAAI;IAI7B;;OAEG;IACH,OAAO,IAAI,KAAK,GAAG,IAAI;IAqBvB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAS5B,eAAe,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI;IAU5C,mBAAmB,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,UAAO,GAAG,KAAK,GAAG,IAAI;IASlE,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI;IAQxD,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI;IAWtD,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,oBAAoB,GAAG,IAAI;IAU9D,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,gBAAgB,GAAG,IAAI;IAU3D,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,EAAE;IAmD9C,gBAAgB,IAAI,OAAO;CAI5B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TableBorderPreset, TableInsertOptions, TableState } from "../types";
|
|
2
|
+
import { SelectionManager } from "./SelectionManager";
|
|
3
|
+
export interface MatrixEntry {
|
|
4
|
+
cell: HTMLTableCellElement;
|
|
5
|
+
row: number;
|
|
6
|
+
col: number;
|
|
7
|
+
rowSpan: number;
|
|
8
|
+
colSpan: number;
|
|
9
|
+
isOrigin: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface TableBounds {
|
|
12
|
+
minR: number;
|
|
13
|
+
maxR: number;
|
|
14
|
+
minC: number;
|
|
15
|
+
maxC: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Manages table creation, logical grid geometry (colspan/rowspan), multi-cell selection,
|
|
19
|
+
* structural modifications, border presets, cell styling, and Tab navigation.
|
|
20
|
+
*/
|
|
21
|
+
export declare class TableController {
|
|
22
|
+
private readonly selection;
|
|
23
|
+
private selectedCells;
|
|
24
|
+
private anchorCell;
|
|
25
|
+
private isDraggingSelection;
|
|
26
|
+
constructor(selection: SelectionManager);
|
|
27
|
+
getSelectedCells(): HTMLTableCellElement[];
|
|
28
|
+
clearCellSelection(): void;
|
|
29
|
+
private setSelectedCells;
|
|
30
|
+
/**
|
|
31
|
+
* Builds a logical 2D matrix resolving colspan and rowspan offsets.
|
|
32
|
+
*/
|
|
33
|
+
buildTableMatrix(table: HTMLTableElement): MatrixEntry[][];
|
|
34
|
+
private findCellBounds;
|
|
35
|
+
private getActiveContext;
|
|
36
|
+
private getEffectiveCells;
|
|
37
|
+
/**
|
|
38
|
+
* Handles mouse down on table cells for single/shift/drag multi-cell selection.
|
|
39
|
+
*/
|
|
40
|
+
handlePointerDown(event: MouseEvent): void;
|
|
41
|
+
handlePointerMove(event: MouseEvent): void;
|
|
42
|
+
handlePointerUp(): void;
|
|
43
|
+
selectCellRange(table: HTMLTableElement, startCell: HTMLTableCellElement, endCell: HTMLTableCellElement): void;
|
|
44
|
+
/**
|
|
45
|
+
* Inserts a new semantic inline-styled table at the current selection.
|
|
46
|
+
*/
|
|
47
|
+
insertTable(options: TableInsertOptions): HTMLTableElement | null;
|
|
48
|
+
insertRowAbove(): boolean;
|
|
49
|
+
insertRowBelow(): boolean;
|
|
50
|
+
private insertRow;
|
|
51
|
+
deleteRow(): boolean;
|
|
52
|
+
toggleHeaderRow(): boolean;
|
|
53
|
+
insertColLeft(): boolean;
|
|
54
|
+
insertColRight(): boolean;
|
|
55
|
+
private insertCol;
|
|
56
|
+
deleteCol(): boolean;
|
|
57
|
+
distributeColumns(): boolean;
|
|
58
|
+
canMergeSelection(table?: HTMLTableElement): boolean;
|
|
59
|
+
mergeSelectedCells(): boolean;
|
|
60
|
+
splitCell(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Applies a border preset to the active table without mutating content structure.
|
|
63
|
+
*/
|
|
64
|
+
applyBorderPreset(preset: TableBorderPreset, color?: string, width?: string): boolean;
|
|
65
|
+
setBorderStyle(width: string, color: string, style?: "solid" | "dashed" | "dotted"): boolean;
|
|
66
|
+
setCellBackground(color: string): boolean;
|
|
67
|
+
setCellAlign(align: "left" | "center" | "right"): boolean;
|
|
68
|
+
setCellVerticalAlign(valign: "top" | "middle" | "bottom"): boolean;
|
|
69
|
+
setCellPadding(padding: string): boolean;
|
|
70
|
+
deleteTable(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Handles Tab / Shift+Tab navigation between table cells.
|
|
73
|
+
*/
|
|
74
|
+
handleTabNavigation(shiftKey: boolean): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Handles safe Backspace/Delete when multiple cells are selected.
|
|
77
|
+
*/
|
|
78
|
+
handleMultiCellDelete(): boolean;
|
|
79
|
+
getTableState(): TableState;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=TableController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableController.d.ts","sourceRoot":"","sources":["../../src/core/TableController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,M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