@formulaxjs/ckeditor5 0.3.0 → 0.4.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 +266 -264
- package/README.zh-CN.md +62 -60
- package/dist/base.css +47 -0
- package/dist/canvg-runtime-UR3JNX5Q.js +2759 -0
- package/dist/canvg-runtime-UR3JNX5Q.js.map +1 -0
- package/dist/chunk-4NHESKRD.js +3407 -0
- package/dist/chunk-4NHESKRD.js.map +1 -0
- package/dist/images/scrollbar/custom/bar-bg.png +0 -0
- package/dist/images/scrollbar/custom/bar.png +0 -0
- package/dist/images/scrollbar/custom/bg.png +0 -0
- package/dist/images/scrollbar/custom/bottom.png +0 -0
- package/dist/images/scrollbar/custom/btn.png +0 -0
- package/dist/images/scrollbar/custom/down.png +0 -0
- package/dist/images/scrollbar/custom/top.png +0 -0
- package/dist/images/scrollbar/custom/up.png +0 -0
- package/dist/images/scrollbar/edit/bar-bg.png +0 -0
- package/dist/images/scrollbar/edit/bar-left.png +0 -0
- package/dist/images/scrollbar/edit/bar-right.png +0 -0
- package/dist/images/scrollbar/edit/thumb-bg.png +0 -0
- package/dist/images/scrollbar/edit/thumb-left.png +0 -0
- package/dist/images/scrollbar/edit/thumb-right.png +0 -0
- package/dist/images/toolbar/btn.png +0 -0
- package/dist/index.cjs +24080 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +294 -150
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3768 -21
- package/dist/index.js.map +1 -1
- package/dist/install-XGCSWTLU.js +5464 -0
- package/dist/install-XGCSWTLU.js.map +1 -0
- package/dist/install-XVTKACEN.js +1349 -0
- package/dist/install-XVTKACEN.js.map +1 -0
- package/dist/other.png +0 -0
- package/dist/scrollbar.css +78 -0
- package/dist/start-CRRRBVTN.js +4926 -0
- package/dist/start-CRRRBVTN.js.map +1 -0
- package/dist/ui.css +625 -0
- package/package.json +10 -5
- /package/dist/{KF_AMS_BB-5QF7FUSO.woff → KF_AMS_BB.woff} +0 -0
- /package/dist/{KF_AMS_CAL-NXRNLAZN.woff → KF_AMS_CAL.woff} +0 -0
- /package/dist/{KF_AMS_FRAK-CO33WWN4.woff → KF_AMS_FRAK.woff} +0 -0
- /package/dist/{KF_AMS_MAIN-25QJVAWY.woff → KF_AMS_MAIN.woff} +0 -0
- /package/dist/{KF_AMS_ROMAN-243BR7HH.woff → KF_AMS_ROMAN.woff} +0 -0
- /package/dist/{btn-5DANP6JY.png → btn.png} +0 -0
- /package/dist/{editor-JT5KLVXX.css → editor.css} +0 -0
- /package/dist/{other-OMWJFGL5.png → images/toolbar/other.png} +0 -0
package/README.zh-CN.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @formulaxjs/ckeditor5
|
|
2
2
|
|
|
3
|
-
[English](
|
|
3
|
+
[English](https://github.com/vndmea/formulaX/blob/main/packages/ckeditor5/README.md) | 简体中文
|
|
4
4
|
|
|
5
5
|
FormulaX 的 CKEditor 5 集成适配器。
|
|
6
6
|
|
|
7
|
-
`@formulaxjs/ckeditor5` 提供了一个 CKEditor 5 插件,会以弹窗形式打开 FormulaX 编辑器,用于在 CKEditor 5 内容中插入和更新行内公式。
|
|
7
|
+
`@formulaxjs/ckeditor5` 提供了一个 CKEditor 5 插件,会以弹窗形式打开 FormulaX 编辑器,用于在 CKEditor 5 内容中插入和更新行内公式。
|
|
8
8
|
|
|
9
9
|
> 状态:实验阶段。在首个稳定版本发布前,公共 API 仍可能调整。
|
|
10
10
|
|
|
@@ -14,13 +14,13 @@ FormulaX 的 CKEditor 5 集成适配器。
|
|
|
14
14
|
- 基于 CKEditor 5 `componentFactory` 注册工具栏按钮
|
|
15
15
|
- 通过 `editor.execute('formulaX')` 在代码中主动打开
|
|
16
16
|
- 将公式作为行内 widget object 插入和更新
|
|
17
|
-
- 支持双击编辑已有公式
|
|
18
|
-
- 在 CKEditor 5 model 中仅持久化 LaTeX 源内容
|
|
19
|
-
- 在 editing view 中运行时渲染 SVG
|
|
20
|
-
- 默认通过 `@formulaxjs/renderer-kity` 完成只读渲染
|
|
21
|
-
- 支持在首次打开弹窗前预加载 runtime
|
|
22
|
-
- 支持在编辑器数据中对公式 markup 进行 upcast 和 downcast
|
|
23
|
-
- 直接导出弹窗工具函数 `openFormulaXModal`
|
|
17
|
+
- 支持双击编辑已有公式
|
|
18
|
+
- 在 CKEditor 5 model 中仅持久化 LaTeX 源内容
|
|
19
|
+
- 在 editing view 中运行时渲染 SVG
|
|
20
|
+
- 默认通过 `@formulaxjs/renderer-kity` 完成只读渲染
|
|
21
|
+
- 支持在首次打开弹窗前预加载 runtime
|
|
22
|
+
- 支持在编辑器数据中对公式 markup 进行 upcast 和 downcast
|
|
23
|
+
- 直接导出弹窗工具函数 `openFormulaXModal`
|
|
24
24
|
|
|
25
25
|
## 兼容性
|
|
26
26
|
|
|
@@ -39,8 +39,7 @@ FormulaX 的 CKEditor 5 集成适配器。
|
|
|
39
39
|
包发布后可使用:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
|
|
43
|
-
pnpm add ckeditor5
|
|
42
|
+
npm install @formulaxjs/ckeditor5 ckeditor5
|
|
44
43
|
```
|
|
45
44
|
|
|
46
45
|
在 FormulaX 工作空间内,直接使用 workspace 包:
|
|
@@ -60,10 +59,10 @@ import {
|
|
|
60
59
|
Essentials,
|
|
61
60
|
Paragraph,
|
|
62
61
|
} from 'ckeditor5';
|
|
63
|
-
import 'ckeditor5/ckeditor5.css';
|
|
64
|
-
|
|
65
|
-
import { FormulaX } from '@formulaxjs/ckeditor5';
|
|
66
|
-
import { createKityFormulaRenderer } from '@formulaxjs/renderer-kity';
|
|
62
|
+
import 'ckeditor5/ckeditor5.css';
|
|
63
|
+
|
|
64
|
+
import { FormulaX } from '@formulaxjs/ckeditor5';
|
|
65
|
+
import { createKityFormulaRenderer } from '@formulaxjs/renderer-kity';
|
|
67
66
|
|
|
68
67
|
await ClassicEditor.create(document.querySelector('#editor')!, {
|
|
69
68
|
licenseKey: 'GPL',
|
|
@@ -73,27 +72,28 @@ await ClassicEditor.create(document.querySelector('#editor')!, {
|
|
|
73
72
|
FormulaX,
|
|
74
73
|
],
|
|
75
74
|
toolbar: ['formulaX'],
|
|
76
|
-
formulaX: {
|
|
77
|
-
toolbarText: 'FormulaX',
|
|
78
|
-
tooltip: '插入或编辑公式',
|
|
79
|
-
modal: {
|
|
80
|
-
title: 'FormulaX 公式编辑器',
|
|
81
|
-
},
|
|
75
|
+
formulaX: {
|
|
76
|
+
toolbarText: 'FormulaX',
|
|
77
|
+
tooltip: '插入或编辑公式',
|
|
78
|
+
modal: {
|
|
79
|
+
title: 'FormulaX 公式编辑器',
|
|
80
|
+
},
|
|
82
81
|
renderer: createKityFormulaRenderer({
|
|
83
82
|
fontSize: 40,
|
|
84
83
|
}),
|
|
85
84
|
editor: {
|
|
85
|
+
locale: 'zh_CN', // 可选,默认 en_US
|
|
86
86
|
render: {
|
|
87
87
|
fontsize: 40,
|
|
88
|
-
},
|
|
88
|
+
},
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
} as any);
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
之后用户可以点击 `FormulaX` 工具栏按钮插入公式。已有公式可以通过双击更新,也可以先选中后再次执行同一个命令进行更新。
|
|
95
|
-
|
|
96
|
-
## 自定义 model 名称
|
|
94
|
+
之后用户可以点击 `FormulaX` 工具栏按钮插入公式。已有公式可以通过双击更新,也可以先选中后再次执行同一个命令进行更新。
|
|
95
|
+
|
|
96
|
+
## 自定义 model 名称
|
|
97
97
|
|
|
98
98
|
默认的 CKEditor 5 model 名称是 `formulaX`。
|
|
99
99
|
|
|
@@ -165,38 +165,39 @@ CKEditor 5 的 model 层只保存公式的 LaTeX 源内容:
|
|
|
165
165
|
></span>
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
编辑态中的 SVG 由持久化的 LaTeX 在运行时生成。用于渲染公式的内部 HTML 结构属于实现细节,后续可能演进。业务侧应优先依赖插件能力和导出的配置项,而不是写死完整 markup 结构。
|
|
169
|
-
|
|
170
|
-
## 自定义 renderer
|
|
171
|
-
|
|
172
|
-
该适配器支持 `renderer` 配置项。默认值是来自 `@formulaxjs/renderer-kity` 的 `createKityFormulaRenderer()`。
|
|
168
|
+
编辑态中的 SVG 由持久化的 LaTeX 在运行时生成。用于渲染公式的内部 HTML 结构属于实现细节,后续可能演进。业务侧应优先依赖插件能力和导出的配置项,而不是写死完整 markup 结构。
|
|
169
|
+
|
|
170
|
+
## 自定义 renderer
|
|
171
|
+
|
|
172
|
+
该适配器支持 `renderer` 配置项。默认值是来自 `@formulaxjs/renderer-kity` 的 `createKityFormulaRenderer()`。
|
|
173
173
|
|
|
174
174
|
## 配置项
|
|
175
175
|
|
|
176
176
|
```ts
|
|
177
|
-
interface FormulaXCKEditor5Options {
|
|
178
|
-
name?: string;
|
|
179
|
-
buttonName?: string;
|
|
180
|
-
toolbarText?: string;
|
|
181
|
-
tooltip?: string;
|
|
182
|
-
cursorStyle?: string;
|
|
183
|
-
formulaClassName?: string;
|
|
184
|
-
formulaAttributeName?: string;
|
|
185
|
-
renderer?: FormulaRenderer;
|
|
186
|
-
preload?: FormulaXEditorPreloadMode;
|
|
187
|
-
modal?: {
|
|
188
|
-
title?: string;
|
|
189
|
-
insertText?: string;
|
|
177
|
+
interface FormulaXCKEditor5Options {
|
|
178
|
+
name?: string;
|
|
179
|
+
buttonName?: string;
|
|
180
|
+
toolbarText?: string;
|
|
181
|
+
tooltip?: string;
|
|
182
|
+
cursorStyle?: string;
|
|
183
|
+
formulaClassName?: string;
|
|
184
|
+
formulaAttributeName?: string;
|
|
185
|
+
renderer?: FormulaRenderer;
|
|
186
|
+
preload?: FormulaXEditorPreloadMode;
|
|
187
|
+
modal?: {
|
|
188
|
+
title?: string;
|
|
189
|
+
insertText?: string;
|
|
190
190
|
updateText?: string;
|
|
191
191
|
cancelText?: string;
|
|
192
192
|
closeOnBackdrop?: boolean;
|
|
193
193
|
};
|
|
194
|
-
editor?: {
|
|
195
|
-
height?: number | string;
|
|
196
|
-
autofocus?: boolean;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
editor?: {
|
|
195
|
+
height?: number | string;
|
|
196
|
+
autofocus?: boolean;
|
|
197
|
+
locale?: FormulaXLocale;
|
|
198
|
+
assets?: Partial<KityEditorAssets>;
|
|
199
|
+
render?: {
|
|
200
|
+
fontsize?: number;
|
|
200
201
|
};
|
|
201
202
|
};
|
|
202
203
|
}
|
|
@@ -208,13 +209,13 @@ interface FormulaXCKEditor5Options {
|
|
|
208
209
|
| `buttonName` | `formulaX` | CKEditor 5 的工具栏按钮名,同时也是命令名。 |
|
|
209
210
|
| `toolbarText` | `FormulaX` | 工具栏按钮显示文本。 |
|
|
210
211
|
| `tooltip` | `Insert or edit formula` | 工具栏按钮 tooltip。 |
|
|
211
|
-
| `cursorStyle` | `pointer` | 应用于生成公式节点的鼠标光标样式。 |
|
|
212
|
-
| `formulaClassName` | `formulax-math` | 生成的公式节点 CSS class。 |
|
|
213
|
-
| `formulaAttributeName` | `data-formulax-latex` | 用于保存 LaTeX 源内容的属性。 |
|
|
214
|
-
| `renderer` | `createKityFormulaRenderer()` | editing view 中运行时 SVG 输出使用的 renderer。 |
|
|
215
|
-
| `preload` | `idle` | 控制在浏览器空闲时、宿主 hover/focus 时,或完全不预加载 FormulaX runtime。 |
|
|
216
|
-
| `modal` | 见下方 | 弹窗文案和关闭行为。 |
|
|
217
|
-
| `editor` | 见下方 | 内嵌 FormulaX 编辑器配置。 |
|
|
212
|
+
| `cursorStyle` | `pointer` | 应用于生成公式节点的鼠标光标样式。 |
|
|
213
|
+
| `formulaClassName` | `formulax-math` | 生成的公式节点 CSS class。 |
|
|
214
|
+
| `formulaAttributeName` | `data-formulax-latex` | 用于保存 LaTeX 源内容的属性。 |
|
|
215
|
+
| `renderer` | `createKityFormulaRenderer()` | editing view 中运行时 SVG 输出使用的 renderer。 |
|
|
216
|
+
| `preload` | `idle` | 控制在浏览器空闲时、宿主 hover/focus 时,或完全不预加载 FormulaX runtime。 |
|
|
217
|
+
| `modal` | 见下方 | 弹窗文案和关闭行为。 |
|
|
218
|
+
| `editor` | 见下方 | 内嵌 FormulaX 编辑器配置。 |
|
|
218
219
|
|
|
219
220
|
### Modal 配置
|
|
220
221
|
|
|
@@ -230,10 +231,11 @@ interface FormulaXCKEditor5Options {
|
|
|
230
231
|
|
|
231
232
|
| 配置项 | 默认值 | 说明 |
|
|
232
233
|
| --- | --- | --- |
|
|
233
|
-
| `height` | `100%` | 内嵌编辑器高度。 |
|
|
234
|
-
| `autofocus` | `true` | 内嵌编辑器是否自动聚焦。 |
|
|
235
|
-
| `
|
|
236
|
-
| `
|
|
234
|
+
| `height` | `100%` | 内嵌编辑器高度。 |
|
|
235
|
+
| `autofocus` | `true` | 内嵌编辑器是否自动聚焦。 |
|
|
236
|
+
| `locale` | `en_US` | 同时切换弹窗默认文案和内嵌 Kity runtime UI。 |
|
|
237
|
+
| `assets` | `{}` | 可选的 Kity runtime 资源覆盖配置。 |
|
|
238
|
+
| `render.fontsize` | `40` | 公式渲染字号。 |
|
|
237
239
|
|
|
238
240
|
## 导出 API
|
|
239
241
|
|
package/dist/base.css
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
.kf-editor {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
border: 1px solid #e0e0e0;
|
|
8
|
+
position: relative;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
|
|
12
|
+
overflow: visible;
|
|
13
|
+
z-index: 2;
|
|
14
|
+
background-color: #f6f5ee;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.kf-editor-edit-area {
|
|
18
|
+
width: 100%;
|
|
19
|
+
position: relative;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
|
|
23
|
+
display: block;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
flex: 1 1 auto;
|
|
26
|
+
min-height: 100px;
|
|
27
|
+
height: 100px;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
background-color: white;
|
|
30
|
+
/*background-color: white;*/
|
|
31
|
+
/*background-size: 21px 21px;*/
|
|
32
|
+
/*background-position: 0 0,10px 10px;*/
|
|
33
|
+
/*background-image: -webkit-linear-gradient(45deg,#efefef 25%,transparent 25%,transparent 75%,#efefef 75%,#efefef),-webkit-linear-gradient(45deg,#efefef 25%,transparent 25%,transparent 75%,#efefef 75%,#efefef);*/
|
|
34
|
+
/*background-image: linear-gradient(45deg,#efefef 25%,transparent 25%,transparent 75%,#efefef 75%,#efefef),linear-gradient(45deg,#efefef 25%,transparent 25%,transparent 75%,#efefef 75%,#efefef);*/
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.kf-editor-canvas-container {
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.kf-editor-input-box {
|
|
43
|
+
position: fixed;
|
|
44
|
+
top: 0;
|
|
45
|
+
left: -99999999px;
|
|
46
|
+
z-index: 999999;
|
|
47
|
+
}
|