@formulaxjs/tiptap 0.3.1 → 0.4.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.
Files changed (48) hide show
  1. package/README.md +39 -33
  2. package/README.zh-CN.md +39 -33
  3. package/dist/base.css +47 -0
  4. package/dist/canvg-runtime-UR3JNX5Q.js +2759 -0
  5. package/dist/canvg-runtime-UR3JNX5Q.js.map +1 -0
  6. package/dist/chunk-OCSSWPUX.js +3407 -0
  7. package/dist/chunk-OCSSWPUX.js.map +1 -0
  8. package/dist/images/scrollbar/custom/bar-bg.png +0 -0
  9. package/dist/images/scrollbar/custom/bar.png +0 -0
  10. package/dist/images/scrollbar/custom/bg.png +0 -0
  11. package/dist/images/scrollbar/custom/bottom.png +0 -0
  12. package/dist/images/scrollbar/custom/btn.png +0 -0
  13. package/dist/images/scrollbar/custom/down.png +0 -0
  14. package/dist/images/scrollbar/custom/top.png +0 -0
  15. package/dist/images/scrollbar/custom/up.png +0 -0
  16. package/dist/images/scrollbar/edit/bar-bg.png +0 -0
  17. package/dist/images/scrollbar/edit/bar-left.png +0 -0
  18. package/dist/images/scrollbar/edit/bar-right.png +0 -0
  19. package/dist/images/scrollbar/edit/thumb-bg.png +0 -0
  20. package/dist/images/scrollbar/edit/thumb-left.png +0 -0
  21. package/dist/images/scrollbar/edit/thumb-right.png +0 -0
  22. package/dist/images/toolbar/btn.png +0 -0
  23. package/dist/index.cjs +24075 -65
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +79 -0
  26. package/dist/index.d.ts +79 -0
  27. package/dist/index.global.js +865 -859
  28. package/dist/index.global.js.map +1 -1
  29. package/dist/index.js +3768 -21
  30. package/dist/index.js.map +1 -1
  31. package/dist/install-XGCSWTLU.js +5464 -0
  32. package/dist/install-XGCSWTLU.js.map +1 -0
  33. package/dist/install-XVTKACEN.js +1349 -0
  34. package/dist/install-XVTKACEN.js.map +1 -0
  35. package/dist/other.png +0 -0
  36. package/dist/scrollbar.css +78 -0
  37. package/dist/start-MBLTNR2Q.js +4926 -0
  38. package/dist/start-MBLTNR2Q.js.map +1 -0
  39. package/dist/ui.css +625 -0
  40. package/package.json +12 -7
  41. /package/dist/{KF_AMS_BB-5QF7FUSO.woff → KF_AMS_BB.woff} +0 -0
  42. /package/dist/{KF_AMS_CAL-NXRNLAZN.woff → KF_AMS_CAL.woff} +0 -0
  43. /package/dist/{KF_AMS_FRAK-CO33WWN4.woff → KF_AMS_FRAK.woff} +0 -0
  44. /package/dist/{KF_AMS_MAIN-25QJVAWY.woff → KF_AMS_MAIN.woff} +0 -0
  45. /package/dist/{KF_AMS_ROMAN-243BR7HH.woff → KF_AMS_ROMAN.woff} +0 -0
  46. /package/dist/{btn-5DANP6JY.png → btn.png} +0 -0
  47. /package/dist/{editor-JT5KLVXX.css → editor.css} +0 -0
  48. /package/dist/{other-OMWJFGL5.png → images/toolbar/other.png} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @formulaxjs/tiptap
2
2
 
3
- English | [简体中文](./README.zh-CN.md)
3
+ English | [简体中文](https://github.com/vndmea/formulaX/blob/main/packages/tiptap/README.zh-CN.md)
4
4
 
5
5
  Tiptap integration adapter for FormulaX.
6
6
 
@@ -57,23 +57,27 @@ import { Editor } from '@tiptap/core';
57
57
  import StarterKit from '@tiptap/starter-kit';
58
58
  import { createFormulaXNode } from '@formulaxjs/tiptap';
59
59
 
60
- const editor = new Editor({
61
- element: document.querySelector('#editor')!,
62
- extensions: [
63
- StarterKit,
64
- createFormulaXNode(),
65
- ],
66
- content: '<p>Click the toolbar button to insert a formula.</p>',
67
- });
68
- ```
69
-
70
- To open the FormulaX modal programmatically:
71
-
72
- ```ts
73
- editor.commands.openFormulaX();
74
- ```
75
-
76
- ## Custom node names
60
+ const editor = new Editor({
61
+ element: document.querySelector('#editor')!,
62
+ extensions: [
63
+ StarterKit,
64
+ createFormulaXNode(undefined, {
65
+ editor: {
66
+ locale: 'zh_CN', // optional, defaults to en_US
67
+ },
68
+ }),
69
+ ],
70
+ content: '<p>Click the toolbar button to insert a formula.</p>',
71
+ });
72
+ ```
73
+
74
+ To open the FormulaX modal programmatically:
75
+
76
+ ```ts
77
+ editor.commands.openFormulaX();
78
+ ```
79
+
80
+ ## Custom node names
77
81
 
78
82
  The default Tiptap node name is `formulaX`.
79
83
 
@@ -116,11 +120,11 @@ The adapter accepts a `renderer` option. By default it uses `createKityFormulaRe
116
120
  import { createFormulaXNode } from '@formulaxjs/tiptap';
117
121
  import { createKityFormulaRenderer } from '@formulaxjs/renderer-kity';
118
122
 
119
- const formulaNode = createFormulaXNode(undefined, {
120
- renderer: createKityFormulaRenderer({
121
- fontSize: 44,
122
- }),
123
- });
123
+ const formulaXNode = createFormulaXNode(undefined, {
124
+ renderer: createKityFormulaRenderer({
125
+ fontSize: 44,
126
+ }),
127
+ });
124
128
  ```
125
129
 
126
130
  ## Options
@@ -141,12 +145,13 @@ interface FormulaXTiptapOptions {
141
145
  cancelText?: string;
142
146
  closeOnBackdrop?: boolean;
143
147
  };
144
- editor?: {
145
- height?: number | string;
146
- autofocus?: boolean;
147
- assets?: Partial<KityEditorAssets>;
148
- render?: {
149
- fontsize?: number;
148
+ editor?: {
149
+ height?: number | string;
150
+ autofocus?: boolean;
151
+ locale?: FormulaXLocale;
152
+ assets?: Partial<KityEditorAssets>;
153
+ render?: {
154
+ fontsize?: number;
150
155
  };
151
156
  };
152
157
  }
@@ -178,10 +183,11 @@ interface FormulaXTiptapOptions {
178
183
 
179
184
  | Option | Default | Description |
180
185
  | --- | --- | --- |
181
- | `height` | `100%` | Embedded editor height. |
182
- | `autofocus` | `true` | Whether the embedded editor should autofocus. |
183
- | `assets` | `{}` | Optional Kity runtime asset overrides. |
184
- | `render.fontsize` | `40` | Formula render font size. |
186
+ | `height` | `100%` | Embedded editor height. |
187
+ | `autofocus` | `true` | Whether the embedded editor should autofocus. |
188
+ | `locale` | `en_US` | Localizes the modal defaults and the embedded Kity runtime UI. |
189
+ | `assets` | `{}` | Optional Kity runtime asset overrides. |
190
+ | `render.fontsize` | `40` | Formula render font size. |
185
191
 
186
192
  ## Exported API
187
193
 
package/README.zh-CN.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @formulaxjs/tiptap
2
2
 
3
- [English](./README.md) | 简体中文
3
+ [English](https://github.com/vndmea/formulaX/blob/main/packages/tiptap/README.md) | 简体中文
4
4
 
5
5
  FormulaX 的 Tiptap 集成适配器。
6
6
 
@@ -57,23 +57,27 @@ import { Editor } from '@tiptap/core';
57
57
  import StarterKit from '@tiptap/starter-kit';
58
58
  import { createFormulaXNode } from '@formulaxjs/tiptap';
59
59
 
60
- const editor = new Editor({
61
- element: document.querySelector('#editor')!,
62
- extensions: [
63
- StarterKit,
64
- createFormulaXNode(),
65
- ],
66
- content: '<p>点击工具栏按钮插入公式。</p>',
67
- });
68
- ```
69
-
70
- 如果要在代码中主动打开 FormulaX 弹窗:
71
-
72
- ```ts
73
- editor.commands.openFormulaX();
74
- ```
75
-
76
- ## 自定义节点名称
60
+ const editor = new Editor({
61
+ element: document.querySelector('#editor')!,
62
+ extensions: [
63
+ StarterKit,
64
+ createFormulaXNode(undefined, {
65
+ editor: {
66
+ locale: 'zh_CN', // 可选,默认 en_US
67
+ },
68
+ }),
69
+ ],
70
+ content: '<p>点击工具栏按钮插入公式。</p>',
71
+ });
72
+ ```
73
+
74
+ 如果要在代码中主动打开 FormulaX 弹窗:
75
+
76
+ ```ts
77
+ editor.commands.openFormulaX();
78
+ ```
79
+
80
+ ## 自定义节点名称
77
81
 
78
82
  默认的 Tiptap 节点名是 `formulaX`。
79
83
 
@@ -116,11 +120,11 @@ Tiptap 节点中只保存 LaTeX 源内容:
116
120
  import { createFormulaXNode } from '@formulaxjs/tiptap';
117
121
  import { createKityFormulaRenderer } from '@formulaxjs/renderer-kity';
118
122
 
119
- const formulaNode = createFormulaXNode(undefined, {
120
- renderer: createKityFormulaRenderer({
121
- fontSize: 44,
122
- }),
123
- });
123
+ const formulaXNode = createFormulaXNode(undefined, {
124
+ renderer: createKityFormulaRenderer({
125
+ fontSize: 44,
126
+ }),
127
+ });
124
128
  ```
125
129
 
126
130
  ## 配置项
@@ -141,12 +145,13 @@ interface FormulaXTiptapOptions {
141
145
  cancelText?: string;
142
146
  closeOnBackdrop?: boolean;
143
147
  };
144
- editor?: {
145
- height?: number | string;
146
- autofocus?: boolean;
147
- assets?: Partial<KityEditorAssets>;
148
- render?: {
149
- fontsize?: number;
148
+ editor?: {
149
+ height?: number | string;
150
+ autofocus?: boolean;
151
+ locale?: FormulaXLocale;
152
+ assets?: Partial<KityEditorAssets>;
153
+ render?: {
154
+ fontsize?: number;
150
155
  };
151
156
  };
152
157
  }
@@ -178,10 +183,11 @@ interface FormulaXTiptapOptions {
178
183
 
179
184
  | 配置项 | 默认值 | 说明 |
180
185
  | --- | --- | --- |
181
- | `height` | `100%` | 内嵌编辑器高度。 |
182
- | `autofocus` | `true` | 内嵌编辑器是否自动聚焦。 |
183
- | `assets` | `{}` | 可选的 Kity runtime 资源覆盖配置。 |
184
- | `render.fontsize` | `40` | 公式渲染字号。 |
186
+ | `height` | `100%` | 内嵌编辑器高度。 |
187
+ | `autofocus` | `true` | 内嵌编辑器是否自动聚焦。 |
188
+ | `locale` | `en_US` | 同时切换弹窗默认文案和内嵌 Kity runtime UI。 |
189
+ | `assets` | `{}` | 可选的 Kity runtime 资源覆盖配置。 |
190
+ | `render.fontsize` | `40` | 公式渲染字号。 |
185
191
 
186
192
  ## 导出 API
187
193
 
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
+ }