dragon-editor 3.0.1 → 3.0.2

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.0.1"
4
+ "version": "3.0.2"
5
5
  }
@@ -156,15 +156,16 @@ function setDecoration(type: string) {
156
156
  _setNodeStyle(`de-${type}`, editorStore);
157
157
  }
158
158
 
159
- function getContentData() {
159
+ function getContentData(): DEContentData {
160
160
  if (editorStore.$content !== null) {
161
161
  return _getContentData(editorStore.$content);
162
162
  } else {
163
163
  console.error("[DragonEditor] Con't find content Element.");
164
+ return [];
164
165
  }
165
166
  }
166
167
 
167
- function setContentData(data: any[]) {
168
+ function setContentData(data: DEContentData) {
168
169
  _setContentData(data, editorStore);
169
170
  }
170
171
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  <script setup lang="ts">
24
24
  const props = defineProps<{
25
- content: any[];
25
+ content: DEContentData;
26
26
  }>();
27
27
  </script>
28
28
 
@@ -22,3 +22,30 @@ interface DEArrangeCursorData {
22
22
  endNodeIdx: number;
23
23
  endOffset: number;
24
24
  }
25
+
26
+ interface DETextBlock {
27
+ type: "text";
28
+ textContent: string;
29
+ }
30
+
31
+ interface DEHeadingBlock {
32
+ type: "heading";
33
+ level: number;
34
+ id: string;
35
+ textContent: string;
36
+ }
37
+
38
+ interface DEUListBlock {
39
+ type: "ul";
40
+ child: string[];
41
+ }
42
+
43
+ interface DEOListBlock {
44
+ type: "ol";
45
+ pattern: "a" | "i" | "1" | "A" | "I";
46
+ child: string[];
47
+ }
48
+
49
+ type DEContent = DETextBlock | DEHeadingBlock | DEUListBlock | DEOListBlock;
50
+
51
+ type DEContentData = DEContent[];
@@ -1,2 +1,2 @@
1
- export declare function _getContentData($content: HTMLDivElement): any[];
1
+ export declare function _getContentData($content: HTMLDivElement): DEContentData;
2
2
  export declare function _setContentData(data: any[], store: any): void;
@@ -676,17 +676,9 @@ function defaultBlockBackspaceEvent(e, store, $element) {
676
676
  function listBlockBackspaceEvent(e, store, $element) {
677
677
  const $listBlock = $element;
678
678
  const $targetItem = _findContentEditableElement(store.cursorData.startNode);
679
- const childList = store.$content.querySelectorAll(".de-block");
680
679
  const liList = $listBlock.querySelectorAll(".de-item");
681
680
  const $target = _getParentElementIfNodeIsText(store.cursorData.startNode, $targetItem);
682
- let elementIdx = -1;
683
681
  let liIdx = -1;
684
- for (let i = 0; childList.length > i; i += 1) {
685
- if (childList[i] === $element) {
686
- elementIdx = i;
687
- break;
688
- }
689
- }
690
682
  for (let i = 0; liList.length > i; i += 1) {
691
683
  if (liList[i] === $targetItem) {
692
684
  liIdx = i;
@@ -726,6 +718,7 @@ function listBlockBackspaceEvent(e, store, $element) {
726
718
  _setCursor($preBlock, 0);
727
719
  }
728
720
  $targetItem.remove();
721
+ $listBlock.remove();
729
722
  }
730
723
  }
731
724
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt3!",
5
5
  "repository": {
6
6
  "type": "git",