Skip to content

Commit f387a5a

Browse files
committed
fix: richeditor load
1 parent bb5551b commit f387a5a

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

resources/js/app/components/form/field-textarea.vue

+6-11
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
:id="id"
44
:name="name"
55
:data-ref="reference"
6-
:data-config="config"
7-
:data-toolbar="toolbar"
6+
:data-loaded="loaded"
87
class="field-textarea"
98
v-model="v"
10-
v-richeditor
9+
v-richeditor="richeditorConfig"
1110
@change="change($event.target.value)"
1211
v-if="loaded"
1312
/>
@@ -39,21 +38,17 @@ export default {
3938
},
4039
data() {
4140
return {
42-
config: null,
41+
richeditorConfig: {},
4342
loaded: false,
44-
toolbar: null,
4543
v: null,
4644
};
4745
},
4846
mounted() {
4947
this.$nextTick(() => {
50-
const map = BEDITA?.richeditorByPropertyConfig?.[this.field] || null;
51-
if (map) {
52-
map.config = map.config || {};
53-
map.toolbar = map.toolbar || {};
48+
this.richeditorConfig = {
49+
config: BEDITA?.richeditorByPropertyConfig?.[this.field]?.config || {},
50+
toolbar: BEDITA?.richeditorByPropertyConfig?.[this.field]?.toolbar || null
5451
}
55-
this.config = JSON.stringify(map?.config) || null;
56-
this.toolbar = JSON.stringify(map?.toolbar) || null;
5752
this.v = this.value;
5853
this.loaded = true;
5954
this.$forceUpdate();

resources/js/app/directives/richeditor.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,18 @@ export default {
7979
async inserted(element, binding) {
8080
let changing = false;
8181
let toolbar = DEFAULT_TOOLBAR;
82-
if (element.dataset?.toolbar?.length > 0 || binding?.expression) {
83-
let exp = element.dataset?.toolbar?.length > 0 ? JSON.parse(element.dataset.toolbar) : JSON.parse(binding.expression);
82+
if (binding?.value?.toolbar) {
83+
toolbar = binding.value.toolbar.join(' ');
84+
} else if (binding?.expression) {
85+
let exp = JSON.parse(binding.expression);
8486
toolbar = exp ? exp.join(' ') : toolbar;
8587
}
8688
if (!binding.modifiers?.placeholders) {
8789
toolbar = toolbar.replace(/\bplaceholders\b/, '');
8890
}
8991
const sizes = {};
90-
if (element.dataset?.config?.length > 0) {
91-
const c = JSON.parse(element.dataset.config);
92+
if (binding?.value?.config) {
93+
const c = binding.value.config;
9294
if (c?.height) {
9395
sizes.height = c.height;
9496
}

0 commit comments

Comments
 (0)