@mnykj/alleditor-dual 0.0.0-stage → 1.1.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.
Files changed (282) hide show
  1. package/README.md +72 -3
  2. package/nuxt.ts +60 -0
  3. package/package.json +59 -6
  4. package/scripts/sync-ueditor.mjs +28 -0
  5. package/src/DualEditor.vue +330 -0
  6. package/src/UeHtmlEngine.vue +385 -0
  7. package/src/index.ts +32 -0
  8. package/src/ueToolbar.ts +128 -0
  9. package/src/ueditorBase.ts +2 -0
  10. package/src/ueditorPaths.ts +11 -0
  11. package/ueditor/dialogs/anchor/anchor.html +40 -0
  12. package/ueditor/dialogs/attachment/attachment.css +681 -0
  13. package/ueditor/dialogs/attachment/attachment.html +60 -0
  14. package/ueditor/dialogs/attachment/attachment.js +760 -0
  15. package/ueditor/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
  16. package/ueditor/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
  17. package/ueditor/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
  18. package/ueditor/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
  19. package/ueditor/dialogs/attachment/fileTypeImages/icon_jpg.gif +0 -0
  20. package/ueditor/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
  21. package/ueditor/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
  22. package/ueditor/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
  23. package/ueditor/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
  24. package/ueditor/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
  25. package/ueditor/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
  26. package/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
  27. package/ueditor/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
  28. package/ueditor/dialogs/attachment/images/alignicon.gif +0 -0
  29. package/ueditor/dialogs/attachment/images/alignicon.png +0 -0
  30. package/ueditor/dialogs/attachment/images/bg.png +0 -0
  31. package/ueditor/dialogs/attachment/images/file-icons.gif +0 -0
  32. package/ueditor/dialogs/attachment/images/file-icons.png +0 -0
  33. package/ueditor/dialogs/attachment/images/icons.gif +0 -0
  34. package/ueditor/dialogs/attachment/images/icons.png +0 -0
  35. package/ueditor/dialogs/attachment/images/image.png +0 -0
  36. package/ueditor/dialogs/attachment/images/progress.png +0 -0
  37. package/ueditor/dialogs/attachment/images/success.gif +0 -0
  38. package/ueditor/dialogs/attachment/images/success.png +0 -0
  39. package/ueditor/dialogs/background/background.css +94 -0
  40. package/ueditor/dialogs/background/background.html +56 -0
  41. package/ueditor/dialogs/background/background.js +376 -0
  42. package/ueditor/dialogs/background/images/bg.png +0 -0
  43. package/ueditor/dialogs/background/images/success.png +0 -0
  44. package/ueditor/dialogs/charts/chart.config.js +65 -0
  45. package/ueditor/dialogs/charts/charts.css +165 -0
  46. package/ueditor/dialogs/charts/charts.html +89 -0
  47. package/ueditor/dialogs/charts/charts.js +519 -0
  48. package/ueditor/dialogs/charts/images/charts0.png +0 -0
  49. package/ueditor/dialogs/charts/images/charts1.png +0 -0
  50. package/ueditor/dialogs/charts/images/charts2.png +0 -0
  51. package/ueditor/dialogs/charts/images/charts3.png +0 -0
  52. package/ueditor/dialogs/charts/images/charts4.png +0 -0
  53. package/ueditor/dialogs/charts/images/charts5.png +0 -0
  54. package/ueditor/dialogs/emotion/emotion.css +43 -0
  55. package/ueditor/dialogs/emotion/emotion.html +54 -0
  56. package/ueditor/dialogs/emotion/emotion.js +186 -0
  57. package/ueditor/dialogs/emotion/images/0.gif +0 -0
  58. package/ueditor/dialogs/emotion/images/bface.gif +0 -0
  59. package/ueditor/dialogs/emotion/images/cface.gif +0 -0
  60. package/ueditor/dialogs/emotion/images/fface.gif +0 -0
  61. package/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
  62. package/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  63. package/ueditor/dialogs/emotion/images/tface.gif +0 -0
  64. package/ueditor/dialogs/emotion/images/wface.gif +0 -0
  65. package/ueditor/dialogs/emotion/images/yface.gif +0 -0
  66. package/ueditor/dialogs/gmap/gmap.html +89 -0
  67. package/ueditor/dialogs/help/help.css +7 -0
  68. package/ueditor/dialogs/help/help.html +82 -0
  69. package/ueditor/dialogs/help/help.js +56 -0
  70. package/ueditor/dialogs/image/image.css +894 -0
  71. package/ueditor/dialogs/image/image.html +120 -0
  72. package/ueditor/dialogs/image/image.js +1123 -0
  73. package/ueditor/dialogs/image/images/alignicon.jpg +0 -0
  74. package/ueditor/dialogs/image/images/bg.png +0 -0
  75. package/ueditor/dialogs/image/images/icons.gif +0 -0
  76. package/ueditor/dialogs/image/images/icons.png +0 -0
  77. package/ueditor/dialogs/image/images/image.png +0 -0
  78. package/ueditor/dialogs/image/images/progress.png +0 -0
  79. package/ueditor/dialogs/image/images/success.gif +0 -0
  80. package/ueditor/dialogs/image/images/success.png +0 -0
  81. package/ueditor/dialogs/insertframe/insertframe.html +98 -0
  82. package/ueditor/dialogs/internal.js +81 -0
  83. package/ueditor/dialogs/link/link.html +132 -0
  84. package/ueditor/dialogs/map/map.html +135 -0
  85. package/ueditor/dialogs/map/show.html +118 -0
  86. package/ueditor/dialogs/music/music.css +30 -0
  87. package/ueditor/dialogs/music/music.html +32 -0
  88. package/ueditor/dialogs/music/music.js +192 -0
  89. package/ueditor/dialogs/preview/preview.html +40 -0
  90. package/ueditor/dialogs/scrawl/images/addimg.png +0 -0
  91. package/ueditor/dialogs/scrawl/images/brush.png +0 -0
  92. package/ueditor/dialogs/scrawl/images/delimg.png +0 -0
  93. package/ueditor/dialogs/scrawl/images/delimgH.png +0 -0
  94. package/ueditor/dialogs/scrawl/images/empty.png +0 -0
  95. package/ueditor/dialogs/scrawl/images/emptyH.png +0 -0
  96. package/ueditor/dialogs/scrawl/images/eraser.png +0 -0
  97. package/ueditor/dialogs/scrawl/images/redo.png +0 -0
  98. package/ueditor/dialogs/scrawl/images/redoH.png +0 -0
  99. package/ueditor/dialogs/scrawl/images/scale.png +0 -0
  100. package/ueditor/dialogs/scrawl/images/scaleH.png +0 -0
  101. package/ueditor/dialogs/scrawl/images/size.png +0 -0
  102. package/ueditor/dialogs/scrawl/images/undo.png +0 -0
  103. package/ueditor/dialogs/scrawl/images/undoH.png +0 -0
  104. package/ueditor/dialogs/scrawl/scrawl.css +72 -0
  105. package/ueditor/dialogs/scrawl/scrawl.html +95 -0
  106. package/ueditor/dialogs/scrawl/scrawl.js +670 -0
  107. package/ueditor/dialogs/searchreplace/searchreplace.html +102 -0
  108. package/ueditor/dialogs/searchreplace/searchreplace.js +170 -0
  109. package/ueditor/dialogs/snapscreen/snapscreen.html +58 -0
  110. package/ueditor/dialogs/spechars/spechars.html +21 -0
  111. package/ueditor/dialogs/spechars/spechars.js +57 -0
  112. package/ueditor/dialogs/table/dragicon.png +0 -0
  113. package/ueditor/dialogs/table/edittable.css +84 -0
  114. package/ueditor/dialogs/table/edittable.html +64 -0
  115. package/ueditor/dialogs/table/edittable.js +237 -0
  116. package/ueditor/dialogs/table/edittd.html +61 -0
  117. package/ueditor/dialogs/table/edittip.html +33 -0
  118. package/ueditor/dialogs/template/config.js +42 -0
  119. package/ueditor/dialogs/template/images/bg.gif +0 -0
  120. package/ueditor/dialogs/template/images/pre0.png +0 -0
  121. package/ueditor/dialogs/template/images/pre1.png +0 -0
  122. package/ueditor/dialogs/template/images/pre2.png +0 -0
  123. package/ueditor/dialogs/template/images/pre3.png +0 -0
  124. package/ueditor/dialogs/template/images/pre4.png +0 -0
  125. package/ueditor/dialogs/template/template.css +18 -0
  126. package/ueditor/dialogs/template/template.html +26 -0
  127. package/ueditor/dialogs/template/template.js +53 -0
  128. package/ueditor/dialogs/video/images/bg.png +0 -0
  129. package/ueditor/dialogs/video/images/center_focus.jpg +0 -0
  130. package/ueditor/dialogs/video/images/file-icons.gif +0 -0
  131. package/ueditor/dialogs/video/images/file-icons.png +0 -0
  132. package/ueditor/dialogs/video/images/icons.gif +0 -0
  133. package/ueditor/dialogs/video/images/icons.png +0 -0
  134. package/ueditor/dialogs/video/images/image.png +0 -0
  135. package/ueditor/dialogs/video/images/left_focus.jpg +0 -0
  136. package/ueditor/dialogs/video/images/none_focus.jpg +0 -0
  137. package/ueditor/dialogs/video/images/progress.png +0 -0
  138. package/ueditor/dialogs/video/images/right_focus.jpg +0 -0
  139. package/ueditor/dialogs/video/images/success.gif +0 -0
  140. package/ueditor/dialogs/video/images/success.png +0 -0
  141. package/ueditor/dialogs/video/video.css +635 -0
  142. package/ueditor/dialogs/video/video.html +86 -0
  143. package/ueditor/dialogs/video/video.js +791 -0
  144. package/ueditor/dialogs/webapp/webapp.html +53 -0
  145. package/ueditor/dialogs/wordimage/fClipboard_ueditor.swf +0 -0
  146. package/ueditor/dialogs/wordimage/imageUploader.swf +0 -0
  147. package/ueditor/dialogs/wordimage/tangram.js +1495 -0
  148. package/ueditor/dialogs/wordimage/wordimage.html +111 -0
  149. package/ueditor/dialogs/wordimage/wordimage.js +157 -0
  150. package/ueditor/index.html +175 -0
  151. package/ueditor/lang/en/en.js +684 -0
  152. package/ueditor/lang/en/images/addimage.png +0 -0
  153. package/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
  154. package/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
  155. package/ueditor/lang/en/images/background.png +0 -0
  156. package/ueditor/lang/en/images/button.png +0 -0
  157. package/ueditor/lang/en/images/copy.png +0 -0
  158. package/ueditor/lang/en/images/deletedisable.png +0 -0
  159. package/ueditor/lang/en/images/deleteenable.png +0 -0
  160. package/ueditor/lang/en/images/listbackground.png +0 -0
  161. package/ueditor/lang/en/images/localimage.png +0 -0
  162. package/ueditor/lang/en/images/music.png +0 -0
  163. package/ueditor/lang/en/images/rotateleftdisable.png +0 -0
  164. package/ueditor/lang/en/images/rotateleftenable.png +0 -0
  165. package/ueditor/lang/en/images/rotaterightdisable.png +0 -0
  166. package/ueditor/lang/en/images/rotaterightenable.png +0 -0
  167. package/ueditor/lang/en/images/upload.png +0 -0
  168. package/ueditor/lang/zh-cn/images/copy.png +0 -0
  169. package/ueditor/lang/zh-cn/images/localimage.png +0 -0
  170. package/ueditor/lang/zh-cn/images/music.png +0 -0
  171. package/ueditor/lang/zh-cn/images/upload.png +0 -0
  172. package/ueditor/lang/zh-cn/zh-cn.js +669 -0
  173. package/ueditor/themes/default/css/ueditor.css +1906 -0
  174. package/ueditor/themes/default/css/ueditor.min.css +8 -0
  175. package/ueditor/themes/default/dialogbase.css +100 -0
  176. package/ueditor/themes/default/images/anchor.gif +0 -0
  177. package/ueditor/themes/default/images/arrow.png +0 -0
  178. package/ueditor/themes/default/images/arrow_down.png +0 -0
  179. package/ueditor/themes/default/images/arrow_up.png +0 -0
  180. package/ueditor/themes/default/images/button-bg.gif +0 -0
  181. package/ueditor/themes/default/images/cancelbutton.gif +0 -0
  182. package/ueditor/themes/default/images/charts.png +0 -0
  183. package/ueditor/themes/default/images/cursor_h.gif +0 -0
  184. package/ueditor/themes/default/images/cursor_h.png +0 -0
  185. package/ueditor/themes/default/images/cursor_v.gif +0 -0
  186. package/ueditor/themes/default/images/cursor_v.png +0 -0
  187. package/ueditor/themes/default/images/dialog-title-bg.png +0 -0
  188. package/ueditor/themes/default/images/filescan.png +0 -0
  189. package/ueditor/themes/default/images/highlighted.gif +0 -0
  190. package/ueditor/themes/default/images/icons-all.gif +0 -0
  191. package/ueditor/themes/default/images/icons.gif +0 -0
  192. package/ueditor/themes/default/images/icons.png +0 -0
  193. package/ueditor/themes/default/images/img-cracked.png +0 -0
  194. package/ueditor/themes/default/images/loaderror.png +0 -0
  195. package/ueditor/themes/default/images/loading.gif +0 -0
  196. package/ueditor/themes/default/images/lock.gif +0 -0
  197. package/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
  198. package/ueditor/themes/default/images/pagebreak.gif +0 -0
  199. package/ueditor/themes/default/images/scale.png +0 -0
  200. package/ueditor/themes/default/images/sortable.png +0 -0
  201. package/ueditor/themes/default/images/spacer.gif +0 -0
  202. package/ueditor/themes/default/images/sparator_v.png +0 -0
  203. package/ueditor/themes/default/images/table-cell-align.png +0 -0
  204. package/ueditor/themes/default/images/tangram-colorpicker.png +0 -0
  205. package/ueditor/themes/default/images/toolbar_bg.png +0 -0
  206. package/ueditor/themes/default/images/unhighlighted.gif +0 -0
  207. package/ueditor/themes/default/images/upload.png +0 -0
  208. package/ueditor/themes/default/images/videologo.gif +0 -0
  209. package/ueditor/themes/default/images/word.gif +0 -0
  210. package/ueditor/themes/default/images/wordpaste.png +0 -0
  211. package/ueditor/themes/iframe.css +1 -0
  212. package/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
  213. package/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
  214. package/ueditor/third-party/codemirror/codemirror.css +104 -0
  215. package/ueditor/third-party/codemirror/codemirror.js +3581 -0
  216. package/ueditor/third-party/highcharts/adapters/mootools-adapter.js +13 -0
  217. package/ueditor/third-party/highcharts/adapters/mootools-adapter.src.js +313 -0
  218. package/ueditor/third-party/highcharts/adapters/prototype-adapter.js +15 -0
  219. package/ueditor/third-party/highcharts/adapters/prototype-adapter.src.js +316 -0
  220. package/ueditor/third-party/highcharts/adapters/standalone-framework.js +17 -0
  221. package/ueditor/third-party/highcharts/adapters/standalone-framework.src.js +583 -0
  222. package/ueditor/third-party/highcharts/highcharts-more.js +50 -0
  223. package/ueditor/third-party/highcharts/highcharts-more.src.js +2430 -0
  224. package/ueditor/third-party/highcharts/highcharts.js +283 -0
  225. package/ueditor/third-party/highcharts/highcharts.src.js +16974 -0
  226. package/ueditor/third-party/highcharts/modules/annotations.js +7 -0
  227. package/ueditor/third-party/highcharts/modules/annotations.src.js +401 -0
  228. package/ueditor/third-party/highcharts/modules/canvas-tools.js +133 -0
  229. package/ueditor/third-party/highcharts/modules/canvas-tools.src.js +3113 -0
  230. package/ueditor/third-party/highcharts/modules/data.js +17 -0
  231. package/ueditor/third-party/highcharts/modules/data.src.js +582 -0
  232. package/ueditor/third-party/highcharts/modules/drilldown.js +11 -0
  233. package/ueditor/third-party/highcharts/modules/drilldown.src.js +447 -0
  234. package/ueditor/third-party/highcharts/modules/exporting.js +22 -0
  235. package/ueditor/third-party/highcharts/modules/exporting.src.js +709 -0
  236. package/ueditor/third-party/highcharts/modules/funnel.js +12 -0
  237. package/ueditor/third-party/highcharts/modules/funnel.src.js +289 -0
  238. package/ueditor/third-party/highcharts/modules/heatmap.js +1 -0
  239. package/ueditor/third-party/highcharts/modules/heatmap.src.js +53 -0
  240. package/ueditor/third-party/highcharts/modules/map.js +27 -0
  241. package/ueditor/third-party/highcharts/modules/map.src.js +1002 -0
  242. package/ueditor/third-party/highcharts/modules/no-data-to-display.js +12 -0
  243. package/ueditor/third-party/highcharts/modules/no-data-to-display.src.js +128 -0
  244. package/ueditor/third-party/highcharts/themes/dark-blue.js +254 -0
  245. package/ueditor/third-party/highcharts/themes/dark-green.js +255 -0
  246. package/ueditor/third-party/highcharts/themes/gray.js +257 -0
  247. package/ueditor/third-party/highcharts/themes/grid.js +103 -0
  248. package/ueditor/third-party/highcharts/themes/skies.js +89 -0
  249. package/ueditor/third-party/jquery-1.10.2.js +9789 -0
  250. package/ueditor/third-party/jquery-1.10.2.min.js +6 -0
  251. package/ueditor/third-party/jquery-1.10.2.min.map +1 -0
  252. package/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
  253. package/ueditor/third-party/video-js/font/vjs.eot +0 -0
  254. package/ueditor/third-party/video-js/font/vjs.svg +65 -0
  255. package/ueditor/third-party/video-js/font/vjs.ttf +0 -0
  256. package/ueditor/third-party/video-js/font/vjs.woff +0 -0
  257. package/ueditor/third-party/video-js/video-js.css +766 -0
  258. package/ueditor/third-party/video-js/video-js.min.css +5 -0
  259. package/ueditor/third-party/video-js/video-js.swf +0 -0
  260. package/ueditor/third-party/video-js/video.dev.js +7108 -0
  261. package/ueditor/third-party/video-js/video.js +129 -0
  262. package/ueditor/third-party/webuploader/Uploader.swf +0 -0
  263. package/ueditor/third-party/webuploader/webuploader.css +28 -0
  264. package/ueditor/third-party/webuploader/webuploader.custom.js +5670 -0
  265. package/ueditor/third-party/webuploader/webuploader.custom.min.js +2 -0
  266. package/ueditor/third-party/webuploader/webuploader.flashonly.js +4176 -0
  267. package/ueditor/third-party/webuploader/webuploader.flashonly.min.js +2 -0
  268. package/ueditor/third-party/webuploader/webuploader.html5only.js +5559 -0
  269. package/ueditor/third-party/webuploader/webuploader.html5only.min.js +2 -0
  270. package/ueditor/third-party/webuploader/webuploader.js +6733 -0
  271. package/ueditor/third-party/webuploader/webuploader.min.js +2 -0
  272. package/ueditor/third-party/webuploader/webuploader.withoutimage.js +4593 -0
  273. package/ueditor/third-party/webuploader/webuploader.withoutimage.min.js +2 -0
  274. package/ueditor/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
  275. package/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js +9 -0
  276. package/ueditor/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
  277. package/ueditor/ueditor.all.js +32931 -0
  278. package/ueditor/ueditor.all.min.js +17 -0
  279. package/ueditor/ueditor.config.js +507 -0
  280. package/ueditor/ueditor.parse.js +1230 -0
  281. package/ueditor/ueditor.parse.min.js +5 -0
  282. package/vite.ts +81 -0
@@ -0,0 +1,385 @@
1
+ <script setup>
2
+ /**
3
+ * AllEditor UE HTML 引擎(隐藏原生工具栏,编辑区保真)。
4
+ * 默认从 /ueditor/ 加载;资源已打进本包,用 @mnykj/alleditor-dual/nuxt 或 /vite 插件挂载即可。
5
+ *
6
+ * 注意:
7
+ * 1) UEditor 会在 ready 前触发空的 contentChange,必须入队、ready 后再灌入。
8
+ * 2) 不要用 height:100%!important 覆盖 iframeholder。
9
+ */
10
+ import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
11
+
12
+ const props = defineProps({
13
+ modelValue: { type: String, default: '' },
14
+ disabled: { type: Boolean, default: false },
15
+ /** 默认 /ueditor/(包内资源经 nuxt 模块 / vite 插件挂出);可改为自建 CDN */
16
+ ueditorBase: { type: String, default: '/ueditor/' },
17
+ editorId: {
18
+ type: String,
19
+ default: () => `alleditor-ue-${Math.random().toString(36).slice(2, 9)}`,
20
+ },
21
+ })
22
+
23
+ const emit = defineEmits(['update:modelValue', 'created', 'ready', 'change'])
24
+
25
+ const hostRef = ref(null)
26
+ const instance = ref(null)
27
+ let applying = false
28
+ let destroyed = false
29
+ let ready = false
30
+ let pendingHtml = undefined
31
+ /** @type {ResizeObserver | null} */
32
+ let resizeObserver = null
33
+
34
+ function normalizeBase(base) {
35
+ const s = String(base || '/ueditor/').trim() || '/ueditor/'
36
+ return s.endsWith('/') ? s : `${s}/`
37
+ }
38
+
39
+ function loadScript(src) {
40
+ return new Promise((resolve, reject) => {
41
+ const existed = document.querySelector(`script[src="${src}"]`)
42
+ if (existed) {
43
+ if (
44
+ existed.dataset.loaded === '1' ||
45
+ (src.includes('ueditor.all') && window.UE)
46
+ ) {
47
+ existed.dataset.loaded = '1'
48
+ resolve()
49
+ return
50
+ }
51
+ existed.addEventListener(
52
+ 'load',
53
+ () => {
54
+ existed.dataset.loaded = '1'
55
+ resolve()
56
+ },
57
+ { once: true }
58
+ )
59
+ existed.addEventListener('error', () => reject(new Error(`load failed: ${src}`)), {
60
+ once: true,
61
+ })
62
+ return
63
+ }
64
+ const el = document.createElement('script')
65
+ el.src = src
66
+ el.async = false
67
+ el.onload = () => {
68
+ el.dataset.loaded = '1'
69
+ resolve()
70
+ }
71
+ el.onerror = () => reject(new Error(`load failed: ${src}`))
72
+ document.head.appendChild(el)
73
+ })
74
+ }
75
+
76
+ async function ensureUEditor() {
77
+ if (typeof window === 'undefined') return null
78
+ const base = normalizeBase(props.ueditorBase)
79
+ window.UEDITOR_HOME_URL = base
80
+ if (!window.UE) {
81
+ await loadScript(`${base}ueditor.config.js`)
82
+ await loadScript(`${base}ueditor.all.min.js`)
83
+ }
84
+ return window.UE
85
+ }
86
+
87
+ function syncDisabled() {
88
+ const ue = instance.value
89
+ if (!ue || !ready) return
90
+ try {
91
+ if (props.disabled) ue.setDisabled?.('fullscreen')
92
+ else ue.setEnabled?.()
93
+ } catch {
94
+ /* ignore */
95
+ }
96
+ }
97
+
98
+ function getContent() {
99
+ const ue = instance.value
100
+ if (!ue || !ready) {
101
+ if (pendingHtml !== undefined) return pendingHtml
102
+ return props.modelValue || ''
103
+ }
104
+ try {
105
+ return ue.getContent() || ''
106
+ } catch {
107
+ return props.modelValue || ''
108
+ }
109
+ }
110
+
111
+ function setContent(html) {
112
+ const next = html || ''
113
+ const ue = instance.value
114
+ if (!ue || !ready) {
115
+ pendingHtml = next
116
+ return
117
+ }
118
+ applying = true
119
+ try {
120
+ ue.setContent(next)
121
+ } finally {
122
+ applying = false
123
+ }
124
+ requestAnimationFrame(() => fitEditorHeight(ue))
125
+ }
126
+
127
+ function execCommand(cmd, ...args) {
128
+ const ue = instance.value
129
+ if (!ue || !ready || props.disabled) return false
130
+ try {
131
+ ue.execCommand(cmd, ...args)
132
+ return true
133
+ } catch (err) {
134
+ console.warn('[AllEditor UeHtmlEngine] execCommand', cmd, err)
135
+ return false
136
+ }
137
+ }
138
+
139
+ function queryCommandState(cmd) {
140
+ const ue = instance.value
141
+ if (!ue || !ready) return -1
142
+ try {
143
+ return ue.queryCommandState(cmd)
144
+ } catch {
145
+ return -1
146
+ }
147
+ }
148
+
149
+ function fitEditorHeight(ue) {
150
+ const host = hostRef.value
151
+ if (!ue || !host) return
152
+ const h = Math.max(Math.floor(host.clientHeight || 0), 320)
153
+ try {
154
+ ue.setHeight?.(h)
155
+ } catch {
156
+ /* ignore */
157
+ }
158
+ try {
159
+ const holder = host.querySelector('.edui-editor-iframeholder')
160
+ const iframe = host.querySelector('iframe')
161
+ if (holder instanceof HTMLElement) {
162
+ holder.style.height = `${h}px`
163
+ holder.style.minHeight = `${h}px`
164
+ }
165
+ if (iframe instanceof HTMLElement) {
166
+ iframe.style.height = `${h}px`
167
+ iframe.setAttribute('height', String(h))
168
+ }
169
+ const editorRoot = host.querySelector('.edui-editor')
170
+ if (editorRoot instanceof HTMLElement) {
171
+ editorRoot.style.height = `${h}px`
172
+ }
173
+ } catch {
174
+ /* ignore */
175
+ }
176
+ }
177
+
178
+ function bindResize(ue) {
179
+ unbindResize()
180
+ const host = hostRef.value
181
+ if (!host || typeof ResizeObserver === 'undefined') return
182
+ resizeObserver = new ResizeObserver(() => {
183
+ if (destroyed || !ready) return
184
+ fitEditorHeight(ue)
185
+ })
186
+ resizeObserver.observe(host)
187
+ }
188
+
189
+ function unbindResize() {
190
+ if (resizeObserver) {
191
+ try {
192
+ resizeObserver.disconnect()
193
+ } catch {
194
+ /* ignore */
195
+ }
196
+ resizeObserver = null
197
+ }
198
+ }
199
+
200
+ function injectReadableBodyStyle(ue) {
201
+ try {
202
+ const doc = ue?.document
203
+ if (!doc?.head) return
204
+ if (doc.getElementById('alleditor-ue-readable')) return
205
+ const style = doc.createElement('style')
206
+ style.id = 'alleditor-ue-readable'
207
+ style.textContent = [
208
+ 'html,body{height:auto!important;min-height:100%;}',
209
+ 'body{color:#333;background:#fff;margin:12px 16px;font-size:15px;line-height:1.75;}',
210
+ 'body.view{overflow-y:auto!important;}',
211
+ 'img{max-width:100%;height:auto;}',
212
+ ].join('')
213
+ doc.head.appendChild(style)
214
+ } catch {
215
+ /* ignore */
216
+ }
217
+ }
218
+
219
+ function destroyEditor() {
220
+ unbindResize()
221
+ const UE = typeof window !== 'undefined' ? window.UE : null
222
+ const id = props.editorId
223
+ if (UE && id) {
224
+ try {
225
+ UE.delEditor?.(id)
226
+ } catch {
227
+ /* ignore */
228
+ }
229
+ }
230
+ instance.value = null
231
+ ready = false
232
+ pendingHtml = undefined
233
+ if (hostRef.value) hostRef.value.innerHTML = ''
234
+ }
235
+
236
+ onMounted(async () => {
237
+ destroyed = false
238
+ pendingHtml = props.modelValue || ''
239
+ try {
240
+ const UE = await ensureUEditor()
241
+ if (!UE || destroyed || !hostRef.value) return
242
+
243
+ const holder = document.createElement('div')
244
+ holder.id = props.editorId
245
+ hostRef.value.innerHTML = ''
246
+ hostRef.value.appendChild(holder)
247
+
248
+ const height = Math.max(Math.floor(hostRef.value.clientHeight || 0), 480)
249
+ const ue = UE.getEditor(props.editorId, {
250
+ toolbars: [[]],
251
+ initialFrameHeight: height,
252
+ initialFrameWidth: '100%',
253
+ autoHeightEnabled: false,
254
+ serverUrl: '',
255
+ enableAutoSave: false,
256
+ elementPathEnabled: false,
257
+ wordCount: false,
258
+ enableContextMenu: true,
259
+ retainOnlyLabelPasted: false,
260
+ pasteplain: false,
261
+ })
262
+
263
+ instance.value = ue
264
+ emit('created', ue)
265
+
266
+ ue.addListener('contentChange', () => {
267
+ if (applying || destroyed || !ready) return
268
+ const html = getContent()
269
+ emit('update:modelValue', html)
270
+ emit('change', html)
271
+ })
272
+
273
+ ue.ready(() => {
274
+ if (destroyed) return
275
+ ready = true
276
+ const initial =
277
+ pendingHtml !== undefined ? pendingHtml : props.modelValue || ''
278
+ pendingHtml = undefined
279
+ applying = true
280
+ try {
281
+ ue.setContent(initial)
282
+ } finally {
283
+ applying = false
284
+ }
285
+ injectReadableBodyStyle(ue)
286
+ fitEditorHeight(ue)
287
+ bindResize(ue)
288
+ requestAnimationFrame(() => fitEditorHeight(ue))
289
+ setTimeout(() => fitEditorHeight(ue), 50)
290
+ setTimeout(() => fitEditorHeight(ue), 200)
291
+ syncDisabled()
292
+ emit('ready', ue)
293
+ })
294
+ } catch (err) {
295
+ console.error('[AllEditor UeHtmlEngine]', err)
296
+ }
297
+ })
298
+
299
+ watch(
300
+ () => props.modelValue,
301
+ (html) => {
302
+ if (destroyed) return
303
+ const next = html || ''
304
+ if (!ready || applying) {
305
+ pendingHtml = next
306
+ return
307
+ }
308
+ try {
309
+ if (getContent() === next) return
310
+ setContent(next)
311
+ } catch {
312
+ /* ignore */
313
+ }
314
+ }
315
+ )
316
+
317
+ watch(
318
+ () => props.disabled,
319
+ () => syncDisabled()
320
+ )
321
+
322
+ onBeforeUnmount(() => {
323
+ destroyed = true
324
+ destroyEditor()
325
+ })
326
+
327
+ defineExpose({
328
+ getContent,
329
+ setContent,
330
+ execCommand,
331
+ queryCommandState,
332
+ getEditor: () => instance.value,
333
+ isReady: () => ready,
334
+ })
335
+ </script>
336
+
337
+ <template>
338
+ <div ref="hostRef" class="alleditor-ue-engine" />
339
+ </template>
340
+
341
+ <style scoped>
342
+ .alleditor-ue-engine {
343
+ width: 100%;
344
+ height: 100%;
345
+ min-height: 0;
346
+ flex: 1 1 0;
347
+ display: block;
348
+ position: relative;
349
+ overflow: hidden;
350
+ background: #fff;
351
+ }
352
+
353
+ .alleditor-ue-engine :deep(.edui-editor-toolbarbox),
354
+ .alleditor-ue-engine :deep(.edui-editor-toolbarboxouter),
355
+ .alleditor-ue-engine :deep(.edui-editor-toolbarboxinner),
356
+ .alleditor-ue-engine :deep(.edui-editor-bottomContainer),
357
+ .alleditor-ue-engine :deep(.edui-editor-messageholder) {
358
+ display: none !important;
359
+ height: 0 !important;
360
+ overflow: hidden !important;
361
+ border: none !important;
362
+ padding: 0 !important;
363
+ margin: 0 !important;
364
+ }
365
+
366
+ .alleditor-ue-engine :deep(.edui-default),
367
+ .alleditor-ue-engine :deep(.edui-editor) {
368
+ width: 100% !important;
369
+ border: none !important;
370
+ box-shadow: none !important;
371
+ background: #fff !important;
372
+ }
373
+
374
+ .alleditor-ue-engine :deep(.edui-editor-iframeholder) {
375
+ width: 100% !important;
376
+ border: none !important;
377
+ }
378
+
379
+ .alleditor-ue-engine :deep(.edui-editor-iframeholder iframe) {
380
+ width: 100% !important;
381
+ display: block !important;
382
+ border: none !important;
383
+ background: #fff !important;
384
+ }
385
+ </style>
package/src/index.ts ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @mnykj/alleditor-dual
3
+ * 双引擎(wang + UE HTML)Vue 组件与工具栏适配。
4
+ * HTML 标记协议见 @mnykj/alleditor 的 engine-marker。
5
+ */
6
+
7
+ export { default as UeHtmlEngine } from './UeHtmlEngine.vue'
8
+ export { default as DualEditor } from './DualEditor.vue'
9
+
10
+ export {
11
+ WANG_MENU_TO_UE,
12
+ routeWangMenuKeyToUe,
13
+ bindUeToolbarAdapter,
14
+ } from './ueToolbar'
15
+ export type { UeCommandRunner, BindUeToolbarOptions, UeToolbarBinding } from './ueToolbar'
16
+
17
+ export { DEFAULT_UEDITOR_PUBLIC_BASE } from './ueditorBase'
18
+
19
+ // 协议工具从核心包再导出,方便只装 dual 的调用方
20
+ export type { AllEditorEngine } from '@mnykj/alleditor'
21
+ export {
22
+ ALLEDITOR_ENGINE_ATTR,
23
+ ALLEDITOR_ENGINE_CLASS,
24
+ isHeavyFidelityHtml,
25
+ stripLegacyEngineComments,
26
+ parseEditorEngineRoot,
27
+ unwrapEditorEngineHtml,
28
+ detectEditorEngine,
29
+ wrapEditorEngineHtml,
30
+ ensureEditorEngineHtml,
31
+ migrateLegacyEngineMarkers,
32
+ } from '@mnykj/alleditor'
@@ -0,0 +1,128 @@
1
+ /**
2
+ * 将 wang 工具栏菜单转发到 UE HTML 引擎。
3
+ * 宿主可传入 toolbar 根节点选择器,以及 UE 实例上的 execCommand。
4
+ */
5
+
6
+ export type UeCommandRunner = {
7
+ execCommand?: (cmd: string, ...args: any[]) => any
8
+ }
9
+
10
+ export const WANG_MENU_TO_UE: Record<string, string> = {
11
+ bold: 'bold',
12
+ italic: 'italic',
13
+ underline: 'underline',
14
+ through: 'strikethrough',
15
+ code: 'code',
16
+ sub: 'subscript',
17
+ sup: 'superscript',
18
+ undo: 'undo',
19
+ redo: 'redo',
20
+ bulletedList: 'insertunorderedlist',
21
+ numberedList: 'insertorderedlist',
22
+ justifyLeft: 'justifyleft',
23
+ justifyCenter: 'justifycenter',
24
+ justifyRight: 'justifyright',
25
+ justifyJustify: 'justifyjustify',
26
+ indent: 'indent',
27
+ delIndent: 'outdent',
28
+ clearAllFormat: 'removeformat',
29
+ dividerAtCursor: 'horizontal',
30
+ emotion: 'emotion',
31
+ insertTable: 'inserttable',
32
+ blockquoteMerged: 'blockquote',
33
+ }
34
+
35
+ /** 自定义菜单仍走 wang Boot / 宿主回调,不转发 UE */
36
+ const PASSTHROUGH_KEYS = new Set(['sourceCode', 'importMarkdown'])
37
+
38
+ export function routeWangMenuKeyToUe(key: string, ue: UeCommandRunner | null | undefined) {
39
+ if (!key || !ue?.execCommand) return
40
+ if (key === 'insertLink') {
41
+ const href =
42
+ typeof window !== 'undefined'
43
+ ? window.prompt('请输入链接地址:', 'https://')
44
+ : ''
45
+ if (!href) return
46
+ ue.execCommand('link', { href })
47
+ return
48
+ }
49
+ if (key === 'insertTable' || key === 'inserttable') {
50
+ ue.execCommand('inserttable', { numRows: 3, numCols: 3 })
51
+ return
52
+ }
53
+ if (key === 'uploadImage' || key === 'insertImage') return
54
+ const cmd = WANG_MENU_TO_UE[key]
55
+ if (cmd) ue.execCommand(cmd)
56
+ }
57
+
58
+ export type BindUeToolbarOptions = {
59
+ /** 工具栏根节点,或 CSS 选择器 */
60
+ toolbar: Element | string
61
+ getUe: () => UeCommandRunner | null | undefined
62
+ /** 返回 false 时不拦截(例如当前不是 UE 模式) */
63
+ shouldCapture?: () => boolean
64
+ passthroughKeys?: Set<string>
65
+ }
66
+
67
+ export type UeToolbarBinding = {
68
+ unbind: () => void
69
+ }
70
+
71
+ export function bindUeToolbarAdapter(options: BindUeToolbarOptions): UeToolbarBinding {
72
+ const passthrough = options.passthroughKeys || PASSTHROUGH_KEYS
73
+ const resolveBar = () => {
74
+ if (typeof options.toolbar === 'string') {
75
+ return typeof document !== 'undefined'
76
+ ? document.querySelector(options.toolbar)
77
+ : null
78
+ }
79
+ return options.toolbar
80
+ }
81
+
82
+ const onCapture = (e: Event) => {
83
+ if (options.shouldCapture && !options.shouldCapture()) return
84
+ const t = e.target as HTMLElement | null
85
+ const btn = t?.closest?.('button[data-menu-key], .w-e-bar-item button') as
86
+ | HTMLElement
87
+ | null
88
+ if (!btn) return
89
+ const key =
90
+ btn.getAttribute?.('data-menu-key') ||
91
+ btn.closest?.('[data-menu-key]')?.getAttribute?.('data-menu-key')
92
+ if (!key || passthrough.has(key)) return
93
+ e.preventDefault()
94
+ e.stopPropagation()
95
+ if (typeof (e as any).stopImmediatePropagation === 'function') {
96
+ ;(e as any).stopImmediatePropagation()
97
+ }
98
+ routeWangMenuKeyToUe(key, options.getUe())
99
+ }
100
+
101
+ let bar = resolveBar()
102
+ let bound = false
103
+
104
+ const attach = (el: Element) => {
105
+ el.addEventListener('pointerdown', onCapture, true)
106
+ el.addEventListener('click', onCapture, true)
107
+ bound = true
108
+ }
109
+
110
+ if (bar) {
111
+ attach(bar)
112
+ } else if (typeof requestAnimationFrame !== 'undefined') {
113
+ requestAnimationFrame(() => {
114
+ bar = resolveBar()
115
+ if (bar && !bound) attach(bar)
116
+ })
117
+ }
118
+
119
+ return {
120
+ unbind() {
121
+ const el = bar || resolveBar()
122
+ if (!el || !bound) return
123
+ el.removeEventListener('pointerdown', onCapture, true)
124
+ el.removeEventListener('click', onCapture, true)
125
+ bound = false
126
+ },
127
+ }
128
+ }
@@ -0,0 +1,2 @@
1
+ /** 浏览器默认挂载路径(包内资源经 nuxt 模块 / vite 插件挂到此处) */
2
+ export const DEFAULT_UEDITOR_PUBLIC_BASE = '/ueditor/'
@@ -0,0 +1,11 @@
1
+ import { dirname, join } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { DEFAULT_UEDITOR_PUBLIC_BASE } from './ueditorBase'
4
+
5
+ export { DEFAULT_UEDITOR_PUBLIC_BASE }
6
+
7
+ /** 包内 ueditor 静态目录的绝对路径(仅 Node / 构建配置用,勿在浏览器组件里 import) */
8
+ export function getUeditorPackageDir(): string {
9
+ const here = dirname(fileURLToPath(import.meta.url))
10
+ return join(here, '..', 'ueditor')
11
+ }
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <title></title>
7
+ <style type="text/css">
8
+ *{color: #838383;margin: 0;padding: 0}
9
+ html,body {font-size: 12px;overflow: hidden; }
10
+ .content{padding:5px 0 0 15px;}
11
+ input{width:210px;height:21px;line-height:21px;margin-left: 4px;}
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div class="content">
16
+ <span><var id="lang_input_anchorName"></var></span><input id="anchorName" value="" />
17
+ </div>
18
+ <script type="text/javascript" src="../internal.js"></script>
19
+ <script type="text/javascript">
20
+ var anchorInput = $G('anchorName'),
21
+ node = editor.selection.getRange().getClosedNode();
22
+ if(node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))){
23
+ anchorInput.value = node;
24
+ }
25
+ anchorInput.onkeydown = function(evt){
26
+ evt = evt || window.event;
27
+ if(evt.keyCode == 13){
28
+ editor.execCommand('anchor', anchorInput.value);
29
+ dialog.close();
30
+ domUtils.preventDefault(evt)
31
+ }
32
+ };
33
+ dialog.onok = function (){
34
+ editor.execCommand('anchor', anchorInput.value);
35
+ dialog.close();
36
+ };
37
+ $focus(anchorInput);
38
+ </script>
39
+ </body>
40
+ </html>