@mnykj/alleditor-vue 0.0.0-stage → 1.3.2

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 (291) hide show
  1. package/README.md +51 -2
  2. package/nuxt.ts +67 -0
  3. package/package.json +62 -4
  4. package/scripts/sync-ueditor.mjs +28 -0
  5. package/src/AllEditor.vue +669 -0
  6. package/src/DualEditor.vue +7 -0
  7. package/src/UeHtmlEngine.vue +438 -0
  8. package/src/assets/iconfont/iconfont.css +27 -0
  9. package/src/assets/iconfont/iconfont.ttf +0 -0
  10. package/src/assets/iconfont/iconfont.woff +0 -0
  11. package/src/assets/iconfont/iconfont.woff2 +0 -0
  12. package/src/defaultToolbar.ts +115 -0
  13. package/src/importMenus.ts +158 -0
  14. package/src/index.ts +58 -0
  15. package/src/markdown.ts +46 -0
  16. package/src/stripJavascriptFromHtml.ts +28 -0
  17. package/src/ueToolbar.ts +257 -0
  18. package/src/ueditorBase.ts +2 -0
  19. package/src/ueditorPaths.ts +11 -0
  20. package/ueditor/dialogs/anchor/anchor.html +40 -0
  21. package/ueditor/dialogs/attachment/attachment.css +681 -0
  22. package/ueditor/dialogs/attachment/attachment.html +60 -0
  23. package/ueditor/dialogs/attachment/attachment.js +760 -0
  24. package/ueditor/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
  25. package/ueditor/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
  26. package/ueditor/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
  27. package/ueditor/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
  28. package/ueditor/dialogs/attachment/fileTypeImages/icon_jpg.gif +0 -0
  29. package/ueditor/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
  30. package/ueditor/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
  31. package/ueditor/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
  32. package/ueditor/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
  33. package/ueditor/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
  34. package/ueditor/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
  35. package/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
  36. package/ueditor/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
  37. package/ueditor/dialogs/attachment/images/alignicon.gif +0 -0
  38. package/ueditor/dialogs/attachment/images/alignicon.png +0 -0
  39. package/ueditor/dialogs/attachment/images/bg.png +0 -0
  40. package/ueditor/dialogs/attachment/images/file-icons.gif +0 -0
  41. package/ueditor/dialogs/attachment/images/file-icons.png +0 -0
  42. package/ueditor/dialogs/attachment/images/icons.gif +0 -0
  43. package/ueditor/dialogs/attachment/images/icons.png +0 -0
  44. package/ueditor/dialogs/attachment/images/image.png +0 -0
  45. package/ueditor/dialogs/attachment/images/progress.png +0 -0
  46. package/ueditor/dialogs/attachment/images/success.gif +0 -0
  47. package/ueditor/dialogs/attachment/images/success.png +0 -0
  48. package/ueditor/dialogs/background/background.css +94 -0
  49. package/ueditor/dialogs/background/background.html +56 -0
  50. package/ueditor/dialogs/background/background.js +376 -0
  51. package/ueditor/dialogs/background/images/bg.png +0 -0
  52. package/ueditor/dialogs/background/images/success.png +0 -0
  53. package/ueditor/dialogs/charts/chart.config.js +65 -0
  54. package/ueditor/dialogs/charts/charts.css +165 -0
  55. package/ueditor/dialogs/charts/charts.html +89 -0
  56. package/ueditor/dialogs/charts/charts.js +519 -0
  57. package/ueditor/dialogs/charts/images/charts0.png +0 -0
  58. package/ueditor/dialogs/charts/images/charts1.png +0 -0
  59. package/ueditor/dialogs/charts/images/charts2.png +0 -0
  60. package/ueditor/dialogs/charts/images/charts3.png +0 -0
  61. package/ueditor/dialogs/charts/images/charts4.png +0 -0
  62. package/ueditor/dialogs/charts/images/charts5.png +0 -0
  63. package/ueditor/dialogs/emotion/emotion.css +43 -0
  64. package/ueditor/dialogs/emotion/emotion.html +54 -0
  65. package/ueditor/dialogs/emotion/emotion.js +186 -0
  66. package/ueditor/dialogs/emotion/images/0.gif +0 -0
  67. package/ueditor/dialogs/emotion/images/bface.gif +0 -0
  68. package/ueditor/dialogs/emotion/images/cface.gif +0 -0
  69. package/ueditor/dialogs/emotion/images/fface.gif +0 -0
  70. package/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
  71. package/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  72. package/ueditor/dialogs/emotion/images/tface.gif +0 -0
  73. package/ueditor/dialogs/emotion/images/wface.gif +0 -0
  74. package/ueditor/dialogs/emotion/images/yface.gif +0 -0
  75. package/ueditor/dialogs/gmap/gmap.html +89 -0
  76. package/ueditor/dialogs/help/help.css +7 -0
  77. package/ueditor/dialogs/help/help.html +82 -0
  78. package/ueditor/dialogs/help/help.js +56 -0
  79. package/ueditor/dialogs/image/image.css +894 -0
  80. package/ueditor/dialogs/image/image.html +120 -0
  81. package/ueditor/dialogs/image/image.js +1123 -0
  82. package/ueditor/dialogs/image/images/alignicon.jpg +0 -0
  83. package/ueditor/dialogs/image/images/bg.png +0 -0
  84. package/ueditor/dialogs/image/images/icons.gif +0 -0
  85. package/ueditor/dialogs/image/images/icons.png +0 -0
  86. package/ueditor/dialogs/image/images/image.png +0 -0
  87. package/ueditor/dialogs/image/images/progress.png +0 -0
  88. package/ueditor/dialogs/image/images/success.gif +0 -0
  89. package/ueditor/dialogs/image/images/success.png +0 -0
  90. package/ueditor/dialogs/insertframe/insertframe.html +98 -0
  91. package/ueditor/dialogs/internal.js +81 -0
  92. package/ueditor/dialogs/link/link.html +132 -0
  93. package/ueditor/dialogs/map/map.html +135 -0
  94. package/ueditor/dialogs/map/show.html +118 -0
  95. package/ueditor/dialogs/music/music.css +30 -0
  96. package/ueditor/dialogs/music/music.html +32 -0
  97. package/ueditor/dialogs/music/music.js +192 -0
  98. package/ueditor/dialogs/preview/preview.html +40 -0
  99. package/ueditor/dialogs/scrawl/images/addimg.png +0 -0
  100. package/ueditor/dialogs/scrawl/images/brush.png +0 -0
  101. package/ueditor/dialogs/scrawl/images/delimg.png +0 -0
  102. package/ueditor/dialogs/scrawl/images/delimgH.png +0 -0
  103. package/ueditor/dialogs/scrawl/images/empty.png +0 -0
  104. package/ueditor/dialogs/scrawl/images/emptyH.png +0 -0
  105. package/ueditor/dialogs/scrawl/images/eraser.png +0 -0
  106. package/ueditor/dialogs/scrawl/images/redo.png +0 -0
  107. package/ueditor/dialogs/scrawl/images/redoH.png +0 -0
  108. package/ueditor/dialogs/scrawl/images/scale.png +0 -0
  109. package/ueditor/dialogs/scrawl/images/scaleH.png +0 -0
  110. package/ueditor/dialogs/scrawl/images/size.png +0 -0
  111. package/ueditor/dialogs/scrawl/images/undo.png +0 -0
  112. package/ueditor/dialogs/scrawl/images/undoH.png +0 -0
  113. package/ueditor/dialogs/scrawl/scrawl.css +72 -0
  114. package/ueditor/dialogs/scrawl/scrawl.html +95 -0
  115. package/ueditor/dialogs/scrawl/scrawl.js +670 -0
  116. package/ueditor/dialogs/searchreplace/searchreplace.html +102 -0
  117. package/ueditor/dialogs/searchreplace/searchreplace.js +170 -0
  118. package/ueditor/dialogs/snapscreen/snapscreen.html +58 -0
  119. package/ueditor/dialogs/spechars/spechars.html +21 -0
  120. package/ueditor/dialogs/spechars/spechars.js +57 -0
  121. package/ueditor/dialogs/table/dragicon.png +0 -0
  122. package/ueditor/dialogs/table/edittable.css +84 -0
  123. package/ueditor/dialogs/table/edittable.html +64 -0
  124. package/ueditor/dialogs/table/edittable.js +237 -0
  125. package/ueditor/dialogs/table/edittd.html +61 -0
  126. package/ueditor/dialogs/table/edittip.html +33 -0
  127. package/ueditor/dialogs/template/config.js +42 -0
  128. package/ueditor/dialogs/template/images/bg.gif +0 -0
  129. package/ueditor/dialogs/template/images/pre0.png +0 -0
  130. package/ueditor/dialogs/template/images/pre1.png +0 -0
  131. package/ueditor/dialogs/template/images/pre2.png +0 -0
  132. package/ueditor/dialogs/template/images/pre3.png +0 -0
  133. package/ueditor/dialogs/template/images/pre4.png +0 -0
  134. package/ueditor/dialogs/template/template.css +18 -0
  135. package/ueditor/dialogs/template/template.html +26 -0
  136. package/ueditor/dialogs/template/template.js +53 -0
  137. package/ueditor/dialogs/video/images/bg.png +0 -0
  138. package/ueditor/dialogs/video/images/center_focus.jpg +0 -0
  139. package/ueditor/dialogs/video/images/file-icons.gif +0 -0
  140. package/ueditor/dialogs/video/images/file-icons.png +0 -0
  141. package/ueditor/dialogs/video/images/icons.gif +0 -0
  142. package/ueditor/dialogs/video/images/icons.png +0 -0
  143. package/ueditor/dialogs/video/images/image.png +0 -0
  144. package/ueditor/dialogs/video/images/left_focus.jpg +0 -0
  145. package/ueditor/dialogs/video/images/none_focus.jpg +0 -0
  146. package/ueditor/dialogs/video/images/progress.png +0 -0
  147. package/ueditor/dialogs/video/images/right_focus.jpg +0 -0
  148. package/ueditor/dialogs/video/images/success.gif +0 -0
  149. package/ueditor/dialogs/video/images/success.png +0 -0
  150. package/ueditor/dialogs/video/video.css +635 -0
  151. package/ueditor/dialogs/video/video.html +86 -0
  152. package/ueditor/dialogs/video/video.js +791 -0
  153. package/ueditor/dialogs/webapp/webapp.html +53 -0
  154. package/ueditor/dialogs/wordimage/fClipboard_ueditor.swf +0 -0
  155. package/ueditor/dialogs/wordimage/imageUploader.swf +0 -0
  156. package/ueditor/dialogs/wordimage/tangram.js +1495 -0
  157. package/ueditor/dialogs/wordimage/wordimage.html +111 -0
  158. package/ueditor/dialogs/wordimage/wordimage.js +157 -0
  159. package/ueditor/lang/en/en.js +684 -0
  160. package/ueditor/lang/en/images/addimage.png +0 -0
  161. package/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
  162. package/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
  163. package/ueditor/lang/en/images/background.png +0 -0
  164. package/ueditor/lang/en/images/button.png +0 -0
  165. package/ueditor/lang/en/images/copy.png +0 -0
  166. package/ueditor/lang/en/images/deletedisable.png +0 -0
  167. package/ueditor/lang/en/images/deleteenable.png +0 -0
  168. package/ueditor/lang/en/images/listbackground.png +0 -0
  169. package/ueditor/lang/en/images/localimage.png +0 -0
  170. package/ueditor/lang/en/images/music.png +0 -0
  171. package/ueditor/lang/en/images/rotateleftdisable.png +0 -0
  172. package/ueditor/lang/en/images/rotateleftenable.png +0 -0
  173. package/ueditor/lang/en/images/rotaterightdisable.png +0 -0
  174. package/ueditor/lang/en/images/rotaterightenable.png +0 -0
  175. package/ueditor/lang/en/images/upload.png +0 -0
  176. package/ueditor/lang/zh-cn/images/copy.png +0 -0
  177. package/ueditor/lang/zh-cn/images/localimage.png +0 -0
  178. package/ueditor/lang/zh-cn/images/music.png +0 -0
  179. package/ueditor/lang/zh-cn/images/upload.png +0 -0
  180. package/ueditor/lang/zh-cn/zh-cn.js +669 -0
  181. package/ueditor/official-demo.html +175 -0
  182. package/ueditor/themes/default/css/ueditor.css +1906 -0
  183. package/ueditor/themes/default/css/ueditor.min.css +8 -0
  184. package/ueditor/themes/default/dialogbase.css +100 -0
  185. package/ueditor/themes/default/images/anchor.gif +0 -0
  186. package/ueditor/themes/default/images/arrow.png +0 -0
  187. package/ueditor/themes/default/images/arrow_down.png +0 -0
  188. package/ueditor/themes/default/images/arrow_up.png +0 -0
  189. package/ueditor/themes/default/images/button-bg.gif +0 -0
  190. package/ueditor/themes/default/images/cancelbutton.gif +0 -0
  191. package/ueditor/themes/default/images/charts.png +0 -0
  192. package/ueditor/themes/default/images/cursor_h.gif +0 -0
  193. package/ueditor/themes/default/images/cursor_h.png +0 -0
  194. package/ueditor/themes/default/images/cursor_v.gif +0 -0
  195. package/ueditor/themes/default/images/cursor_v.png +0 -0
  196. package/ueditor/themes/default/images/dialog-title-bg.png +0 -0
  197. package/ueditor/themes/default/images/filescan.png +0 -0
  198. package/ueditor/themes/default/images/highlighted.gif +0 -0
  199. package/ueditor/themes/default/images/icons-all.gif +0 -0
  200. package/ueditor/themes/default/images/icons.gif +0 -0
  201. package/ueditor/themes/default/images/icons.png +0 -0
  202. package/ueditor/themes/default/images/img-cracked.png +0 -0
  203. package/ueditor/themes/default/images/loaderror.png +0 -0
  204. package/ueditor/themes/default/images/loading.gif +0 -0
  205. package/ueditor/themes/default/images/lock.gif +0 -0
  206. package/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
  207. package/ueditor/themes/default/images/pagebreak.gif +0 -0
  208. package/ueditor/themes/default/images/scale.png +0 -0
  209. package/ueditor/themes/default/images/sortable.png +0 -0
  210. package/ueditor/themes/default/images/spacer.gif +0 -0
  211. package/ueditor/themes/default/images/sparator_v.png +0 -0
  212. package/ueditor/themes/default/images/table-cell-align.png +0 -0
  213. package/ueditor/themes/default/images/tangram-colorpicker.png +0 -0
  214. package/ueditor/themes/default/images/toolbar_bg.png +0 -0
  215. package/ueditor/themes/default/images/unhighlighted.gif +0 -0
  216. package/ueditor/themes/default/images/upload.png +0 -0
  217. package/ueditor/themes/default/images/videologo.gif +0 -0
  218. package/ueditor/themes/default/images/word.gif +0 -0
  219. package/ueditor/themes/default/images/wordpaste.png +0 -0
  220. package/ueditor/themes/iframe.css +1 -0
  221. package/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
  222. package/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
  223. package/ueditor/third-party/codemirror/codemirror.css +104 -0
  224. package/ueditor/third-party/codemirror/codemirror.js +3581 -0
  225. package/ueditor/third-party/highcharts/adapters/mootools-adapter.js +13 -0
  226. package/ueditor/third-party/highcharts/adapters/mootools-adapter.src.js +313 -0
  227. package/ueditor/third-party/highcharts/adapters/prototype-adapter.js +15 -0
  228. package/ueditor/third-party/highcharts/adapters/prototype-adapter.src.js +316 -0
  229. package/ueditor/third-party/highcharts/adapters/standalone-framework.js +17 -0
  230. package/ueditor/third-party/highcharts/adapters/standalone-framework.src.js +583 -0
  231. package/ueditor/third-party/highcharts/highcharts-more.js +50 -0
  232. package/ueditor/third-party/highcharts/highcharts-more.src.js +2430 -0
  233. package/ueditor/third-party/highcharts/highcharts.js +283 -0
  234. package/ueditor/third-party/highcharts/highcharts.src.js +16974 -0
  235. package/ueditor/third-party/highcharts/modules/annotations.js +7 -0
  236. package/ueditor/third-party/highcharts/modules/annotations.src.js +401 -0
  237. package/ueditor/third-party/highcharts/modules/canvas-tools.js +133 -0
  238. package/ueditor/third-party/highcharts/modules/canvas-tools.src.js +3113 -0
  239. package/ueditor/third-party/highcharts/modules/data.js +17 -0
  240. package/ueditor/third-party/highcharts/modules/data.src.js +582 -0
  241. package/ueditor/third-party/highcharts/modules/drilldown.js +11 -0
  242. package/ueditor/third-party/highcharts/modules/drilldown.src.js +447 -0
  243. package/ueditor/third-party/highcharts/modules/exporting.js +22 -0
  244. package/ueditor/third-party/highcharts/modules/exporting.src.js +709 -0
  245. package/ueditor/third-party/highcharts/modules/funnel.js +12 -0
  246. package/ueditor/third-party/highcharts/modules/funnel.src.js +289 -0
  247. package/ueditor/third-party/highcharts/modules/heatmap.js +1 -0
  248. package/ueditor/third-party/highcharts/modules/heatmap.src.js +53 -0
  249. package/ueditor/third-party/highcharts/modules/map.js +27 -0
  250. package/ueditor/third-party/highcharts/modules/map.src.js +1002 -0
  251. package/ueditor/third-party/highcharts/modules/no-data-to-display.js +12 -0
  252. package/ueditor/third-party/highcharts/modules/no-data-to-display.src.js +128 -0
  253. package/ueditor/third-party/highcharts/themes/dark-blue.js +254 -0
  254. package/ueditor/third-party/highcharts/themes/dark-green.js +255 -0
  255. package/ueditor/third-party/highcharts/themes/gray.js +257 -0
  256. package/ueditor/third-party/highcharts/themes/grid.js +103 -0
  257. package/ueditor/third-party/highcharts/themes/skies.js +89 -0
  258. package/ueditor/third-party/jquery-1.10.2.js +9789 -0
  259. package/ueditor/third-party/jquery-1.10.2.min.js +6 -0
  260. package/ueditor/third-party/jquery-1.10.2.min.map +1 -0
  261. package/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
  262. package/ueditor/third-party/video-js/font/vjs.eot +0 -0
  263. package/ueditor/third-party/video-js/font/vjs.svg +65 -0
  264. package/ueditor/third-party/video-js/font/vjs.ttf +0 -0
  265. package/ueditor/third-party/video-js/font/vjs.woff +0 -0
  266. package/ueditor/third-party/video-js/video-js.css +766 -0
  267. package/ueditor/third-party/video-js/video-js.min.css +5 -0
  268. package/ueditor/third-party/video-js/video-js.swf +0 -0
  269. package/ueditor/third-party/video-js/video.dev.js +7108 -0
  270. package/ueditor/third-party/video-js/video.js +129 -0
  271. package/ueditor/third-party/webuploader/Uploader.swf +0 -0
  272. package/ueditor/third-party/webuploader/webuploader.css +28 -0
  273. package/ueditor/third-party/webuploader/webuploader.custom.js +5670 -0
  274. package/ueditor/third-party/webuploader/webuploader.custom.min.js +2 -0
  275. package/ueditor/third-party/webuploader/webuploader.flashonly.js +4176 -0
  276. package/ueditor/third-party/webuploader/webuploader.flashonly.min.js +2 -0
  277. package/ueditor/third-party/webuploader/webuploader.html5only.js +5559 -0
  278. package/ueditor/third-party/webuploader/webuploader.html5only.min.js +2 -0
  279. package/ueditor/third-party/webuploader/webuploader.js +6733 -0
  280. package/ueditor/third-party/webuploader/webuploader.min.js +2 -0
  281. package/ueditor/third-party/webuploader/webuploader.withoutimage.js +4593 -0
  282. package/ueditor/third-party/webuploader/webuploader.withoutimage.min.js +2 -0
  283. package/ueditor/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
  284. package/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js +9 -0
  285. package/ueditor/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
  286. package/ueditor/ueditor.all.js +32931 -0
  287. package/ueditor/ueditor.all.min.js +17 -0
  288. package/ueditor/ueditor.config.js +507 -0
  289. package/ueditor/ueditor.parse.js +1230 -0
  290. package/ueditor/ueditor.parse.min.js +5 -0
  291. package/vite.ts +87 -0
@@ -0,0 +1,438 @@
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
+ /**
99
+ * 清理公众号/Slate 残留:
100
+ * - <span leaf=""> 包住的 img 易让 UEditor 图片缩放框错位,挡住正文无法编辑
101
+ * - 去掉无意义的 leaf 属性
102
+ */
103
+ function sanitizeUeHtml(html) {
104
+ return String(html ?? '')
105
+ .replace(/<span\b[^>]*\bleaf(?:\s*=\s*(?:""|''|[^>\s]+))?\s*[^>]*>\s*(<img\b[^>]*>)\s*<\/span>/gi, '$1')
106
+ .replace(/\sleaf(?:\s*=\s*(?:""|''|"[^"]*"|'[^']*'|[^\s>]+))?/gi, '')
107
+ }
108
+
109
+ function hideImageScaleUi(ue) {
110
+ try {
111
+ const uiRoot = ue?.ui?.getDom?.()
112
+ if (!uiRoot) return
113
+ uiRoot.querySelectorAll('.edui-editor-imagescale, [id$="_imagescale"], [id$="_imagescale_cover"]').forEach((el) => {
114
+ el.style.display = 'none'
115
+ })
116
+ } catch {
117
+ /* ignore */
118
+ }
119
+ }
120
+
121
+ function getContent() {
122
+ const ue = instance.value
123
+ if (!ue || !ready) {
124
+ if (pendingHtml !== undefined) return pendingHtml
125
+ return props.modelValue || ''
126
+ }
127
+ try {
128
+ return ue.getContent() || ''
129
+ } catch {
130
+ return props.modelValue || ''
131
+ }
132
+ }
133
+
134
+ function setContent(html) {
135
+ const next = sanitizeUeHtml(html || '')
136
+ const ue = instance.value
137
+ if (!ue || !ready) {
138
+ pendingHtml = next
139
+ return
140
+ }
141
+ applying = true
142
+ try {
143
+ ue.setContent(next)
144
+ } finally {
145
+ applying = false
146
+ }
147
+ hideImageScaleUi(ue)
148
+ requestAnimationFrame(() => fitEditorHeight(ue))
149
+ }
150
+
151
+ function focus() {
152
+ const ue = instance.value
153
+ if (!ue || !ready) return
154
+ try {
155
+ ue.focus?.()
156
+ } catch {
157
+ /* ignore */
158
+ }
159
+ }
160
+
161
+ function execCommand(cmd, ...args) {
162
+ const ue = instance.value
163
+ if (!ue || !ready || props.disabled) return false
164
+ try {
165
+ focus()
166
+ ue.execCommand(cmd, ...args)
167
+ return true
168
+ } catch (err) {
169
+ console.warn('[AllEditor UeHtmlEngine] execCommand', cmd, err)
170
+ return false
171
+ }
172
+ }
173
+
174
+ function queryCommandState(cmd) {
175
+ const ue = instance.value
176
+ if (!ue || !ready) return -1
177
+ try {
178
+ return ue.queryCommandState(cmd)
179
+ } catch {
180
+ return -1
181
+ }
182
+ }
183
+
184
+ function fitEditorHeight(ue) {
185
+ const host = hostRef.value
186
+ if (!ue || !host) return
187
+ const h = Math.max(Math.floor(host.clientHeight || 0), 320)
188
+ try {
189
+ ue.setHeight?.(h)
190
+ } catch {
191
+ /* ignore */
192
+ }
193
+ try {
194
+ const holder = host.querySelector('.edui-editor-iframeholder')
195
+ const iframe = host.querySelector('iframe')
196
+ if (holder instanceof HTMLElement) {
197
+ holder.style.height = `${h}px`
198
+ holder.style.minHeight = `${h}px`
199
+ }
200
+ if (iframe instanceof HTMLElement) {
201
+ iframe.style.height = `${h}px`
202
+ iframe.setAttribute('height', String(h))
203
+ }
204
+ const editorRoot = host.querySelector('.edui-editor')
205
+ if (editorRoot instanceof HTMLElement) {
206
+ editorRoot.style.height = `${h}px`
207
+ }
208
+ } catch {
209
+ /* ignore */
210
+ }
211
+ }
212
+
213
+ function bindResize(ue) {
214
+ unbindResize()
215
+ const host = hostRef.value
216
+ if (!host || typeof ResizeObserver === 'undefined') return
217
+ resizeObserver = new ResizeObserver(() => {
218
+ if (destroyed || !ready) return
219
+ fitEditorHeight(ue)
220
+ })
221
+ resizeObserver.observe(host)
222
+ }
223
+
224
+ function unbindResize() {
225
+ if (resizeObserver) {
226
+ try {
227
+ resizeObserver.disconnect()
228
+ } catch {
229
+ /* ignore */
230
+ }
231
+ resizeObserver = null
232
+ }
233
+ }
234
+
235
+ function injectReadableBodyStyle(ue) {
236
+ try {
237
+ const doc = ue?.document
238
+ if (!doc?.head) return
239
+ if (doc.getElementById('alleditor-ue-readable')) return
240
+ const style = doc.createElement('style')
241
+ style.id = 'alleditor-ue-readable'
242
+ style.textContent = [
243
+ 'html,body{height:auto!important;min-height:100%;}',
244
+ 'body{color:#333;background:#fff;margin:12px 16px;font-size:15px;line-height:1.75;}',
245
+ 'body.view{overflow-y:auto!important;}',
246
+ 'img{max-width:100%;height:auto;}',
247
+ ].join('')
248
+ doc.head.appendChild(style)
249
+ } catch {
250
+ /* ignore */
251
+ }
252
+ }
253
+
254
+ function destroyEditor() {
255
+ unbindResize()
256
+ const UE = typeof window !== 'undefined' ? window.UE : null
257
+ const id = props.editorId
258
+ if (UE && id) {
259
+ try {
260
+ UE.delEditor?.(id)
261
+ } catch {
262
+ /* ignore */
263
+ }
264
+ }
265
+ instance.value = null
266
+ ready = false
267
+ pendingHtml = undefined
268
+ if (hostRef.value) hostRef.value.innerHTML = ''
269
+ }
270
+
271
+ onMounted(async () => {
272
+ destroyed = false
273
+ pendingHtml = props.modelValue || ''
274
+ try {
275
+ const UE = await ensureUEditor()
276
+ if (!UE || destroyed || !hostRef.value) return
277
+
278
+ const holder = document.createElement('div')
279
+ holder.id = props.editorId
280
+ hostRef.value.innerHTML = ''
281
+ hostRef.value.appendChild(holder)
282
+
283
+ const height = Math.max(Math.floor(hostRef.value.clientHeight || 0), 480)
284
+ const ue = UE.getEditor(props.editorId, {
285
+ toolbars: [[]],
286
+ initialFrameHeight: height,
287
+ initialFrameWidth: '100%',
288
+ autoHeightEnabled: false,
289
+ // 关闭图片八爪缩放框:编辑区在 iframe 内时缩放层常错位/关不掉,正文点不动
290
+ imageScaleEnabled: false,
291
+ imagePopup: false,
292
+ scaleEnabled: false,
293
+ serverUrl: '',
294
+ enableAutoSave: false,
295
+ elementPathEnabled: false,
296
+ wordCount: false,
297
+ enableContextMenu: true,
298
+ retainOnlyLabelPasted: false,
299
+ pasteplain: false,
300
+ })
301
+
302
+ instance.value = ue
303
+ emit('created', ue)
304
+
305
+ ue.addListener('contentChange', () => {
306
+ if (applying || destroyed || !ready) return
307
+ const html = getContent()
308
+ emit('update:modelValue', html)
309
+ emit('change', html)
310
+ })
311
+ // 即便外部配置被覆盖,缩放层弹出时立刻隐藏,避免挡住编辑
312
+ ue.addListener('afterscaleshow', () => hideImageScaleUi(ue))
313
+
314
+ ue.ready(() => {
315
+ if (destroyed) return
316
+ ready = true
317
+ const initial = sanitizeUeHtml(
318
+ pendingHtml !== undefined ? pendingHtml : props.modelValue || ''
319
+ )
320
+ pendingHtml = undefined
321
+ applying = true
322
+ try {
323
+ ue.setContent(initial)
324
+ } finally {
325
+ applying = false
326
+ }
327
+ injectReadableBodyStyle(ue)
328
+ hideImageScaleUi(ue)
329
+ fitEditorHeight(ue)
330
+ bindResize(ue)
331
+ requestAnimationFrame(() => fitEditorHeight(ue))
332
+ setTimeout(() => fitEditorHeight(ue), 50)
333
+ setTimeout(() => fitEditorHeight(ue), 200)
334
+ syncDisabled()
335
+ emit('ready', ue)
336
+ })
337
+ } catch (err) {
338
+ console.error('[AllEditor UeHtmlEngine]', err)
339
+ }
340
+ })
341
+
342
+ watch(
343
+ () => props.modelValue,
344
+ (html) => {
345
+ if (destroyed) return
346
+ const next = sanitizeUeHtml(html || '')
347
+ if (!ready || applying) {
348
+ pendingHtml = next
349
+ return
350
+ }
351
+ try {
352
+ const live = sanitizeUeHtml(getContent() || '')
353
+ if (live === next) return
354
+ setContent(next)
355
+ } catch {
356
+ /* ignore */
357
+ }
358
+ }
359
+ )
360
+
361
+ watch(
362
+ () => props.disabled,
363
+ () => syncDisabled()
364
+ )
365
+
366
+ onBeforeUnmount(() => {
367
+ destroyed = true
368
+ destroyEditor()
369
+ })
370
+
371
+ defineExpose({
372
+ getContent,
373
+ setContent,
374
+ execCommand,
375
+ queryCommandState,
376
+ focus,
377
+ getEditor: () => instance.value,
378
+ isReady: () => ready,
379
+ })
380
+ </script>
381
+
382
+ <template>
383
+ <div ref="hostRef" class="alleditor-ue-engine" />
384
+ </template>
385
+
386
+ <style scoped>
387
+ .alleditor-ue-engine {
388
+ width: 100%;
389
+ height: 100%;
390
+ min-height: 0;
391
+ flex: 1 1 0;
392
+ display: block;
393
+ position: relative;
394
+ overflow: hidden;
395
+ background: #fff;
396
+ }
397
+
398
+ .alleditor-ue-engine :deep(.edui-editor-toolbarbox),
399
+ .alleditor-ue-engine :deep(.edui-editor-toolbarboxouter),
400
+ .alleditor-ue-engine :deep(.edui-editor-toolbarboxinner),
401
+ .alleditor-ue-engine :deep(.edui-editor-bottomContainer),
402
+ .alleditor-ue-engine :deep(.edui-editor-messageholder) {
403
+ display: none !important;
404
+ height: 0 !important;
405
+ overflow: hidden !important;
406
+ border: none !important;
407
+ padding: 0 !important;
408
+ margin: 0 !important;
409
+ }
410
+
411
+ .alleditor-ue-engine :deep(.edui-default),
412
+ .alleditor-ue-engine :deep(.edui-editor) {
413
+ width: 100% !important;
414
+ border: none !important;
415
+ box-shadow: none !important;
416
+ background: #fff !important;
417
+ }
418
+
419
+ .alleditor-ue-engine :deep(.edui-editor-iframeholder) {
420
+ width: 100% !important;
421
+ border: none !important;
422
+ }
423
+
424
+ .alleditor-ue-engine :deep(.edui-editor-iframeholder iframe) {
425
+ width: 100% !important;
426
+ display: block !important;
427
+ border: none !important;
428
+ background: #fff !important;
429
+ }
430
+
431
+ /* 兜底隐藏图片缩放框(错位时会盖住正文) */
432
+ .alleditor-ue-engine :deep(.edui-editor-imagescale),
433
+ .alleditor-ue-engine :deep([id$='_imagescale']),
434
+ .alleditor-ue-engine :deep([id$='_imagescale_cover']) {
435
+ display: none !important;
436
+ pointer-events: none !important;
437
+ }
438
+ </style>
@@ -0,0 +1,27 @@
1
+ /* iconfont 项目 5252173(markdown / HTML / 清空文档);字体已随包备份 */
2
+ @font-face {
3
+ font-family: 'iconfont';
4
+ src: url('./iconfont.woff2') format('woff2'),
5
+ url('./iconfont.woff') format('woff'),
6
+ url('./iconfont.ttf') format('truetype');
7
+ }
8
+
9
+ .iconfont {
10
+ font-family: 'iconfont' !important;
11
+ font-size: 16px;
12
+ font-style: normal;
13
+ -webkit-font-smoothing: antialiased;
14
+ -moz-osx-font-smoothing: grayscale;
15
+ }
16
+
17
+ .icon-html:before {
18
+ content: '\e648';
19
+ }
20
+
21
+ .icon-markdown-line:before {
22
+ content: '\e8d4';
23
+ }
24
+
25
+ .icon-qingkongwendang1:before {
26
+ content: '\e601';
27
+ }
Binary file
@@ -0,0 +1,115 @@
1
+ /**
2
+ * DualEditor 默认工具栏:AllEditor 标准项 + MD/HTML 导入。
3
+ * 宿主传入 toolbarConfig.toolbarKeys 时可完全覆盖。
4
+ */
5
+ export const DEFAULT_DUAL_TOOLBAR_KEYS: Array<string | Record<string, any>> = [
6
+ 'headerSelect',
7
+ 'blockquote',
8
+ '|',
9
+ 'bold',
10
+ 'underline',
11
+ 'italic',
12
+ {
13
+ key: 'group-more-style',
14
+ title: '更多',
15
+ iconSvg:
16
+ '<svg viewBox="0 0 1024 1024"><path d="M204.8 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M505.6 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M806.4 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path></svg>',
17
+ menuKeys: ['through', 'code', 'sup', 'sub', 'clearStyle'],
18
+ },
19
+ 'color',
20
+ 'bgColor',
21
+ '|',
22
+ 'fontSize',
23
+ 'fontFamily',
24
+ 'lineHeight',
25
+ '|',
26
+ 'bulletedList',
27
+ 'numberedList',
28
+ 'todo',
29
+ {
30
+ key: 'group-justify',
31
+ title: '对齐',
32
+ iconSvg:
33
+ '<svg viewBox="0 0 1024 1024"><path d="M768 793.6v102.4H51.2v-102.4h716.8z m204.8-230.4v102.4H51.2v-102.4h921.6z m-204.8-230.4v102.4H51.2v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z"></path></svg>',
34
+ menuKeys: ['justifyLeft', 'justifyRight', 'justifyCenter', 'justifyJustify'],
35
+ },
36
+ {
37
+ key: 'group-indent',
38
+ title: '缩进',
39
+ iconSvg:
40
+ '<svg viewBox="0 0 1024 1024"><path d="M0 64h1024v128H0z m384 192h640v128H384z m0 192h640v128H384z m0 192h640v128H384zM0 832h1024v128H0z m0-128V320l256 192z"></path></svg>',
41
+ menuKeys: ['indent', 'delIndent'],
42
+ },
43
+ '|',
44
+ 'emotion',
45
+ 'insertLink',
46
+ {
47
+ key: 'group-image',
48
+ title: '图片',
49
+ iconSvg:
50
+ '<svg viewBox="0 0 1024 1024"><path d="M959.877 128l0.123 0.123v767.775l-0.123 0.122H64.102l-0.122-0.122V128.123l0.122-0.123h895.775zM960 64H64C28.795 64 0 92.795 0 128v768c0 35.205 28.795 64 64 64h896c35.205 0 64-28.795 64-64V128c0-35.205-28.795-64-64-64zM832 288.01c0 53.023-42.988 96.01-96.01 96.01s-96.01-42.987-96.01-96.01S682.967 192 735.99 192 832 234.988 832 288.01zM896 832H128V704l224.01-384 256 320h64l224.01-192z"></path></svg>',
51
+ menuKeys: ['insertImage', 'uploadImage'],
52
+ },
53
+ {
54
+ key: 'group-video',
55
+ title: '视频',
56
+ iconSvg:
57
+ '<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>',
58
+ menuKeys: ['insertVideo', 'uploadVideo'],
59
+ },
60
+ 'insertTable',
61
+ 'codeBlock',
62
+ 'divider',
63
+ '|',
64
+ 'undo',
65
+ 'redo',
66
+ '|',
67
+ 'importMarkdown',
68
+ 'sourceCode',
69
+ '|',
70
+ 'clearContent',
71
+ 'fullScreen',
72
+ ]
73
+
74
+ function ensureKeyBefore(
75
+ keys: Array<string | Record<string, any>>,
76
+ key: string,
77
+ beforeKey: string
78
+ ) {
79
+ const has = keys.some((k: any) => k === key || k?.key === key)
80
+ if (has) return keys
81
+ const idx = keys.findIndex((k: any) => k === beforeKey || k?.key === beforeKey)
82
+ const next = [...keys]
83
+ if (idx >= 0) next.splice(idx, 0, key)
84
+ else next.push(key)
85
+ return next
86
+ }
87
+
88
+ export function mergeToolbarConfig(
89
+ userConfig: Record<string, any> | null | undefined,
90
+ options?: { enableImport?: boolean }
91
+ ) {
92
+ const enableImport = options?.enableImport !== false
93
+ const user = userConfig && typeof userConfig === 'object' ? { ...userConfig } : {}
94
+ if (Array.isArray(user.toolbarKeys) && user.toolbarKeys.length) {
95
+ let keys = [...user.toolbarKeys]
96
+ if (enableImport) {
97
+ const hasMd = keys.some(
98
+ (k: any) => k === 'importMarkdown' || k?.key === 'importMarkdown'
99
+ )
100
+ const hasHtml = keys.some(
101
+ (k: any) => k === 'sourceCode' || k?.key === 'sourceCode'
102
+ )
103
+ if (!hasMd) keys.push('importMarkdown')
104
+ if (!hasHtml) keys.push('sourceCode')
105
+ }
106
+ keys = ensureKeyBefore(keys, 'clearContent', 'fullScreen')
107
+ return { ...user, toolbarKeys: keys }
108
+ }
109
+ const keys = enableImport
110
+ ? DEFAULT_DUAL_TOOLBAR_KEYS
111
+ : DEFAULT_DUAL_TOOLBAR_KEYS.filter(
112
+ (k) => k !== 'importMarkdown' && k !== 'sourceCode'
113
+ )
114
+ return { ...user, toolbarKeys: keys }
115
+ }