@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.
- package/README.md +72 -3
- package/nuxt.ts +60 -0
- package/package.json +59 -6
- package/scripts/sync-ueditor.mjs +28 -0
- package/src/DualEditor.vue +330 -0
- package/src/UeHtmlEngine.vue +385 -0
- package/src/index.ts +32 -0
- package/src/ueToolbar.ts +128 -0
- package/src/ueditorBase.ts +2 -0
- package/src/ueditorPaths.ts +11 -0
- package/ueditor/dialogs/anchor/anchor.html +40 -0
- package/ueditor/dialogs/attachment/attachment.css +681 -0
- package/ueditor/dialogs/attachment/attachment.html +60 -0
- package/ueditor/dialogs/attachment/attachment.js +760 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_jpg.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
- package/ueditor/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
- package/ueditor/dialogs/attachment/images/alignicon.gif +0 -0
- package/ueditor/dialogs/attachment/images/alignicon.png +0 -0
- package/ueditor/dialogs/attachment/images/bg.png +0 -0
- package/ueditor/dialogs/attachment/images/file-icons.gif +0 -0
- package/ueditor/dialogs/attachment/images/file-icons.png +0 -0
- package/ueditor/dialogs/attachment/images/icons.gif +0 -0
- package/ueditor/dialogs/attachment/images/icons.png +0 -0
- package/ueditor/dialogs/attachment/images/image.png +0 -0
- package/ueditor/dialogs/attachment/images/progress.png +0 -0
- package/ueditor/dialogs/attachment/images/success.gif +0 -0
- package/ueditor/dialogs/attachment/images/success.png +0 -0
- package/ueditor/dialogs/background/background.css +94 -0
- package/ueditor/dialogs/background/background.html +56 -0
- package/ueditor/dialogs/background/background.js +376 -0
- package/ueditor/dialogs/background/images/bg.png +0 -0
- package/ueditor/dialogs/background/images/success.png +0 -0
- package/ueditor/dialogs/charts/chart.config.js +65 -0
- package/ueditor/dialogs/charts/charts.css +165 -0
- package/ueditor/dialogs/charts/charts.html +89 -0
- package/ueditor/dialogs/charts/charts.js +519 -0
- package/ueditor/dialogs/charts/images/charts0.png +0 -0
- package/ueditor/dialogs/charts/images/charts1.png +0 -0
- package/ueditor/dialogs/charts/images/charts2.png +0 -0
- package/ueditor/dialogs/charts/images/charts3.png +0 -0
- package/ueditor/dialogs/charts/images/charts4.png +0 -0
- package/ueditor/dialogs/charts/images/charts5.png +0 -0
- package/ueditor/dialogs/emotion/emotion.css +43 -0
- package/ueditor/dialogs/emotion/emotion.html +54 -0
- package/ueditor/dialogs/emotion/emotion.js +186 -0
- package/ueditor/dialogs/emotion/images/0.gif +0 -0
- package/ueditor/dialogs/emotion/images/bface.gif +0 -0
- package/ueditor/dialogs/emotion/images/cface.gif +0 -0
- package/ueditor/dialogs/emotion/images/fface.gif +0 -0
- package/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
- package/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- package/ueditor/dialogs/emotion/images/tface.gif +0 -0
- package/ueditor/dialogs/emotion/images/wface.gif +0 -0
- package/ueditor/dialogs/emotion/images/yface.gif +0 -0
- package/ueditor/dialogs/gmap/gmap.html +89 -0
- package/ueditor/dialogs/help/help.css +7 -0
- package/ueditor/dialogs/help/help.html +82 -0
- package/ueditor/dialogs/help/help.js +56 -0
- package/ueditor/dialogs/image/image.css +894 -0
- package/ueditor/dialogs/image/image.html +120 -0
- package/ueditor/dialogs/image/image.js +1123 -0
- package/ueditor/dialogs/image/images/alignicon.jpg +0 -0
- package/ueditor/dialogs/image/images/bg.png +0 -0
- package/ueditor/dialogs/image/images/icons.gif +0 -0
- package/ueditor/dialogs/image/images/icons.png +0 -0
- package/ueditor/dialogs/image/images/image.png +0 -0
- package/ueditor/dialogs/image/images/progress.png +0 -0
- package/ueditor/dialogs/image/images/success.gif +0 -0
- package/ueditor/dialogs/image/images/success.png +0 -0
- package/ueditor/dialogs/insertframe/insertframe.html +98 -0
- package/ueditor/dialogs/internal.js +81 -0
- package/ueditor/dialogs/link/link.html +132 -0
- package/ueditor/dialogs/map/map.html +135 -0
- package/ueditor/dialogs/map/show.html +118 -0
- package/ueditor/dialogs/music/music.css +30 -0
- package/ueditor/dialogs/music/music.html +32 -0
- package/ueditor/dialogs/music/music.js +192 -0
- package/ueditor/dialogs/preview/preview.html +40 -0
- package/ueditor/dialogs/scrawl/images/addimg.png +0 -0
- package/ueditor/dialogs/scrawl/images/brush.png +0 -0
- package/ueditor/dialogs/scrawl/images/delimg.png +0 -0
- package/ueditor/dialogs/scrawl/images/delimgH.png +0 -0
- package/ueditor/dialogs/scrawl/images/empty.png +0 -0
- package/ueditor/dialogs/scrawl/images/emptyH.png +0 -0
- package/ueditor/dialogs/scrawl/images/eraser.png +0 -0
- package/ueditor/dialogs/scrawl/images/redo.png +0 -0
- package/ueditor/dialogs/scrawl/images/redoH.png +0 -0
- package/ueditor/dialogs/scrawl/images/scale.png +0 -0
- package/ueditor/dialogs/scrawl/images/scaleH.png +0 -0
- package/ueditor/dialogs/scrawl/images/size.png +0 -0
- package/ueditor/dialogs/scrawl/images/undo.png +0 -0
- package/ueditor/dialogs/scrawl/images/undoH.png +0 -0
- package/ueditor/dialogs/scrawl/scrawl.css +72 -0
- package/ueditor/dialogs/scrawl/scrawl.html +95 -0
- package/ueditor/dialogs/scrawl/scrawl.js +670 -0
- package/ueditor/dialogs/searchreplace/searchreplace.html +102 -0
- package/ueditor/dialogs/searchreplace/searchreplace.js +170 -0
- package/ueditor/dialogs/snapscreen/snapscreen.html +58 -0
- package/ueditor/dialogs/spechars/spechars.html +21 -0
- package/ueditor/dialogs/spechars/spechars.js +57 -0
- package/ueditor/dialogs/table/dragicon.png +0 -0
- package/ueditor/dialogs/table/edittable.css +84 -0
- package/ueditor/dialogs/table/edittable.html +64 -0
- package/ueditor/dialogs/table/edittable.js +237 -0
- package/ueditor/dialogs/table/edittd.html +61 -0
- package/ueditor/dialogs/table/edittip.html +33 -0
- package/ueditor/dialogs/template/config.js +42 -0
- package/ueditor/dialogs/template/images/bg.gif +0 -0
- package/ueditor/dialogs/template/images/pre0.png +0 -0
- package/ueditor/dialogs/template/images/pre1.png +0 -0
- package/ueditor/dialogs/template/images/pre2.png +0 -0
- package/ueditor/dialogs/template/images/pre3.png +0 -0
- package/ueditor/dialogs/template/images/pre4.png +0 -0
- package/ueditor/dialogs/template/template.css +18 -0
- package/ueditor/dialogs/template/template.html +26 -0
- package/ueditor/dialogs/template/template.js +53 -0
- package/ueditor/dialogs/video/images/bg.png +0 -0
- package/ueditor/dialogs/video/images/center_focus.jpg +0 -0
- package/ueditor/dialogs/video/images/file-icons.gif +0 -0
- package/ueditor/dialogs/video/images/file-icons.png +0 -0
- package/ueditor/dialogs/video/images/icons.gif +0 -0
- package/ueditor/dialogs/video/images/icons.png +0 -0
- package/ueditor/dialogs/video/images/image.png +0 -0
- package/ueditor/dialogs/video/images/left_focus.jpg +0 -0
- package/ueditor/dialogs/video/images/none_focus.jpg +0 -0
- package/ueditor/dialogs/video/images/progress.png +0 -0
- package/ueditor/dialogs/video/images/right_focus.jpg +0 -0
- package/ueditor/dialogs/video/images/success.gif +0 -0
- package/ueditor/dialogs/video/images/success.png +0 -0
- package/ueditor/dialogs/video/video.css +635 -0
- package/ueditor/dialogs/video/video.html +86 -0
- package/ueditor/dialogs/video/video.js +791 -0
- package/ueditor/dialogs/webapp/webapp.html +53 -0
- package/ueditor/dialogs/wordimage/fClipboard_ueditor.swf +0 -0
- package/ueditor/dialogs/wordimage/imageUploader.swf +0 -0
- package/ueditor/dialogs/wordimage/tangram.js +1495 -0
- package/ueditor/dialogs/wordimage/wordimage.html +111 -0
- package/ueditor/dialogs/wordimage/wordimage.js +157 -0
- package/ueditor/index.html +175 -0
- package/ueditor/lang/en/en.js +684 -0
- package/ueditor/lang/en/images/addimage.png +0 -0
- package/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
- package/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
- package/ueditor/lang/en/images/background.png +0 -0
- package/ueditor/lang/en/images/button.png +0 -0
- package/ueditor/lang/en/images/copy.png +0 -0
- package/ueditor/lang/en/images/deletedisable.png +0 -0
- package/ueditor/lang/en/images/deleteenable.png +0 -0
- package/ueditor/lang/en/images/listbackground.png +0 -0
- package/ueditor/lang/en/images/localimage.png +0 -0
- package/ueditor/lang/en/images/music.png +0 -0
- package/ueditor/lang/en/images/rotateleftdisable.png +0 -0
- package/ueditor/lang/en/images/rotateleftenable.png +0 -0
- package/ueditor/lang/en/images/rotaterightdisable.png +0 -0
- package/ueditor/lang/en/images/rotaterightenable.png +0 -0
- package/ueditor/lang/en/images/upload.png +0 -0
- package/ueditor/lang/zh-cn/images/copy.png +0 -0
- package/ueditor/lang/zh-cn/images/localimage.png +0 -0
- package/ueditor/lang/zh-cn/images/music.png +0 -0
- package/ueditor/lang/zh-cn/images/upload.png +0 -0
- package/ueditor/lang/zh-cn/zh-cn.js +669 -0
- package/ueditor/themes/default/css/ueditor.css +1906 -0
- package/ueditor/themes/default/css/ueditor.min.css +8 -0
- package/ueditor/themes/default/dialogbase.css +100 -0
- package/ueditor/themes/default/images/anchor.gif +0 -0
- package/ueditor/themes/default/images/arrow.png +0 -0
- package/ueditor/themes/default/images/arrow_down.png +0 -0
- package/ueditor/themes/default/images/arrow_up.png +0 -0
- package/ueditor/themes/default/images/button-bg.gif +0 -0
- package/ueditor/themes/default/images/cancelbutton.gif +0 -0
- package/ueditor/themes/default/images/charts.png +0 -0
- package/ueditor/themes/default/images/cursor_h.gif +0 -0
- package/ueditor/themes/default/images/cursor_h.png +0 -0
- package/ueditor/themes/default/images/cursor_v.gif +0 -0
- package/ueditor/themes/default/images/cursor_v.png +0 -0
- package/ueditor/themes/default/images/dialog-title-bg.png +0 -0
- package/ueditor/themes/default/images/filescan.png +0 -0
- package/ueditor/themes/default/images/highlighted.gif +0 -0
- package/ueditor/themes/default/images/icons-all.gif +0 -0
- package/ueditor/themes/default/images/icons.gif +0 -0
- package/ueditor/themes/default/images/icons.png +0 -0
- package/ueditor/themes/default/images/img-cracked.png +0 -0
- package/ueditor/themes/default/images/loaderror.png +0 -0
- package/ueditor/themes/default/images/loading.gif +0 -0
- package/ueditor/themes/default/images/lock.gif +0 -0
- package/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
- package/ueditor/themes/default/images/pagebreak.gif +0 -0
- package/ueditor/themes/default/images/scale.png +0 -0
- package/ueditor/themes/default/images/sortable.png +0 -0
- package/ueditor/themes/default/images/spacer.gif +0 -0
- package/ueditor/themes/default/images/sparator_v.png +0 -0
- package/ueditor/themes/default/images/table-cell-align.png +0 -0
- package/ueditor/themes/default/images/tangram-colorpicker.png +0 -0
- package/ueditor/themes/default/images/toolbar_bg.png +0 -0
- package/ueditor/themes/default/images/unhighlighted.gif +0 -0
- package/ueditor/themes/default/images/upload.png +0 -0
- package/ueditor/themes/default/images/videologo.gif +0 -0
- package/ueditor/themes/default/images/word.gif +0 -0
- package/ueditor/themes/default/images/wordpaste.png +0 -0
- package/ueditor/themes/iframe.css +1 -0
- package/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
- package/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
- package/ueditor/third-party/codemirror/codemirror.css +104 -0
- package/ueditor/third-party/codemirror/codemirror.js +3581 -0
- package/ueditor/third-party/highcharts/adapters/mootools-adapter.js +13 -0
- package/ueditor/third-party/highcharts/adapters/mootools-adapter.src.js +313 -0
- package/ueditor/third-party/highcharts/adapters/prototype-adapter.js +15 -0
- package/ueditor/third-party/highcharts/adapters/prototype-adapter.src.js +316 -0
- package/ueditor/third-party/highcharts/adapters/standalone-framework.js +17 -0
- package/ueditor/third-party/highcharts/adapters/standalone-framework.src.js +583 -0
- package/ueditor/third-party/highcharts/highcharts-more.js +50 -0
- package/ueditor/third-party/highcharts/highcharts-more.src.js +2430 -0
- package/ueditor/third-party/highcharts/highcharts.js +283 -0
- package/ueditor/third-party/highcharts/highcharts.src.js +16974 -0
- package/ueditor/third-party/highcharts/modules/annotations.js +7 -0
- package/ueditor/third-party/highcharts/modules/annotations.src.js +401 -0
- package/ueditor/third-party/highcharts/modules/canvas-tools.js +133 -0
- package/ueditor/third-party/highcharts/modules/canvas-tools.src.js +3113 -0
- package/ueditor/third-party/highcharts/modules/data.js +17 -0
- package/ueditor/third-party/highcharts/modules/data.src.js +582 -0
- package/ueditor/third-party/highcharts/modules/drilldown.js +11 -0
- package/ueditor/third-party/highcharts/modules/drilldown.src.js +447 -0
- package/ueditor/third-party/highcharts/modules/exporting.js +22 -0
- package/ueditor/third-party/highcharts/modules/exporting.src.js +709 -0
- package/ueditor/third-party/highcharts/modules/funnel.js +12 -0
- package/ueditor/third-party/highcharts/modules/funnel.src.js +289 -0
- package/ueditor/third-party/highcharts/modules/heatmap.js +1 -0
- package/ueditor/third-party/highcharts/modules/heatmap.src.js +53 -0
- package/ueditor/third-party/highcharts/modules/map.js +27 -0
- package/ueditor/third-party/highcharts/modules/map.src.js +1002 -0
- package/ueditor/third-party/highcharts/modules/no-data-to-display.js +12 -0
- package/ueditor/third-party/highcharts/modules/no-data-to-display.src.js +128 -0
- package/ueditor/third-party/highcharts/themes/dark-blue.js +254 -0
- package/ueditor/third-party/highcharts/themes/dark-green.js +255 -0
- package/ueditor/third-party/highcharts/themes/gray.js +257 -0
- package/ueditor/third-party/highcharts/themes/grid.js +103 -0
- package/ueditor/third-party/highcharts/themes/skies.js +89 -0
- package/ueditor/third-party/jquery-1.10.2.js +9789 -0
- package/ueditor/third-party/jquery-1.10.2.min.js +6 -0
- package/ueditor/third-party/jquery-1.10.2.min.map +1 -0
- package/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
- package/ueditor/third-party/video-js/font/vjs.eot +0 -0
- package/ueditor/third-party/video-js/font/vjs.svg +65 -0
- package/ueditor/third-party/video-js/font/vjs.ttf +0 -0
- package/ueditor/third-party/video-js/font/vjs.woff +0 -0
- package/ueditor/third-party/video-js/video-js.css +766 -0
- package/ueditor/third-party/video-js/video-js.min.css +5 -0
- package/ueditor/third-party/video-js/video-js.swf +0 -0
- package/ueditor/third-party/video-js/video.dev.js +7108 -0
- package/ueditor/third-party/video-js/video.js +129 -0
- package/ueditor/third-party/webuploader/Uploader.swf +0 -0
- package/ueditor/third-party/webuploader/webuploader.css +28 -0
- package/ueditor/third-party/webuploader/webuploader.custom.js +5670 -0
- package/ueditor/third-party/webuploader/webuploader.custom.min.js +2 -0
- package/ueditor/third-party/webuploader/webuploader.flashonly.js +4176 -0
- package/ueditor/third-party/webuploader/webuploader.flashonly.min.js +2 -0
- package/ueditor/third-party/webuploader/webuploader.html5only.js +5559 -0
- package/ueditor/third-party/webuploader/webuploader.html5only.min.js +2 -0
- package/ueditor/third-party/webuploader/webuploader.js +6733 -0
- package/ueditor/third-party/webuploader/webuploader.min.js +2 -0
- package/ueditor/third-party/webuploader/webuploader.withoutimage.js +4593 -0
- package/ueditor/third-party/webuploader/webuploader.withoutimage.min.js +2 -0
- package/ueditor/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
- package/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js +9 -0
- package/ueditor/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
- package/ueditor/ueditor.all.js +32931 -0
- package/ueditor/ueditor.all.min.js +17 -0
- package/ueditor/ueditor.config.js +507 -0
- package/ueditor/ueditor.parse.js +1230 -0
- package/ueditor/ueditor.parse.min.js +5 -0
- package/vite.ts +81 -0
package/README.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @mnykj/alleditor-dual
|
|
2
|
+
|
|
3
|
+
AllEditor 双引擎(**wang / Slate** + **UE HTML**)。UEditor 静态资源已打进本包,装上即可用。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @mnykj/alleditor @mnykj/alleditor-for-vue @mnykj/alleditor-dual
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 一步挂载静态资源(必做一次)
|
|
12
|
+
|
|
13
|
+
组件默认从站点 `/ueditor/` 加载脚本。本包自带完整 `ueditor/`,用插件/模块自动挂上去即可,**无需再单独下载 UEditor**。
|
|
14
|
+
|
|
15
|
+
### Nuxt 3
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// nuxt.config.ts
|
|
19
|
+
export default defineNuxtConfig({
|
|
20
|
+
modules: ['@mnykj/alleditor-dual/nuxt'],
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Vite
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// vite.config.ts
|
|
28
|
+
import { defineConfig } from 'vite'
|
|
29
|
+
import { alleditorDualUeditor } from '@mnykj/alleditor-dual/vite'
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
plugins: [alleditorDualUeditor()],
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 使用
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<script setup>
|
|
40
|
+
import { ref } from 'vue'
|
|
41
|
+
import { DualEditor } from '@mnykj/alleditor-dual'
|
|
42
|
+
import '@mnykj/alleditor/dist/css/style.css'
|
|
43
|
+
|
|
44
|
+
const html = ref('<p>hello</p>')
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<DualEditor v-model="html" style="height: 70vh" />
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
一般不用再写 `ueditor-base`。若自建 CDN,可覆盖:
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<DualEditor v-model="html" ueditor-base="https://cdn.example.com/ueditor/" />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## HTML 协议
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<div class="alleditor-root" data-alleditor-engine="ue">…</div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
兼容旧注释 `<!--yunkee-editor:ue-html-->`。
|
|
65
|
+
|
|
66
|
+
## 开发(monorepo)
|
|
67
|
+
|
|
68
|
+
从 `other_editor/ueditor` 同步资源:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run sync:ueditor -w @mnykj/alleditor-dual
|
|
72
|
+
```
|
package/nuxt.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nuxt 模块:自动把包内 ueditor 挂到 /ueditor/(开发 + 生产 publicAssets)。
|
|
3
|
+
*
|
|
4
|
+
* // nuxt.config.ts
|
|
5
|
+
* export default defineNuxtConfig({
|
|
6
|
+
* modules: ['@mnykj/alleditor-dual/nuxt'],
|
|
7
|
+
* })
|
|
8
|
+
*/
|
|
9
|
+
import { defineNuxtModule } from '@nuxt/kit'
|
|
10
|
+
import { existsSync } from 'node:fs'
|
|
11
|
+
import { join } from 'node:path'
|
|
12
|
+
import { DEFAULT_UEDITOR_PUBLIC_BASE, getUeditorPackageDir } from './src/ueditorPaths'
|
|
13
|
+
|
|
14
|
+
export interface ModuleOptions {
|
|
15
|
+
/** 浏览器访问前缀,默认 /ueditor */
|
|
16
|
+
baseURL?: string
|
|
17
|
+
/** 是否启用,默认 true */
|
|
18
|
+
enabled?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default defineNuxtModule<ModuleOptions>({
|
|
22
|
+
meta: {
|
|
23
|
+
name: '@mnykj/alleditor-dual',
|
|
24
|
+
configKey: 'alleditorDual',
|
|
25
|
+
},
|
|
26
|
+
defaults: {
|
|
27
|
+
baseURL: 'ueditor',
|
|
28
|
+
enabled: true,
|
|
29
|
+
},
|
|
30
|
+
setup(options, nuxt) {
|
|
31
|
+
if (options.enabled === false) return
|
|
32
|
+
const dir = getUeditorPackageDir()
|
|
33
|
+
if (!existsSync(join(dir, 'ueditor.all.min.js'))) {
|
|
34
|
+
console.warn('[alleditor-dual] 包内缺少 ueditor 资源:', dir)
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const baseURL = String(options.baseURL || 'ueditor').replace(/^\/+|\/+$/g, '')
|
|
38
|
+
nuxt.options.nitro = nuxt.options.nitro || {}
|
|
39
|
+
nuxt.options.nitro.publicAssets = nuxt.options.nitro.publicAssets || []
|
|
40
|
+
nuxt.options.nitro.publicAssets.push({
|
|
41
|
+
baseURL,
|
|
42
|
+
dir,
|
|
43
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
44
|
+
})
|
|
45
|
+
// 开发时也允许 Vite 读包内文件
|
|
46
|
+
nuxt.options.vite = nuxt.options.vite || {}
|
|
47
|
+
nuxt.options.vite.server = nuxt.options.vite.server || {}
|
|
48
|
+
nuxt.options.vite.server.fs = nuxt.options.vite.server.fs || {}
|
|
49
|
+
const allow = new Set([
|
|
50
|
+
...((nuxt.options.vite.server.fs.allow as string[]) || []),
|
|
51
|
+
dir,
|
|
52
|
+
])
|
|
53
|
+
nuxt.options.vite.server.fs.allow = [...allow]
|
|
54
|
+
|
|
55
|
+
// 标记默认 public base,供运行时可选读取
|
|
56
|
+
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {}
|
|
57
|
+
;(nuxt.options.runtimeConfig.public as any).alleditorUeditorBase =
|
|
58
|
+
`/${baseURL}/` || DEFAULT_UEDITOR_PUBLIC_BASE
|
|
59
|
+
},
|
|
60
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mnykj/alleditor-dual",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@mnykj/alleditor-dual",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "AllEditor dual-engine (wang + UE HTML) Vue3 components, with bundled UEditor static assets",
|
|
5
|
+
"author": "mnykj",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./src/index.ts",
|
|
9
|
+
"module": "./src/index.ts",
|
|
10
|
+
"types": "./src/index.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.ts",
|
|
13
|
+
"./UeHtmlEngine.vue": "./src/UeHtmlEngine.vue",
|
|
14
|
+
"./DualEditor.vue": "./src/DualEditor.vue",
|
|
15
|
+
"./vite": "./vite.ts",
|
|
16
|
+
"./nuxt": "./nuxt.ts",
|
|
17
|
+
"./ueditor/*": "./ueditor/*"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"src",
|
|
21
|
+
"ueditor",
|
|
22
|
+
"vite.ts",
|
|
23
|
+
"nuxt.ts",
|
|
24
|
+
"README.md",
|
|
25
|
+
"scripts"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"AllEditor",
|
|
29
|
+
"alleditor",
|
|
30
|
+
"dual-engine",
|
|
31
|
+
"ueditor",
|
|
32
|
+
"vue3",
|
|
33
|
+
"mnykj"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mnykj/alleditor": "^1.1.0",
|
|
41
|
+
"@mnykj/alleditor-for-vue": "^1.1.0",
|
|
42
|
+
"vue": "^3.0.5",
|
|
43
|
+
"vite": ">=4",
|
|
44
|
+
"@nuxt/kit": ">=3"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"vite": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"@nuxt/kit": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"sync:ueditor": "node ./scripts/sync-ueditor.mjs",
|
|
56
|
+
"prepack": "node ./scripts/sync-ueditor.mjs",
|
|
57
|
+
"build": "node -e \"console.log('@mnykj/alleditor-dual ships Vue/TS source + ueditor assets; no bundle step')\""
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从 monorepo 的 other_editor/ueditor 构建产物同步到本包 ueditor/,便于发 npm。
|
|
3
|
+
* 若源不存在但包内已有资源,则跳过(方便纯发包场景)。
|
|
4
|
+
*/
|
|
5
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs'
|
|
6
|
+
import { dirname, join, resolve } from 'node:path'
|
|
7
|
+
import { fileURLToPath } from 'node:url'
|
|
8
|
+
|
|
9
|
+
const dualRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
10
|
+
const dest = join(dualRoot, 'ueditor')
|
|
11
|
+
const src = resolve(dualRoot, '../../../other_editor/ueditor/dist/utf8-php')
|
|
12
|
+
const destOk = existsSync(join(dest, 'ueditor.all.min.js'))
|
|
13
|
+
const srcOk = existsSync(join(src, 'ueditor.all.min.js'))
|
|
14
|
+
|
|
15
|
+
if (!srcOk) {
|
|
16
|
+
if (destOk) {
|
|
17
|
+
console.log('[sync-ueditor] 源不存在,保留包内已有 ueditor/', dest)
|
|
18
|
+
process.exit(0)
|
|
19
|
+
}
|
|
20
|
+
console.error('[sync-ueditor] 未找到源产物且包内无资源')
|
|
21
|
+
console.error(' 源:', join(src, 'ueditor.all.min.js'))
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
rmSync(dest, { recursive: true, force: true })
|
|
26
|
+
mkdirSync(dest, { recursive: true })
|
|
27
|
+
cpSync(src, dest, { recursive: true })
|
|
28
|
+
console.log('[sync-ueditor] synced ->', dest)
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
/**
|
|
3
|
+
* AllEditor 双引擎门面:按 HTML 协议自动选 wang / ue,共用 wang 工具栏。
|
|
4
|
+
*
|
|
5
|
+
* v-model 存「可入库」HTML(UE 模式会包 data-alleditor-engine 根节点)。
|
|
6
|
+
* 宿主需自行提供 UEditor 静态资源(默认 /ueditor/)。
|
|
7
|
+
*/
|
|
8
|
+
import {
|
|
9
|
+
computed,
|
|
10
|
+
nextTick,
|
|
11
|
+
onBeforeUnmount,
|
|
12
|
+
ref,
|
|
13
|
+
shallowRef,
|
|
14
|
+
watch,
|
|
15
|
+
} from 'vue'
|
|
16
|
+
import { Editor, Toolbar } from '@mnykj/alleditor-for-vue'
|
|
17
|
+
import {
|
|
18
|
+
detectEditorEngine,
|
|
19
|
+
unwrapEditorEngineHtml,
|
|
20
|
+
wrapEditorEngineHtml,
|
|
21
|
+
} from '@mnykj/alleditor'
|
|
22
|
+
import UeHtmlEngine from './UeHtmlEngine.vue'
|
|
23
|
+
import { bindUeToolbarAdapter } from './ueToolbar'
|
|
24
|
+
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
modelValue: { type: String, default: '' },
|
|
27
|
+
mode: { type: String, default: 'default' },
|
|
28
|
+
disabled: { type: Boolean, default: false },
|
|
29
|
+
ueditorBase: { type: String, default: '/ueditor/' },
|
|
30
|
+
toolbarConfig: { type: Object, default: () => ({}) },
|
|
31
|
+
editorConfig: { type: Object, default: () => ({}) },
|
|
32
|
+
/** wang 占位正文(UE 模式下避免把高保真 HTML 喂进 Slate) */
|
|
33
|
+
wangPlaceholder: { type: String, default: '<p><br></p>' },
|
|
34
|
+
/** 仅当引擎为 ue 时才写外层 div(推荐;wang 正文保持干净) */
|
|
35
|
+
wrapOnlyWhenUe: { type: Boolean, default: true },
|
|
36
|
+
toolbarSelector: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: '.alleditor-dual .w-e-toolbar, .alleditor-dual .editor-toolbar',
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const emit = defineEmits([
|
|
43
|
+
'update:modelValue',
|
|
44
|
+
'change',
|
|
45
|
+
'engine-change',
|
|
46
|
+
'wang-created',
|
|
47
|
+
'ue-created',
|
|
48
|
+
'ue-ready',
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
/** @type {import('vue').Ref<'wang' | 'ue'>} */
|
|
52
|
+
const engineMode = ref(detectEditorEngine(props.modelValue))
|
|
53
|
+
const rootRef = ref(null)
|
|
54
|
+
const wangEditorRef = shallowRef(null)
|
|
55
|
+
const ueEngineRef = shallowRef(null)
|
|
56
|
+
const wangHtml = ref(props.wangPlaceholder)
|
|
57
|
+
const ueHtml = ref('')
|
|
58
|
+
let toolbarBinding = null
|
|
59
|
+
let applyingExternal = false
|
|
60
|
+
|
|
61
|
+
const useUe = computed(() => engineMode.value === 'ue')
|
|
62
|
+
|
|
63
|
+
function bodyOf(html) {
|
|
64
|
+
return unwrapEditorEngineHtml(html || '') || '<p><br></p>'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function encodeForModel(rawBody) {
|
|
68
|
+
const body = String(rawBody ?? '').trim() || '<p><br></p>'
|
|
69
|
+
if (engineMode.value === 'ue') {
|
|
70
|
+
return wrapEditorEngineHtml(body, 'ue', {
|
|
71
|
+
onlyWhenUe: props.wrapOnlyWhenUe,
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
if (props.wrapOnlyWhenUe) return body
|
|
75
|
+
return wrapEditorEngineHtml(body, 'wang')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function emitModel(rawBody) {
|
|
79
|
+
const next = encodeForModel(rawBody)
|
|
80
|
+
emit('update:modelValue', next)
|
|
81
|
+
emit('change', next, engineMode.value)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function applyIncoming(html, { forceEngine } = {}) {
|
|
85
|
+
applyingExternal = true
|
|
86
|
+
try {
|
|
87
|
+
const nextEngine = forceEngine || detectEditorEngine(html)
|
|
88
|
+
const body = bodyOf(html)
|
|
89
|
+
if (nextEngine !== engineMode.value) {
|
|
90
|
+
engineMode.value = nextEngine
|
|
91
|
+
emit('engine-change', nextEngine)
|
|
92
|
+
}
|
|
93
|
+
if (nextEngine === 'ue') {
|
|
94
|
+
wangHtml.value = props.wangPlaceholder
|
|
95
|
+
ueHtml.value = body
|
|
96
|
+
ueEngineRef.value?.setContent?.(body)
|
|
97
|
+
nextTick(() => bindToolbar())
|
|
98
|
+
} else {
|
|
99
|
+
unbindToolbar()
|
|
100
|
+
ueHtml.value = ''
|
|
101
|
+
wangHtml.value = body
|
|
102
|
+
}
|
|
103
|
+
} finally {
|
|
104
|
+
applyingExternal = false
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function bindToolbar() {
|
|
109
|
+
unbindToolbar()
|
|
110
|
+
toolbarBinding = bindUeToolbarAdapter({
|
|
111
|
+
toolbar: props.toolbarSelector,
|
|
112
|
+
getUe: () => ueEngineRef.value,
|
|
113
|
+
shouldCapture: () => engineMode.value === 'ue',
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function unbindToolbar() {
|
|
118
|
+
toolbarBinding?.unbind?.()
|
|
119
|
+
toolbarBinding = null
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function onWangCreated(editor) {
|
|
123
|
+
wangEditorRef.value = editor
|
|
124
|
+
emit('wang-created', editor)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function onWangChange(editor) {
|
|
128
|
+
if (applyingExternal || engineMode.value !== 'wang') return
|
|
129
|
+
try {
|
|
130
|
+
emitModel(editor.getHtml?.() || wangHtml.value)
|
|
131
|
+
} catch {
|
|
132
|
+
emitModel(wangHtml.value)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function onUeUpdate(html) {
|
|
137
|
+
if (applyingExternal || engineMode.value !== 'ue') return
|
|
138
|
+
ueHtml.value = html
|
|
139
|
+
emitModel(html)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function onUeReady(ue) {
|
|
143
|
+
emit('ue-ready', ue)
|
|
144
|
+
bindToolbar()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function onUeCreated(ue) {
|
|
148
|
+
emit('ue-created', ue)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function getHtml() {
|
|
152
|
+
if (engineMode.value === 'ue') {
|
|
153
|
+
const raw =
|
|
154
|
+
ueEngineRef.value?.getContent?.() ?? ueHtml.value ?? ''
|
|
155
|
+
return encodeForModel(raw)
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
return encodeForModel(wangEditorRef.value?.getHtml?.() || wangHtml.value)
|
|
159
|
+
} catch {
|
|
160
|
+
return encodeForModel(wangHtml.value)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function setHtml(html, options = {}) {
|
|
165
|
+
applyIncoming(html, options)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function getEngineMode() {
|
|
169
|
+
return engineMode.value
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** 强制切引擎(导入 HTML 等场景) */
|
|
173
|
+
function setEngineMode(mode, html) {
|
|
174
|
+
const next = mode === 'ue' ? 'ue' : 'wang'
|
|
175
|
+
const raw = html !== undefined ? html : getHtml()
|
|
176
|
+
const body = bodyOf(raw)
|
|
177
|
+
applyIncoming(
|
|
178
|
+
next === 'ue'
|
|
179
|
+
? wrapEditorEngineHtml(body, 'ue')
|
|
180
|
+
: body,
|
|
181
|
+
{ forceEngine: next }
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
watch(
|
|
186
|
+
() => props.modelValue,
|
|
187
|
+
(html) => {
|
|
188
|
+
if (applyingExternal) return
|
|
189
|
+
const incomingEngine = detectEditorEngine(html)
|
|
190
|
+
const incomingBody = bodyOf(html)
|
|
191
|
+
const currentBody =
|
|
192
|
+
engineMode.value === 'ue'
|
|
193
|
+
? bodyOf(ueHtml.value)
|
|
194
|
+
: bodyOf(wangHtml.value)
|
|
195
|
+
if (
|
|
196
|
+
incomingEngine === engineMode.value &&
|
|
197
|
+
incomingBody === currentBody
|
|
198
|
+
) {
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
applyIncoming(html)
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
watch(engineMode, (mode) => {
|
|
206
|
+
if (mode === 'ue') nextTick(() => bindToolbar())
|
|
207
|
+
else unbindToolbar()
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
applyIncoming(props.modelValue)
|
|
211
|
+
|
|
212
|
+
onBeforeUnmount(() => {
|
|
213
|
+
unbindToolbar()
|
|
214
|
+
const ed = wangEditorRef.value
|
|
215
|
+
if (ed && !ed.isDestroyed) {
|
|
216
|
+
try {
|
|
217
|
+
ed.destroy()
|
|
218
|
+
} catch {
|
|
219
|
+
/* ignore */
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
defineExpose({
|
|
225
|
+
getHtml,
|
|
226
|
+
setHtml,
|
|
227
|
+
getEngineMode,
|
|
228
|
+
setEngineMode,
|
|
229
|
+
getWangEditor: () => wangEditorRef.value,
|
|
230
|
+
getUeEngine: () => ueEngineRef.value,
|
|
231
|
+
engineMode,
|
|
232
|
+
})
|
|
233
|
+
</script>
|
|
234
|
+
|
|
235
|
+
<template>
|
|
236
|
+
<div ref="rootRef" class="alleditor-dual" :data-engine="engineMode">
|
|
237
|
+
<Toolbar
|
|
238
|
+
v-if="wangEditorRef"
|
|
239
|
+
:editor="wangEditorRef"
|
|
240
|
+
:default-config="toolbarConfig"
|
|
241
|
+
:mode="mode"
|
|
242
|
+
class="alleditor-dual__toolbar editor-toolbar"
|
|
243
|
+
/>
|
|
244
|
+
<div class="alleditor-dual__body">
|
|
245
|
+
<!-- UE 时离屏挂着 wang,避免 display:none 破坏 TextArea / Toolbar 绑定 -->
|
|
246
|
+
<Editor
|
|
247
|
+
v-model="wangHtml"
|
|
248
|
+
:default-config="editorConfig"
|
|
249
|
+
:mode="mode"
|
|
250
|
+
class="alleditor-dual__wang"
|
|
251
|
+
:class="{ 'is-wang-parked': useUe }"
|
|
252
|
+
@onCreated="onWangCreated"
|
|
253
|
+
@onChange="onWangChange"
|
|
254
|
+
/>
|
|
255
|
+
<div v-if="useUe" class="alleditor-dual__ue-wrap">
|
|
256
|
+
<UeHtmlEngine
|
|
257
|
+
ref="ueEngineRef"
|
|
258
|
+
v-model="ueHtml"
|
|
259
|
+
:disabled="disabled"
|
|
260
|
+
:ueditor-base="ueditorBase"
|
|
261
|
+
class="alleditor-dual__ue"
|
|
262
|
+
@created="onUeCreated"
|
|
263
|
+
@ready="onUeReady"
|
|
264
|
+
@update:model-value="onUeUpdate"
|
|
265
|
+
@change="onUeUpdate"
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
</template>
|
|
271
|
+
|
|
272
|
+
<style>
|
|
273
|
+
.alleditor-dual {
|
|
274
|
+
display: flex;
|
|
275
|
+
flex-direction: column;
|
|
276
|
+
width: 100%;
|
|
277
|
+
height: 100%;
|
|
278
|
+
min-height: 0;
|
|
279
|
+
background: #fff;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.alleditor-dual__toolbar {
|
|
283
|
+
flex-shrink: 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.alleditor-dual__body {
|
|
287
|
+
position: relative;
|
|
288
|
+
flex: 1 1 0;
|
|
289
|
+
min-height: 0;
|
|
290
|
+
display: flex;
|
|
291
|
+
flex-direction: column;
|
|
292
|
+
overflow: hidden;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.alleditor-dual__wang {
|
|
296
|
+
flex: 1 1 0;
|
|
297
|
+
min-height: 0;
|
|
298
|
+
height: 100%;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.alleditor-dual__wang.is-wang-parked {
|
|
302
|
+
position: absolute !important;
|
|
303
|
+
left: -10000px !important;
|
|
304
|
+
top: 0 !important;
|
|
305
|
+
width: 800px !important;
|
|
306
|
+
height: 400px !important;
|
|
307
|
+
margin: 0 !important;
|
|
308
|
+
padding: 0 !important;
|
|
309
|
+
overflow: hidden !important;
|
|
310
|
+
opacity: 0 !important;
|
|
311
|
+
visibility: hidden !important;
|
|
312
|
+
pointer-events: none !important;
|
|
313
|
+
flex: none !important;
|
|
314
|
+
z-index: -1;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.alleditor-dual__ue-wrap {
|
|
318
|
+
flex: 1 1 0;
|
|
319
|
+
min-height: 0;
|
|
320
|
+
height: 100%;
|
|
321
|
+
display: flex;
|
|
322
|
+
flex-direction: column;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.alleditor-dual__ue {
|
|
326
|
+
flex: 1 1 0;
|
|
327
|
+
min-height: 0;
|
|
328
|
+
height: 100%;
|
|
329
|
+
}
|
|
330
|
+
</style>
|