fx-platform-ui 0.0.13-alpha7 → 0.0.13-alpha8
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/lib/fx-platform-ui.mjs +31482 -60028
- package/lib/fx-platform-ui.umd.js +68 -110
- package/lib/packages/components/editor/src/hook/index.d.ts +1 -0
- package/lib/packages/components/editor/src/hook/useEditorState.d.ts +28 -0
- package/lib/packages/components/editor/src/index.vue.d.ts +20 -28
- package/lib/packages/components/editor/src/plat-editor-emits.d.ts +1 -0
- package/lib/packages/components/editor/src/plat-editor-props.d.ts +37 -0
- package/lib/packages/components/editor/src/type/index.d.ts +10 -0
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/components/editor/src/index.vue +65 -147
|
@@ -1,167 +1,85 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<editor
|
|
3
|
-
:
|
|
4
|
-
|
|
5
|
-
:init="init"
|
|
6
|
-
:disabled="disabled"
|
|
7
|
-
></editor>
|
|
2
|
+
<div class="fx-editor">
|
|
3
|
+
<editor v-model="modelValue" :init="init" :disabled="disabled"></editor>
|
|
4
|
+
</div>
|
|
8
5
|
</template>
|
|
9
6
|
|
|
10
|
-
<script
|
|
11
|
-
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { onMounted, watch, ref } from 'vue'
|
|
12
9
|
//在js中引入所需的主题和组件
|
|
13
10
|
import tinymce from 'tinymce/tinymce'
|
|
14
|
-
import 'tinymce/skins/content/default/content.css'
|
|
15
|
-
import Editor from '@tinymce/tinymce-vue'
|
|
16
|
-
import 'tinymce/themes/silver'
|
|
17
|
-
import 'tinymce/themes/silver/theme'
|
|
18
|
-
import 'tinymce/icons/default' //引入编辑器图标icon,不引入则不显示对应图标
|
|
19
|
-
import 'tinymce/models/dom' // 这里是个坑 一定要引入
|
|
11
|
+
// import 'tinymce/skins/content/default/content.css'
|
|
12
|
+
// import Editor from '@tinymce/tinymce-vue'
|
|
13
|
+
// import 'tinymce/themes/silver'
|
|
14
|
+
// import 'tinymce/themes/silver/theme'
|
|
15
|
+
// import 'tinymce/icons/default' //引入编辑器图标icon,不引入则不显示对应图标
|
|
16
|
+
// import 'tinymce/models/dom' // 这里是个坑 一定要引入
|
|
17
|
+
//
|
|
18
|
+
// //在TinyMce.vue中接着引入相关插件
|
|
19
|
+
// import 'tinymce/icons/default/icons'
|
|
20
|
+
// import 'tinymce/plugins/image' // 插入上传图片插件
|
|
21
|
+
// import 'tinymce/plugins/media' // 插入视频插件
|
|
22
|
+
// import 'tinymce/plugins/table' // 插入表格插件
|
|
23
|
+
// import 'tinymce/plugins/lists' // 列表插件
|
|
24
|
+
// import 'tinymce/plugins/wordcount' // 字数统计插件
|
|
25
|
+
// import 'tinymce/plugins/code' // 源码
|
|
26
|
+
// import 'tinymce/plugins/fullscreen' //全屏
|
|
27
|
+
// import 'tinymce/plugins/pagebreak' //插入分页符
|
|
28
|
+
// import 'tinymce/plugins/codesample'
|
|
29
|
+
// import 'tinymce/plugins/searchreplace'
|
|
30
|
+
// import 'tinymce/plugins/link'
|
|
31
|
+
// import 'tinymce/plugins/autolink'
|
|
32
|
+
// import 'tinymce/plugins/anchor'
|
|
20
33
|
|
|
21
|
-
|
|
22
|
-
import '
|
|
23
|
-
|
|
24
|
-
// import "tinymce/plugins/media" // 插入视频插件
|
|
25
|
-
import 'tinymce/plugins/table' // 插入表格插件
|
|
26
|
-
import 'tinymce/plugins/lists' // 列表插件
|
|
27
|
-
import 'tinymce/plugins/wordcount' // 字数统计插件
|
|
28
|
-
import 'tinymce/plugins/code' // 源码
|
|
29
|
-
// import "tinymce/plugins/fullscreen" //全屏
|
|
30
|
-
|
|
31
|
-
//接下来定义编辑器所需要的插件数据
|
|
32
|
-
import { reactive, ref } from 'vue'
|
|
33
|
-
import { onMounted, defineEmits, watch } from 'vue'
|
|
34
|
-
import axios from 'axios'
|
|
35
|
-
// import { updateImg } from '@/api/order/order'
|
|
34
|
+
import { platEditorProps } from './plat-editor-props'
|
|
35
|
+
import { platEditorEmits } from './plat-editor-emits'
|
|
36
|
+
import { useEditorState } from './hook'
|
|
36
37
|
defineOptions({
|
|
37
38
|
name: 'PlEditor'
|
|
38
39
|
})
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const props = defineProps({
|
|
42
|
-
value: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: () => {
|
|
45
|
-
return ''
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
baseUrl: {
|
|
49
|
-
type: String,
|
|
50
|
-
default: ''
|
|
51
|
-
},
|
|
52
|
-
disabled: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: false
|
|
55
|
-
},
|
|
56
|
-
plugins: {
|
|
57
|
-
type: [String, Array],
|
|
58
|
-
default: 'lists table'
|
|
59
|
-
}, //必填
|
|
60
|
-
toolbar: {
|
|
61
|
-
type: [String, Array],
|
|
62
|
-
default:
|
|
63
|
-
'codesample bold italic underline alignleft aligncenter alignright alignjustify | undo redo | formatselect | fontselect | fontsizeselect | forecolor backcolor | bullist numlist outdent indent | lists link table code | removeformat '
|
|
64
|
-
} //必填
|
|
65
|
-
})
|
|
66
|
-
//用于接收外部传递进来的富文本
|
|
67
|
-
const myValue = ref(props.value)
|
|
68
|
-
const tinymceId = ref(
|
|
69
|
-
`vue-tinymce-${+new Date()}${(Math.random() * 1000).toFixed(0)}`
|
|
70
|
-
)
|
|
71
|
-
//定义一个对象 init初始化
|
|
72
|
-
const init = reactive({
|
|
73
|
-
selector: `#${tinymceId.value}`, //富文本编辑器的id,
|
|
74
|
-
language_url: '/tinymce/langs/zh_CN.js', // 语言包的路径,具体路径看自己的项目,文档后面附上中文js文件
|
|
75
|
-
language: 'zh_CN', //语言
|
|
76
|
-
skin_url: '/tinymce/skins/ui/oxide', // skin路径,具体路径看自己的项目
|
|
77
|
-
height: 400, //编辑器高度
|
|
78
|
-
branding: false, //是否禁用“Powered by TinyMCE”
|
|
79
|
-
menubar: true, //顶部菜单栏显示
|
|
80
|
-
image_dimensions: false, //去除宽高属性
|
|
81
|
-
plugins: props.plugins, //这里的数据是在props里面就定义好了的
|
|
82
|
-
toolbar: props.toolbar, //这里的数据是在props里面就定义好了的
|
|
83
|
-
font_formats:
|
|
84
|
-
'Arial=arial,helvetica,sans-serif; 宋体=SimSun; 微软雅黑=Microsoft Yahei; Impact=impact,chicago;', //字体
|
|
85
|
-
fontsize_formats: '11px 12px 14px 16px 18px 24px 36px 48px 64px 72px', //文字大小
|
|
86
|
-
// paste_convert_word_fake_lists: false, // 插入word文档需要该属性
|
|
87
|
-
paste_webkit_styles: 'all',
|
|
88
|
-
paste_merge_formats: true,
|
|
89
|
-
nonbreaking_force_tab: false,
|
|
90
|
-
paste_auto_cleanup_on_paste: false,
|
|
91
|
-
file_picker_types: 'file',
|
|
92
|
-
content_css: '/tinymce/skins/content/default/content.css', //以css文件方式自定义可编辑区域的css样式,css文件需自己创建并引入
|
|
93
|
-
//图片上传
|
|
94
|
-
images_upload_handler: (blobInfo, progress) =>
|
|
95
|
-
new Promise((resolve, reject) => {
|
|
96
|
-
if (blobInfo.blob().size / 1024 / 1024 > 2) {
|
|
97
|
-
reject({ message: '上传失败,图片大小请控制在 2M 以内', remove: true })
|
|
98
|
-
return
|
|
99
|
-
} else {
|
|
100
|
-
const ph = `${import.meta.env.VITE_BASE_PATH}:${
|
|
101
|
-
import.meta.env.VITE_SERVER_PORT
|
|
102
|
-
}/`
|
|
103
|
-
const params = new FormData()
|
|
104
|
-
params.append('file', blobInfo.blob())
|
|
40
|
+
const props = defineProps(platEditorProps)
|
|
41
|
+
const emit = defineEmits(platEditorEmits)
|
|
105
42
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'Content-Type': 'multipart/form-data'
|
|
109
|
-
}
|
|
110
|
-
}
|
|
43
|
+
const { init, modelValue } = useEditorState(props)
|
|
44
|
+
const editorBorder = ref('1px solid #d9d9d9')
|
|
111
45
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
.catch(() => {
|
|
123
|
-
reject('上传出错,服务器开小差了呢')
|
|
124
|
-
return
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
}),
|
|
46
|
+
watch(
|
|
47
|
+
() => modelValue.value,
|
|
48
|
+
(val) => {
|
|
49
|
+
emit('update:value', val)
|
|
50
|
+
emit('change', val)
|
|
51
|
+
}
|
|
52
|
+
)
|
|
128
53
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
callback('mypage.html', { text: 'My text' })
|
|
134
|
-
}
|
|
54
|
+
// 添加红色边框
|
|
55
|
+
const addValidate = (border = '1px solid #ff4d4f') => {
|
|
56
|
+
editorBorder.value = border
|
|
57
|
+
}
|
|
135
58
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
59
|
+
// 取消红色边框
|
|
60
|
+
const removeValidate = (border = '1px solid #d9d9d9') => {
|
|
61
|
+
editorBorder.value = border
|
|
62
|
+
}
|
|
140
63
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
64
|
+
const instance = {
|
|
65
|
+
...props,
|
|
66
|
+
addValidate,
|
|
67
|
+
removeValidate
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
defineExpose(instance)
|
|
147
71
|
|
|
148
|
-
//监听外部传递进来的的数据变化
|
|
149
|
-
watch(
|
|
150
|
-
() => props.value,
|
|
151
|
-
() => {
|
|
152
|
-
myValue.value = props.value
|
|
153
|
-
emits('getContent', myValue.value)
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
//监听富文本中的数据变化
|
|
157
|
-
watch(
|
|
158
|
-
() => myValue.value,
|
|
159
|
-
() => {
|
|
160
|
-
emits('getContent', myValue.value)
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
72
|
//在onMounted中初始化编辑器
|
|
164
73
|
onMounted(() => {
|
|
165
74
|
tinymce.init({})
|
|
166
75
|
})
|
|
167
76
|
</script>
|
|
77
|
+
<style lang="less" scoped>
|
|
78
|
+
:deep(.tox-tinymce) {
|
|
79
|
+
border: v-bind(editorBorder);
|
|
80
|
+
border-radius: 2px;
|
|
81
|
+
}
|
|
82
|
+
:deep(.tox-tinymce-aux) {
|
|
83
|
+
z-index: 1000;
|
|
84
|
+
}
|
|
85
|
+
</style>
|