cloud-web-corejs 1.1.0-dev.62 → 1.1.0-dev.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Tinymce/index.vue +59 -6
- package/src/components/xform/form-designer/form-widget/field-widget/rich-editor-widget.vue +67 -26
- package/src/components/xform/form-designer/setting-panel/property-editor/contentHeight-editor.vue +23 -0
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +46 -0
- package/src/components/xform/form-render/indexMixin.js +1 -0
- package/src/components/xform/lang/en-US.js +1 -0
- package/src/components/xform/lang/zh-CN.js +1 -0
- package/src/components/xform/utils/sfc-generator.js +5 -3
package/package.json
CHANGED
|
@@ -43,6 +43,24 @@ import plugins from "./plugins";
|
|
|
43
43
|
import toolbar from "./toolbar";
|
|
44
44
|
import load from "./dynamicLoadScript";
|
|
45
45
|
import { richTextResourcePath } from "../../utils/featureResources";
|
|
46
|
+
|
|
47
|
+
function isBlankRichText(val) {
|
|
48
|
+
if (val == null) return true;
|
|
49
|
+
const html = String(val);
|
|
50
|
+
if (!html.trim()) return true;
|
|
51
|
+
const text = html
|
|
52
|
+
.replace(/<br\s*\/?>/gi, "")
|
|
53
|
+
.replace(/ /gi, " ")
|
|
54
|
+
.replace(/<[^>]+>/g, "")
|
|
55
|
+
.trim();
|
|
56
|
+
if (text) return false;
|
|
57
|
+
return !/<(img|video|audio|iframe|table|hr)\b/i.test(html);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function sameRichText(a, b) {
|
|
61
|
+
if ((a || "") === (b || "")) return true;
|
|
62
|
+
return isBlankRichText(a) && isBlankRichText(b);
|
|
63
|
+
}
|
|
46
64
|
// import EditorImage from './components/EditorImage.vue'
|
|
47
65
|
|
|
48
66
|
// why use this cdn, detail see https://github.com/PanJiaChen/tinymce-all-in-one
|
|
@@ -98,6 +116,7 @@ export default {
|
|
|
98
116
|
initializing: false,
|
|
99
117
|
initGeneration: 0,
|
|
100
118
|
hasChange: false,
|
|
119
|
+
applyingExternal: false,
|
|
101
120
|
hasInit: false,
|
|
102
121
|
isActivated: true,
|
|
103
122
|
tinymceId: this.id,
|
|
@@ -122,12 +141,13 @@ export default {
|
|
|
122
141
|
},
|
|
123
142
|
watch: {
|
|
124
143
|
value(val) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
this.syncEditorContent(val);
|
|
145
|
+
},
|
|
146
|
+
readonly() {
|
|
147
|
+
this.applyReadonly();
|
|
148
|
+
},
|
|
149
|
+
height() {
|
|
150
|
+
this.applyHeight();
|
|
131
151
|
},
|
|
132
152
|
},
|
|
133
153
|
mounted() {
|
|
@@ -222,10 +242,19 @@ export default {
|
|
|
222
242
|
}
|
|
223
243
|
_this.hasInit = true;
|
|
224
244
|
_this.initializing = false;
|
|
245
|
+
_this.applyReadonly();
|
|
246
|
+
_this.applyHeight();
|
|
225
247
|
editor.on("NodeChange Change KeyUp SetContent", () => {
|
|
248
|
+
if (this.applyingExternal) return;
|
|
226
249
|
this.hasChange = true;
|
|
227
250
|
this.$emit("input", editor.getContent());
|
|
228
251
|
});
|
|
252
|
+
editor.on("focus", (event) => {
|
|
253
|
+
this.$emit("focus", event);
|
|
254
|
+
});
|
|
255
|
+
editor.on("blur", (event) => {
|
|
256
|
+
this.$emit("blur", event);
|
|
257
|
+
});
|
|
229
258
|
},
|
|
230
259
|
setup(editor) {
|
|
231
260
|
editor.on("FullscreenStateChanged", (e) => {
|
|
@@ -309,6 +338,30 @@ export default {
|
|
|
309
338
|
}
|
|
310
339
|
}
|
|
311
340
|
},
|
|
341
|
+
syncEditorContent(val) {
|
|
342
|
+
if (!this.hasInit || this.applyingExternal) return;
|
|
343
|
+
this.$nextTick(() => {
|
|
344
|
+
const editor = window.tinymce && window.tinymce.get(this.tinymceId);
|
|
345
|
+
if (!editor || this.applyingExternal) return;
|
|
346
|
+
const incoming = val == null ? "" : String(val);
|
|
347
|
+
if (sameRichText(incoming, editor.getContent())) return;
|
|
348
|
+
this.applyingExternal = true;
|
|
349
|
+
editor.setContent(incoming);
|
|
350
|
+
this.applyingExternal = false;
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
applyReadonly() {
|
|
354
|
+
const editor = window.tinymce && window.tinymce.get(this.tinymceId);
|
|
355
|
+
if (editor && typeof editor.setMode === "function") {
|
|
356
|
+
editor.setMode(this.readonly ? "readonly" : "design");
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
applyHeight() {
|
|
360
|
+
const editor = window.tinymce && window.tinymce.get(this.tinymceId);
|
|
361
|
+
const height = parseInt(this.height, 10);
|
|
362
|
+
if (!editor || !editor.iframeElement || !height) return;
|
|
363
|
+
editor.iframeElement.style.height = height + "px";
|
|
364
|
+
},
|
|
312
365
|
setContent(value) {
|
|
313
366
|
const editor = window.tinymce && window.tinymce.get(this.tinymceId);
|
|
314
367
|
if (editor) editor.setContent(value);
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<form-item-wrapper :designer="designer" :field="field" :rules="rules" :design-state="designState"
|
|
3
3
|
:parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
|
|
4
4
|
:sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
<div class="rich-editor-host">
|
|
6
|
+
<tinymce ref="fieldEditor" :value="designState ? '' : (fieldModel || '')" :readonly="!designState && isReadonly"
|
|
7
|
+
:height="editorHeight" @input="handleRichEditorInput" @focus="handleRichEditorFocus"
|
|
8
|
+
@blur="handleRichEditorBlur">
|
|
9
|
+
</tinymce>
|
|
10
|
+
<div v-if="designState" class="rich-editor-mask"></div>
|
|
11
|
+
</div>
|
|
12
|
+
</form-item-wrapper>
|
|
11
13
|
</template>
|
|
12
14
|
|
|
13
15
|
<script>
|
|
14
16
|
import FormItemWrapper from './form-item-wrapper'
|
|
15
|
-
/* import {VueEditor} from 'vue2-editor'//vue2-editor */
|
|
16
17
|
import emitter from '../../../../../components/xform/utils/emitter'
|
|
17
18
|
import i18n from "../../../../../components/xform/utils/i18n"
|
|
18
19
|
import {deepClone} from "../../../../../components/xform/utils/util"
|
|
19
20
|
import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin"
|
|
20
21
|
|
|
22
|
+
function isBlankRichText(val) {
|
|
23
|
+
if (val == null) return true
|
|
24
|
+
const html = String(val)
|
|
25
|
+
if (!html.trim()) return true
|
|
26
|
+
const text = html
|
|
27
|
+
.replace(/<br\s*\/?>/gi, "")
|
|
28
|
+
.replace(/ /gi, " ")
|
|
29
|
+
.replace(/<[^>]+>/g, "")
|
|
30
|
+
.trim()
|
|
31
|
+
if (text) return false
|
|
32
|
+
return !/<(img|video|audio|iframe|table|hr)\b/i.test(html)
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
export default {
|
|
22
36
|
name: "rich-editor-widget",
|
|
23
37
|
componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
|
|
@@ -50,10 +64,7 @@
|
|
|
50
64
|
},
|
|
51
65
|
components: {
|
|
52
66
|
FormItemWrapper,
|
|
53
|
-
|
|
54
|
-
// VueEditor: resolve => { //懒加载!!
|
|
55
|
-
// require(['vue2-editor'], ({VueEditor}) => resolve(VueEditor))
|
|
56
|
-
// }
|
|
67
|
+
Tinymce: () => import('@base/components/Tinymce'),
|
|
57
68
|
},
|
|
58
69
|
inject: ['refList', 'globalOptionData', 'globalModel'],
|
|
59
70
|
data() {
|
|
@@ -61,13 +72,17 @@
|
|
|
61
72
|
oldFieldValue: null, //field组件change之前的值
|
|
62
73
|
fieldModel: null,
|
|
63
74
|
rules: [],
|
|
64
|
-
|
|
65
|
-
customToolbar: [], //富文本编辑器自定义工具栏
|
|
66
|
-
valueChangedFlag: false, //vue2-editor数据值是否改变标志
|
|
75
|
+
changeTimer: null,
|
|
67
76
|
}
|
|
68
77
|
},
|
|
69
78
|
computed: {
|
|
70
|
-
|
|
79
|
+
isReadonly() {
|
|
80
|
+
return !!(this.field.options.readonly || this.field.options.disabled)
|
|
81
|
+
},
|
|
82
|
+
editorHeight() {
|
|
83
|
+
const height = Number(this.field.options.contentHeight)
|
|
84
|
+
return height > 0 ? height : 300
|
|
85
|
+
},
|
|
71
86
|
},
|
|
72
87
|
beforeCreate() {
|
|
73
88
|
/* 这里不能访问方法和属性!! */
|
|
@@ -89,24 +104,40 @@
|
|
|
89
104
|
},
|
|
90
105
|
|
|
91
106
|
beforeDestroy() {
|
|
107
|
+
clearTimeout(this.changeTimer)
|
|
92
108
|
this.unregisterFromRefList()
|
|
93
109
|
},
|
|
94
110
|
|
|
95
111
|
methods: {
|
|
96
|
-
|
|
97
|
-
this.
|
|
98
|
-
|
|
112
|
+
handleRichEditorInput(val) {
|
|
113
|
+
if (this.designState) return
|
|
114
|
+
const next = isBlankRichText(val) ? "" : (val || "")
|
|
115
|
+
if (this.fieldModel === next) return
|
|
116
|
+
this.fieldModel = next
|
|
117
|
+
this.syncUpdateFormModel(next)
|
|
118
|
+
clearTimeout(this.changeTimer)
|
|
119
|
+
this.changeTimer = setTimeout(() => {
|
|
120
|
+
this.flushRichEditorChange()
|
|
121
|
+
}, 200)
|
|
99
122
|
},
|
|
100
123
|
|
|
101
|
-
|
|
124
|
+
flushRichEditorChange() {
|
|
125
|
+
this.changeTimer = null
|
|
126
|
+
this.emitFieldDataChange(this.fieldModel, this.oldFieldValue)
|
|
102
127
|
this.oldFieldValue = deepClone(this.fieldModel)
|
|
128
|
+
this.dispatch("VFormRender", "fieldValidation", [this.getPropName()])
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
handleRichEditorFocus(event) {
|
|
132
|
+
this.handleFocusCustomEvent(event)
|
|
103
133
|
},
|
|
104
134
|
|
|
105
|
-
|
|
106
|
-
if (this.
|
|
107
|
-
|
|
108
|
-
this.
|
|
135
|
+
handleRichEditorBlur(event) {
|
|
136
|
+
if (this.changeTimer) {
|
|
137
|
+
clearTimeout(this.changeTimer)
|
|
138
|
+
this.flushRichEditorChange()
|
|
109
139
|
}
|
|
140
|
+
this.handleBlurCustomEvent(event)
|
|
110
141
|
},
|
|
111
142
|
|
|
112
143
|
}
|
|
@@ -116,8 +147,18 @@
|
|
|
116
147
|
<style lang="scss" scoped>
|
|
117
148
|
@import "~@base/styles/theme-variables.scss"; //* form-item-wrapper已引入,还需要重复引入吗? *//
|
|
118
149
|
|
|
119
|
-
.
|
|
120
|
-
|
|
150
|
+
.rich-editor-host {
|
|
151
|
+
position: relative;
|
|
152
|
+
width: 100%;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.rich-editor-mask {
|
|
156
|
+
position: absolute;
|
|
157
|
+
top: 0;
|
|
158
|
+
right: 0;
|
|
159
|
+
bottom: 0;
|
|
160
|
+
left: 0;
|
|
161
|
+
z-index: 3;
|
|
121
162
|
}
|
|
122
163
|
|
|
123
164
|
</style>
|
package/src/components/xform/form-designer/setting-panel/property-editor/contentHeight-editor.vue
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-item :label="i18nt('designer.setting.contentHeight')" class="form-item-label-top">
|
|
3
|
+
<el-input-number v-model="optionModel.contentHeight" :min="120" :step="20" style="width: 100%"></el-input-number>
|
|
4
|
+
</el-form-item>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import i18n from "../../../../../components/xform/utils/i18n"
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: "contentHeight-editor",
|
|
12
|
+
mixins: [i18n],
|
|
13
|
+
props: {
|
|
14
|
+
designer: Object,
|
|
15
|
+
selectedWidget: Object,
|
|
16
|
+
optionModel: Object,
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
|
|
23
|
+
</style>
|
|
@@ -1342,6 +1342,51 @@ export const basicFields = [
|
|
|
1342
1342
|
...defaultTextFlagConfig,
|
|
1343
1343
|
},
|
|
1344
1344
|
},
|
|
1345
|
+
{
|
|
1346
|
+
type: "rich-editor",
|
|
1347
|
+
icon: "rich-editor-field",
|
|
1348
|
+
commonFlag: !0,
|
|
1349
|
+
formItemFlag: !0,
|
|
1350
|
+
columnFlag: false,
|
|
1351
|
+
tableField: null,
|
|
1352
|
+
options: {
|
|
1353
|
+
name: "",
|
|
1354
|
+
keyNameEnabled: !1,
|
|
1355
|
+
keyName: "",
|
|
1356
|
+
label: "",
|
|
1357
|
+
labelColor: "",
|
|
1358
|
+
submitFlag: true,
|
|
1359
|
+
labelAlign: "",
|
|
1360
|
+
defaultValue: "",
|
|
1361
|
+
contentHeight: 300,
|
|
1362
|
+
columnWidth: "200px",
|
|
1363
|
+
labelWidth: null,
|
|
1364
|
+
labelHidden: !1,
|
|
1365
|
+
readonly: !1,
|
|
1366
|
+
disabled: !1,
|
|
1367
|
+
hidden: !1,
|
|
1368
|
+
required: !1,
|
|
1369
|
+
requiredHint: "",
|
|
1370
|
+
validation: "",
|
|
1371
|
+
validationHint: "",
|
|
1372
|
+
customClass: "",
|
|
1373
|
+
labelIconClass: null,
|
|
1374
|
+
labelIconPosition: "rear",
|
|
1375
|
+
labelTooltip: null,
|
|
1376
|
+
onCreated: "",
|
|
1377
|
+
onMounted: "",
|
|
1378
|
+
onChange: "",
|
|
1379
|
+
onFocus: "",
|
|
1380
|
+
onBlur: "",
|
|
1381
|
+
onValidate: "",
|
|
1382
|
+
accessType: "1",
|
|
1383
|
+
...defaultWfConfig,
|
|
1384
|
+
|
|
1385
|
+
showRuleFlag: 1,
|
|
1386
|
+
showRuleEnabled: 1,
|
|
1387
|
+
showRules: [],
|
|
1388
|
+
},
|
|
1389
|
+
},
|
|
1345
1390
|
{
|
|
1346
1391
|
type: "script-input",
|
|
1347
1392
|
icon: "component",
|
|
@@ -4734,6 +4779,7 @@ export const widgetPanelOrder = {
|
|
|
4734
4779
|
"a-link2",
|
|
4735
4780
|
"button",
|
|
4736
4781
|
"divider",
|
|
4782
|
+
"rich-editor",
|
|
4737
4783
|
],
|
|
4738
4784
|
/* 图表 → 展示 → 按钮 */
|
|
4739
4785
|
advancedFields: [
|
|
@@ -331,9 +331,11 @@ const elTemplates = { //字段组件属性
|
|
|
331
331
|
},
|
|
332
332
|
|
|
333
333
|
'rich-editor': (widget, formConfig) => {
|
|
334
|
-
const {vModel
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
const {vModel} = getElAttrs(widget, formConfig)
|
|
335
|
+
const wop = widget.options
|
|
336
|
+
const readonly = (wop.readonly || wop.disabled) ? `:readonly="true"` : ''
|
|
337
|
+
const height = isNotNull(wop.contentHeight) ? `:height="${wop.contentHeight}"` : ':height="300"'
|
|
338
|
+
return `<tinymce ${vModel} ${readonly} ${height}></tinymce>`
|
|
337
339
|
},
|
|
338
340
|
|
|
339
341
|
'cascader': (widget, formConfig) => {
|