@formulaxjs/tinymce 0.2.1 → 0.3.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/README.md +47 -29
- package/README.zh-CN.md +47 -29
- 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 +24136 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.global.js +162 -156
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3762 -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 +12 -7
- /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.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @formulaxjs/tinymce
|
|
2
2
|
|
|
3
|
-
English | [简体中文](
|
|
3
|
+
English | [简体中文](https://github.com/vndmea/formulaX/blob/main/packages/tinymce/README.zh-CN.md)
|
|
4
4
|
|
|
5
5
|
TinyMCE integration adapter for FormulaX.
|
|
6
6
|
|
|
@@ -58,18 +58,35 @@ Register the FormulaX TinyMCE plugin before calling `tinymce.init`:
|
|
|
58
58
|
import tinymce from 'tinymce';
|
|
59
59
|
import { registerFormulaXTinyMcePlugin } from '@formulaxjs/tinymce';
|
|
60
60
|
|
|
61
|
-
registerFormulaXTinyMcePlugin(tinymce, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
registerFormulaXTinyMcePlugin(tinymce, {
|
|
62
|
+
pluginName: 'formulax', // TinyMCE plugin id used in the plugins list
|
|
63
|
+
buttonName: 'formulax', // toolbar button id used in the toolbar string
|
|
64
|
+
menuItemName: 'formulax', // menu item id if you also expose the action in menus
|
|
65
|
+
toolbarText: 'FormulaX',
|
|
66
|
+
tooltip: 'Insert or edit formula',
|
|
67
|
+
cursorStyle: 'pointer', // cursor applied to generated formula nodes
|
|
68
|
+
formulaClassName: 'formulax-math', // DOM class written on formula wrappers
|
|
69
|
+
formulaAttributeName: 'data-formulax-latex', // attribute that stores source LaTeX
|
|
70
|
+
initialLatex: '\\sqrt{x}', // default LaTeX for newly inserted formulas
|
|
71
|
+
preload: 'idle', // 'idle' | 'hover' | false
|
|
72
|
+
modal: {
|
|
73
|
+
title: 'FormulaX Editor',
|
|
74
|
+
insertText: 'Insert',
|
|
75
|
+
updateText: 'Update',
|
|
76
|
+
cancelText: 'Cancel',
|
|
77
|
+
width: '1100px',
|
|
78
|
+
height: 'auto',
|
|
79
|
+
closeOnBackdrop: true,
|
|
80
|
+
},
|
|
81
|
+
editor: {
|
|
82
|
+
// forwarded to the embedded FormulaX editor instance
|
|
83
|
+
locale: 'zh_CN', // optional, defaults to en_US
|
|
84
|
+
height: 320,
|
|
85
|
+
autofocus: true,
|
|
86
|
+
assets: {},
|
|
87
|
+
render: { fontsize: 40 },
|
|
88
|
+
},
|
|
89
|
+
});
|
|
73
90
|
|
|
74
91
|
await tinymce.init({
|
|
75
92
|
selector: '#editor',
|
|
@@ -81,9 +98,9 @@ await tinymce.init({
|
|
|
81
98
|
});
|
|
82
99
|
```
|
|
83
100
|
|
|
84
|
-
Then users can click the `FormulaX` toolbar button to insert a formula. Existing formulas can be edited by double-clicking them or selecting them and pressing Enter or Space.
|
|
85
|
-
|
|
86
|
-
## Programmatic opening
|
|
101
|
+
Then users can click the `FormulaX` toolbar button to insert a formula. Existing formulas can be edited by double-clicking them or selecting them and pressing Enter or Space.
|
|
102
|
+
|
|
103
|
+
## Programmatic opening
|
|
87
104
|
|
|
88
105
|
The plugin registers the `FormulaXOpen` command:
|
|
89
106
|
|
|
@@ -167,7 +184,7 @@ registerFormulaXTinyMcePlugin(tinymce, {
|
|
|
167
184
|
## Options
|
|
168
185
|
|
|
169
186
|
```ts
|
|
170
|
-
interface FormulaXTinyMceOptions {
|
|
187
|
+
interface FormulaXTinyMceOptions {
|
|
171
188
|
pluginName?: string;
|
|
172
189
|
buttonName?: string;
|
|
173
190
|
menuItemName?: string;
|
|
@@ -176,13 +193,13 @@ interface FormulaXTinyMceOptions {
|
|
|
176
193
|
cursorStyle?: string;
|
|
177
194
|
formulaClassName?: string;
|
|
178
195
|
formulaAttributeName?: string;
|
|
179
|
-
renderer?: FormulaRenderer;
|
|
180
|
-
preload?: FormulaXEditorPreloadMode;
|
|
181
|
-
initialLatex?: string;
|
|
182
|
-
modal?: FormulaXModalOptions;
|
|
183
|
-
editor?: FormulaXEditorOptions
|
|
184
|
-
}
|
|
185
|
-
```
|
|
196
|
+
renderer?: FormulaRenderer;
|
|
197
|
+
preload?: FormulaXEditorPreloadMode;
|
|
198
|
+
initialLatex?: string;
|
|
199
|
+
modal?: FormulaXModalOptions;
|
|
200
|
+
editor?: Omit<FormulaXEditorOptions, 'initialLatex'>;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
186
203
|
|
|
187
204
|
| Option | Default | Description |
|
|
188
205
|
| --- | --- | --- |
|
|
@@ -204,7 +221,7 @@ interface FormulaXTinyMceOptions {
|
|
|
204
221
|
|
|
205
222
|
| Option | Default | Description |
|
|
206
223
|
| --- | --- | --- |
|
|
207
|
-
| `title` | `FormulaX` | Modal title. |
|
|
224
|
+
| `title` | `FormulaX Editor` | Modal title. |
|
|
208
225
|
| `insertText` | `Insert` | Submit button text when inserting. |
|
|
209
226
|
| `updateText` | `Update` | Submit button text when updating. |
|
|
210
227
|
| `cancelText` | `Cancel` | Cancel button text. |
|
|
@@ -216,10 +233,11 @@ interface FormulaXTinyMceOptions {
|
|
|
216
233
|
|
|
217
234
|
| Option | Default | Description |
|
|
218
235
|
| --- | --- | --- |
|
|
219
|
-
| `height` | `100%` | Embedded editor height. |
|
|
220
|
-
| `autofocus` | `true` | Whether the embedded editor should autofocus. |
|
|
221
|
-
| `
|
|
222
|
-
| `
|
|
236
|
+
| `height` | `100%` | Embedded editor height. |
|
|
237
|
+
| `autofocus` | `true` | Whether the embedded editor should autofocus. |
|
|
238
|
+
| `locale` | `en_US` | Localizes the modal defaults and the embedded Kity runtime UI. |
|
|
239
|
+
| `assets` | `{}` | Optional Kity runtime asset overrides. |
|
|
240
|
+
| `render.fontsize` | `40` | Formula render font size. |
|
|
223
241
|
|
|
224
242
|
## Exported API
|
|
225
243
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @formulaxjs/tinymce
|
|
2
2
|
|
|
3
|
-
[English](
|
|
3
|
+
[English](https://github.com/vndmea/formulaX/blob/main/packages/tinymce/README.md) | 简体中文
|
|
4
4
|
|
|
5
5
|
FormulaX 的 TinyMCE 集成适配器。
|
|
6
6
|
|
|
@@ -58,18 +58,35 @@ pnpm dev:tinymce
|
|
|
58
58
|
import tinymce from 'tinymce';
|
|
59
59
|
import { registerFormulaXTinyMcePlugin } from '@formulaxjs/tinymce';
|
|
60
60
|
|
|
61
|
-
registerFormulaXTinyMcePlugin(tinymce, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
registerFormulaXTinyMcePlugin(tinymce, {
|
|
62
|
+
pluginName: 'formulax', // TinyMCE 插件名,需要和 plugins 配置一致
|
|
63
|
+
buttonName: 'formulax', // 工具栏按钮名,需要和 toolbar 配置一致
|
|
64
|
+
menuItemName: 'formulax', // 如果菜单里也要出现该操作,可复用这个标识
|
|
65
|
+
toolbarText: 'FormulaX',
|
|
66
|
+
tooltip: '插入或编辑公式',
|
|
67
|
+
cursorStyle: 'pointer', // 应用于公式节点的鼠标样式
|
|
68
|
+
formulaClassName: 'formulax-math', // 公式外层 DOM class
|
|
69
|
+
formulaAttributeName: 'data-formulax-latex', // 保存源 LaTeX 的属性名
|
|
70
|
+
initialLatex: '\\sqrt{x}', // 新插入公式的默认内容
|
|
71
|
+
preload: 'idle', // 'idle' | 'hover' | false
|
|
72
|
+
modal: {
|
|
73
|
+
title: 'FormulaX 公式编辑器',
|
|
74
|
+
insertText: 'Insert',
|
|
75
|
+
updateText: 'Update',
|
|
76
|
+
cancelText: 'Cancel',
|
|
77
|
+
width: '1100px',
|
|
78
|
+
height: 'auto',
|
|
79
|
+
closeOnBackdrop: true,
|
|
80
|
+
},
|
|
81
|
+
editor: {
|
|
82
|
+
// 这些配置会透传给内嵌的 FormulaX 编辑器
|
|
83
|
+
locale: 'zh_CN', // 可选,默认 en_US
|
|
84
|
+
height: 320,
|
|
85
|
+
autofocus: true,
|
|
86
|
+
assets: {},
|
|
87
|
+
render: { fontsize: 40 },
|
|
88
|
+
},
|
|
89
|
+
});
|
|
73
90
|
|
|
74
91
|
await tinymce.init({
|
|
75
92
|
selector: '#editor',
|
|
@@ -81,9 +98,9 @@ await tinymce.init({
|
|
|
81
98
|
});
|
|
82
99
|
```
|
|
83
100
|
|
|
84
|
-
之后用户可以点击 `FormulaX` 工具栏按钮插入公式。已有公式可以通过双击编辑,也可以选中后按 Enter 或 Space 编辑。
|
|
85
|
-
|
|
86
|
-
## 代码中主动打开
|
|
101
|
+
之后用户可以点击 `FormulaX` 工具栏按钮插入公式。已有公式可以通过双击编辑,也可以选中后按 Enter 或 Space 编辑。
|
|
102
|
+
|
|
103
|
+
## 代码中主动打开
|
|
87
104
|
|
|
88
105
|
插件会注册 `FormulaXOpen` 命令:
|
|
89
106
|
|
|
@@ -167,7 +184,7 @@ registerFormulaXTinyMcePlugin(tinymce, {
|
|
|
167
184
|
## 配置项
|
|
168
185
|
|
|
169
186
|
```ts
|
|
170
|
-
interface FormulaXTinyMceOptions {
|
|
187
|
+
interface FormulaXTinyMceOptions {
|
|
171
188
|
pluginName?: string;
|
|
172
189
|
buttonName?: string;
|
|
173
190
|
menuItemName?: string;
|
|
@@ -176,13 +193,13 @@ interface FormulaXTinyMceOptions {
|
|
|
176
193
|
cursorStyle?: string;
|
|
177
194
|
formulaClassName?: string;
|
|
178
195
|
formulaAttributeName?: string;
|
|
179
|
-
renderer?: FormulaRenderer;
|
|
180
|
-
preload?: FormulaXEditorPreloadMode;
|
|
181
|
-
initialLatex?: string;
|
|
182
|
-
modal?: FormulaXModalOptions;
|
|
183
|
-
editor?: FormulaXEditorOptions
|
|
184
|
-
}
|
|
185
|
-
```
|
|
196
|
+
renderer?: FormulaRenderer;
|
|
197
|
+
preload?: FormulaXEditorPreloadMode;
|
|
198
|
+
initialLatex?: string;
|
|
199
|
+
modal?: FormulaXModalOptions;
|
|
200
|
+
editor?: Omit<FormulaXEditorOptions, 'initialLatex'>;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
186
203
|
|
|
187
204
|
| 配置项 | 默认值 | 说明 |
|
|
188
205
|
| --- | --- | --- |
|
|
@@ -204,7 +221,7 @@ interface FormulaXTinyMceOptions {
|
|
|
204
221
|
|
|
205
222
|
| 配置项 | 默认值 | 说明 |
|
|
206
223
|
| --- | --- | --- |
|
|
207
|
-
| `title` | `FormulaX` | 弹窗标题。 |
|
|
224
|
+
| `title` | `FormulaX Editor` | 弹窗标题。 |
|
|
208
225
|
| `insertText` | `Insert` | 插入公式时的提交按钮文本。 |
|
|
209
226
|
| `updateText` | `Update` | 更新公式时的提交按钮文本。 |
|
|
210
227
|
| `cancelText` | `Cancel` | 取消按钮文本。 |
|
|
@@ -216,10 +233,11 @@ interface FormulaXTinyMceOptions {
|
|
|
216
233
|
|
|
217
234
|
| 配置项 | 默认值 | 说明 |
|
|
218
235
|
| --- | --- | --- |
|
|
219
|
-
| `height` | `100%` | 内嵌编辑器高度。 |
|
|
220
|
-
| `autofocus` | `true` | 内嵌编辑器是否自动聚焦。 |
|
|
221
|
-
| `
|
|
222
|
-
| `
|
|
236
|
+
| `height` | `100%` | 内嵌编辑器高度。 |
|
|
237
|
+
| `autofocus` | `true` | 内嵌编辑器是否自动聚焦。 |
|
|
238
|
+
| `locale` | `en_US` | 同时切换弹窗默认文案和内嵌 Kity runtime UI。 |
|
|
239
|
+
| `assets` | `{}` | 可选的 Kity runtime 资源覆盖配置。 |
|
|
240
|
+
| `render.fontsize` | `40` | 公式渲染字号。 |
|
|
223
241
|
|
|
224
242
|
## 导出 API
|
|
225
243
|
|
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
|
+
}
|