dragon-editor 3.5.19 → 3.5.21
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 +1 -1
- package/dist/runtime/components/DragonEditor.vue +9 -9
- package/dist/runtime/type.d.ts +1 -0
- package/dist/runtime/utils/event/mouse.d.ts +1 -1
- package/dist/runtime/utils/event/mouse.js +3 -3
- package/dist/runtime/utils/layout/body.d.ts +0 -3
- package/dist/runtime/utils/layout/body.js +36 -1
- package/dist/runtime/utils/layout/menuBar.js +3 -3
- package/dist/runtime/utils/style/anchor.d.ts +1 -1
- package/dist/runtime/utils/style/anchor.js +24 -17
- package/package.json +1 -1
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 {
|
|
@@ -6,6 +6,6 @@ export declare function _editorMousemoveEvent(event: MouseEvent, store: Ref<Drag
|
|
|
6
6
|
export declare function _editorMouseupEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
7
7
|
export declare function _editorMouseleaveEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
8
8
|
export declare function _checkOthersideClick(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
9
|
-
export declare function _openAnchorArea(store: Ref<DragonEditorStore>): void;
|
|
9
|
+
export declare function _openAnchorArea(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
10
10
|
export declare function _decideWhetherOpenControlBar(store: Ref<DragonEditorStore>): void;
|
|
11
11
|
export declare function _editorContextMenuEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -14,7 +14,7 @@ export function _editorMousemoveEvent(event, store) {
|
|
|
14
14
|
}
|
|
15
15
|
export function _editorMouseupEvent(event, store) {
|
|
16
16
|
_imageResizeEventEnd(event, store);
|
|
17
|
-
_updateAnchorTagValue(store);
|
|
17
|
+
_updateAnchorTagValue(event, store);
|
|
18
18
|
}
|
|
19
19
|
export function _editorMouseleaveEvent(event, store) {
|
|
20
20
|
_imageResizeEventEnd(event, store);
|
|
@@ -39,9 +39,9 @@ function __blockAddOthersideEvent(event, store) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
export function _openAnchorArea(store) {
|
|
42
|
+
export function _openAnchorArea(event, store) {
|
|
43
43
|
store.value.controlStatus.previousCorsorData = store.value.cursorData;
|
|
44
|
-
_updateAnchorTagValue(store, true);
|
|
44
|
+
_updateAnchorTagValue(event, store, true);
|
|
45
45
|
_updateHeadingBlockList(store);
|
|
46
46
|
if (store.value.controlStatus.anchorHref !== "" && store.value.controlStatus.anchorHref.charAt(0) === "#") {
|
|
47
47
|
store.value.controlStatus.anchorTabType = "heading";
|
|
@@ -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
|
+
}
|
|
@@ -35,7 +35,7 @@ export function _getMenuBarVNodeStructure(store) {
|
|
|
35
35
|
h("input", {
|
|
36
36
|
class: ["de-input", { "--error": store.value.controlStatus.anchorValidation === false }],
|
|
37
37
|
value: store.value.controlStatus.anchorHref,
|
|
38
|
-
|
|
38
|
+
onInput: (event) => {
|
|
39
39
|
store.value.controlStatus.anchorHref = event.currentTarget.value;
|
|
40
40
|
}
|
|
41
41
|
}),
|
|
@@ -146,8 +146,8 @@ function __getMenuListStructure(store) {
|
|
|
146
146
|
"button",
|
|
147
147
|
{
|
|
148
148
|
class: ["de-menu", "js-de-link-btn"],
|
|
149
|
-
onClick: () => {
|
|
150
|
-
_openAnchorArea(store);
|
|
149
|
+
onClick: (event) => {
|
|
150
|
+
_openAnchorArea(event, store);
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
153
|
[_getIconNode("add-link")]
|
|
@@ -2,4 +2,4 @@ import type { Ref } from "vue";
|
|
|
2
2
|
import type { DragonEditorStore } from "../../type.js";
|
|
3
3
|
export declare function _setAnchorTag(url: string, isOutsideLink: boolean, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _unsetAnchorTag(store: Ref<DragonEditorStore>): false | undefined;
|
|
5
|
-
export declare function _updateAnchorTagValue(store: Ref<DragonEditorStore>, previous?: boolean): void;
|
|
5
|
+
export declare function _updateAnchorTagValue(event: MouseEvent, store: Ref<DragonEditorStore>, previous?: boolean): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _setRangeCursor, _updateCursorData, _updateModelData, _sortingCursorDataOnElement } from "../event/index.js";
|
|
2
2
|
import { _findContentEditableElement, _findPoverTextNode } from "../node/index.js";
|
|
3
3
|
export function _setAnchorTag(url, isOutsideLink, store) {
|
|
4
|
+
console.log("url", url);
|
|
4
5
|
if (store.value.controlStatus.previousCorsorData !== null && store.value.controlStatus.$currentBlock !== null) {
|
|
5
6
|
const cursorData = store.value.controlStatus.previousCorsorData;
|
|
6
7
|
const typeIgnoreList = ["image", "code", "custom"];
|
|
@@ -215,25 +216,31 @@ export function _unsetAnchorTag(store) {
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
export function _updateAnchorTagValue(store, previous = false) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (
|
|
226
|
-
$
|
|
219
|
+
export function _updateAnchorTagValue(event, store, previous = false) {
|
|
220
|
+
const $target = event.target;
|
|
221
|
+
if ($target !== null) {
|
|
222
|
+
const $linkArea = $target.closest(".js-de-link-exit-area");
|
|
223
|
+
if ($linkArea === null) {
|
|
224
|
+
if (store.value.controlStatus.previousCorsorData !== null && store.value.cursorData !== null) {
|
|
225
|
+
const cursorData = previous === true ? store.value.controlStatus.previousCorsorData : store.value.cursorData;
|
|
226
|
+
if (cursorData.type === "Caret" || cursorData.type === "Range" && cursorData.startNode === cursorData.endNode) {
|
|
227
|
+
const $element = _findContentEditableElement(cursorData.startNode);
|
|
228
|
+
let $targetNode = cursorData.startNode;
|
|
229
|
+
if ($targetNode.constructor.name === "Text") {
|
|
230
|
+
if ($targetNode.parentElement !== $element) {
|
|
231
|
+
$targetNode = $targetNode.parentElement;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if ($targetNode.constructor.name === "HTMLAnchorElement") {
|
|
235
|
+
const $tag = $targetNode;
|
|
236
|
+
store.value.controlStatus.anchorHref = $tag.href;
|
|
237
|
+
} else {
|
|
238
|
+
store.value.controlStatus.anchorHref = "";
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
store.value.controlStatus.anchorHref = "";
|
|
227
242
|
}
|
|
228
243
|
}
|
|
229
|
-
if ($targetNode.constructor.name === "HTMLAnchorElement") {
|
|
230
|
-
const $tag = $targetNode;
|
|
231
|
-
store.value.controlStatus.anchorHref = $tag.href;
|
|
232
|
-
} else {
|
|
233
|
-
store.value.controlStatus.anchorHref = "";
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
store.value.controlStatus.anchorHref = "";
|
|
237
244
|
}
|
|
238
245
|
}
|
|
239
246
|
}
|