dragon-editor 3.2.2 → 3.2.3
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
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</div>
|
|
86
86
|
</div>
|
|
87
87
|
|
|
88
|
-
<div class="de-control-bar" :class="{ '--active': editorStore.controlBar.active === true }" :style="{ top: `${editorStore.controlBar.y}px`, left: `${editorStore.controlBar.x}px` }" ref="$controlBar">
|
|
88
|
+
<div v-if="editorStore.$currentBlock !== null" class="de-control-bar" :class="{ '--active': editorStore.controlBar.active === true }" :style="{ top: `${editorStore.controlBar.y}px`, left: `${editorStore.controlBar.x}px` }" ref="$controlBar">
|
|
89
89
|
<div v-if="['code'].includes(curruntType) === true" class="de-col">
|
|
90
90
|
<p class="de-name">Theme :</p>
|
|
91
91
|
<select class="de-selector" v-model="codeBlockTheme" @change="codeBlockThemeChangeEvent">
|
|
@@ -133,7 +133,7 @@ import { _findScrollingElement, _findContentEditableElement } from "../utils/ele
|
|
|
133
133
|
import { _elementKeyEvent, _hotKeyEvent, _copyEvent, _pasteEvent } from "../utils/keyboardEvent";
|
|
134
134
|
import { _getBlockType, _createTextBlock, _createHeadingBlock, _createListBlock, _createImageBlock, _createCustomBlock, _createCodeBlock } from "../utils/block";
|
|
135
135
|
import { _setNodeStyle, _setTextAlign } from "../utils/style";
|
|
136
|
-
import { _setCursorData, _clenupCursor } from "../utils/cursor";
|
|
136
|
+
import { _setCursor, _setCursorData, _clenupCursor } from "../utils/cursor";
|
|
137
137
|
import { _getContentData, _setContentData } from "../utils/convertor";
|
|
138
138
|
import { _addBlockToContent } from "../utils/content";
|
|
139
139
|
import "../type.d.ts";
|
|
@@ -306,7 +306,18 @@ function checkOthersideClick(event: MouseEvent) {
|
|
|
306
306
|
// 블럭 삭제
|
|
307
307
|
function deleteBlock() {
|
|
308
308
|
if (editorStore.$currentBlock !== null) {
|
|
309
|
+
const childCount: number = editorStore.$content?.childElementCount ?? 1;
|
|
310
|
+
|
|
309
311
|
editorStore.$currentBlock.remove();
|
|
312
|
+
editorStore.setCurrentBlock(null);
|
|
313
|
+
|
|
314
|
+
if (childCount < 2) {
|
|
315
|
+
// 모든 엘리먼트를 지우려는 경우
|
|
316
|
+
const $block = _createTextBlock();
|
|
317
|
+
|
|
318
|
+
editorStore.$content?.insertAdjacentElement("beforeend", $block);
|
|
319
|
+
_setCursor($block, 0);
|
|
320
|
+
}
|
|
310
321
|
}
|
|
311
322
|
}
|
|
312
323
|
|
package/dist/runtime/store.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"editorStor
|
|
|
4
4
|
setContentElement(value: HTMLDivElement): void;
|
|
5
5
|
setParentWrapElement(value: HTMLElement | Window): void;
|
|
6
6
|
setCursorData(data: DEditorCursor): void;
|
|
7
|
-
setCurrentBlock(block: HTMLElement): void;
|
|
7
|
+
setCurrentBlock(block: HTMLElement | null): void;
|
|
8
8
|
setContrulBar(value: HTMLDivElement): void;
|
|
9
9
|
controlBarActive(): void;
|
|
10
10
|
controlBarDeactive(): void;
|
|
@@ -28,7 +28,7 @@ export function _elementKeyEvent(event, store) {
|
|
|
28
28
|
keyEventCount += 1;
|
|
29
29
|
setTimeout(() => {
|
|
30
30
|
keyEventCount = 0;
|
|
31
|
-
},
|
|
31
|
+
}, 200);
|
|
32
32
|
break;
|
|
33
33
|
case "Backspace":
|
|
34
34
|
elementBackspaceEvent(event, store);
|
|
@@ -44,7 +44,7 @@ export function _elementKeyEvent(event, store) {
|
|
|
44
44
|
keyEventCount += 1;
|
|
45
45
|
setTimeout(() => {
|
|
46
46
|
keyEventCount = 0;
|
|
47
|
-
},
|
|
47
|
+
}, 200);
|
|
48
48
|
break;
|
|
49
49
|
case "Space":
|
|
50
50
|
break;
|
|
@@ -187,12 +187,15 @@ function defaultBlockEnterEvent(store, $element) {
|
|
|
187
187
|
const text = node.textContent;
|
|
188
188
|
const preSpan = document.createElement("span");
|
|
189
189
|
const nextSpan = document.createElement("span");
|
|
190
|
+
const nextText = text.slice(store.cursorData.startOffset);
|
|
190
191
|
preSpan.classList.add(...originalClassList);
|
|
191
192
|
preSpan.textContent = text.slice(0, store.cursorData.startOffset);
|
|
192
193
|
preStructure.push(preSpan);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
if (nextText !== "") {
|
|
195
|
+
nextSpan.classList.add(...originalClassList);
|
|
196
|
+
nextSpan.textContent = nextText;
|
|
197
|
+
nextStructure.push(nextSpan);
|
|
198
|
+
}
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
});
|
|
@@ -292,7 +295,7 @@ function defaultBlockEnterEvent(store, $element) {
|
|
|
292
295
|
}
|
|
293
296
|
});
|
|
294
297
|
}
|
|
295
|
-
const $nextBlock = _createTextBlock(
|
|
298
|
+
const $nextBlock = _createTextBlock({ type: "text", classList: [], textContent: "" });
|
|
296
299
|
$textBlock.insertAdjacentElement("afterend", $nextBlock);
|
|
297
300
|
$textBlock.replaceChildren(...preStructure);
|
|
298
301
|
$nextBlock.replaceChildren(...nextStructure);
|
|
@@ -40,7 +40,7 @@ export function _setNodeStyle(className, store) {
|
|
|
40
40
|
_setCursor($element.childNodes[targetIdx], cursorOffset);
|
|
41
41
|
} else {
|
|
42
42
|
if ($parentElement.tagName === "SPAN") {
|
|
43
|
-
const classList =
|
|
43
|
+
const classList = $parentElement.classList.value.split(" ");
|
|
44
44
|
const classIdx = classList.indexOf(className);
|
|
45
45
|
if (classIdx === -1) {
|
|
46
46
|
$parentElement.classList.add(className);
|
|
@@ -92,7 +92,7 @@ export function _setNodeStyle(className, store) {
|
|
|
92
92
|
} else {
|
|
93
93
|
const $target = cursorData.startNode;
|
|
94
94
|
if ($target.tagName !== "A") {
|
|
95
|
-
const classList =
|
|
95
|
+
const classList = $target.classList.value.split(" ");
|
|
96
96
|
const classIdx = classList.indexOf(className);
|
|
97
97
|
if (classIdx === -1) {
|
|
98
98
|
if (cursorData.startOffset !== 0) {
|
|
@@ -157,7 +157,7 @@ export function _setNodeStyle(className, store) {
|
|
|
157
157
|
isDuble = true;
|
|
158
158
|
}
|
|
159
159
|
} else {
|
|
160
|
-
const classList =
|
|
160
|
+
const classList = $elementNode.classList.value.split(" ");
|
|
161
161
|
const classIdx = classList.indexOf(className);
|
|
162
162
|
if ($elementNode.tagName === "SPAN") {
|
|
163
163
|
if (classIdx === -1) {
|
|
@@ -196,7 +196,7 @@ export function _setNodeStyle(className, store) {
|
|
|
196
196
|
structureArray.push(childNode.textContent);
|
|
197
197
|
}
|
|
198
198
|
} else {
|
|
199
|
-
const classList =
|
|
199
|
+
const classList = $elementNode.classList.value.split(" ");
|
|
200
200
|
const classIdx = classList.indexOf(className);
|
|
201
201
|
if ($elementNode.tagName === "SPAN") {
|
|
202
202
|
if (isWrap === true) {
|
|
@@ -236,7 +236,7 @@ export function _setNodeStyle(className, store) {
|
|
|
236
236
|
structureArray.push(childNode.textContent);
|
|
237
237
|
}
|
|
238
238
|
} else {
|
|
239
|
-
const classList =
|
|
239
|
+
const classList = $elementNode.classList.value.split(" ");
|
|
240
240
|
const classIdx = classList.indexOf(className);
|
|
241
241
|
if ($elementNode.tagName === "SPAN") {
|
|
242
242
|
if (isWrap === true) {
|
|
@@ -351,12 +351,15 @@ export function _setTextAlign(type, store) {
|
|
|
351
351
|
if ($element.classList.contains(className) === true) {
|
|
352
352
|
$element.classList.remove(className);
|
|
353
353
|
} else {
|
|
354
|
-
const curruntClassname = alignClassList.filter((text) =>
|
|
354
|
+
const curruntClassname = alignClassList.filter((text) => $element.classList.contains(text) === true)[0];
|
|
355
355
|
if (curruntClassname !== void 0) {
|
|
356
356
|
$element.classList.remove(curruntClassname);
|
|
357
357
|
}
|
|
358
358
|
$element.classList.add(className);
|
|
359
359
|
}
|
|
360
|
+
if (store.$currentBlock.classList.contains("de-image-block") !== true) {
|
|
361
|
+
_setCursor($element, 0);
|
|
362
|
+
}
|
|
360
363
|
}
|
|
361
364
|
}
|
|
362
365
|
}
|