dragon-editor 3.8.6 → 4.0.0

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.
Files changed (91) hide show
  1. package/README.md +10 -9
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +9 -7
  4. package/dist/runtime/components/Block/Code.d.vue.ts +13 -0
  5. package/dist/runtime/components/Block/Code.vue +193 -0
  6. package/dist/runtime/components/Block/Code.vue.d.ts +13 -0
  7. package/dist/runtime/components/Block/Custom.d.vue.ts +9 -0
  8. package/dist/runtime/components/Block/Custom.vue +28 -0
  9. package/dist/runtime/components/Block/Custom.vue.d.ts +9 -0
  10. package/dist/runtime/components/Block/Divider.d.vue.ts +9 -0
  11. package/dist/runtime/components/Block/Divider.vue +27 -0
  12. package/dist/runtime/components/Block/Divider.vue.d.ts +9 -0
  13. package/dist/runtime/components/Block/Heading.d.vue.ts +13 -0
  14. package/dist/runtime/components/Block/Heading.vue +84 -0
  15. package/dist/runtime/components/Block/Heading.vue.d.ts +13 -0
  16. package/dist/runtime/components/Block/Image.d.vue.ts +13 -0
  17. package/dist/runtime/components/Block/Image.vue +146 -0
  18. package/dist/runtime/components/Block/Image.vue.d.ts +13 -0
  19. package/dist/runtime/components/Block/List.d.vue.ts +13 -0
  20. package/dist/runtime/components/Block/List.vue +170 -0
  21. package/dist/runtime/components/Block/List.vue.d.ts +13 -0
  22. package/dist/runtime/components/Block/Text.d.vue.ts +13 -0
  23. package/dist/runtime/components/Block/Text.vue +84 -0
  24. package/dist/runtime/components/Block/Text.vue.d.ts +13 -0
  25. package/dist/runtime/components/DragonEditor.d.vue.ts +28 -22
  26. package/dist/runtime/components/DragonEditor.vue +75 -1225
  27. package/dist/runtime/components/DragonEditor.vue.d.ts +28 -22
  28. package/dist/runtime/components/DragonEditorViewer.d.vue.ts +13 -5
  29. package/dist/runtime/components/DragonEditorViewer.vue +17 -813
  30. package/dist/runtime/components/DragonEditorViewer.vue.d.ts +13 -5
  31. package/dist/runtime/components/MenuBar.d.vue.ts +3 -0
  32. package/dist/runtime/components/MenuBar.vue +385 -0
  33. package/dist/runtime/components/MenuBar.vue.d.ts +3 -0
  34. package/dist/runtime/scss/editor.css +237 -283
  35. package/dist/runtime/scss/viewer.css +184 -210
  36. package/dist/runtime/store/editor.d.ts +2 -0
  37. package/dist/runtime/store/editor.js +59 -0
  38. package/dist/runtime/type.d.mts +101 -124
  39. package/dist/runtime/utils/data/block.d.ts +20 -0
  40. package/dist/runtime/utils/data/block.js +663 -0
  41. package/dist/runtime/utils/data/cursor.d.ts +9 -0
  42. package/dist/runtime/utils/data/cursor.js +137 -0
  43. package/dist/runtime/utils/data/index.d.ts +5 -0
  44. package/dist/runtime/utils/data/index.js +17 -0
  45. package/dist/runtime/utils/data/node.d.ts +9 -0
  46. package/dist/runtime/utils/data/node.js +101 -0
  47. package/dist/runtime/utils/event/cursor.d.ts +3 -6
  48. package/dist/runtime/utils/event/cursor.js +52 -105
  49. package/dist/runtime/utils/event/index.d.ts +2 -6
  50. package/dist/runtime/utils/event/index.js +48 -6
  51. package/dist/runtime/utils/event/keyboard.d.ts +22 -7
  52. package/dist/runtime/utils/event/keyboard.js +910 -1406
  53. package/dist/runtime/utils/layout/body.d.ts +3 -4
  54. package/dist/runtime/utils/layout/body.js +83 -51
  55. package/dist/runtime/utils/layout/icon.d.ts +1 -2
  56. package/dist/runtime/utils/layout/icon.js +64 -67
  57. package/dist/runtime/utils/layout/index.d.ts +0 -3
  58. package/dist/runtime/utils/layout/index.js +0 -3
  59. package/dist/runtime/utils/node/element.d.ts +4 -6
  60. package/dist/runtime/utils/node/element.js +58 -71
  61. package/dist/runtime/utils/node/index.d.ts +1 -1
  62. package/dist/runtime/utils/node/index.js +1 -1
  63. package/dist/runtime/utils/node/style.d.ts +5 -0
  64. package/dist/runtime/utils/node/style.js +702 -0
  65. package/package.json +31 -17
  66. package/dist/runtime/utils/event/block.d.ts +0 -7
  67. package/dist/runtime/utils/event/block.js +0 -110
  68. package/dist/runtime/utils/event/data.d.ts +0 -8
  69. package/dist/runtime/utils/event/data.js +0 -379
  70. package/dist/runtime/utils/event/mouse.d.ts +0 -11
  71. package/dist/runtime/utils/event/mouse.js +0 -85
  72. package/dist/runtime/utils/event/scroll.d.ts +0 -3
  73. package/dist/runtime/utils/event/scroll.js +0 -29
  74. package/dist/runtime/utils/event/touch.d.ts +0 -5
  75. package/dist/runtime/utils/event/touch.js +0 -10
  76. package/dist/runtime/utils/event/window.d.ts +0 -5
  77. package/dist/runtime/utils/event/window.js +0 -47
  78. package/dist/runtime/utils/layout/block.d.ts +0 -7
  79. package/dist/runtime/utils/layout/block.js +0 -123
  80. package/dist/runtime/utils/layout/controlbar.d.ts +0 -3
  81. package/dist/runtime/utils/layout/controlbar.js +0 -99
  82. package/dist/runtime/utils/layout/menuBar.d.ts +0 -3
  83. package/dist/runtime/utils/layout/menuBar.js +0 -408
  84. package/dist/runtime/utils/node/block.d.ts +0 -19
  85. package/dist/runtime/utils/node/block.js +0 -256
  86. package/dist/runtime/utils/style/anchor.d.ts +0 -5
  87. package/dist/runtime/utils/style/anchor.js +0 -245
  88. package/dist/runtime/utils/style/decoration.d.ts +0 -4
  89. package/dist/runtime/utils/style/decoration.js +0 -378
  90. package/dist/runtime/utils/style/index.d.ts +0 -2
  91. package/dist/runtime/utils/style/index.js +0 -2
@@ -1,245 +0,0 @@
1
- import { _setRangeCursor, _updateCursorData, _updateModelData, _sortingCursorDataOnElement } from "../event/index.js";
2
- import { _findContentEditableElement, _findPoverTextNode } from "../node/index.js";
3
- export function _setAnchorTag(url, isOutsideLink, store) {
4
- if (store.value.controlStatus.previousCorsorData !== null && store.value.controlStatus.$currentBlock !== null) {
5
- const cursorData = store.value.controlStatus.previousCorsorData;
6
- const typeIgnoreList = ["image", "code", "custom"];
7
- const hrefValue = isOutsideLink === true ? url : `#${url}`;
8
- const $element = _findContentEditableElement(cursorData.startNode);
9
- if (typeIgnoreList.includes(store.value.controlStatus.currentBlockType) === false && $element !== null) {
10
- if (cursorData.type === "Caret") {
11
- if ($element.hasChildNodes() === true) {
12
- let $target = cursorData.startNode;
13
- if ($target.constructor.name === "Text") {
14
- const $parentElement = $target.parentElement;
15
- if ($parentElement === $element) {
16
- let childList = $element.childNodes;
17
- let targetIdx = -1;
18
- let structure = "";
19
- for (let i = 0; childList.length > i; i += 1) {
20
- if ($target === childList[i]) {
21
- targetIdx = i;
22
- break;
23
- }
24
- }
25
- targetIdx = _findPoverTextNode(childList[targetIdx], targetIdx);
26
- $element.innerHTML = $element.innerHTML;
27
- childList = $element.childNodes;
28
- childList.forEach((node, i) => {
29
- if (i === targetIdx) {
30
- structure += `<a class="de-link"`;
31
- structure += `href="${hrefValue}"`;
32
- if (isOutsideLink === true) {
33
- structure += `target="_blank"`;
34
- }
35
- structure += `>`;
36
- structure += `${node.textContent}</a>`;
37
- } else {
38
- if (node.constructor.name === "Text") {
39
- structure += node.textContent;
40
- } else {
41
- structure += node.outerHTML;
42
- }
43
- }
44
- });
45
- $element.innerHTML = structure;
46
- const targetElement = $element.childNodes[targetIdx];
47
- _setRangeCursor(targetElement, targetElement, 0, targetElement.textContent?.length ?? 0);
48
- } else {
49
- if ($parentElement.tagName === "A") {
50
- $parentElement.href = hrefValue;
51
- if (isOutsideLink === true) {
52
- $parentElement.target = "_blank";
53
- } else {
54
- $parentElement.removeAttribute("target");
55
- }
56
- _setRangeCursor($parentElement, $parentElement, 0, $parentElement.textContent?.length ?? 0);
57
- }
58
- }
59
- }
60
- }
61
- } else {
62
- const newCursorData = _sortingCursorDataOnElement(cursorData, $element);
63
- let structure = "";
64
- let isDuble = false;
65
- if (newCursorData.startNodeIdx === newCursorData.endNodeIdx) {
66
- if (newCursorData.startNode.constructor.name === "Text") {
67
- $element.childNodes.forEach((childNode, i) => {
68
- if (newCursorData.startNodeIdx === i) {
69
- if (newCursorData.startOffset !== 0) {
70
- structure += childNode.textContent.slice(0, newCursorData.startOffset);
71
- isDuble = true;
72
- }
73
- structure += `<a class="de-link"`;
74
- structure += `href="${hrefValue}"`;
75
- if (isOutsideLink === true) {
76
- structure += `target="_blank"`;
77
- }
78
- structure += `>`;
79
- structure += `${childNode.textContent.slice(newCursorData.startOffset, newCursorData.endOffset)}</a>`;
80
- if (newCursorData.endOffset !== childNode.textContent.length) {
81
- structure += childNode.textContent.slice(newCursorData.endOffset);
82
- }
83
- } else {
84
- if (childNode.constructor.name === "Text") {
85
- structure += childNode.textContent;
86
- } else {
87
- structure += childNode.outerHTML;
88
- }
89
- }
90
- });
91
- let childNumber = newCursorData.startNodeIdx;
92
- if (isDuble === true) {
93
- childNumber += 1;
94
- }
95
- $element.innerHTML = structure;
96
- const targetNode = $element.childNodes[childNumber];
97
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
98
- } else {
99
- const $target = newCursorData.startNode;
100
- if ($target.tagName !== "A") {
101
- const classList = $target.classList.value.split(" ");
102
- if (newCursorData.startOffset !== 0) {
103
- structure += `<span class="${classList.join(" ")}">${$target.textContent.slice(0, newCursorData.startOffset)}</span>`;
104
- isDuble = true;
105
- }
106
- structure += `<a class="de-link"`;
107
- structure += `href="${hrefValue}"`;
108
- if (isOutsideLink === true) {
109
- structure += `target="_blank"`;
110
- }
111
- structure += `>`;
112
- structure += `${$target.textContent.slice(newCursorData.startOffset, newCursorData.endOffset)}</a>`;
113
- if (newCursorData.endOffset !== $target.textContent.length) {
114
- structure += `<span class="${classList.join(" ")}">${$target.textContent.slice(newCursorData.endOffset)}</span>`;
115
- }
116
- $target.insertAdjacentHTML("afterend", structure);
117
- let $nextElement = $target.nextSibling;
118
- if (isDuble === true) {
119
- $nextElement = $nextElement.nextSibling;
120
- }
121
- $target.remove();
122
- const targetNode = $nextElement;
123
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
124
- } else {
125
- $target.href = hrefValue;
126
- if (isOutsideLink === true) {
127
- $target.target = "_blank";
128
- } else {
129
- $target.removeAttribute("target");
130
- }
131
- _setRangeCursor($target, $target, 0, $target.textContent?.length ?? 0);
132
- }
133
- }
134
- } else {
135
- let preStructure = "";
136
- let anchorTextContent = "";
137
- let nextStructure = "";
138
- $element.childNodes.forEach((childNode, i) => {
139
- const $elementNode = childNode;
140
- let isText = childNode.constructor.name === "Text";
141
- if (newCursorData.startNodeIdx > i) {
142
- if (isText === true) {
143
- preStructure += childNode.textContent;
144
- } else {
145
- preStructure += $elementNode.outerHTML;
146
- }
147
- }
148
- if (newCursorData.startNodeIdx === i) {
149
- if (isText === true) {
150
- preStructure += childNode.textContent.slice(0, newCursorData.startOffset);
151
- } else {
152
- preStructure += `<span class="${childNode.classList.value}">${childNode.textContent.slice(0, newCursorData.startOffset)}</span>`;
153
- }
154
- anchorTextContent += childNode.textContent.slice(newCursorData.startOffset);
155
- }
156
- if (newCursorData.startNodeIdx < i && newCursorData.endNodeIdx > i) {
157
- anchorTextContent += childNode.textContent;
158
- }
159
- if (newCursorData.endNodeIdx === i) {
160
- anchorTextContent += childNode.textContent.slice(0, newCursorData.endOffset);
161
- if (isText === true) {
162
- nextStructure += childNode.textContent.slice(newCursorData.startOffset);
163
- } else {
164
- nextStructure += `<span class="${childNode.classList.value}">${childNode.textContent.slice(newCursorData.startOffset)}</span>`;
165
- }
166
- }
167
- if (newCursorData.endNodeIdx < i) {
168
- if (isText === true) {
169
- nextStructure += childNode.textContent;
170
- } else {
171
- nextStructure += $elementNode.outerHTML;
172
- }
173
- }
174
- });
175
- let anchorTag = "";
176
- anchorTag += `<a class="de-link"`;
177
- anchorTag += `href="${hrefValue}"`;
178
- if (isOutsideLink === true) {
179
- anchorTag += `target="_blank"`;
180
- }
181
- anchorTag += `>`;
182
- anchorTag += anchorTextContent;
183
- anchorTag += `</a>`;
184
- $element.innerHTML = preStructure + anchorTag + nextStructure;
185
- let targetNode = $element.childNodes[newCursorData.startNodeIdx];
186
- if (newCursorData.startOffset !== 0) {
187
- targetNode = $element.childNodes[newCursorData.startNodeIdx + 1];
188
- }
189
- _setRangeCursor(targetNode, targetNode, 0, targetNode?.textContent?.length ?? 0);
190
- }
191
- }
192
- _updateCursorData(store);
193
- _updateModelData(store);
194
- }
195
- }
196
- }
197
- export function _unsetAnchorTag(store) {
198
- if (store.value.cursorData !== null) {
199
- const cursorData = store.value.cursorData;
200
- const $element = _findContentEditableElement(cursorData.startNode);
201
- if ($element !== null) {
202
- const newCursorData = _sortingCursorDataOnElement(cursorData, $element);
203
- if (newCursorData.startNode.constructor.name === "HTMLAnchorElement") {
204
- if (cursorData.type === "Range") {
205
- if (newCursorData.startNodeIdx !== newCursorData.endNodeIdx) {
206
- return false;
207
- }
208
- }
209
- const $anchorTag = newCursorData.startNode;
210
- $anchorTag.insertAdjacentText("afterend", newCursorData.startNode.textContent ?? "");
211
- const $targetNode = $anchorTag.nextSibling;
212
- $anchorTag.remove();
213
- _setRangeCursor($targetNode, $targetNode, 0, $targetNode.textContent?.length ?? 0);
214
- }
215
- }
216
- }
217
- }
218
- export function _updateAnchorTagValue(event, store, previous = false) {
219
- const $target = event.target;
220
- if ($target !== null) {
221
- const $linkArea = $target.closest(".js-de-link-exit-area");
222
- if ($linkArea === null) {
223
- if (store.value.controlStatus.previousCorsorData !== null && store.value.cursorData !== null) {
224
- const cursorData = previous === true ? store.value.controlStatus.previousCorsorData : store.value.cursorData;
225
- if (cursorData.type === "Caret" || cursorData.type === "Range" && cursorData.startNode === cursorData.endNode) {
226
- const $element = _findContentEditableElement(cursorData.startNode);
227
- let $targetNode = cursorData.startNode;
228
- if ($targetNode.constructor.name === "Text") {
229
- if ($targetNode.parentElement !== $element) {
230
- $targetNode = $targetNode.parentElement;
231
- }
232
- }
233
- if ($targetNode.constructor.name === "HTMLAnchorElement") {
234
- const $tag = $targetNode;
235
- store.value.controlStatus.anchorHref = $tag.href;
236
- } else {
237
- store.value.controlStatus.anchorHref = "";
238
- }
239
- } else {
240
- store.value.controlStatus.anchorHref = "";
241
- }
242
- }
243
- }
244
- }
245
- }
@@ -1,4 +0,0 @@
1
- import type { Ref } from "vue";
2
- import type { DragonEditorStore, DETextalign } from "../../type.d.mts.js";
3
- export declare function _setDecoration(className: string, store: Ref<DragonEditorStore>): void;
4
- export declare function _setTextAlign(type: DETextalign, store: Ref<DragonEditorStore>): void;
@@ -1,378 +0,0 @@
1
- import { _setRangeCursor, _sortingCursorDataOnElement, _updateModelData, _updateCursorData } from "../event/index.js";
2
- import { _findContentEditableElement, _findPoverTextNode } from "../node/index.js";
3
- export function _setDecoration(className, store) {
4
- if (store.value.cursorData !== null && store.value.controlStatus.$currentBlock !== null) {
5
- const cursorData = store.value.cursorData;
6
- const typeIgnoreList = ["image", "code", "custom"];
7
- if (typeIgnoreList.includes(store.value.controlStatus.currentBlockType) === false) {
8
- const $element = _findContentEditableElement(cursorData.startNode);
9
- if ($element !== null) {
10
- if (cursorData.type === "Caret") {
11
- if ($element.hasChildNodes() === true) {
12
- let $target = cursorData.startNode;
13
- if ($target.constructor.name === "Text") {
14
- const $parentElement = $target.parentElement;
15
- if ($parentElement === $element) {
16
- let childList = $element.childNodes;
17
- let targetIdx = -1;
18
- let structure = "";
19
- for (let i = 0; childList.length > i; i += 1) {
20
- if ($target === childList[i]) {
21
- targetIdx = i;
22
- break;
23
- }
24
- }
25
- targetIdx = _findPoverTextNode(childList[targetIdx], targetIdx);
26
- $element.innerHTML = $element.innerHTML;
27
- childList = $element.childNodes;
28
- childList.forEach((node, i) => {
29
- if (i === targetIdx) {
30
- structure += `<span class="${className}">${node.textContent}</span>`;
31
- } else {
32
- if (node.constructor.name === "Text") {
33
- structure += node.textContent;
34
- } else {
35
- structure += node.outerHTML;
36
- }
37
- }
38
- });
39
- $element.innerHTML = structure;
40
- const targetElement = $element.childNodes[targetIdx];
41
- _setRangeCursor(targetElement, targetElement, 0, targetElement.textContent?.length ?? 0);
42
- } else {
43
- if ($parentElement.tagName === "SPAN") {
44
- const classList = $parentElement.classList.value.split(" ");
45
- const classIdx = classList.indexOf(className);
46
- if (classIdx === -1) {
47
- $parentElement.classList.add(className);
48
- const targetNode = $parentElement.childNodes[0];
49
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
50
- } else {
51
- if (classList.length === 1) {
52
- $parentElement.insertAdjacentText("afterend", $parentElement.textContent);
53
- const targetNode = $parentElement.nextSibling;
54
- $parentElement.remove();
55
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
56
- } else {
57
- $parentElement.classList.remove(className);
58
- const targetNode = $parentElement.childNodes[0];
59
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
60
- }
61
- }
62
- }
63
- }
64
- }
65
- }
66
- } else {
67
- const newCursorData = _sortingCursorDataOnElement(cursorData, $element);
68
- let structure = "";
69
- let isDuble = false;
70
- if (newCursorData.startNodeIdx === newCursorData.endNodeIdx) {
71
- if (newCursorData.startNode.constructor.name === "Text") {
72
- $element.childNodes.forEach((childNode, i) => {
73
- if (newCursorData.startNodeIdx === i) {
74
- if (newCursorData.startOffset !== 0) {
75
- structure += childNode.textContent.slice(0, newCursorData.startOffset);
76
- isDuble = true;
77
- }
78
- structure += `<span class="${className}">${childNode.textContent.slice(newCursorData.startOffset, newCursorData.endOffset)}</span>`;
79
- if (newCursorData.endOffset !== childNode.textContent.length) {
80
- structure += childNode.textContent.slice(newCursorData.endOffset);
81
- }
82
- } else {
83
- if (childNode.constructor.name === "Text") {
84
- structure += childNode.textContent;
85
- } else {
86
- structure += childNode.outerHTML;
87
- }
88
- }
89
- });
90
- let childNumber = newCursorData.startNodeIdx;
91
- if (isDuble === true) {
92
- childNumber += 1;
93
- }
94
- $element.innerHTML = structure;
95
- const targetNode = $element.childNodes[childNumber];
96
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
97
- } else {
98
- const $target = newCursorData.startNode;
99
- if ($target.tagName !== "A") {
100
- const classList = $target.classList.value.split(" ");
101
- const classIdx = classList.indexOf(className);
102
- if (classIdx === -1) {
103
- if (newCursorData.startOffset !== 0) {
104
- structure += `<span class="${classList.join(" ")}">${$target.textContent.slice(0, newCursorData.startOffset)}</span>`;
105
- isDuble = true;
106
- }
107
- structure += `<span class="${classList.join(" ")} ${className}">${$target.textContent.slice(newCursorData.startOffset, newCursorData.endOffset)}</span>`;
108
- if (newCursorData.endOffset !== $target.textContent.length) {
109
- structure += `<span class="${classList.join(" ")}">${$target.textContent.slice(newCursorData.endOffset)}</span>`;
110
- }
111
- } else {
112
- if (newCursorData.startOffset !== 0) {
113
- structure += `<span class="${classList.join(" ")}">${$target.textContent.slice(0, newCursorData.startOffset)}</span>`;
114
- isDuble = true;
115
- }
116
- if (classList.length === 1) {
117
- structure += $target.textContent.slice(newCursorData.startOffset, newCursorData.endOffset);
118
- } else {
119
- const copyList = [...classList];
120
- copyList.splice(classIdx, 1);
121
- structure += `<span class="${copyList.join(" ")}">${$target.textContent.slice(newCursorData.startOffset, newCursorData.endOffset)}</span>`;
122
- }
123
- if (newCursorData.endOffset !== $target.textContent.length) {
124
- structure += `<span class="${classList.join(" ")}">${$target.textContent.slice(newCursorData.endOffset)}</span>`;
125
- }
126
- }
127
- $target.insertAdjacentHTML("afterend", structure);
128
- let $nextElement = $target.nextSibling;
129
- if (isDuble === true) {
130
- $nextElement = $nextElement.nextSibling;
131
- }
132
- $target.remove();
133
- const targetNode = $nextElement;
134
- _setRangeCursor(targetNode, targetNode, 0, targetNode.textContent?.length ?? 0);
135
- } else {
136
- alert(store.value.message.linkTextNoStyle);
137
- }
138
- }
139
- } else {
140
- let isAnchorElement = false;
141
- let isWrap = false;
142
- let startNodeIdx = newCursorData.startNodeIdx;
143
- let startOffset = newCursorData.startOffset;
144
- let endNodeIdx = newCursorData.endNodeIdx;
145
- let endOffset = newCursorData.endOffset;
146
- let structureArray = [];
147
- $element.childNodes.forEach((childNode, i) => {
148
- const $elementNode = childNode;
149
- let isText = childNode.constructor.name === "Text";
150
- if (newCursorData.startNodeIdx > i) {
151
- if (isText === true) {
152
- structureArray.push(childNode.textContent);
153
- } else {
154
- structureArray.push($elementNode.outerHTML);
155
- }
156
- }
157
- if (newCursorData.startNodeIdx === i) {
158
- const preTextContent = childNode.textContent.slice(0, newCursorData.startOffset);
159
- const textContent = childNode.textContent.slice(newCursorData.startOffset);
160
- if (isText === true) {
161
- structureArray.push(preTextContent);
162
- structureArray.push(`<span class="${className}">${textContent}</span>`);
163
- isWrap = true;
164
- if (newCursorData.startOffset !== 0) {
165
- isDuble = true;
166
- }
167
- } else {
168
- const classList = $elementNode.classList.value.split(" ");
169
- const classIdx = classList.indexOf(className);
170
- if ($elementNode.tagName === "SPAN") {
171
- if (classIdx === -1) {
172
- if (preTextContent !== "") {
173
- structureArray.push(`<span class="${classList.join(" ")}">${preTextContent}</span>`);
174
- }
175
- structureArray.push(`<span class="${classList.join(" ")} ${className}">${textContent}</span>`);
176
- isWrap = true;
177
- } else {
178
- if (classList.length === 1) {
179
- if (preTextContent !== "") {
180
- structureArray.push(`<span class="${classList.join(" ")}">${preTextContent}</span>`);
181
- }
182
- structureArray.push(textContent);
183
- } else {
184
- const newClassList = [...classList];
185
- newClassList.splice(classIdx, 1);
186
- if (preTextContent !== "") {
187
- structureArray.push(`<span class="${classList.join(" ")}">${preTextContent}</span>`);
188
- }
189
- structureArray.push(`<span class="${newClassList.join(" ")}">${textContent}</span>`);
190
- }
191
- }
192
- } else if ($elementNode.tagName === "BR") {
193
- structureArray.push("<br>");
194
- } else {
195
- isAnchorElement = true;
196
- }
197
- }
198
- }
199
- if (newCursorData.startNodeIdx < i && newCursorData.endNodeIdx > i) {
200
- if (isText === true) {
201
- if (isWrap === true) {
202
- structureArray.push(`<span class="${className}">${childNode.textContent}</span>`);
203
- } else {
204
- structureArray.push(childNode.textContent);
205
- }
206
- } else {
207
- const classList = $elementNode.classList.value.split(" ");
208
- const classIdx = classList.indexOf(className);
209
- if ($elementNode.tagName === "SPAN") {
210
- if (isWrap === true) {
211
- if (classIdx === -1) {
212
- structureArray.push(`<span class="${classList.join(" ")} ${className}">${childNode.textContent}</span>`);
213
- } else {
214
- structureArray.push($elementNode.outerHTML);
215
- }
216
- } else {
217
- if (classIdx === -1) {
218
- structureArray.push($elementNode.outerHTML);
219
- } else {
220
- if (classList.length === 1) {
221
- structureArray.push(childNode.textContent);
222
- } else {
223
- const newClassList = [...classList];
224
- newClassList.splice(classIdx, 1);
225
- structureArray.push(`<span class="${newClassList.join(" ")}">${childNode.textContent}</span>`);
226
- }
227
- }
228
- }
229
- } else if ($elementNode.tagName === "BR") {
230
- structureArray.push("<br>");
231
- } else {
232
- isAnchorElement = true;
233
- }
234
- }
235
- }
236
- if (newCursorData.endNodeIdx === i) {
237
- const textContent = childNode.textContent.slice(0, newCursorData.endOffset);
238
- const endTextContent = childNode.textContent.slice(newCursorData.endOffset);
239
- if (isText === true) {
240
- if (isWrap === true) {
241
- structureArray.push(`<span class="${className}">${textContent}</span>`);
242
- structureArray.push(endTextContent);
243
- } else {
244
- structureArray.push(childNode.textContent);
245
- }
246
- } else {
247
- const classList = $elementNode.classList.value.split(" ");
248
- const classIdx = classList.indexOf(className);
249
- if ($elementNode.tagName === "SPAN") {
250
- if (isWrap === true) {
251
- if (classIdx === -1) {
252
- structureArray.push(`<span class="${classList.join(" ")} ${className}">${textContent}</span>`);
253
- if (endTextContent !== "") {
254
- structureArray.push(`<span class="${classList.join(" ")}">${endTextContent}</span>`);
255
- }
256
- } else {
257
- structureArray.push($elementNode.outerHTML);
258
- }
259
- } else {
260
- if (classIdx === -1) {
261
- structureArray.push($elementNode.outerHTML);
262
- } else {
263
- if (classList.length === 1) {
264
- structureArray.push(textContent);
265
- if (endTextContent !== "") {
266
- structureArray.push(`<span class="${classList.join(" ")}">${endTextContent}</span>`);
267
- }
268
- } else {
269
- const newClassList = [...classList];
270
- newClassList.splice(classIdx, 1);
271
- structureArray.push(`<span class="${newClassList.join(" ")}">${textContent}</span>`);
272
- if (endTextContent !== "") {
273
- structureArray.push(`<span class="${classList.join(" ")}">${endTextContent}</span>`);
274
- }
275
- }
276
- }
277
- }
278
- } else if ($elementNode.tagName === "BR") {
279
- structureArray.push("<br>");
280
- } else {
281
- isAnchorElement = true;
282
- }
283
- }
284
- }
285
- if (newCursorData.endNodeIdx < i) {
286
- if (isText === true) {
287
- structureArray.push(childNode.textContent);
288
- } else {
289
- structureArray.push($elementNode.outerHTML);
290
- }
291
- }
292
- });
293
- if (isAnchorElement === false) {
294
- $element.innerHTML = structureArray.join("");
295
- if (isWrap === true) {
296
- if (isDuble === true) {
297
- startNodeIdx += 1;
298
- endNodeIdx += 1;
299
- startOffset = 0;
300
- }
301
- } else {
302
- const tagReg = new RegExp("(<([^>]+)>)", "i");
303
- const isTagList = [];
304
- let newStartNodeIdx = 0;
305
- let newStartOffset = startOffset * 1;
306
- let newEndOffset = 0;
307
- let endMinusCount = 0;
308
- structureArray.forEach((string, i) => {
309
- const isTag = tagReg.test(string);
310
- isTagList.push(isTag);
311
- if (startNodeIdx <= i && i <= endNodeIdx) {
312
- if (isTag === true) {
313
- newEndOffset = 0;
314
- } else {
315
- endMinusCount += 1;
316
- newEndOffset += string.length;
317
- }
318
- }
319
- });
320
- if (isTagList[startNodeIdx - 1] === false) {
321
- newStartNodeIdx = startNodeIdx - 1;
322
- newStartOffset = startOffset + structureArray[startNodeIdx - 1].length;
323
- }
324
- if (isTagList.slice(startNodeIdx, endNodeIdx).includes(true) === true) {
325
- endNodeIdx -= endMinusCount - 1;
326
- endOffset = newEndOffset;
327
- } else {
328
- endNodeIdx = newStartNodeIdx;
329
- endOffset = newStartOffset + newEndOffset;
330
- }
331
- startNodeIdx = newStartNodeIdx;
332
- startOffset = newStartOffset;
333
- }
334
- _setRangeCursor($element.childNodes[startNodeIdx], $element.childNodes[endNodeIdx], startOffset, endOffset);
335
- } else {
336
- alert(store.value.message.linkTextNoStyle);
337
- }
338
- }
339
- }
340
- _updateCursorData(store);
341
- _updateModelData(store);
342
- }
343
- }
344
- }
345
- }
346
- export function _setTextAlign(type, store) {
347
- if (store.value.cursorData !== null && store.value.controlStatus.$currentBlock !== null) {
348
- const cursorData = store.value.cursorData;
349
- const typeIgnoreList = ["code", "custom"];
350
- if (typeIgnoreList.includes(store.value.controlStatus.currentBlockType) === false) {
351
- const alignClassList = ["de-align-left", "de-align-right", "de-align-center", "de-align-justify"];
352
- const className = `de-align-${type}`;
353
- let $element = null;
354
- if (store.value.controlStatus.$currentBlock.classList.contains("de-image-block") === true) {
355
- $element = store.value.controlStatus.$currentBlock;
356
- } else {
357
- if (cursorData !== null) {
358
- $element = _findContentEditableElement(cursorData.startNode);
359
- }
360
- }
361
- if ($element !== null) {
362
- if ($element.classList.contains(className) === true) {
363
- $element.classList.remove(className);
364
- } else {
365
- const currentClassname = alignClassList.filter((text) => $element.classList.contains(text) === true)[0];
366
- if (currentClassname !== void 0) {
367
- $element.classList.remove(currentClassname);
368
- }
369
- $element.classList.add(className);
370
- }
371
- if (store.value.controlStatus.$currentBlock.classList.contains("de-image-block") !== true) {
372
- }
373
- _updateCursorData(store);
374
- _updateModelData(store);
375
- }
376
- }
377
- }
378
- }
@@ -1,2 +0,0 @@
1
- export * from "./decoration.js";
2
- export * from "./anchor.js";
@@ -1,2 +0,0 @@
1
- export * from "./decoration.js";
2
- export * from "./anchor.js";