vdc-editor 0.1.13 → 0.1.15

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 CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  # Web Editor and React Native App
3
2
 
4
3
  ## Overview
@@ -11,6 +10,7 @@ This repository contains two main projects:
11
10
  ---
12
11
 
13
12
  ## Table of Contents
13
+
14
14
  - [Web Editor](#web-editor)
15
15
  - [Features](#features)
16
16
  - [Setup and Installation](#setup-and-installation)
@@ -29,6 +29,7 @@ This repository contains two main projects:
29
29
  ## Web Editor
30
30
 
31
31
  ### Features
32
+
32
33
  - **Rich-text editing**: Using Tiptap to provide a highly customizable editing experience.
33
34
  - **Vue.js**: The frontend framework for building reactive user interfaces.
34
35
  - **Customization**: Easily extendable with additional features and plugins from the Tiptap ecosystem.
@@ -36,22 +37,26 @@ This repository contains two main projects:
36
37
  ### Setup and Installation
37
38
 
38
39
  1. **Clone the repository:**
40
+
39
41
  ```bash
40
42
  git clone https://github.com/your-username/your-repo-name.git
41
43
  cd your-repo-name
42
44
  ```
43
45
 
44
46
  2. **Navigate to the web editor folder:**
47
+
45
48
  ```bash
46
49
  cd pakages/web
47
50
  ```
48
51
 
49
52
  3. **Install dependencies:**
53
+
50
54
  ```bash
51
55
  npm install
52
56
  ```
53
57
 
54
58
  4. **Run the development server:**
59
+
55
60
  ```bash
56
61
  npm run dev
57
62
  ```
@@ -59,6 +64,7 @@ This repository contains two main projects:
59
64
  5. **Open the editor in your browser** at `http://localhost:5173/`.
60
65
 
61
66
  ### Usage
67
+
62
68
  To start using the editor, simply open the URL in your browser, and you will see a full-featured text editor. You can edit, format, and style text as you like. More features can be added through Tiptap extensions.
63
69
 
64
70
  ---
@@ -66,6 +72,7 @@ To start using the editor, simply open the URL in your browser, and you will see
66
72
  ## React Native App
67
73
 
68
74
  ### Features
75
+
69
76
  - **WebView**: Displays the Vue-based web editor inside a WebView component.
70
77
  - **Cross-platform**: Available for both iOS and Android through React Native.
71
78
  - **Simple navigation**: Load the web editor seamlessly inside the app.
@@ -73,16 +80,19 @@ To start using the editor, simply open the URL in your browser, and you will see
73
80
  ### Setup and Installation
74
81
 
75
82
  1. **Navigate to the React Native app folder:**
83
+
76
84
  ```bash
77
85
  cd pakages/native
78
86
  ```
79
87
 
80
88
  2. **Install dependencies:**
89
+
81
90
  ```bash
82
91
  npm install
83
92
  ```
84
93
 
85
94
  3. **Link required packages (for React Native < 0.60):**
95
+
86
96
  ```bash
87
97
  react-native link
88
98
  ```
@@ -90,16 +100,19 @@ To start using the editor, simply open the URL in your browser, and you will see
90
100
  4. **Run the app on iOS or Android:**
91
101
 
92
102
  For iOS:
103
+
93
104
  ```bash
94
105
  npx react-native run-ios
95
106
  ```
96
107
 
97
108
  For Android:
109
+
98
110
  ```bash
99
111
  npx react-native run-android
100
112
  ```
101
113
 
102
114
  ### Usage
115
+
103
116
  Once the app is running, it will open the web editor inside a WebView, allowing users to edit text from their mobile devices with a responsive interface.
104
117
 
105
118
  ---
@@ -136,6 +149,7 @@ The `package.json` file includes the following script commands under the `"scrip
136
149
  ### Breakdown:
137
150
 
138
151
  - **`"app": "yarn workspace native-app start"`**
152
+
139
153
  - This command is used to **start the React Native app**.
140
154
  - It specifies that the command should be run within the `native-app` workspace.
141
155
  - `native-app` refers to the folder that contains the React Native code.
@@ -150,6 +164,7 @@ The `package.json` file includes the following script commands under the `"scrip
150
164
  ### How to Use:
151
165
 
152
166
  1. **To run the mobile app (React Native)**:
167
+
153
168
  ```bash
154
169
  yarn app
155
170
  ```
@@ -174,4 +189,5 @@ Contributions are welcome! Please follow the steps below to contribute:
174
189
  ---
175
190
 
176
191
  ## License
192
+
177
193
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './src/index'
2
- import SBSEditor from './src/index'
3
- export default SBSEditor
2
+ import VDCEditor from './src/index'
3
+ export default VDCEditor
@@ -9,6 +9,7 @@ interface Props {
9
9
  title?: string;
10
10
  tooltip?: string;
11
11
  disabled?: boolean;
12
+ hidden?: boolean;
12
13
  shortcutKeys?: string[];
13
14
  customClass?: string;
14
15
  loading?: boolean;
@@ -8,7 +8,17 @@ type SBSEditorOnChange = {
8
8
  /** Output content, can be a string or JSON content */
9
9
  output: string | JSONContent;
10
10
  };
11
- interface EditorProps {
11
+ export interface EditorProps {
12
+ /**
13
+ * super Text Area
14
+ *
15
+ * @default show: false
16
+ * @default default: false
17
+ */
18
+ superTextArea?: {
19
+ view: boolean;
20
+ button: boolean;
21
+ };
12
22
  /**
13
23
  * Editor mode
14
24
  *
@@ -88,6 +98,12 @@ interface EditorProps {
88
98
  */
89
99
  contentClass?: string | string[] | Record<string, any>;
90
100
  }
101
+ export interface EditorEmits {
102
+ (event: 'enter'): void;
103
+ (event: 'change', value: SBSEditorOnChange): void;
104
+ (event: 'update:modelValue', value: EditorProps['modelValue']): void;
105
+ (event: 'changed:selection', value: any): void;
106
+ }
91
107
  declare const _default: import('vue').DefineComponent<globalThis.ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<EditorProps>, {
92
108
  modelValue: string;
93
109
  output: string;
@@ -97,6 +113,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
97
113
  hideToolbar: boolean;
98
114
  disableBubble: boolean;
99
115
  hideBubble: boolean;
116
+ superTextArea: any;
100
117
  removeDefaultWrapper: boolean;
101
118
  maxWidth: undefined;
102
119
  minHeight: undefined;
@@ -120,6 +137,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
120
137
  hideToolbar: boolean;
121
138
  disableBubble: boolean;
122
139
  hideBubble: boolean;
140
+ superTextArea: any;
123
141
  removeDefaultWrapper: boolean;
124
142
  maxWidth: undefined;
125
143
  minHeight: undefined;
@@ -140,6 +158,10 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
140
158
  maxHeight: string | number;
141
159
  maxWidth: string | number;
142
160
  minHeight: string | number;
161
+ superTextArea: {
162
+ view: boolean;
163
+ button: boolean;
164
+ };
143
165
  dark: boolean;
144
166
  dense: boolean;
145
167
  hideToolbar: boolean;
@@ -102,5 +102,6 @@ export declare const icons: {
102
102
  FlipHorizontal: string;
103
103
  LucidePanelLeft: string;
104
104
  LucidePanelRight: string;
105
+ ALargeSmall: string;
105
106
  };
106
107
  export default icons;
@@ -7,61 +7,61 @@ export declare const sameListCalculation: ComputedFn;
7
7
  export declare const sameItemCalculation: ComputedFn;
8
8
  export declare const defaultNodesComputed: NodesComputed;
9
9
  /**
10
- * 分页上下文类
10
+ * Page context class
11
11
  */
12
12
  export declare class SplitContext {
13
13
  #private;
14
14
  attributes: Record<string, any>;
15
15
  schema: Schema;
16
16
  /**
17
- * 获取文档
18
- * @returns 文档
17
+ * Get document
18
+ * @returns Document
19
19
  */
20
20
  getDoc(): Node;
21
21
  /**
22
- * 构造函数
23
- * @param doc 文档
24
- * @param height 分页高度
25
- * @param paragraphDefaultHeight p标签的默认高度
22
+ * Constructor
23
+ * @param doc Document
24
+ * @param height Page height
25
+ * @param paragraphDefaultHeight Default height of p tag
26
26
  */
27
27
  constructor(schema: Schema, doc: Node, height: number, paragraphDefaultHeight: number);
28
28
  getHeight(): number;
29
29
  /**
30
- * 获取默认高度
31
- * @returns 默认高度
30
+ * Get default height
31
+ * @returns Default height
32
32
  */
33
33
  getDefaultHeight(): number;
34
34
  /**
35
- * 判断是否溢出
36
- * @param height 增加的高度
37
- * @returns 是否溢出
35
+ * Check if overflow
36
+ * @param height Height to add
37
+ * @returns Whether overflow
38
38
  */
39
39
  isOverflow(height: number): boolean;
40
40
  /**
41
- * 增加高度
42
- * @param height 增加的高度
41
+ * Add height
42
+ * @param height Height to add
43
43
  */
44
44
  addHeight(height: number): void;
45
45
  /**
46
- * 设置切割点
47
- * @param pos 切割点位置
48
- * @param depth 切割点深度
46
+ * Set split point
47
+ * @param pos Split point position
48
+ * @param depth Split point depth
49
49
  */
50
50
  setBoundary(pos: number, depth: number): void;
51
51
  /**
52
- * 获取切割点
53
- * @returns 切割点
52
+ * Get split point
53
+ * @returns Split point
54
54
  */
55
55
  pageBoundary(): SplitInfo | null;
56
56
  /**
57
- * 解析切割点
58
- * @param pos 切割点位置
59
- * @returns 解析结果
57
+ * Parse split point
58
+ * @param pos Split point position
59
+ * @returns Parse result
60
60
  */
61
61
  splitResolve(pos: number): any;
62
62
  /**
63
- * 获取最后一页
64
- * @returns 最后一页
63
+ * Get last page
64
+ * @returns Last page
65
65
  */
66
66
  lastPage(): Node | null;
67
67
  }
@@ -83,16 +83,16 @@ export declare class PageComputedContext {
83
83
  mergeDefaultDocument(count: number): void;
84
84
  /**
85
85
  * @method mergeDocument
86
- * @description 合并剩余文档 将剩余文档进行分页
87
- * 深度判断:如果剩余页的 第一个子标签是 扩展类型(是主类型的拆分类型) 进行合并的时候 深度为2
88
- * 如果第一个标签不是扩展类型 则深度为1
86
+ * @description Merge remaining document and paginate remaining document
87
+ * Depth determination: If first child tag of remaining page is extension type (split type of main type), depth is 2 when merging
88
+ * If first tag is not extension type, depth is 1
89
89
  */
90
90
  mergeDocument(): void;
91
91
  forceSplit(): Transaction;
92
92
  /**
93
- * @description 分页主要逻辑 修改系统tr split方法 添加默认 extend判断 默认id重新生成
93
+ * @description Main pagination logic - Modifies system tr split method, adds default extend check and regenerates default id
94
94
  * @author Cassie
95
- * @method splitPage 分割页面
95
+ * @method splitPage Split page
96
96
  * @param pos
97
97
  * @param depth
98
98
  * @param typesAfter
@@ -100,13 +100,13 @@ export declare class PageComputedContext {
100
100
  */
101
101
  lift({ pos, depth, typesAfter, schema, force }: SplitParams): void;
102
102
  /**
103
- * desc 检查并修正分页造成的段落分行问题
103
+ * Check and fix paragraph line break issues caused by pagination
104
104
  */
105
105
  checkNodeAndFix(): Transaction;
106
106
  /**
107
- * @description 获取需要分页的点 然后返回
107
+ * @description Get pagination points and return them
108
108
  * @author Cassie
109
- * @method getNodeHeight 获取节点高度
109
+ * @method getNodeHeight Get node height
110
110
  */
111
111
  getNodeHeight(): SplitInfo | null;
112
112
  }
@@ -30,27 +30,27 @@ export declare class UnitConversion {
30
30
  arrDPI: any[];
31
31
  constructor();
32
32
  /**
33
- * @description px to mm
34
- * @param value px值
35
- */
33
+ * @description px to mm
34
+ * @param value px值
35
+ */
36
36
  pxConversionMm(value: number): number;
37
37
  /**
38
- * @description mm to px
39
- * @param value px值
40
- */
38
+ * @description mm to px
39
+ * @param value px值
40
+ */
41
41
  mmConversionPx(value: number): number;
42
42
  cmConversionPx(value: number): number;
43
43
  /**
44
- * Convert px string to number
45
- * @param value String containing px value
46
- * @returns number without px unit
47
- */
44
+ * Convert px string to number
45
+ * @param value String containing px value
46
+ * @returns number without px unit
47
+ */
48
48
  pxToNumber(value: string | number): number;
49
49
  /**
50
- * Convert height CSS value to px number
51
- * @param value CSS height value
52
- * @returns number in pixels
53
- */
50
+ * Convert height CSS value to px number
51
+ * @param value CSS height value
52
+ * @returns number in pixels
53
+ */
54
54
  convertHeightToPx(value: string | number): number;
55
55
  }
56
56
  export declare function getPageOption(restore?: boolean): any;
@@ -16,6 +16,12 @@ declare module '@tiptap/core' {
16
16
  */
17
17
  autoPaging: (status: boolean | undefined) => ReturnType;
18
18
  };
19
+ togglePagePlugin: {
20
+ /**
21
+ * Toggle the page plugin.
22
+ */
23
+ togglePagePlugin: (disable: boolean) => ReturnType;
24
+ };
19
25
  }
20
26
  }
21
27
  declare const _default: Node<PageOptions, any>;
@@ -35,6 +35,7 @@ export declare class PageState {
35
35
  initSplit: boolean;
36
36
  scrollHeight: number;
37
37
  runState: boolean;
38
+ enable: boolean;
38
39
  constructor(deleting: boolean, inserting: boolean, splitPage: boolean, initSplit: boolean, scrollHeight: number, runState?: boolean);
39
40
  transform(tr: Transaction): PageState;
40
41
  }
@@ -1,3 +1,3 @@
1
1
  export { SpellcheckerExtension } from './spellchecker-extension';
2
- export type { IProofreaderInterface, ITextWithPosition, ITransferSpellData, SpellCheckDataType } from './i-proofreader-interface';
2
+ export type { IProofreaderInterface, ITextWithPosition, ITransferSpellData, SpellCheckDataType } from '../../type';
3
3
  export { Proofreader } from './proofreader';
@@ -1,9 +1,10 @@
1
- import { IProofreaderInterface, ITextWithPosition, ITransferSpellData } from './i-proofreader-interface';
1
+ import { IProofreaderInterface, ITextWithPosition, ITransferSpellData } from '../../type';
2
2
  import { AxiosResponse } from 'axios';
3
3
 
4
4
  export declare class Proofreader implements IProofreaderInterface {
5
5
  private suggestions;
6
6
  private api;
7
+ enabled: boolean;
7
8
  limit: number | undefined;
8
9
  transfer?: (data: AxiosResponse<any, any>) => ITransferSpellData[];
9
10
  constructor({ api, limit, transfer, }: {
@@ -16,5 +17,6 @@ export declare class Proofreader implements IProofreaderInterface {
16
17
  getApi(): string;
17
18
  normalizeTextForLanguage(text: string): string;
18
19
  proofreadText(sentence: string): Promise<ITextWithPosition[]>;
20
+ setActiveSpellCheck(): void;
19
21
  }
20
22
  export type ProofreaderType = typeof Proofreader;
@@ -1,5 +1,5 @@
1
1
  import { Extension } from '@tiptap/core';
2
- import { IProofreaderInterface } from './i-proofreader-interface';
2
+ import { IProofreaderInterface } from '../../type';
3
3
  import { default as Spellchecker } from './spellchecker';
4
4
 
5
5
  export declare const SPELLCHECKER_TRANSACTION = "spellchecker-transation";
@@ -21,6 +21,9 @@ declare module '@tiptap/core' {
21
21
  spellchecker: {
22
22
  checkSpelling: () => ReturnType;
23
23
  };
24
+ handleActiveSpellCheck: {
25
+ handleActiveSpellCheck: () => ReturnType;
26
+ };
24
27
  }
25
28
  }
26
29
  export declare const SpellcheckerExtension: Extension<ISpellcheckerOptions, ISpellcheckerStorage>;
@@ -1,7 +1,7 @@
1
1
  import { Node } from 'prosemirror-model';
2
2
  import { Transaction } from 'prosemirror-state';
3
3
  import { DecorationSet, EditorView } from 'prosemirror-view';
4
- import { IProofreaderInterface } from './i-proofreader-interface';
4
+ import { IProofreaderInterface } from '../../type';
5
5
  import { IUiStrings } from './spellchecker-extension';
6
6
 
7
7
  export default class Spellchecker {
@@ -19,6 +19,7 @@ export default class Spellchecker {
19
19
  private lastOriginalFrom;
20
20
  private readonly suggestionBox;
21
21
  constructor(proofreader: IProofreaderInterface, uiStrings?: IUiStrings, showSuggestionsEvent?: (word: string) => void);
22
+ setStatusSpellCheck(): void;
22
23
  setDecorationSet(decorationSet: DecorationSet): void;
23
24
  getDecorationSet(): DecorationSet;
24
25
  setEditorView(editorView: EditorView): void;
@@ -4,6 +4,8 @@ declare module '@tiptap/core' {
4
4
  interface Commands<ReturnType> {
5
5
  superText: {
6
6
  updateSuperText: () => ReturnType;
7
+ toggleSuperText: () => ReturnType;
8
+ showSuperTextButton: (isShow: boolean) => ReturnType;
7
9
  };
8
10
  }
9
11
  }
@@ -1,14 +1,14 @@
1
1
  import { Plugin } from 'vue';
2
- import { default as CoreEditor } from './components/CoreEditor.vue';
3
- import { default as ActionButton } from './components/ActionButton.vue';
2
+ import { default as CoreEditor, EditorProps, EditorEmits } from './components/CoreEditor.vue';
4
3
 
5
4
  declare const SBSEditorPlugin: Plugin;
6
- export * from './extensions';
7
- export * from './hooks';
8
- export * from './utils/node-names';
5
+ export * as extension from './extensions';
6
+ export { useConfigTiptap, useTiptapStore } from './hooks';
7
+ export * as nodeNames from './utils/node-names';
9
8
  export type * from './type';
10
9
  export { useEditor } from '@tiptap/vue-3';
11
10
  export { type Editor as EditorInstance } from '@tiptap/core';
12
11
  export { enUS, koKR } from './locales';
13
- export { SBSEditorPlugin, CoreEditor, ActionButton };
12
+ export { SBSEditorPlugin, CoreEditor };
13
+ export type { EditorProps, EditorEmits, };
14
14
  export default SBSEditorPlugin;
package/lib/src/type.d.ts CHANGED
@@ -92,12 +92,12 @@ export interface ButtonView<T = any> {
92
92
  }
93
93
  /**
94
94
  * The computed function for the page extension a node.
95
- * @param splitContex 分割上下文.
96
- * @param node 当前需要计算的节点.
97
- * @param pos 当前计算节点的位置.
98
- * @param parent 当前计算节点的父节点.
99
- * @param dom 当前计算节点的 dom.
100
- * @returns 如果返回 true 则会会进入当前节点的 子标签计算.
95
+ * @param splitContex Split context.
96
+ * @param node Current node to be computed.
97
+ * @param pos Position of the current computed node.
98
+ * @param parent Parent node of the current computed node.
99
+ * @param dom DOM element of the current computed node.
100
+ * @returns If returns true, it will proceed to compute child tags of the current node.
101
101
  */
102
102
  export type ComputedFn = (splitContex: SplitContext, node: Node, pos: number, parent: Node | null, dom: HTMLElement) => boolean;
103
103
  export type NodesComputed = Record<string, ComputedFn>;
@@ -147,3 +147,25 @@ export interface Config {
147
147
  sidebar: boolean;
148
148
  }
149
149
  export type EditorMode = 'editor' | 'straight' | 'report';
150
+ export interface ITextWithPosition {
151
+ startIndex: number;
152
+ length: number;
153
+ wrongWord: string;
154
+ }
155
+ export interface ITransferSpellData {
156
+ errorText: ITextWithPosition;
157
+ spellData: SpellCheckDataType;
158
+ }
159
+ export type SpellCheckDataType = {
160
+ correctWord: string[];
161
+ startIndex: number;
162
+ endIndex: number;
163
+ wrongWordIndex: number;
164
+ wrongWord: string;
165
+ };
166
+ export interface IProofreaderInterface {
167
+ proofreadText(sentence: string): Promise<ITextWithPosition[]>;
168
+ getSuggestions(word: string): Promise<string[]>;
169
+ normalizeTextForLanguage(text: string): string;
170
+ setActiveSpellCheck(): void;
171
+ }
@@ -0,0 +1,3 @@
1
+ export declare enum EventKey {
2
+ TOGGLE_SUPER_TEXT = "toggle-super-text"
3
+ }