dragon-editor 3.4.3 → 3.4.5

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,5 +1,5 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
3
  "configKey": "dragon-editor",
4
- "version": "3.4.3"
4
+ "version": "3.4.5"
5
5
  }
@@ -397,9 +397,23 @@ function checkOthersideClick(event: MouseEvent) {
397
397
  function deleteBlock() {
398
398
  if (editorStore.$currentBlock !== null) {
399
399
  const childCount: number = editorStore.$content?.childElementCount ?? 1;
400
+ const preElement = editorStore.$currentBlock.previousElementSibling;
400
401
 
401
402
  editorStore.$currentBlock.remove();
402
- editorStore.setCurrentBlock(null);
403
+
404
+ if (preElement === null) {
405
+ editorStore.setCurrentBlock(null);
406
+ } else {
407
+ const { type } = _getBlockType(editorStore.$currentBlock);
408
+ const activeList = ["text", "heading"];
409
+
410
+ if (activeList.includes(type) === true) {
411
+ editorStore.setCurrentBlock(preElement as HTMLElement);
412
+ _setCursor(preElement, 0);
413
+ } else {
414
+ editorStore.setCurrentBlock(null);
415
+ }
416
+ }
403
417
 
404
418
  if (childCount < 2) {
405
419
  // 모든 엘리먼트를 지우려는 경우
@@ -77,7 +77,6 @@ export function _createImageBlock(data, imageHostURL = "") {
77
77
  const $p = document.createElement("p");
78
78
  $wrap.classList.add("de-block", "de-image-block", ...data.classList);
79
79
  $div.classList.add("de-image-area");
80
- \u0192;
81
80
  $leftBtn.classList.add("de-btn", "de-btn-left");
82
81
  $rightBtn.classList.add("de-btn", "de-btn-right");
83
82
  $image.classList.add("de-img");
@@ -27,13 +27,17 @@ export function _findContentEditableElement($target) {
27
27
  $target = $target.parentNode;
28
28
  }
29
29
  const $baseElement = $target;
30
- if ($baseElement.parentElement.tagName === "BODY") {
30
+ if ($baseElement.parentElement === null) {
31
31
  return null;
32
32
  } else {
33
- if ($baseElement.getAttribute("contentEditable") === null) {
34
- return _findContentEditableElement($baseElement.parentNode);
33
+ if ($baseElement.parentElement.tagName === "BODY") {
34
+ return null;
35
35
  } else {
36
- return $baseElement;
36
+ if ($baseElement.getAttribute("contentEditable") === null) {
37
+ return _findContentEditableElement($baseElement.parentNode);
38
+ } else {
39
+ return $baseElement;
40
+ }
37
41
  }
38
42
  }
39
43
  }
@@ -135,9 +135,10 @@ function defaultBlockEnterEvent(store, $element) {
135
135
  $textBlock.insertAdjacentElement("afterend", $newTextBlock);
136
136
  $newTextBlock.focus();
137
137
  } else {
138
+ const brList = $textBlock.querySelectorAll("br");
138
139
  let preStructure = [];
139
140
  let nextStructure = [];
140
- $textBlock.childNodes.forEach((_, i) => {
141
+ brList.forEach((_, i) => {
141
142
  const $br = document.createElement("br");
142
143
  if (store.cursorData.startOffset < i) {
143
144
  preStructure.push($br);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.4.3",
3
+ "version": "3.4.5",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt3!",
5
5
  "repository": {
6
6
  "type": "git",