open-edit 0.1.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.
@@ -0,0 +1,16 @@
1
+ import type { EditorPlugin } from '../core/types.js';
2
+ export interface AIPluginOptions {
3
+ /** Anthropic API key. Keep this server-side in production — use `endpoint` for a proxy. */
4
+ apiKey?: string;
5
+ /**
6
+ * Custom endpoint URL (proxy server). The plugin POSTs the same payload as the
7
+ * Anthropic Messages API. Use this to avoid exposing your API key in the browser.
8
+ * Example: '/api/ai' → your server calls Anthropic and returns the response.
9
+ */
10
+ endpoint?: string;
11
+ /** Model ID. Default: 'claude-sonnet-4-6' */
12
+ model?: string;
13
+ /** Max output tokens. Default: 2048 */
14
+ maxTokens?: number;
15
+ }
16
+ export declare function createAIPlugin(opts?: AIPluginOptions): EditorPlugin;
@@ -0,0 +1,5 @@
1
+ import type { EditorPlugin } from '../core/types.js';
2
+ import type { CalloutVariant } from '../core/types.js';
3
+ declare const CALLOUT_VARIANTS: CalloutVariant[];
4
+ export declare function createCalloutPlugin(): EditorPlugin;
5
+ export { CALLOUT_VARIANTS };
@@ -0,0 +1,2 @@
1
+ import type { EditorPlugin } from '../core/types.js';
2
+ export declare function createEmojiPlugin(): EditorPlugin;
@@ -0,0 +1,24 @@
1
+ import type { EditorPlugin } from '../core/types.js';
2
+ declare global {
3
+ interface Window {
4
+ hljs?: {
5
+ highlightElement(el: HTMLElement): void;
6
+ configure(opts: Record<string, unknown>): void;
7
+ };
8
+ }
9
+ }
10
+ export interface HighlightPluginOptions {
11
+ /** Force 'light' or 'dark' theme for code highlighting. Default: follows editor theme. */
12
+ theme?: 'light' | 'dark';
13
+ /**
14
+ * Custom highlight.js CSS theme URL.
15
+ * Pass a string to use the same URL for light and dark,
16
+ * or an object `{ light, dark }` to use different URLs per mode.
17
+ * Available themes: https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/
18
+ */
19
+ themeUrl?: string | {
20
+ light: string;
21
+ dark: string;
22
+ };
23
+ }
24
+ export declare function createHighlightPlugin(opts?: HighlightPluginOptions): EditorPlugin;
@@ -0,0 +1,22 @@
1
+ import type { EditorPlugin, EditorInterface } from '../core/types.js';
2
+ export interface SlashCommand {
3
+ /** Eindeutiger Bezeichner, wird für CSS data-Attribute verwendet */
4
+ id: string;
5
+ /** Angezeigter Titel im Menü */
6
+ title: string;
7
+ /** Optionale kurze Beschreibung unter dem Titel */
8
+ description?: string;
9
+ /** Icon: SVG-String oder HTML-Text (z.B. "H1", "¶") */
10
+ icon: string;
11
+ /** Suchbegriffe für die Filterung (lowercase) */
12
+ keywords: string[];
13
+ /** Wird ausgeführt wenn der Nutzer den Befehl auswählt */
14
+ execute: (editor: EditorInterface) => void;
15
+ }
16
+ export interface SlashCommandsOptions {
17
+ /** Komplett eigene Befehlsliste (ersetzt die Standardbefehle) */
18
+ commands?: SlashCommand[];
19
+ /** Zusätzliche Befehle die zu den Standardbefehlen hinzugefügt werden */
20
+ extraCommands?: SlashCommand[];
21
+ }
22
+ export declare function createSlashCommandsPlugin(options?: SlashCommandsOptions): EditorPlugin;
@@ -0,0 +1,2 @@
1
+ import type { EditorPlugin } from '../core/types.js';
2
+ export declare function createTemplateTagPlugin(): EditorPlugin;
@@ -0,0 +1,16 @@
1
+ import type { EditorInterface } from '../core/types.js';
2
+ import type { EditorLocale } from '../locales/types.js';
3
+ export declare class BubbleToolbar {
4
+ private el;
5
+ private editor;
6
+ private locale;
7
+ private hideTimer;
8
+ constructor(el: HTMLElement, editor: EditorInterface, locale?: EditorLocale);
9
+ private get editorEl();
10
+ private render;
11
+ onSelectionChange(): void;
12
+ private showAtSelection;
13
+ private hide;
14
+ private updateActiveState;
15
+ destroy(): void;
16
+ }
@@ -0,0 +1,20 @@
1
+ import type { EditorInterface } from '../core/types.js';
2
+ export declare class CodeLangPicker {
3
+ private editorEl;
4
+ private editor;
5
+ private pickerEl;
6
+ private activeIndex;
7
+ private filtered;
8
+ private targetPreEl;
9
+ private onOutside;
10
+ private onOutsideTimer;
11
+ constructor(editorEl: HTMLElement, editor: EditorInterface);
12
+ private readonly onBadgeMousedown;
13
+ private readonly onBadgeClick;
14
+ private openPicker;
15
+ private renderList;
16
+ private updateActive;
17
+ private selectLang;
18
+ private closePicker;
19
+ destroy(): void;
20
+ }
@@ -0,0 +1 @@
1
+ export declare const ICONS: Record<string, string>;
@@ -0,0 +1,15 @@
1
+ export declare class ImageResizer {
2
+ private editorEl;
3
+ private syncCallback;
4
+ private overlay;
5
+ private selectedImg;
6
+ private scrollParents;
7
+ private boundUpdatePos;
8
+ constructor(editorEl: HTMLElement, syncCallback: () => void);
9
+ destroy(): void;
10
+ private readonly onEditorClick;
11
+ private readonly onDocMousedown;
12
+ private selectImage;
13
+ private hideOverlay;
14
+ private startResize;
15
+ }
@@ -0,0 +1,11 @@
1
+ import type { EditorDocument } from '../core/types.js';
2
+ /**
3
+ * Full render: replace the content of `root` with a fresh render.
4
+ * Attaches data-oe-key to each block element for future diffing.
5
+ */
6
+ export declare function renderDocument(doc: EditorDocument, root: HTMLElement): void;
7
+ /**
8
+ * Patch render: compare existing block elements by key and update only changed ones.
9
+ * Blocks without a key get a fresh render.
10
+ */
11
+ export declare function patchDocument(doc: EditorDocument, root: HTMLElement, keys: string[]): string[];
@@ -0,0 +1,17 @@
1
+ import type { EditorDocument, ModelSelection } from '../core/types.js';
2
+ /**
3
+ * Convert the current browser selection into a ModelSelection.
4
+ * Returns null if there's no valid selection within the editor root.
5
+ */
6
+ export declare function domSelectionToModel(root: HTMLElement, _doc: EditorDocument): ModelSelection | null;
7
+ /**
8
+ * Restore a selection in the DOM after a re-render.
9
+ * Uses character offsets to find the correct text node.
10
+ */
11
+ export declare function modelSelectionToDOM(root: HTMLElement, sel: ModelSelection): void;
12
+ /** Get the block index of the element containing the current cursor */
13
+ export declare function getActiveBlockIndex(root: HTMLElement): number;
14
+ /** Get the tag name of the block element containing the cursor */
15
+ export declare function getActiveBlockTag(root: HTMLElement): string;
16
+ /** Collect all mark types active on every character in the current selection */
17
+ export declare function getActiveMarks(root: HTMLElement): Set<string>;
@@ -0,0 +1 @@
1
+ export declare function injectStyles(theme: 'light' | 'dark' | 'auto'): void;
@@ -0,0 +1,31 @@
1
+ import type { EditorInterface, ToolbarItemConfig } from '../core/types.js';
2
+ import type { EditorLocale } from '../locales/types.js';
3
+ /** All item IDs available in the default toolbar, in order. */
4
+ export declare const TOOLBAR_ITEM_IDS: readonly ["undo", "redo", "blockType", "bold", "italic", "underline", "code", "alignLeft", "alignCenter", "alignRight", "alignJustify", "bulletList", "orderedList", "link", "image", "blockquote", "hr", "callout"];
5
+ /** English default toolbar (backwards-compatible export). */
6
+ export declare const DEFAULT_TOOLBAR: ToolbarItemConfig[];
7
+ /**
8
+ * Filter the default toolbar by a list of item IDs.
9
+ * Orphaned separators (leading, trailing, consecutive) are removed automatically.
10
+ */
11
+ export declare function filterToolbar(ids: string[], locale?: EditorLocale): ToolbarItemConfig[];
12
+ export declare class Toolbar {
13
+ private el;
14
+ private editor;
15
+ private config;
16
+ private itemEls;
17
+ private disabled;
18
+ private locale;
19
+ private calloutPickerEl;
20
+ constructor(el: HTMLElement, editor: EditorInterface, config?: ToolbarItemConfig[], toolbarItems?: string[], locale?: EditorLocale);
21
+ private render;
22
+ private renderItem;
23
+ private handleCommand;
24
+ private toggleCalloutPicker;
25
+ private closeCalloutPicker;
26
+ private handleBlockTypeChange;
27
+ private handleLinkCommand;
28
+ private handleImageCommand;
29
+ updateActiveState(): void;
30
+ setDisabled(disabled: boolean): void;
31
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "open-edit",
3
+ "version": "0.1.0",
4
+ "description": "Lightweight, embeddable WYSIWYG HTML editor. Zero dependencies, plugin system, clean HTML5 output.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/open-edit.cjs.js",
8
+ "module": "./dist/open-edit.esm.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/open-edit.esm.js",
13
+ "require": "./dist/open-edit.cjs.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/cnagel08/open-edit.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/cnagel08/open-edit/issues"
28
+ },
29
+ "homepage": "https://github.com/cnagel08/open-edit#readme",
30
+ "keywords": [
31
+ "wysiwyg",
32
+ "editor",
33
+ "rich-text",
34
+ "html-editor",
35
+ "contenteditable",
36
+ "typescript",
37
+ "tinymce-alternative",
38
+ "ckeditor-alternative",
39
+ "embeddable",
40
+ "lightweight"
41
+ ],
42
+ "scripts": {
43
+ "dev": "vite build --watch",
44
+ "build": "vite build && tsc -p tsconfig.lib.json --emitDeclarationOnly",
45
+ "preview": "vite",
46
+ "lint": "eslint . --ext .ts --max-warnings 0",
47
+ "test": "vitest run --environment jsdom",
48
+ "test:watch": "vitest --environment jsdom",
49
+ "licenses:summary": "npx license-checker --summary --development",
50
+ "licenses:full": "npx license-checker --csv --development > THIRD_PARTY_LICENSES.csv"
51
+ },
52
+ "devDependencies": {
53
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
54
+ "@typescript-eslint/parser": "^8.57.0",
55
+ "eslint": "^8.57.0",
56
+ "jsdom": "^28.1.0",
57
+ "typescript": "^5.5.0",
58
+ "vite": "^8.0.0",
59
+ "vite-plugin-dts": "^4.5.4",
60
+ "vitest": "^4.1.0"
61
+ }
62
+ }