@phenix1024/editor 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +188 -2
- package/dist/ophx-editor.cjs +1 -0
- package/dist/ophx-editor.css +2 -0
- package/dist/ophx-editor.iife.js +149 -0
- package/dist/ophx-editor.iife.js.map +1 -0
- package/dist/ophx-editor.js +813 -0
- package/dist/ophx-editor.standalone.js +20537 -0
- package/dist/ophx-editor.standalone.js.map +1 -0
- package/dist/types/editor/extensions.d.ts +28 -0
- package/dist/types/editor/ophx-archive.d.ts +27 -0
- package/dist/types/editor/ophx-editor.d.ts +27 -0
- package/dist/types/editor/ophx.css.d.ts +2 -0
- package/dist/types/editor/template-fields.d.ts +7 -0
- package/dist/types/editor/toolbar.d.ts +6 -0
- package/dist/types/index.d.ts +6 -0
- package/package.json +81 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Extension, Mark, Node } from '@tiptap/core';
|
|
2
|
+
export declare const Label: Mark<any, any>;
|
|
3
|
+
/** Inline template field: its textual value stays editable inside the editor. */
|
|
4
|
+
export declare const OphxInlineField: Node<any, any>;
|
|
5
|
+
/** Block template field, accepting the v2 <p> and <div> wrapper forms. */
|
|
6
|
+
export declare const OphxBlockField: Node<any, any>;
|
|
7
|
+
/** Preserves a readonly inline span while allowing editable field descendants. */
|
|
8
|
+
export declare const OphxReadonlyInline: Mark<any, any>;
|
|
9
|
+
/** A readonly block container can still contain nested editable template fields. */
|
|
10
|
+
export declare const OphxReadonlyBlock: Node<any, any>;
|
|
11
|
+
export declare const CollapsibleHeading: Node<import("@tiptap/extension-heading").HeadingOptions, any>;
|
|
12
|
+
type SearchStorage = {
|
|
13
|
+
query: string;
|
|
14
|
+
};
|
|
15
|
+
declare module '@tiptap/core' {
|
|
16
|
+
interface Commands<ReturnType> {
|
|
17
|
+
ophxSearch: {
|
|
18
|
+
setSearchQuery: (query: string) => ReturnType;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export declare const TextSearch: Extension<SearchStorage, any>;
|
|
23
|
+
export declare const WysiwymRules: Extension<any, any>;
|
|
24
|
+
export declare const Indentation: Extension<any, any>;
|
|
25
|
+
/** Retains v2 contenteditable overrides on schema nodes and marks. */
|
|
26
|
+
export declare const OphxEditability: Extension<any, any>;
|
|
27
|
+
export declare function isValidOphxFieldId(value: string): boolean;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface OphxDocument {
|
|
2
|
+
/** Sanitized body HTML ready for the Tiptap schema. */
|
|
3
|
+
html: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** Basename of the required root-level HTML entry, without extension. */
|
|
6
|
+
filename: string;
|
|
7
|
+
/** Local stylesheet files keyed by their exact archive filename. */
|
|
8
|
+
styles: Record<string, string>;
|
|
9
|
+
/** Convenience alias for the first stylesheet, if present. */
|
|
10
|
+
css: string;
|
|
11
|
+
bodyContentEditable?: 'true' | 'false';
|
|
12
|
+
}
|
|
13
|
+
export interface OphxExportOptions {
|
|
14
|
+
/** Basename used for both the outer .ophx file and the root-level HTML file. */
|
|
15
|
+
filename?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Flat stylesheet filenames mapped to CSS source. */
|
|
18
|
+
styles?: Record<string, string>;
|
|
19
|
+
/** Files for already-referenced local image names, keyed by exact archive filename. */
|
|
20
|
+
assets?: Record<string, Blob | Uint8Array | ArrayBuffer>;
|
|
21
|
+
bodyContentEditable?: 'true' | 'false';
|
|
22
|
+
}
|
|
23
|
+
/** Creates a v2 .ophx ZIP using only flat, UTF-8-named STORE/DEFLATE entries. */
|
|
24
|
+
export declare function exportOphx(html: string, options?: OphxExportOptions): Promise<Blob>;
|
|
25
|
+
/** Reads only current v2 archives; legacy non-ZIP/XML formats are rejected. */
|
|
26
|
+
export declare function importOphx(file: Blob): Promise<OphxDocument>;
|
|
27
|
+
export declare function downloadBlob(blob: Blob, filename: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Editor, type Content, type EditorOptions } from '@tiptap/core';
|
|
2
|
+
export interface OphxFieldValue {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string | null;
|
|
5
|
+
required: boolean;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OphxEditorOptions {
|
|
9
|
+
element: HTMLElement;
|
|
10
|
+
content?: Content;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
editable?: boolean;
|
|
13
|
+
onUpdate?: EditorOptions['onUpdate'];
|
|
14
|
+
extensions?: NonNullable<EditorOptions['extensions']>;
|
|
15
|
+
}
|
|
16
|
+
/** A framework-neutral Tiptap editor wrapper. UI is intentionally optional. */
|
|
17
|
+
export declare class OphxEditor {
|
|
18
|
+
readonly editor: Editor;
|
|
19
|
+
constructor(options: OphxEditorOptions);
|
|
20
|
+
getHTML(): string;
|
|
21
|
+
getJSON(): import("@tiptap/core").DocumentType<Record<string, any> | undefined, import("@tiptap/core").NodeType<string, Record<string, any> | undefined, any, (import("@tiptap/core").NodeType<any, any, any, any> | import("@tiptap/core").TextType<import("@tiptap/core").MarkType<any, any>>)[]>[]>;
|
|
22
|
+
setContent(content: Content): void;
|
|
23
|
+
setSearchQuery(query: string): void;
|
|
24
|
+
getFields(): OphxFieldValue[];
|
|
25
|
+
getMissingRequiredFields(): OphxFieldValue[];
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface UnderscoreFieldConversion {
|
|
2
|
+
html: string;
|
|
3
|
+
count: number;
|
|
4
|
+
ids: string[];
|
|
5
|
+
}
|
|
6
|
+
/** Replaces each run of two or more underscores in editable text with an empty v2 field. */
|
|
7
|
+
export declare function convertUnderscoresToFields(html: string, prefix?: string): UnderscoreFieldConversion;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
export interface ToolbarOptions {
|
|
3
|
+
onInsertImage?: (file: File) => void;
|
|
4
|
+
}
|
|
5
|
+
/** Mounts an optional accessible toolbar; consumers can provide their own UI instead. */
|
|
6
|
+
export declare function mountToolbar(host: HTMLElement, editor: Editor, options?: ToolbarOptions): () => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './editor/ophx.css';
|
|
2
|
+
export { OphxEditor, type OphxEditorOptions, type OphxFieldValue } from './editor/ophx-editor';
|
|
3
|
+
export { mountToolbar, type ToolbarOptions } from './editor/toolbar';
|
|
4
|
+
export { exportOphx, importOphx, downloadBlob, type OphxDocument, type OphxExportOptions, } from './editor/ophx-archive';
|
|
5
|
+
export { CollapsibleHeading, Indentation, Label, OphxBlockField, OphxEditability, OphxInlineField, OphxReadonlyBlock, OphxReadonlyInline, TextSearch, WysiwymRules, isValidOphxFieldId, } from './editor/extensions';
|
|
6
|
+
export { convertUnderscoresToFields, type UnderscoreFieldConversion } from './editor/template-fields';
|
package/package.json
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phenix1024/editor",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Framework-agnostic WYSIWYM document editor and .ophx archive tools, powered by Tiptap",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/ophx-editor.cjs",
|
|
9
|
+
"module": "./dist/ophx-editor.js",
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"import": "./dist/ophx-editor.js",
|
|
20
|
+
"require": "./dist/ophx-editor.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./style.css": "./dist/ophx-editor.css",
|
|
23
|
+
"./standalone": {
|
|
24
|
+
"import": "./dist/ophx-editor.standalone.js",
|
|
25
|
+
"default": "./dist/ophx-editor.iife.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"unpkg": "./dist/ophx-editor.iife.js",
|
|
30
|
+
"jsdelivr": "./dist/ophx-editor.iife.js",
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"**/*.css"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/mars102/pluginEditor.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/mars102/pluginEditor#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/mars102/pluginEditor/issues"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"tiptap",
|
|
47
|
+
"editor",
|
|
48
|
+
"wysiwyg",
|
|
49
|
+
"wysiwym",
|
|
50
|
+
"ophx",
|
|
51
|
+
"document-editor"
|
|
52
|
+
],
|
|
53
|
+
"author": "mars102",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "vite",
|
|
56
|
+
"build": "rm -rf dist dist-demo && npm run typecheck && vite build --config vite.config.ts && tsc -p tsconfig.types.json && node scripts/copy-css-types.mjs && vite build --config vite.lib.config.ts && vite build --config vite.standalone.config.ts && rm -f dist/favicon.svg dist/icons.svg",
|
|
57
|
+
"build:demo": "vite build --config vite.config.ts",
|
|
58
|
+
"build:lib": "rm -rf dist && npm run typecheck && tsc -p tsconfig.types.json && node scripts/copy-css-types.mjs && vite build --config vite.lib.config.ts && vite build --config vite.standalone.config.ts && rm -f dist/favicon.svg dist/icons.svg",
|
|
59
|
+
"preview": "vite preview",
|
|
60
|
+
"typecheck": "tsc --noEmit",
|
|
61
|
+
"prepare": "npm run build:lib",
|
|
62
|
+
"prepublishOnly": "npm run build:lib"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"typescript": "~7.0.2",
|
|
66
|
+
"vite": "^8.3.6"
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@tiptap/core": "^3.33.0",
|
|
70
|
+
"@tiptap/extension-heading": "^3.33.0",
|
|
71
|
+
"@tiptap/extension-image": "^3.33.0",
|
|
72
|
+
"@tiptap/extension-link": "^3.33.0",
|
|
73
|
+
"@tiptap/extension-placeholder": "^3.33.0",
|
|
74
|
+
"@tiptap/extension-table": "^3.33.0",
|
|
75
|
+
"@tiptap/extension-table-cell": "^3.33.0",
|
|
76
|
+
"@tiptap/extension-table-header": "^3.33.0",
|
|
77
|
+
"@tiptap/extension-table-row": "^3.33.0",
|
|
78
|
+
"@tiptap/extension-underline": "^3.33.0",
|
|
79
|
+
"@tiptap/pm": "^3.33.0",
|
|
80
|
+
"@tiptap/starter-kit": "^3.33.0",
|
|
81
|
+
"jszip": "^3.10.2"
|
|
82
|
+
}
|
|
83
|
+
}
|