@umoteam/editor 7.0.0 → 8.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umoteam/editor",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "type": "module",
5
5
  "description": "Umo Editor is open-source document editor based on Vue3 and Tiptap. Umo Editor provides comprehensive document editing capabilities and AI creation features, supports pagination, supports Markdown syntax, offers basic rich text editing functions, allows for the insertion of various node types in multiple formats, provides a variety of practical tools, and supports setting page styles. It also supports exporting in various formats, printing and print preview, block-level document editing, adding custom extensions, multi-language settings, and a dark theme.",
6
6
  "keywords": [
@@ -27,7 +27,7 @@
27
27
  "url": "https://www.umodoc.com"
28
28
  },
29
29
  "license": "MIT",
30
- "homepage": "https://editor.umodoc.com/en/docs",
30
+ "homepage": "https://www.umodoc.com",
31
31
  "repository": {
32
32
  "type": "git",
33
33
  "url": "https://github.com/umodoc/editor.git"
@@ -38,7 +38,8 @@
38
38
  },
39
39
  "files": [
40
40
  "dist",
41
- "types/index.d.ts"
41
+ "types/index.d.ts",
42
+ "types/src/*"
42
43
  ],
43
44
  "exports": {
44
45
  ".": {
@@ -109,6 +110,7 @@
109
110
  "@tool-belt/type-predicates": "^1.3.0",
110
111
  "@types/svg64": "^1.1.2",
111
112
  "@umoteam/editor-external": "6.1.0",
113
+ "@umoteam/viewer": "^0.1.8",
112
114
  "@vueuse/core": "^11.0.3",
113
115
  "buffer-image-size": "^0.6.4",
114
116
  "dom-to-image-more": "^3.4.3",
@@ -186,6 +188,7 @@
186
188
  "unplugin-vue-components": "^0.27.4",
187
189
  "unplugin-vue-macros": "^2.11.11",
188
190
  "vite": "^4.5.3",
191
+ "vite-plugin-dts": "^4.5.4",
189
192
  "vite-plugin-inspect": "^0.8.7",
190
193
  "vite-plugin-svg-icons": "^2.0.1",
191
194
  "vite-tsconfig-paths": "^5.0.1",
package/types/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import type { Extension } from '@tiptap/core'
1
+ import type { Extension, HTMLContent, JSONContent } from '@tiptap/core'
2
+ import type { FocusPosition } from '@tiptap/core'
3
+ import { Fragment, Node as ProseMirrorNode } from '@tiptap/pm/model'
2
4
  import type { AsyncFunction } from '@tool-belt/type-predicates'
3
5
 
4
- export type SupportedLocale = 'en-US' | 'zh-CN' | 'ru-RU'
6
+ export type SupportedLocale = 'en-US' | 'zh-CN'
7
+ export type LayoutOption = 'web' | 'page'
5
8
  export interface MarginOption {
6
9
  left: number
7
10
  right: number
@@ -18,6 +21,7 @@ export interface WatermarkOption {
18
21
  text?: string
19
22
  }
20
23
  export interface PageOption {
24
+ layouts: LayoutOption[]
21
25
  defaultMargin?: MarginOption
22
26
  defaultOrientation?: string
23
27
  defaultBackground?: string
@@ -64,19 +68,19 @@ export type ToolbarMenu =
64
68
  export interface ToolbarOptions {
65
69
  defaultMode?: 'classic' | 'ribbon'
66
70
  menus?: ToolbarMenu[]
67
- disableMenuItems?: string[]
68
- importWord?: {
69
- enabled?: boolean
70
- maxSize?: number
71
- options?: unknown
72
- useCustomMethod?: boolean
73
- onCustomImportMethod?: (file: File) => Promise<{
74
- id: string
75
- url: string
76
- value: string
77
- messages: { type: string; message: string }
78
- }>
79
- }
71
+ }
72
+
73
+ export interface ImportWordOptions {
74
+ enabled?: boolean
75
+ maxSize?: number
76
+ options?: unknown
77
+ useCustomMethod?: boolean
78
+ onCustomImportMethod?: (file: File) => Promise<{
79
+ id: string
80
+ url: string
81
+ value: string
82
+ messages: { type: string; message: string }
83
+ }>
80
84
  }
81
85
 
82
86
  export interface AutoSaveOptions {
@@ -102,9 +106,7 @@ export interface DocumentOptions {
102
106
  autoSave?: AutoSaveOptions
103
107
  }
104
108
 
105
- export type LocaleLabel =
106
- | string
107
- | { en_US: string; zh_CN: string; ru_RU: string }
109
+ export type LocaleLabel = string | { en_US: string; zh_CN: string }
108
110
 
109
111
  export interface PageSize {
110
112
  label: LocaleLabel
@@ -202,6 +204,29 @@ export interface FileOptions {
202
204
  }[]
203
205
  }
204
206
 
207
+ export type InsterContentType = string | Fragment | ProseMirrorNode
208
+
209
+ export interface SetContentOptions {
210
+ emitUpdate: boolean
211
+ focusPosition: FocusPosition
212
+ focusOptions: { scrollIntoView: boolean }
213
+ }
214
+ export type InsterContentOptions = Omit<SetContentOptions, 'emitUpdate'> & {
215
+ updateSelection: boolean
216
+ }
217
+
218
+ export type SetContentType = InsterContentType | JSONContent | JSONContent[]
219
+
220
+ type OnSaveFunction = (
221
+ content: {
222
+ html: HTMLContent
223
+ json: JSONContent
224
+ text: string
225
+ },
226
+ page: PageOption,
227
+ document: DocumentOptions,
228
+ ) => Promise<unknown>
229
+
205
230
  export interface UmoEditorOptions {
206
231
  editorKey?: string
207
232
  locale?: SupportedLocale
@@ -228,15 +253,17 @@ export interface UmoEditorOptions {
228
253
  cdnUrl?: string
229
254
  shareUrl?: string
230
255
  diagrams?: Record<string, unknown>
256
+ importWord?: ImportWordOptions
231
257
  file?: FileOptions
232
258
  user?: Record<string, unknown>
233
259
  users?: UserItem[]
234
260
  extensions?: Extension[]
261
+ disableExtensions?: string[]
235
262
  translations?: Record<string, unknown>
236
- onSave?: AsyncFunction
263
+ onSave?: OnSaveFunction
237
264
  onFileUpload?: (file: File) => Promise<{ id: string; url: string }>
238
265
  onFileDelete?: CallableFunction
239
266
  }
240
267
 
241
268
  // 组件类型声明
242
- export * from '../dist/umo-editor'
269
+ export * from './src/components'
@@ -0,0 +1,9 @@
1
+ import { UmoEditorOptions } from '../../../types';
2
+ import { default as UmoEditor } from './index.vue';
3
+ import { default as UmoMenuButton } from './menus/button.vue';
4
+ import { default as UmoDialog } from './modal.vue';
5
+ import { default as UmoTooltip } from './tooltip.vue';
6
+ declare const useUmoEditor: {
7
+ install: (app: any, options: UmoEditorOptions) => void;
8
+ };
9
+ export { UmoEditor as default, UmoDialog, UmoEditor, UmoMenuButton, UmoTooltip, useUmoEditor, };