@mache-hangar/lunar-editor-react 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/THIRD_PARTY_NOTICES.md +58 -0
- package/dist/code-editor-Cq33u9jq.cjs +2 -0
- package/dist/code-editor-Cq33u9jq.cjs.map +1 -0
- package/dist/code-editor-um45ekRh.js +78 -0
- package/dist/code-editor-um45ekRh.js.map +1 -0
- package/dist/code-editor.cjs +2 -0
- package/dist/code-editor.cjs.map +1 -0
- package/dist/code-editor.js +8 -0
- package/dist/code-editor.js.map +1 -0
- package/dist/extensions/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/extensions/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/extensions/math/index.cjs +2 -0
- package/dist/extensions/math/index.cjs.map +1 -0
- package/dist/extensions/math/index.js +285 -0
- package/dist/extensions/math/index.js.map +1 -0
- package/dist/extensions/math.css +1 -0
- package/dist/extensions/table/index.cjs +2 -0
- package/dist/extensions/table/index.cjs.map +1 -0
- package/dist/extensions/table/index.js +356 -0
- package/dist/extensions/table/index.js.map +1 -0
- package/dist/extensions/table.css +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/rich-editor.cjs +2 -0
- package/dist/rich-editor.cjs.map +1 -0
- package/dist/rich-editor.js +67 -0
- package/dist/rich-editor.js.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/types/code-editor-types.d.ts +5 -0
- package/dist/types/code-editor.d.ts +6 -0
- package/dist/types/controller-hooks.d.ts +6 -0
- package/dist/types/extensions/math/index.d.ts +3 -0
- package/dist/types/extensions/math/math-input.d.ts +4 -0
- package/dist/types/extensions/math/math-node-view.d.ts +27 -0
- package/dist/types/extensions/math/nodes.d.ts +9 -0
- package/dist/types/extensions/table/column-layout.d.ts +9 -0
- package/dist/types/extensions/table/index.d.ts +2 -0
- package/dist/types/extensions/table/resize-transaction.d.ts +4 -0
- package/dist/types/extensions/table/table-node-view.d.ts +30 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/rich-editor.d.ts +25 -0
- package/package.json +77 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Node as ProseMirrorNode, type EditorView, type NodeView } from '@mache-hangar/lunar-editor-core/pm';
|
|
2
|
+
type GetPos = () => number | undefined;
|
|
3
|
+
export declare class MathNodeView implements NodeView {
|
|
4
|
+
private readonly view;
|
|
5
|
+
private readonly getPos;
|
|
6
|
+
readonly dom: HTMLElement;
|
|
7
|
+
private node;
|
|
8
|
+
private readonly mathfield;
|
|
9
|
+
private readonly display;
|
|
10
|
+
private selected;
|
|
11
|
+
private editing;
|
|
12
|
+
constructor(node: ProseMirrorNode, view: EditorView, getPos: GetPos);
|
|
13
|
+
private handlePointerDown;
|
|
14
|
+
private handleFocus;
|
|
15
|
+
private handleBlur;
|
|
16
|
+
private setEditing;
|
|
17
|
+
private handleChange;
|
|
18
|
+
private handleKeyDown;
|
|
19
|
+
private deleteEmptyBlock;
|
|
20
|
+
update(node: ProseMirrorNode): boolean;
|
|
21
|
+
selectNode(): void;
|
|
22
|
+
deselectNode(): void;
|
|
23
|
+
stopEvent(event: Event): boolean;
|
|
24
|
+
ignoreMutation(): boolean;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeSpec } from '@mache-hangar/lunar-editor-core/pm';
|
|
2
|
+
export declare function parseMathAttrs(element: HTMLElement): {
|
|
3
|
+
htmlAttrs: {
|
|
4
|
+
[x: string]: string;
|
|
5
|
+
};
|
|
6
|
+
latex: string;
|
|
7
|
+
sourceKey: string | null;
|
|
8
|
+
};
|
|
9
|
+
export declare const mathNodes: Record<string, NodeSpec>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Measure logical columns, including cells spanning rows or columns. */
|
|
2
|
+
export type ColumnLayout = {
|
|
3
|
+
widths: number[];
|
|
4
|
+
boundaries: number[];
|
|
5
|
+
direction: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const MIN_COLUMN_WIDTH = 48;
|
|
8
|
+
export declare function measureColumns(table: HTMLTableElement): ColumnLayout | undefined;
|
|
9
|
+
export declare function resizeColumns(widths: readonly number[], column: number, delta: number): number[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type EditorView } from '@mache-hangar/lunar-editor-core/pm';
|
|
2
|
+
export declare function withWidth(style: string | undefined, width: number, document: Document, table?: boolean): string;
|
|
3
|
+
/** Commit ordinary HTML col widths through the existing source-aware transaction. */
|
|
4
|
+
export declare function commitColumnWidths(view: EditorView, position: number, widths: readonly number[]): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Node as ProseMirrorNode, NodeView, EditorView, ViewMutationRecord } from '@mache-hangar/lunar-editor-core/pm';
|
|
2
|
+
export declare class TableNodeView implements NodeView {
|
|
3
|
+
private readonly view;
|
|
4
|
+
private readonly getPos;
|
|
5
|
+
readonly dom: HTMLDivElement;
|
|
6
|
+
readonly contentDOM: HTMLTableElement;
|
|
7
|
+
private readonly controls;
|
|
8
|
+
private node;
|
|
9
|
+
private observer?;
|
|
10
|
+
private frame;
|
|
11
|
+
private readonly previewNodes;
|
|
12
|
+
private drag?;
|
|
13
|
+
constructor(node: ProseMirrorNode, view: EditorView, getPos: () => number | undefined);
|
|
14
|
+
update(node: ProseMirrorNode): boolean;
|
|
15
|
+
private showControls;
|
|
16
|
+
private hideControls;
|
|
17
|
+
private scheduleLayout;
|
|
18
|
+
private refreshControls;
|
|
19
|
+
private handleColumn;
|
|
20
|
+
private startDrag;
|
|
21
|
+
private moveDrag;
|
|
22
|
+
private endDrag;
|
|
23
|
+
private cancelDrag;
|
|
24
|
+
private onDragKeyDown;
|
|
25
|
+
private finishDrag;
|
|
26
|
+
private onHandleKeyDown;
|
|
27
|
+
stopEvent(event: Event): boolean;
|
|
28
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CodeEditor } from './code-editor';
|
|
2
|
+
export type { CodeEditorApi, CodeEditorProps } from './code-editor-types';
|
|
3
|
+
export { useController, useControllerProps, useControllerEvents, } from './controller-hooks';
|
|
4
|
+
export { RichEditor } from './rich-editor';
|
|
5
|
+
export type { RichEditorApi, RichEditorProps } from './rich-editor';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createLunarEditor, getLunarEditorSourceSnapshot, type CreateLunarEditorOptions } from '@mache-hangar/lunar-editor-core/lunar-editor';
|
|
2
|
+
type EditorView = ReturnType<typeof createLunarEditor>;
|
|
3
|
+
export type RichEditorProps = Omit<CreateLunarEditorOptions, 'html' | 'editable' | 'editorClass' | 'onDocChanged'> & {
|
|
4
|
+
content: string;
|
|
5
|
+
readonly?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
editorClass?: string;
|
|
8
|
+
onDocChanged?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export type RichEditorApi = {
|
|
11
|
+
getView: () => EditorView | undefined;
|
|
12
|
+
getHtml: () => string;
|
|
13
|
+
getSourceState: () => ReturnType<typeof getLunarEditorSourceSnapshot>;
|
|
14
|
+
undo: () => boolean;
|
|
15
|
+
redo: () => boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Generic React adapter. Product plugins are supplied by the caller. */
|
|
18
|
+
export declare const RichEditor: import("react").ForwardRefExoticComponent<Omit<CreateLunarEditorOptions, "html" | "editable" | "editorClass" | "onDocChanged"> & {
|
|
19
|
+
content: string;
|
|
20
|
+
readonly?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
editorClass?: string;
|
|
23
|
+
onDocChanged?: () => void;
|
|
24
|
+
} & import("react").RefAttributes<RichEditorApi>>;
|
|
25
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mache-hangar/lunar-editor-react",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Native React HTML editor components backed by lunar-editor-core",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./rich-editor": {
|
|
8
|
+
"types": "./dist/types/rich-editor.d.ts",
|
|
9
|
+
"import": "./dist/rich-editor.js",
|
|
10
|
+
"require": "./dist/rich-editor.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./code-editor": {
|
|
13
|
+
"types": "./dist/types/code-editor.d.ts",
|
|
14
|
+
"import": "./dist/code-editor.js",
|
|
15
|
+
"require": "./dist/code-editor.cjs"
|
|
16
|
+
},
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./styles.css": "./dist/styles.css",
|
|
23
|
+
"./extensions/math": {
|
|
24
|
+
"types": "./dist/types/extensions/math/index.d.ts",
|
|
25
|
+
"import": "./dist/extensions/math/index.js",
|
|
26
|
+
"require": "./dist/extensions/math/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./extensions/math.css": "./dist/extensions/math.css",
|
|
29
|
+
"./extensions/table": {
|
|
30
|
+
"types": "./dist/types/extensions/table/index.d.ts",
|
|
31
|
+
"import": "./dist/extensions/table/index.js",
|
|
32
|
+
"require": "./dist/extensions/table/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./extensions/table.css": "./dist/extensions/table.css"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"THIRD_PARTY_NOTICES.md"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"mathlive": "0.110.0",
|
|
42
|
+
"@mache-hangar/lunar-editor-core": "0.0.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"jsdom": "^26.1.0",
|
|
46
|
+
"@types/node": "^22.13.5",
|
|
47
|
+
"@types/react": "19.2.14",
|
|
48
|
+
"@types/react-dom": "19.2.3",
|
|
49
|
+
"react": "^19.1.1",
|
|
50
|
+
"react-dom": "^19.1.1",
|
|
51
|
+
"sass": "^1.95.0",
|
|
52
|
+
"typescript": "^5.9.3",
|
|
53
|
+
"vite": "^7.2.4"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
57
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
58
|
+
},
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"homepage": "https://github.com/felix007-github/web-components/tree/main/packages/lunar-editor-react#readme",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "git+https://github.com/felix007-github/web-components.git",
|
|
64
|
+
"directory": "packages/lunar-editor-react"
|
|
65
|
+
},
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/felix007-github/web-components/issues"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public",
|
|
71
|
+
"registry": "https://registry.npmjs.org/"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "vite build && tsc -p tsconfig.json && node scripts/build-styles.cjs",
|
|
75
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
76
|
+
"test": "node --test --test-concurrency=1 test/*.test.cjs",
|
|
77
|
+
"dev": "node ../../scripts/watch-editor.mjs",
|
|
78
|
+
"clean": "node ../../scripts/tasks.cjs clean"
|
|
79
|
+
}
|
|
6
80
|
}
|