adtec-core-package 3.0.2 → 3.0.4

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": "adtec-core-package",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,9 @@
1
1
  <!-- RichTextEditor:基于预编译 Umo Editor(prebuilt/umo-editor),对外 API 与原 AiEditor 封装保持一致 -->
2
2
  <template>
3
- <div ref="rootRef" class="umo-rich-text-editor-root">
3
+ <div
4
+ ref="rootRef"
5
+ class="umo-rich-text-editor-root"
6
+ :class="{ 'umo-rich-text-editor-root--readonly': !editable }">
4
7
  <UmoEditor
5
8
  v-if="umoMountOptions"
6
9
  :key="umoRuntimeKey"
@@ -36,9 +39,44 @@ export type RichTextEditorConfig = {
36
39
  }
37
40
 
38
41
  /** 始终保留 BlockImage NodeView;只读由 document.readOnly + node-view 静态分支控制 */
39
- const DISABLED_EXTENSIONS = ['mermaid', 'diagrams'] as const
40
-
41
- const OFFICIAL_TOOLBAR_MENUS = ['base', 'insert', 'table', 'tools', 'page', 'view', 'export'] as const
42
+ const DISABLED_EXTENSIONS = [
43
+ 'locale', // 视图 Tab:隐藏语言设置下拉(locale 固定 zh-CN;状态栏指示器另用 CSS 隐藏)
44
+ 'theme', // 视图 Tab:隐藏主题设置(light/dark,theme 固定 light)
45
+ 'mermaid',
46
+ 'diagrams',
47
+ // Block 菜单(+ 插入新内容):仅保留表格与图片
48
+ 'qrcode',
49
+ 'barcode',
50
+ 'signature',
51
+ 'math',
52
+ 'echarts',
53
+ 'print', // 开始 Tab:隐藏打印
54
+ // 插入 Tab:仅保留图片
55
+ 'link',
56
+ 'video',
57
+ 'audio',
58
+ 'file',
59
+ 'text-box',
60
+ 'details',
61
+ 'code-block',
62
+ 'symbol',
63
+ 'chinese-date',
64
+ 'emoji',
65
+ 'tag',
66
+ 'columns',
67
+ 'callout',
68
+ 'mention',
69
+ 'option-box',
70
+ 'hard-break',
71
+ 'hr',
72
+ 'bookmark',
73
+ 'footnote',
74
+ 'toc',
75
+ 'template',
76
+ 'web-page',
77
+ ] as const
78
+
79
+ const OFFICIAL_TOOLBAR_MENUS = ['base', 'insert', 'table', 'page', 'view'] as const
42
80
 
43
81
  const emit = defineEmits<{
44
82
  onBlur: [payload: { html: string; text: string }]
@@ -107,7 +145,10 @@ function handlePanelShown() {
107
145
  }
108
146
  if (!rootWasHidden) return
109
147
  rootWasHidden = false
110
- if (!ready.value) return
148
+ if (!ready.value) {
149
+ void bootstrapEditor()
150
+ return
151
+ }
111
152
  void applyEditableStateWithRetry()
112
153
  if (editable.value) {
113
154
  void ensureBlockImageNodeView()
@@ -208,7 +249,7 @@ function seedUmoLayoutStorage() {
208
249
  localStorage.setItem(`umo-editor:${umoRuntimeKey.value}:layout`, JSON.stringify('web'))
209
250
  localStorage.setItem(
210
251
  `umo-editor:${umoRuntimeKey.value}:toolbar`,
211
- JSON.stringify({ mode: 'ribbon', show: showToolbar }),
252
+ JSON.stringify({ mode: 'classic', show: showToolbar }),
212
253
  )
213
254
  } catch {
214
255
  // ignore quota / private mode
@@ -277,7 +318,8 @@ function buildUmoMountOptions(content: string) {
277
318
  fullscreenZIndex: 2500,
278
319
  toolbar: {
279
320
  showSaveLabel: false,
280
- defaultMode: 'ribbon',
321
+ defaultMode: 'classic',
322
+ // Umo schema 要求 menus 至少含 base;只读时 readOnly=true 会隐藏工具栏 UI
281
323
  menus:
282
324
  props.showToolbar && editableNow
283
325
  ? [...OFFICIAL_TOOLBAR_MENUS]
@@ -364,7 +406,7 @@ async function applyEditableState() {
364
406
  editor.setReadOnly?.(!canEdit)
365
407
  ensureTipTapEditable(canEdit)
366
408
  editor.setToolbar?.({
367
- mode: 'ribbon',
409
+ mode: 'classic',
368
410
  show: props.showToolbar && canEdit,
369
411
  })
370
412
  const tipTap = editor.getEditor?.()?.value
@@ -431,9 +473,12 @@ async function bootstrapEditor() {
431
473
 
432
474
  await nextTick()
433
475
  await waitEditorPaintFrames()
434
- await waitEditorPaintFrames()
435
476
  ready.value = true
436
477
  await nextTick()
478
+ const pendingHtml = model.value ?? ''
479
+ if (pendingHtml && pendingHtml !== getRawHtml()) {
480
+ applyEditorHtml(pendingHtml, false)
481
+ }
437
482
  await applyEditableStateWithRetry()
438
483
  syncEditorPresentation()
439
484
  if (editable.value) {
@@ -544,6 +589,7 @@ defineExpose({
544
589
  applyEditorHtml(html, focus)
545
590
  }
546
591
  },
592
+ isReady: () => ready.value,
547
593
  })
548
594
 
549
595
  onUnmounted(() => {
@@ -640,4 +686,18 @@ onUnmounted(() => {
640
686
  cursor: text;
641
687
  min-height: 120px;
642
688
  }
689
+
690
+ .umo-rich-text-editor-root--readonly {
691
+ :deep(.umo-loading),
692
+ :deep(.umo-loading--visible),
693
+ :deep(.umo-loading__overlay),
694
+ :deep(.umo-loading--center),
695
+ :deep(.umo-icon-loading) {
696
+ display: none !important;
697
+ }
698
+
699
+ :deep(.umo-editor-content .ProseMirror) {
700
+ cursor: default;
701
+ }
702
+ }
643
703
  </style>
@@ -5,6 +5,26 @@ import { umoGlobalComponents } from '../../../prebuilt/umo-editor/umo-editor.js'
5
5
  const registeredApps = new WeakSet<App>()
6
6
  const tdesignApps = new WeakSet<App>()
7
7
 
8
+ /** 嵌入 Umo 的全局样式覆盖(须注入 document.head,全屏 Teleport 到 body 时组件 scoped :deep 无法命中) */
9
+ function injectUmoEmbedStyles() {
10
+ if (typeof document === 'undefined') return
11
+ if (document.getElementById('umo-embed-overrides')) return
12
+
13
+ const style = document.createElement('style')
14
+ style.id = 'umo-embed-overrides'
15
+ style.textContent = `
16
+ svg.umo-icon:not(.t-icon) {
17
+ fill: none;
18
+ }
19
+ .umo-status-bar-button.umo-lang-button {
20
+ display: none !important;
21
+ }
22
+ `
23
+ document.head.appendChild(style)
24
+ }
25
+
26
+ injectUmoEmbedStyles()
27
+
8
28
  /** 预编译 Umo 内部用 resolveComponent,须在宿主 Vue App 上注册 umoGlobalComponents */
9
29
  export function installUmoEditorApp(app?: App | null) {
10
30
  if (!app) return false