dragon-editor 3.5.19 → 3.5.20
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/dist/module.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="
|
|
2
|
+
<component :is="mainStrucutre"></component>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { ref, h, onMounted, onBeforeUnmount, watch } from "vue";
|
|
7
|
-
import { _getBodyVNodeStructure, _getMenuBarVNodeStructure, _getControlbarVNodeStructure } from "../utils/layout";
|
|
7
|
+
import { _getBodyVNodeStructure, _getMenuBarVNodeStructure, _getControlbarVNodeStructure, _updateBodyStructure } from "../utils/layout";
|
|
8
8
|
import { _eidtorMountEvent, _eidtorUnmountEvent, _editorMousemoveEvent, _editorMouseupEvent, _editorMouseleaveEvent, _editorTouchmoveEvent, _editorTouchendEvent, _checkOthersideClick, _parentWrapScollEvent, _editorContextMenuEvent, _windowResizeEvent } from "../utils/event";
|
|
9
9
|
import { _addBlock } from "../utils/node";
|
|
10
10
|
import { _setDecoration, _setTextAlign } from "../utils/style";
|
|
@@ -127,7 +127,6 @@ const editorStore = ref<DragonEditorStore>({
|
|
|
127
127
|
_parentWrapScollEvent(event, editorStore);
|
|
128
128
|
},
|
|
129
129
|
});
|
|
130
|
-
const editorStructure = ref<VNode>(mainStrucutre());
|
|
131
130
|
|
|
132
131
|
function mainStrucutre(): VNode {
|
|
133
132
|
const childList: VNode[] = [];
|
|
@@ -194,13 +193,13 @@ function setAlign(align: DETextalign): void {
|
|
|
194
193
|
_setTextAlign(align, editorStore);
|
|
195
194
|
}
|
|
196
195
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(
|
|
200
|
-
editorStore.value.
|
|
201
|
-
|
|
196
|
+
// 데이터 변경용 함수
|
|
197
|
+
function changeEditorData(data: DEContentData): void {
|
|
198
|
+
if (editorStore.value.$body !== null) {
|
|
199
|
+
editorStore.value.$body.innerHTML = "";
|
|
200
|
+
_updateBodyStructure(data, editorStore);
|
|
202
201
|
}
|
|
203
|
-
|
|
202
|
+
}
|
|
204
203
|
|
|
205
204
|
onMounted(() => {
|
|
206
205
|
_eidtorMountEvent(editorStore);
|
|
@@ -214,6 +213,7 @@ defineExpose({
|
|
|
214
213
|
addBlock,
|
|
215
214
|
setDecoration,
|
|
216
215
|
setAlign,
|
|
216
|
+
changeEditorData,
|
|
217
217
|
});
|
|
218
218
|
</script>
|
|
219
219
|
|
package/dist/runtime/type.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ interface DragonEditor {
|
|
|
112
112
|
addBlock: (type: DEBlockData) => void;
|
|
113
113
|
setDecoration: (data: DEDecoration) => void;
|
|
114
114
|
setTextAlign: (type: DETextalign) => void;
|
|
115
|
+
changeEditorData: (data: DEContentData) => void;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
interface DETextBlock {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h } from "vue";
|
|
2
2
|
import { _createBlockList } from "./index.js";
|
|
3
|
-
import { _contentKeydownEvent, _contentKeyupEvent, _contentPasteEvent, _contentMouseupEvent, _contentMousedownEvnet, _contentTouchstartEvent } from "../event/index.js";
|
|
3
|
+
import { _contentKeydownEvent, _contentKeyupEvent, _contentPasteEvent, _contentMouseupEvent, _contentMousedownEvnet, _contentTouchstartEvent, _getDefaultBlockData, _updateModelData } from "../event/index.js";
|
|
4
|
+
import { _createTextBlock, _createHeadingBlock, _createListBlock, _createImageBlock, _createCodeBlock, _createCustomBlock } from "../node/index.js";
|
|
4
5
|
export function _getBodyVNodeStructure(store) {
|
|
5
6
|
return h(
|
|
6
7
|
"div",
|
|
@@ -20,3 +21,37 @@ export function _getBodyVNodeStructure(store) {
|
|
|
20
21
|
})
|
|
21
22
|
);
|
|
22
23
|
}
|
|
24
|
+
export function _updateBodyStructure(bodyData, store) {
|
|
25
|
+
if (store.value.$body !== null) {
|
|
26
|
+
let htmlSturcutre = "";
|
|
27
|
+
if (bodyData.length === 0) {
|
|
28
|
+
htmlSturcutre += _createTextBlock(_getDefaultBlockData("text")).outerHTML;
|
|
29
|
+
} else {
|
|
30
|
+
bodyData.forEach((data) => {
|
|
31
|
+
switch (data.type) {
|
|
32
|
+
case "text":
|
|
33
|
+
htmlSturcutre += _createTextBlock(data).outerHTML;
|
|
34
|
+
break;
|
|
35
|
+
case "heading":
|
|
36
|
+
htmlSturcutre += _createHeadingBlock(data).outerHTML;
|
|
37
|
+
break;
|
|
38
|
+
case "image":
|
|
39
|
+
htmlSturcutre += _createImageBlock(data, store.value.imageHostURL).outerHTML;
|
|
40
|
+
break;
|
|
41
|
+
case "list":
|
|
42
|
+
htmlSturcutre += _createListBlock(data).outerHTML;
|
|
43
|
+
break;
|
|
44
|
+
case "code":
|
|
45
|
+
htmlSturcutre += _createCodeBlock(data, store).outerHTML;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
htmlSturcutre += _createCustomBlock(data).outerHTML;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
store.value.$body.innerHTML = htmlSturcutre;
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
_updateModelData(store);
|
|
55
|
+
}, 250);
|
|
56
|
+
}
|
|
57
|
+
}
|