@mache-hangar/lunar-editor-react 0.0.0-stage → 0.0.3
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 +128 -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 +838 -0
- package/dist/extensions/table/index.js.map +1 -0
- package/dist/extensions/table-ui/index.cjs +2 -0
- package/dist/extensions/table-ui/index.cjs.map +1 -0
- package/dist/extensions/table-ui/index.js +531 -0
- package/dist/extensions/table-ui/index.js.map +1 -0
- package/dist/extensions/table-ui.css +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/cell-drag.d.ts +14 -0
- package/dist/types/extensions/table/column-layout.d.ts +9 -0
- package/dist/types/extensions/table/commands.d.ts +67 -0
- package/dist/types/extensions/table/grid.d.ts +49 -0
- package/dist/types/extensions/table/index.d.ts +6 -0
- package/dist/types/extensions/table/interaction.d.ts +6 -0
- package/dist/types/extensions/table/resize-transaction.d.ts +4 -0
- package/dist/types/extensions/table/selection-state.d.ts +3 -0
- package/dist/types/extensions/table/table-node-view.d.ts +30 -0
- package/dist/types/extensions/table-ui/TableProperties.d.ts +9 -0
- package/dist/types/extensions/table-ui/TableTools.d.ts +14 -0
- package/dist/types/extensions/table-ui/index.d.ts +2 -0
- package/dist/types/extensions/table-ui/useTableOverlay.d.ts +24 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/rich-editor.d.ts +25 -0
- package/package.json +95 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,129 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Lunar Editor React
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
通用 React 适配器及可复用编辑扩展,依赖 lunar-editor-core;不导入 App 或 Redline 规则。
|
|
4
|
+
|
|
5
|
+
采用 [MIT 许可](LICENSE),随包资源的许可说明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
|
|
6
|
+
npm 发布配置为公开访问,`prepublishOnly` 会自动执行构建。
|
|
7
|
+
|
|
8
|
+
## 通用入口
|
|
9
|
+
|
|
10
|
+
RichEditor 提供基础富文本挂载、生命周期、source/history 回调和类型化 ref。
|
|
11
|
+
CodeEditor 提供源码编辑适配。useController 等 hooks 可用于 App 自己的组合组件。
|
|
12
|
+
|
|
13
|
+
只使用一种编辑器时,可以从 `@mache-hangar/lunar-editor-react/rich-editor`
|
|
14
|
+
或 `@mache-hangar/lunar-editor-react/code-editor` 子入口导入。源码编辑器、
|
|
15
|
+
公式扩展和格式化器支持按需加载,普通富文本页面无需预先加载这些能力。
|
|
16
|
+
|
|
17
|
+
基础样式从 @mache-hangar/lunar-editor-react/styles.css 引入。
|
|
18
|
+
RichEditor 的 content 表示外部文档输入;普通父组件重渲染保留 view/history,
|
|
19
|
+
修改 content/source version 则重置输入。Schema 和 extensions 使用稳定引用。
|
|
20
|
+
ref 提供 getView/getHtml/getSourceState/undo/redo。
|
|
21
|
+
|
|
22
|
+
## 可选通用扩展
|
|
23
|
+
|
|
24
|
+
- @mache-hangar/lunar-editor-react/extensions/math:createMathExtension,公式节点、输入与 MathLive 视图。
|
|
25
|
+
- @mache-hangar/lunar-editor-react/extensions/table:createTableExtension,表格选区、结构命令、属性、滚动视图和列宽拖拽。
|
|
26
|
+
- 样式分别从 extensions/math.css 和 extensions/table.css 引入。
|
|
27
|
+
|
|
28
|
+
扩展实现遵守 core 的 EditorExtension 接口,普通 TS 引擎逻辑与 React 挂载分开。
|
|
29
|
+
基础入口不重导出公式扩展,因此普通 HTML 编辑不会自动加载 MathLive。
|
|
30
|
+
公式入口使用浏览器能力;SSR 应延迟到浏览器加载。
|
|
31
|
+
|
|
32
|
+
表格内部分隔线支持拖拽,相邻两列一增一减,保持表格总宽度。
|
|
33
|
+
支持 rowspan/colspan,默认最小列宽 48px(已有更窄的列保留原下限)。
|
|
34
|
+
拖动仅预览,松手后通过源码事务一次提交标准 colgroup/col 宽度,支持保存、撤销和重做。
|
|
35
|
+
Esc、指针取消或窗口失焦会取消当前拖动;只读模式不显示手柄。
|
|
36
|
+
手柄获得键盘焦点后,可用左右方向键以 10px 步长调整。
|
|
37
|
+
|
|
38
|
+
自定义扩展所需的 ProseMirror 类型、插件和命令统一从 @mache-hangar/lunar-editor-core/pm
|
|
39
|
+
导入,无需在使用方重复声明 prosemirror-* 依赖。此包构建会拒绝直接导入这些包。
|
|
40
|
+
|
|
41
|
+
扩展由 App 显式选择,例如创建稳定的数组:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { RichEditor } from '@mache-hangar/lunar-editor-react';
|
|
45
|
+
import { createMathExtension } from '@mache-hangar/lunar-editor-react/extensions/math';
|
|
46
|
+
import { createTableExtension } from '@mache-hangar/lunar-editor-react/extensions/table';
|
|
47
|
+
import '@mache-hangar/lunar-editor-react/styles.css';
|
|
48
|
+
import '@mache-hangar/lunar-editor-react/extensions/math.css';
|
|
49
|
+
import '@mache-hangar/lunar-editor-react/extensions/table.css';
|
|
50
|
+
|
|
51
|
+
// 在组件外创建,或在组件内用稳定的 memo 引用。
|
|
52
|
+
const extensions = [createMathExtension(), createTableExtension()];
|
|
53
|
+
<RichEditor content={html} extensions={extensions} />;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## App 业务
|
|
57
|
+
|
|
58
|
+
带修订/AI/PDF 联动的 HtmlEditor、LunarEditor、HtmlPreview 和菜单组合由使用方
|
|
59
|
+
项目维护,不包含在本仓库中。使用方可以实现自己的组合层。
|
|
60
|
+
|
|
61
|
+
## 验证
|
|
62
|
+
|
|
63
|
+
在本仓库根目录运行 pnpm build:lunar-editor-react 或 pnpm dev:lunar-editor-react。
|
|
64
|
+
测试命令为 pnpm --filter @mache-hangar/lunar-editor-react test,
|
|
65
|
+
覆盖 StrictMode/重渲染、文档切换、源码与历史、基础入口隔离、
|
|
66
|
+
表格拖拽预览、合并单元格、列属性、保存重载、取消和只读状态。
|
|
67
|
+
|
|
68
|
+
## 表格命令与状态
|
|
69
|
+
|
|
70
|
+
通用命令通过表格逻辑网格处理 rowspan/colspan,保留 caption、thead/tbody/tfoot、列组和已有属性。
|
|
71
|
+
createTableExtension({ onStateChange }) 回调提供 TableState;getTableState(view) 可主动读取。
|
|
72
|
+
工具栏可从可选的 table-ui 入口使用,也可自定义 UI 调用 runTableCommand(view, command),返回是否实际应用。
|
|
73
|
+
|
|
74
|
+
- insert:rows、columns(1–50),可选 headerRow。
|
|
75
|
+
- row_before/row_after/delete_rows、column_before/column_after/delete_columns、delete_table。
|
|
76
|
+
- merge/split:矩形选区合并、按原跨度拆分;合并按阅读顺序保留所有内容。
|
|
77
|
+
- header_row/header_column、caption:切换选中行列的 th/scope 和可编辑标题。
|
|
78
|
+
- cell_style:textAlign、verticalAlign、backgroundColor(#RRGGBB 或 transparent)。
|
|
79
|
+
- table_style:align(left/center/right)、width(25%/50%/75%/100%)。
|
|
80
|
+
- clear_cells:清空选中格内容,保留表格结构。
|
|
81
|
+
|
|
82
|
+
跨单元格拖选(包含空单元格)或 Shift + 单击可建立矩形选区;单格内保留原生文字选择。
|
|
83
|
+
跨格拖选由表格接管鼠标,选区限制在当前表格,避免选中后续正文或滚动跳动。
|
|
84
|
+
格内拖选文字、双击单词与三击段落保留;Escape 收起为光标,多格选中时输入或 Delete 替换/清空内容。
|
|
85
|
+
Tab/Shift+Tab 在单元格间移动,末格 Tab 新增一行并移动到第一格。
|
|
86
|
+
结构编辑上限为 200 行、100 列(单格 rowspan/colspan 上限 100)。
|
|
87
|
+
不规则/超限表格保留原 HTML 并禁用网格结构命令;跨行组无法合并。
|
|
88
|
+
只读、源码不同步或无法编译源码事务时命令返回 false,避免只改视图未改源码。
|
|
89
|
+
每条修改命令独立支持撤销/重做,并保持表格外源码内容。
|
|
90
|
+
|
|
91
|
+
## 可选表格工具栏
|
|
92
|
+
|
|
93
|
+
`extensions/table-ui` 提供 `InsertTableButton`、`TableToolbar` 和 props 类型。
|
|
94
|
+
包含尺寸选择器、浮动工具栏、行列菜单、合并/拆分、属性面板、选区边框及键盘焦点交互。
|
|
95
|
+
UI 使用 Ant Design 5 和组件库的 WtIcon;仅使用该入口时需要安装可选 peer dependencies
|
|
96
|
+
`antd@^5.27.6`、`@mache-hangar/components@^0.1.4`。基础编辑器和 table 命令入口不加载这两个 UI 包。
|
|
97
|
+
引入 `extensions/table-ui.css`,配合 `extensions/table.css` 使用。
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { useRef, useState } from 'react';
|
|
101
|
+
import { RichEditor } from '@mache-hangar/lunar-editor-react/rich-editor';
|
|
102
|
+
import { createTableExtension, EMPTY_TABLE_STATE, runTableCommand } from '@mache-hangar/lunar-editor-react/extensions/table';
|
|
103
|
+
import { InsertTableButton, TableToolbar } from '@mache-hangar/lunar-editor-react/extensions/table-ui';
|
|
104
|
+
import '@mache-hangar/lunar-editor-react/styles.css';
|
|
105
|
+
import '@mache-hangar/lunar-editor-react/extensions/table.css';
|
|
106
|
+
import '@mache-hangar/lunar-editor-react/extensions/table-ui.css';
|
|
107
|
+
|
|
108
|
+
function Editor({ html }: { html: string }) {
|
|
109
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
110
|
+
const editorRef = useRef<import('@mache-hangar/lunar-editor-react/rich-editor').RichEditorApi>(null);
|
|
111
|
+
const [state, setState] = useState(EMPTY_TABLE_STATE);
|
|
112
|
+
const [extensions] = useState(() => [createTableExtension({ onStateChange: setState })]);
|
|
113
|
+
const onCommand = (command: import('@mache-hangar/lunar-editor-react/extensions/table').TableCommand) => {
|
|
114
|
+
runTableCommand(editorRef.current?.getView(), command);
|
|
115
|
+
};
|
|
116
|
+
return (
|
|
117
|
+
<div ref={rootRef}>
|
|
118
|
+
<InsertTableButton state={state} onCommand={onCommand} />
|
|
119
|
+
<RichEditor ref={editorRef} content={html} extensions={extensions} />
|
|
120
|
+
<TableToolbar rootRef={rootRef} state={state} onCommand={onCommand} />
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`state` 来自表格扩展回调,`onCommand` 交由宿主执行并处理失败提示,`disabled` 用于只读或模式切换。
|
|
127
|
+
`rootRef` 指向编辑器根元素或包含编辑器及其工具栏的容器。组件自行定位表格、跟随滚动并清理监听器,
|
|
128
|
+
不依赖应用页面类名。浮层通过 portal 挂到编辑区域外,不会进入保存 HTML。
|
|
129
|
+
保存、AI、PDF 联动及业务通知仍由消费应用维护。
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The package includes MathLive-derived formula styles and KaTeX font files copied
|
|
4
|
+
from mathlive@0.110.0 into dist/extensions/fonts. These files retain their
|
|
5
|
+
upstream licenses and attribution below. Other npm dependencies are distributed
|
|
6
|
+
separately and retain the licenses included with those packages.
|
|
7
|
+
|
|
8
|
+
## MathLive
|
|
9
|
+
|
|
10
|
+
Source: https://github.com/arnog/mathlive/tree/v0.110.0
|
|
11
|
+
License text: mathlive@0.110.0/LICENSE.txt
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2017 - present Arno Gourdol. All rights reserved.
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
16
|
+
copy of this software and associated documentation files (the "Software"),
|
|
17
|
+
to deal in the Software without restriction, including without limitation
|
|
18
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
19
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
20
|
+
Software is furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in
|
|
23
|
+
all copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
30
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
31
|
+
DEALINGS IN THE SOFTWARE.
|
|
32
|
+
|
|
33
|
+
## KaTeX fonts
|
|
34
|
+
|
|
35
|
+
Files: dist/extensions/fonts/KaTeX_*.woff2
|
|
36
|
+
Source and license: https://github.com/KaTeX/katex-fonts/blob/master/LICENSE
|
|
37
|
+
|
|
38
|
+
MIT License
|
|
39
|
+
|
|
40
|
+
Copyright (c) 2018 Khan Academy
|
|
41
|
+
|
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
43
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
44
|
+
in the Software without restriction, including without limitation the rights
|
|
45
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
46
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
47
|
+
furnished to do so, subject to the following conditions:
|
|
48
|
+
|
|
49
|
+
The above copyright notice and this permission notice shall be included in all
|
|
50
|
+
copies or substantial portions of the Software.
|
|
51
|
+
|
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
54
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
55
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
56
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
57
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
58
|
+
SOFTWARE.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const a=require("react/jsx-runtime"),m=require("@mache-hangar/lunar-editor-core/controllers/code-editor-controller"),e=require("react");function h(n){const[t]=e.useState(n);return e.useSyncExternalStore(t.subscribe,t.getSnapshot),t}function g(n,t){e.useLayoutEffect(()=>{n.updateProps(t)},[n,t])}function v(n,t,c){const s=e.useRef(t);e.useLayoutEffect(()=>{s.current=t}),e.useLayoutEffect(()=>{const l=c.map(o=>Reflect.get(n,o).subscribe(i=>{const u=Reflect.get(s.current,`on${o[0].toUpperCase()}${o.slice(1)}`);typeof u=="function"&&u(i)}));return()=>{l.forEach(o=>o())}},[n,c])}const R=e.forwardRef(function(t,c){const{content:s="",readonly:l=!1,isShowDiff:o=!1,format:f=!1,language:i="html",className:u=""}=t,r=h(()=>Object.assign(new m.CodeEditorController,{content:s,readonly:l,isShowDiff:o,format:f,language:i})),d=e.useRef(null),E=e.useRef(null),C=e.useRef(null);return g(r,{content:s,readonly:l,isShowDiff:o,format:f,language:i}),e.useLayoutEffect(()=>(r.hostEl=d.current,r.editorContainerEl=E.current,r.diffContainerEl=C.current,r.connect(),()=>r.dispose()),[r]),e.useImperativeHandle(c,()=>r,[r]),a.jsx("div",{ref:d,className:`code-editor-host ${u}`,children:a.jsxs("div",{className:"code-editor",children:[a.jsx("div",{ref:E,className:`editor-container ${o?"dialog-ani-lr":""}`}),a.jsx("div",{ref:C,className:`diff-container ${o?"dialog-ani-rl":""}`})]})})});exports.CodeEditor=R;exports.useController=h;exports.useControllerEvents=v;exports.useControllerProps=g;
|
|
2
|
+
//# sourceMappingURL=code-editor-Cq33u9jq.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor-Cq33u9jq.cjs","sources":["../src/controller-hooks.ts","../src/code-editor.tsx"],"sourcesContent":["import {\n ControllerEvent,\n type EditorController,\n} from '@mache-hangar/lunar-editor-core/controllers/controller';\nimport { useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';\n\nexport function useController<T extends EditorController>(create: () => T) {\n const [controller] = useState(create);\n useSyncExternalStore(controller.subscribe, controller.getSnapshot);\n return controller;\n}\n\nexport function useControllerProps<T>(\n controller: { updateProps(props: T): Promise<void> },\n props: T\n) {\n useLayoutEffect(() => {\n void controller.updateProps(props);\n }, [controller, props]);\n}\n\nexport function useControllerEvents(\n controller: object,\n props: object,\n events: readonly string[]\n) {\n const latest = useRef(props);\n useLayoutEffect(() => {\n latest.current = props;\n });\n useLayoutEffect(() => {\n const teardowns = events.map((name) => {\n const channel = Reflect.get(controller, name) as ControllerEvent<unknown>;\n return channel.subscribe((detail) => {\n const callback = Reflect.get(\n latest.current,\n `on${name[0].toUpperCase()}${name.slice(1)}`\n );\n if (typeof callback === 'function') callback(detail);\n });\n });\n return () => {\n teardowns.forEach((teardown) => teardown());\n };\n }, [controller, events]);\n}\n","import { CodeEditorController } from '@mache-hangar/lunar-editor-core/controllers/code-editor-controller';\nimport {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n} from 'react';\nimport { useController, useControllerProps } from './controller-hooks';\nimport type { CodeEditorApi, CodeEditorProps } from './code-editor-types';\nexport type { CodeEditorApi, CodeEditorProps } from './code-editor-types';\n\nexport const CodeEditor = forwardRef<CodeEditorApi, CodeEditorProps>(\n function CodeEditor(props, ref) {\n const {\n content = '',\n readonly = false,\n isShowDiff = false,\n format = false,\n language = 'html',\n className = '',\n } = props;\n const controller = useController(() =>\n Object.assign(new CodeEditorController(), {\n content,\n readonly,\n isShowDiff,\n format,\n language,\n })\n );\n const host = useRef<HTMLDivElement>(null);\n const editor = useRef<HTMLDivElement>(null);\n const diff = useRef<HTMLDivElement>(null);\n useControllerProps(controller, {\n content,\n readonly,\n isShowDiff,\n format,\n language,\n });\n useLayoutEffect(() => {\n controller.hostEl = host.current!;\n controller.editorContainerEl = editor.current!;\n controller.diffContainerEl = diff.current!;\n void controller.connect();\n return () => controller.dispose();\n }, [controller]);\n useImperativeHandle(ref, () => controller, [controller]);\n return (\n <div ref={host} className={`code-editor-host ${className}`}>\n <div className=\"code-editor\">\n <div\n ref={editor}\n className={`editor-container ${isShowDiff ? 'dialog-ani-lr' : ''}`}\n />\n <div\n ref={diff}\n className={`diff-container ${isShowDiff ? 'dialog-ani-rl' : ''}`}\n />\n </div>\n </div>\n );\n }\n);\n"],"names":["useController","create","controller","useState","useSyncExternalStore","useControllerProps","props","useLayoutEffect","useControllerEvents","events","latest","useRef","teardowns","name","detail","callback","teardown","CodeEditor","forwardRef","ref","content","readonly","isShowDiff","format","language","className","CodeEditorController","host","editor","diff","useImperativeHandle","jsx","jsxs"],"mappings":"qJAMO,SAASA,EAA0CC,EAAiB,CACzE,KAAM,CAACC,CAAU,EAAIC,EAAAA,SAASF,CAAM,EACpCG,OAAAA,EAAAA,qBAAqBF,EAAW,UAAWA,EAAW,WAAW,EAC1DA,CACT,CAEO,SAASG,EACdH,EACAI,EACA,CACAC,EAAAA,gBAAgB,IAAM,CACfL,EAAW,YAAYI,CAAK,CACnC,EAAG,CAACJ,EAAYI,CAAK,CAAC,CACxB,CAEO,SAASE,EACdN,EACAI,EACAG,EACA,CACA,MAAMC,EAASC,EAAAA,OAAOL,CAAK,EAC3BC,EAAAA,gBAAgB,IAAM,CACpBG,EAAO,QAAUJ,CACnB,CAAC,EACDC,EAAAA,gBAAgB,IAAM,CACpB,MAAMK,EAAYH,EAAO,IAAKI,GACZ,QAAQ,IAAIX,EAAYW,CAAI,EAC7B,UAAWC,GAAW,CACnC,MAAMC,EAAW,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gBAAkB,EAAE,EAAA,CAAA,EAElES,EAAAA,IAAC,MAAA,CACC,IAAKF,EACL,UAAW,kBAAkBP,EAAa,gBAAkB,EAAE,EAAA,CAAA,CAChE,CAAA,CACF,CAAA,CACF,CAEJ,CACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as u, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { CodeEditorController as E } from "@mache-hangar/lunar-editor-core/controllers/code-editor-controller";
|
|
3
|
+
import { useState as g, useSyncExternalStore as b, useLayoutEffect as f, useRef as l, forwardRef as v, useImperativeHandle as N } from "react";
|
|
4
|
+
function S(n) {
|
|
5
|
+
const [e] = g(n);
|
|
6
|
+
return b(e.subscribe, e.getSnapshot), e;
|
|
7
|
+
}
|
|
8
|
+
function $(n, e) {
|
|
9
|
+
f(() => {
|
|
10
|
+
n.updateProps(e);
|
|
11
|
+
}, [n, e]);
|
|
12
|
+
}
|
|
13
|
+
function R(n, e, s) {
|
|
14
|
+
const r = l(e);
|
|
15
|
+
f(() => {
|
|
16
|
+
r.current = e;
|
|
17
|
+
}), f(() => {
|
|
18
|
+
const c = s.map((t) => Reflect.get(n, t).subscribe((a) => {
|
|
19
|
+
const i = Reflect.get(
|
|
20
|
+
r.current,
|
|
21
|
+
`on${t[0].toUpperCase()}${t.slice(1)}`
|
|
22
|
+
);
|
|
23
|
+
typeof i == "function" && i(a);
|
|
24
|
+
}));
|
|
25
|
+
return () => {
|
|
26
|
+
c.forEach((t) => t());
|
|
27
|
+
};
|
|
28
|
+
}, [n, s]);
|
|
29
|
+
}
|
|
30
|
+
const j = v(
|
|
31
|
+
function(e, s) {
|
|
32
|
+
const {
|
|
33
|
+
content: r = "",
|
|
34
|
+
readonly: c = !1,
|
|
35
|
+
isShowDiff: t = !1,
|
|
36
|
+
format: d = !1,
|
|
37
|
+
language: a = "html",
|
|
38
|
+
className: i = ""
|
|
39
|
+
} = e, o = S(
|
|
40
|
+
() => Object.assign(new E(), {
|
|
41
|
+
content: r,
|
|
42
|
+
readonly: c,
|
|
43
|
+
isShowDiff: t,
|
|
44
|
+
format: d,
|
|
45
|
+
language: a
|
|
46
|
+
})
|
|
47
|
+
), m = l(null), h = l(null), C = l(null);
|
|
48
|
+
return $(o, {
|
|
49
|
+
content: r,
|
|
50
|
+
readonly: c,
|
|
51
|
+
isShowDiff: t,
|
|
52
|
+
format: d,
|
|
53
|
+
language: a
|
|
54
|
+
}), f(() => (o.hostEl = m.current, o.editorContainerEl = h.current, o.diffContainerEl = C.current, o.connect(), () => o.dispose()), [o]), N(s, () => o, [o]), /* @__PURE__ */ u("div", { ref: m, className: `code-editor-host ${i}`, children: /* @__PURE__ */ p("div", { className: "code-editor", children: [
|
|
55
|
+
/* @__PURE__ */ u(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
ref: h,
|
|
59
|
+
className: `editor-container ${t ? "dialog-ani-lr" : ""}`
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ u(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
ref: C,
|
|
66
|
+
className: `diff-container ${t ? "dialog-ani-rl" : ""}`
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] }) });
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
export {
|
|
73
|
+
j as C,
|
|
74
|
+
R as a,
|
|
75
|
+
$ as b,
|
|
76
|
+
S as u
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=code-editor-um45ekRh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor-um45ekRh.js","sources":["../src/controller-hooks.ts","../src/code-editor.tsx"],"sourcesContent":["import {\n ControllerEvent,\n type EditorController,\n} from '@mache-hangar/lunar-editor-core/controllers/controller';\nimport { useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';\n\nexport function useController<T extends EditorController>(create: () => T) {\n const [controller] = useState(create);\n useSyncExternalStore(controller.subscribe, controller.getSnapshot);\n return controller;\n}\n\nexport function useControllerProps<T>(\n controller: { updateProps(props: T): Promise<void> },\n props: T\n) {\n useLayoutEffect(() => {\n void controller.updateProps(props);\n }, [controller, props]);\n}\n\nexport function useControllerEvents(\n controller: object,\n props: object,\n events: readonly string[]\n) {\n const latest = useRef(props);\n useLayoutEffect(() => {\n latest.current = props;\n });\n useLayoutEffect(() => {\n const teardowns = events.map((name) => {\n const channel = Reflect.get(controller, name) as ControllerEvent<unknown>;\n return channel.subscribe((detail) => {\n const callback = Reflect.get(\n latest.current,\n `on${name[0].toUpperCase()}${name.slice(1)}`\n );\n if (typeof callback === 'function') callback(detail);\n });\n });\n return () => {\n teardowns.forEach((teardown) => teardown());\n };\n }, [controller, events]);\n}\n","import { CodeEditorController } from '@mache-hangar/lunar-editor-core/controllers/code-editor-controller';\nimport {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n} from 'react';\nimport { useController, useControllerProps } from './controller-hooks';\nimport type { CodeEditorApi, CodeEditorProps } from './code-editor-types';\nexport type { CodeEditorApi, CodeEditorProps } from './code-editor-types';\n\nexport const CodeEditor = forwardRef<CodeEditorApi, CodeEditorProps>(\n function CodeEditor(props, ref) {\n const {\n content = '',\n readonly = false,\n isShowDiff = false,\n format = false,\n language = 'html',\n className = '',\n } = props;\n const controller = useController(() =>\n Object.assign(new CodeEditorController(), {\n content,\n readonly,\n isShowDiff,\n format,\n language,\n })\n );\n const host = useRef<HTMLDivElement>(null);\n const editor = useRef<HTMLDivElement>(null);\n const diff = useRef<HTMLDivElement>(null);\n useControllerProps(controller, {\n content,\n readonly,\n isShowDiff,\n format,\n language,\n });\n useLayoutEffect(() => {\n controller.hostEl = host.current!;\n controller.editorContainerEl = editor.current!;\n controller.diffContainerEl = diff.current!;\n void controller.connect();\n return () => controller.dispose();\n }, [controller]);\n useImperativeHandle(ref, () => controller, [controller]);\n return (\n <div ref={host} className={`code-editor-host ${className}`}>\n <div className=\"code-editor\">\n <div\n ref={editor}\n className={`editor-container ${isShowDiff ? 'dialog-ani-lr' : ''}`}\n />\n <div\n ref={diff}\n className={`diff-container ${isShowDiff ? 'dialog-ani-rl' : ''}`}\n />\n </div>\n </div>\n );\n }\n);\n"],"names":["useController","create","controller","useState","useSyncExternalStore","useControllerProps","props","useLayoutEffect","useControllerEvents","events","latest","useRef","teardowns","name","detail","callback","teardown","CodeEditor","forwardRef","ref","content","readonly","isShowDiff","format","language","className","CodeEditorController","host","editor","diff","useImperativeHandle","jsx","jsxs"],"mappings":";;;AAMO,SAASA,EAA0CC,GAAiB;AACzE,QAAM,CAACC,CAAU,IAAIC,EAASF,CAAM;AACpC,SAAAG,EAAqBF,EAAW,WAAWA,EAAW,WAAW,GAC1DA;AACT;AAEO,SAASG,EACdH,GACAI,GACA;AACA,EAAAC,EAAgB,MAAM;AACpB,IAAKL,EAAW,YAAYI,CAAK;AAAA,EACnC,GAAG,CAACJ,GAAYI,CAAK,CAAC;AACxB;AAEO,SAASE,EACdN,GACAI,GACAG,GACA;AACA,QAAMC,IAASC,EAAOL,CAAK;AAC3B,EAAAC,EAAgB,MAAM;AACpB,IAAAG,EAAO,UAAUJ;AAAA,EACnB,CAAC,GACDC,EAAgB,MAAM;AACpB,UAAMK,IAAYH,EAAO,IAAI,CAACI,MACZ,QAAQ,IAAIX,GAAYW,CAAI,EAC7B,UAAU,CAACC,MAAW;AACnC,YAAMC,IAAW,QAAQ;AAAA,QACvBL,EAAO;AAAA,QACP,KAAKG,EAAK,CAAC,EAAE,YAAA,CAAa,GAAGA,EAAK,MAAM,CAAC,CAAC;AAAA,MAAA;AAE5C,MAAI,OAAOE,KAAa,cAAYA,EAASD,CAAM;AAAA,IACrD,CAAC,CACF;AACD,WAAO,MAAM;AACX,MAAAF,EAAU,QAAQ,CAACI,MAAaA,EAAA,CAAU;AAAA,IAC5C;AAAA,EACF,GAAG,CAACd,GAAYO,CAAM,CAAC;AACzB;AClCO,MAAMQ,IAAaC;AAAA,EACxB,SAAoBZ,GA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,CACF,EAAA,CACF;AAAA,EAEJ;AACF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("@mache-hangar/lunar-editor-core/controllers/code-editor-controller");require("react");const e=require("./code-editor-Cq33u9jq.cjs");exports.CodeEditor=e.CodeEditor;
|
|
2
|
+
//# sourceMappingURL=code-editor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@mache-hangar/lunar-editor-core/source/dom-projection"),w=require("@mache-hangar/lunar-editor-core/schema/dom-attributes"),p=require("mathlive"),l=require("@mache-hangar/lunar-editor-core/pm");function c(e){const t=w.readHtmlAttributes(e);return delete t["data-type"],delete t["data-display"],delete t["data-latex"],{htmlAttrs:t,latex:e.dataset.latex||"",sourceKey:v.getDomSourceKey(e)||null}}const u={math_block:{attrs:{htmlAttrs:{default:{}},latex:{default:""},sourceKey:{default:null}},atom:!0,group:"block",isolating:!0,parseDOM:[{tag:'p[data-type="math"][data-display="block"]',priority:100,getAttrs:e=>c(e)}],toDOM:e=>["p",{...e.attrs.htmlAttrs,"data-type":"math","data-display":"block","data-latex":e.attrs.latex||""}]},math_inline:{attrs:{htmlAttrs:{default:{}},latex:{default:""},sourceKey:{default:null}},atom:!0,group:"inline",inline:!0,isolating:!0,parseDOM:[{tag:'span[data-type="math"][data-display="inline"]',priority:100,getAttrs:e=>c(e)}],toDOM:e=>["span",{...e.attrs.htmlAttrs,"data-type":"math","data-display":"inline","data-latex":e.attrs.latex||""}]}};p.MathfieldElement.soundsDirectory=null;function b(e,t){Array.from(e.attributes).forEach(a=>{a.name in t||e.removeAttribute(a.name)}),Object.entries(t).forEach(([a,s])=>{e.setAttribute(a,s)})}function E(e,t,a,s){const i={...e.attrs.htmlAttrs||{}},n=new Set(String(i.class||"").split(/\s+/).filter(Boolean));return n.add("lunar-math-node"),n.add(`lunar-math-${s}`),t&&n.add("ProseMirror-selectednode"),a&&n.add("lunar-math-node--editing"),{...i,class:Array.from(n).join(" "),"data-type":"math","data-display":s,"data-latex":e.attrs.latex||"",contenteditable:"false"}}class m{constructor(t,a,s){this.view=a,this.getPos=s,this.node=t,this.display=t.type.name==="math_inline"?"inline":"block",this.dom=document.createElement(this.display==="inline"?"span":"p"),this.mathfield=new p.MathfieldElement,this.mathfield.className=`lunar-math-field lunar-math-field--${this.display}`,this.mathfield.smartFence=!0,this.mathfield.mathVirtualKeyboardPolicy="auto",this.mathfield.setAttribute("aria-label",this.display==="inline"?"Inline math formula":"Math formula"),this.mathfield.addEventListener("change",this.handleChange),this.mathfield.addEventListener("focus",this.handleFocus),this.mathfield.addEventListener("blur",this.handleBlur),this.mathfield.addEventListener("keydown",this.handleKeyDown),this.dom.addEventListener("pointerdown",this.handlePointerDown,!0),this.dom.appendChild(this.mathfield),this.update(t)}view;getPos;dom;node;mathfield;display;selected=!1;editing=!1;handlePointerDown=()=>{if(!this.view.editable){this.setEditing(!1);return}this.setEditing(!0);const t=this.getPos();if(t===void 0)return;const a=this.view.state.selection;(!(a instanceof l.NodeSelection)||a.from!==t)&&this.view.dispatch(this.view.state.tr.setSelection(l.NodeSelection.create(this.view.state.doc,t))),window.requestAnimationFrame(()=>{this.editing&&this.view.editable&&this.mathfield.focus()})};handleFocus=()=>{this.setEditing(!0)};handleBlur=()=>{this.setEditing(!1)};setEditing(t){this.editing=t&&this.view.editable,this.dom.classList.toggle("lunar-math-node--editing",this.editing),this.mathfield.readOnly=!this.view.editable}handleChange=()=>{const t=this.getPos();if(t===void 0||!this.view.editable)return;const a=this.view.state.doc.nodeAt(t),s=this.mathfield.value;a?.type!==this.node.type||a.attrs.latex===s||this.view.dispatch(this.view.state.tr.setNodeMarkup(t,void 0,{...a.attrs,latex:s}))};handleKeyDown=t=>{if((t.key==="Backspace"||t.key==="Delete")&&this.mathfield.value.trim()===""){t.preventDefault(),t.stopPropagation(),this.deleteEmptyBlock(t.key==="Backspace"?-1:1);return}t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.mathfield.blur(),this.view.focus())};deleteEmptyBlock(t){const a=this.getPos();if(a===void 0||!this.view.editable)return;const s=this.view.state.doc.nodeAt(a);if(s?.type!==this.node.type)return;const i=this.view.state.tr.delete(a,a+s.nodeSize),n=Math.min(a,i.doc.content.size);i.setSelection(l.Selection.near(i.doc.resolve(n),t)),this.view.dispatch(i),window.requestAnimationFrame(()=>{this.view.focus()})}update(t){if(t.type.name!==`math_${this.display}`)return!1;this.node=t,b(this.dom,E(t,this.selected,this.editing,this.display)),this.mathfield.readOnly=!this.view.editable;const a=t.attrs.latex||"";return this.mathfield.value!==a&&this.mathfield.setValue(a,{silenceNotifications:!0}),!0}selectNode(){if(this.selected=!0,this.dom.classList.add("ProseMirror-selectednode"),!this.view.editable){this.setEditing(!1);return}this.setEditing(!0),window.requestAnimationFrame(()=>{this.mathfield.focus()})}deselectNode(){this.selected=!1,this.dom.classList.remove("ProseMirror-selectednode"),this.setEditing(!1)}stopEvent(t){return t.target instanceof Node&&this.dom.contains(t.target)}ignoreMutation(){return!0}destroy(){this.mathfield.removeEventListener("change",this.handleChange),this.mathfield.removeEventListener("focus",this.handleFocus),this.mathfield.removeEventListener("blur",this.handleBlur),this.mathfield.removeEventListener("keydown",this.handleKeyDown),this.dom.removeEventListener("pointerdown",this.handlePointerDown,!0)}}function A(e,t,a,s){const i=e.state.doc.resolve(t),n=e.state.doc.resolve(a);if(i.parent!==n.parent||i.parent.type!==e.state.schema.nodes.paragraph)return;const r=i.parent,o=r.textBetween(0,i.parentOffset,"",""),d=r.textBetween(n.parentOffset,r.content.size,"","");return{paragraph:r,text:`${o}${s}${d}`,paragraphStart:i.before(),paragraphEnd:i.after()}}function f(e,t,a,s){if(!s.includes("$"))return!1;const i=A(e,t,a,s),n=e.state.schema.nodes.math_block;if(!i||i.text!=="$$"||!n)return!1;const r={...i.paragraph.attrs.htmlAttrs||{}};delete r["data-type"],delete r["data-display"],delete r["data-latex"];const o=e.state.tr.replaceWith(i.paragraphStart,i.paragraphEnd,n.create({htmlAttrs:r,latex:"",sourceKey:i.paragraph.attrs.sourceKey||null}));return o.setSelection(l.NodeSelection.create(o.doc,i.paragraphStart)),e.dispatch(o.scrollIntoView()),!0}function g(e,t,a,s){if(s!=="$"||t!==a)return!1;const i=e.state.doc.resolve(t);if(i.parent.type!==e.state.schema.nodes.paragraph||i.parentOffset<2)return!1;const n=i.parentOffset-2,r=i.parent.textBetween(n,i.parentOffset,"",""),o=e.state.schema.nodes.math_inline;if(r!=="$."||!o)return!1;const d=t-2,h=e.state.tr.replaceWith(d,a,o.create({htmlAttrs:{},latex:""}));return h.setSelection(l.NodeSelection.create(h.doc,d)),e.dispatch(h.scrollIntoView()),!0}function y(){return new l.Plugin({props:{handleTextInput:(e,t,a,s)=>g(e,t,a,s)||f(e,t,a,s)}})}function x(){return{name:"math",nodes:{math_block:{...u.math_block,sourceUnit:!0},math_inline:{...u.math_inline,sourceUnit:!0}},plugins:()=>[y()],nodeViews:{math_block:(e,t,a)=>new m(e,t,a),math_inline:(e,t,a)=>new m(e,t,a)}}}exports.createMathExtension=x;exports.createMathInputPlugin=y;exports.insertBlockMathFromDollarInput=f;exports.insertInlineMathFromDotDollarInput=g;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/extensions/math/nodes.ts","../../../src/extensions/math/math-node-view.ts","../../../src/extensions/math/math-input.ts","../../../src/extensions/math/index.ts"],"sourcesContent":["import type { NodeSpec, DOMOutputSpec } from '@mache-hangar/lunar-editor-core/pm';\nimport { getDomSourceKey } from '@mache-hangar/lunar-editor-core/source/dom-projection';\nimport { readHtmlAttributes } from '@mache-hangar/lunar-editor-core/schema/dom-attributes';\nexport function parseMathAttrs(element: HTMLElement) {\n const htmlAttrs = readHtmlAttributes(element);\n delete htmlAttrs['data-type'];\n delete htmlAttrs['data-display'];\n delete htmlAttrs['data-latex'];\n\n return {\n htmlAttrs,\n latex: element.dataset.latex || '',\n sourceKey: getDomSourceKey(element) || null,\n };\n}\n\nexport const mathNodes: Record<string, NodeSpec> = {\n math_block: {\n attrs: {\n htmlAttrs: { default: {} },\n latex: { default: '' },\n sourceKey: { default: null },\n },\n atom: true,\n group: 'block',\n isolating: true,\n parseDOM: [\n {\n tag: 'p[data-type=\"math\"][data-display=\"block\"]',\n priority: 100,\n getAttrs: (element) => parseMathAttrs(element as HTMLElement),\n },\n ],\n toDOM: (node): DOMOutputSpec => [\n 'p',\n {\n ...node.attrs.htmlAttrs,\n 'data-type': 'math',\n 'data-display': 'block',\n 'data-latex': node.attrs.latex || '',\n },\n ],\n },\n math_inline: {\n attrs: {\n htmlAttrs: { default: {} },\n latex: { default: '' },\n sourceKey: { default: null },\n },\n atom: true,\n group: 'inline',\n inline: true,\n isolating: true,\n parseDOM: [\n {\n tag: 'span[data-type=\"math\"][data-display=\"inline\"]',\n priority: 100,\n getAttrs: (element) => parseMathAttrs(element as HTMLElement),\n },\n ],\n toDOM: (node): DOMOutputSpec => [\n 'span',\n {\n ...node.attrs.htmlAttrs,\n 'data-type': 'math',\n 'data-display': 'inline',\n 'data-latex': node.attrs.latex || '',\n },\n ],\n },\n};\n","import { MathfieldElement } from 'mathlive';\nimport {\n type Node as ProseMirrorNode,\n NodeSelection,\n Selection,\n type EditorView,\n type NodeView,\n} from '@mache-hangar/lunar-editor-core/pm';\n\ntype HtmlAttributes = Record<string, string>;\ntype GetPos = () => number | undefined;\ntype MathDisplay = 'block' | 'inline';\n\nMathfieldElement.soundsDirectory = null;\n\nfunction updateHtmlAttributes(\n element: HTMLElement,\n attributes: HtmlAttributes\n) {\n Array.from(element.attributes).forEach((attribute) => {\n if (!(attribute.name in attributes)) {\n element.removeAttribute(attribute.name);\n }\n });\n\n Object.entries(attributes).forEach(([name, value]) => {\n element.setAttribute(name, value);\n });\n}\n\nfunction mathNodeAttributes(\n node: ProseMirrorNode,\n selected: boolean,\n editing: boolean,\n display: MathDisplay\n): HtmlAttributes {\n const htmlAttrs = { ...(node.attrs.htmlAttrs || {}) };\n const classNames = new Set(\n String(htmlAttrs.class || '')\n .split(/\\s+/)\n .filter(Boolean)\n );\n classNames.add('lunar-math-node');\n classNames.add(`lunar-math-${display}`);\n if (selected) {\n classNames.add('ProseMirror-selectednode');\n }\n if (editing) {\n classNames.add('lunar-math-node--editing');\n }\n\n return {\n ...htmlAttrs,\n class: Array.from(classNames).join(' '),\n 'data-type': 'math',\n 'data-display': display,\n 'data-latex': node.attrs.latex || '',\n contenteditable: 'false',\n };\n}\n\nexport class MathNodeView implements NodeView {\n readonly dom: HTMLElement;\n\n private node: ProseMirrorNode;\n private readonly mathfield: MathfieldElement;\n private readonly display: MathDisplay;\n private selected = false;\n private editing = false;\n\n constructor(\n node: ProseMirrorNode,\n private readonly view: EditorView,\n private readonly getPos: GetPos\n ) {\n this.node = node;\n this.display = node.type.name === 'math_inline' ? 'inline' : 'block';\n this.dom = document.createElement(this.display === 'inline' ? 'span' : 'p');\n this.mathfield = new MathfieldElement();\n this.mathfield.className = `lunar-math-field lunar-math-field--${this.display}`;\n this.mathfield.smartFence = true;\n this.mathfield.mathVirtualKeyboardPolicy = 'auto';\n this.mathfield.setAttribute(\n 'aria-label',\n this.display === 'inline' ? 'Inline math formula' : 'Math formula'\n );\n this.mathfield.addEventListener('change', this.handleChange);\n this.mathfield.addEventListener('focus', this.handleFocus);\n this.mathfield.addEventListener('blur', this.handleBlur);\n this.mathfield.addEventListener('keydown', this.handleKeyDown);\n this.dom.addEventListener('pointerdown', this.handlePointerDown, true);\n this.dom.appendChild(this.mathfield);\n this.update(node);\n }\n\n private handlePointerDown = () => {\n if (!this.view.editable) {\n this.setEditing(false);\n return;\n }\n\n this.setEditing(true);\n\n const position = this.getPos();\n if (position === undefined) {\n return;\n }\n\n const selection = this.view.state.selection;\n if (!(selection instanceof NodeSelection) || selection.from !== position) {\n this.view.dispatch(\n this.view.state.tr.setSelection(\n NodeSelection.create(this.view.state.doc, position)\n )\n );\n }\n\n window.requestAnimationFrame(() => {\n if (this.editing && this.view.editable) {\n this.mathfield.focus();\n }\n });\n };\n\n private handleFocus = () => {\n this.setEditing(true);\n };\n\n private handleBlur = () => {\n this.setEditing(false);\n };\n\n private setEditing(editing: boolean) {\n this.editing = editing && this.view.editable;\n this.dom.classList.toggle('lunar-math-node--editing', this.editing);\n this.mathfield.readOnly = !this.view.editable;\n }\n\n private handleChange = () => {\n const position = this.getPos();\n if (position === undefined || !this.view.editable) {\n return;\n }\n\n const currentNode = this.view.state.doc.nodeAt(position);\n const latex = this.mathfield.value;\n if (\n currentNode?.type !== this.node.type ||\n currentNode.attrs.latex === latex\n ) {\n return;\n }\n\n this.view.dispatch(\n this.view.state.tr.setNodeMarkup(position, undefined, {\n ...currentNode.attrs,\n latex,\n })\n );\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (\n (event.key === 'Backspace' || event.key === 'Delete') &&\n this.mathfield.value.trim() === ''\n ) {\n event.preventDefault();\n event.stopPropagation();\n this.deleteEmptyBlock(event.key === 'Backspace' ? -1 : 1);\n return;\n }\n\n if (event.key !== 'Escape') {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.mathfield.blur();\n this.view.focus();\n };\n\n private deleteEmptyBlock(direction: -1 | 1) {\n const position = this.getPos();\n if (position === undefined || !this.view.editable) {\n return;\n }\n\n const currentNode = this.view.state.doc.nodeAt(position);\n if (currentNode?.type !== this.node.type) {\n return;\n }\n\n const transaction = this.view.state.tr.delete(\n position,\n position + currentNode.nodeSize\n );\n const selectionPosition = Math.min(position, transaction.doc.content.size);\n transaction.setSelection(\n Selection.near(transaction.doc.resolve(selectionPosition), direction)\n );\n this.view.dispatch(transaction);\n\n window.requestAnimationFrame(() => {\n this.view.focus();\n });\n }\n\n update(node: ProseMirrorNode) {\n if (node.type.name !== `math_${this.display}`) {\n return false;\n }\n\n this.node = node;\n updateHtmlAttributes(\n this.dom,\n mathNodeAttributes(node, this.selected, this.editing, this.display)\n );\n this.mathfield.readOnly = !this.view.editable;\n\n const latex = node.attrs.latex || '';\n if (this.mathfield.value !== latex) {\n this.mathfield.setValue(latex, { silenceNotifications: true });\n }\n return true;\n }\n\n selectNode() {\n this.selected = true;\n this.dom.classList.add('ProseMirror-selectednode');\n if (!this.view.editable) {\n this.setEditing(false);\n return;\n }\n\n this.setEditing(true);\n\n window.requestAnimationFrame(() => {\n this.mathfield.focus();\n });\n }\n\n deselectNode() {\n this.selected = false;\n this.dom.classList.remove('ProseMirror-selectednode');\n this.setEditing(false);\n }\n\n stopEvent(event: Event) {\n return event.target instanceof Node && this.dom.contains(event.target);\n }\n\n ignoreMutation() {\n return true;\n }\n\n destroy() {\n this.mathfield.removeEventListener('change', this.handleChange);\n this.mathfield.removeEventListener('focus', this.handleFocus);\n this.mathfield.removeEventListener('blur', this.handleBlur);\n this.mathfield.removeEventListener('keydown', this.handleKeyDown);\n this.dom.removeEventListener('pointerdown', this.handlePointerDown, true);\n }\n}\n","import {\n NodeSelection,\n Plugin,\n type EditorView,\n} from '@mache-hangar/lunar-editor-core/pm';\n\nfunction getParagraphTextWithInput(\n view: EditorView,\n from: number,\n to: number,\n text: string\n) {\n const resolvedFrom = view.state.doc.resolve(from);\n const resolvedTo = view.state.doc.resolve(to);\n\n if (\n resolvedFrom.parent !== resolvedTo.parent ||\n resolvedFrom.parent.type !== view.state.schema.nodes.paragraph\n ) {\n return undefined;\n }\n\n const paragraph = resolvedFrom.parent;\n const before = paragraph.textBetween(0, resolvedFrom.parentOffset, '', '');\n const after = paragraph.textBetween(\n resolvedTo.parentOffset,\n paragraph.content.size,\n '',\n ''\n );\n\n return {\n paragraph,\n text: `${before}${text}${after}`,\n paragraphStart: resolvedFrom.before(),\n paragraphEnd: resolvedFrom.after(),\n };\n}\n\nexport function insertBlockMathFromDollarInput(\n view: EditorView,\n from: number,\n to: number,\n text: string\n) {\n if (!text.includes('$')) {\n return false;\n }\n\n const match = getParagraphTextWithInput(view, from, to, text);\n const mathBlock = view.state.schema.nodes.math_block;\n if (!match || match.text !== '$$' || !mathBlock) {\n return false;\n }\n\n const htmlAttrs = { ...(match.paragraph.attrs.htmlAttrs || {}) };\n delete htmlAttrs['data-type'];\n delete htmlAttrs['data-display'];\n delete htmlAttrs['data-latex'];\n\n const transaction = view.state.tr.replaceWith(\n match.paragraphStart,\n match.paragraphEnd,\n mathBlock.create({\n htmlAttrs,\n latex: '',\n sourceKey: match.paragraph.attrs.sourceKey || null,\n })\n );\n transaction.setSelection(\n NodeSelection.create(transaction.doc, match.paragraphStart)\n );\n view.dispatch(transaction.scrollIntoView());\n return true;\n}\n\nexport function insertInlineMathFromDotDollarInput(\n view: EditorView,\n from: number,\n to: number,\n text: string\n) {\n if (text !== '$' || from !== to) {\n return false;\n }\n\n const resolvedFrom = view.state.doc.resolve(from);\n if (\n resolvedFrom.parent.type !== view.state.schema.nodes.paragraph ||\n resolvedFrom.parentOffset < 2\n ) {\n return false;\n }\n\n const triggerStartOffset = resolvedFrom.parentOffset - 2;\n const triggerPrefix = resolvedFrom.parent.textBetween(\n triggerStartOffset,\n resolvedFrom.parentOffset,\n '',\n ''\n );\n const mathInline = view.state.schema.nodes.math_inline;\n if (triggerPrefix !== '$.' || !mathInline) {\n return false;\n }\n\n const triggerStart = from - 2;\n const transaction = view.state.tr.replaceWith(\n triggerStart,\n to,\n mathInline.create({ htmlAttrs: {}, latex: '' })\n );\n transaction.setSelection(NodeSelection.create(transaction.doc, triggerStart));\n view.dispatch(transaction.scrollIntoView());\n return true;\n}\n\nexport function createMathInputPlugin() {\n return new Plugin({\n props: {\n handleTextInput: (view, from, to, text) =>\n insertInlineMathFromDotDollarInput(view, from, to, text) ||\n insertBlockMathFromDollarInput(view, from, to, text),\n },\n });\n}\n","import type { EditorExtension } from '@mache-hangar/lunar-editor-core/extensions';\nimport { mathNodes } from './nodes';\nimport { MathNodeView } from './math-node-view';\nimport { createMathInputPlugin } from './math-input';\nexport * from './math-input';\nexport function createMathExtension(): EditorExtension {\n return {\n name: 'math',\n nodes: {\n math_block: { ...mathNodes.math_block, sourceUnit: true },\n math_inline: { ...mathNodes.math_inline, sourceUnit: true },\n },\n plugins: () => [createMathInputPlugin()],\n nodeViews: {\n math_block: (node, view, getPos) => new MathNodeView(node, view, getPos),\n math_inline: (node, view, getPos) => new MathNodeView(node, view, getPos),\n },\n };\n}\n"],"names":["parseMathAttrs","element","htmlAttrs","readHtmlAttributes","getDomSourceKey","mathNodes","node","MathfieldElement","updateHtmlAttributes","attributes","attribute","name","value","mathNodeAttributes","selected","editing","display","classNames","MathNodeView","view","getPos","position","selection","NodeSelection","currentNode","latex","event","direction","transaction","selectionPosition","Selection","getParagraphTextWithInput","from","to","text","resolvedFrom","resolvedTo","paragraph","before","after","insertBlockMathFromDollarInput","match","mathBlock","insertInlineMathFromDotDollarInput","triggerStartOffset","triggerPrefix","mathInline","triggerStart","createMathInputPlugin","Plugin","createMathExtension"],"mappings":"kSAGO,SAASA,EAAeC,EAAsB,CACnD,MAAMC,EAAYC,EAAAA,mBAAmBF,CAAO,EAC5C,cAAOC,EAAU,WAAW,EAC5B,OAAOA,EAAU,cAAc,EAC/B,OAAOA,EAAU,YAAY,EAEtB,CACL,UAAAA,EACA,MAAOD,EAAQ,QAAQ,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