dragon-editor 2.1.2 → 3.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 (58) hide show
  1. package/README.md +82 -96
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +10 -12
  4. package/dist/runtime/components/DragonEditor.vue +457 -0
  5. package/dist/runtime/components/DragonEditorViewer.vue +228 -0
  6. package/dist/runtime/plugin.d.ts +2 -0
  7. package/dist/runtime/plugin.mjs +10 -0
  8. package/dist/runtime/scss/editor.css +261 -0
  9. package/dist/runtime/scss/viewer.css +198 -0
  10. package/dist/runtime/store.d.ts +7 -0
  11. package/dist/runtime/store.mjs +27 -0
  12. package/dist/runtime/type.d.ts +24 -0
  13. package/dist/runtime/utils/block.d.ts +9 -0
  14. package/dist/runtime/utils/block.mjs +70 -0
  15. package/dist/runtime/utils/convertor.d.ts +2 -0
  16. package/dist/runtime/utils/convertor.mjs +86 -0
  17. package/dist/runtime/utils/cursor.d.ts +6 -0
  18. package/dist/runtime/utils/cursor.mjs +132 -0
  19. package/dist/runtime/utils/element.d.ts +3 -0
  20. package/dist/runtime/utils/element.mjs +39 -0
  21. package/dist/runtime/utils/keyboardEvent.d.ts +10 -0
  22. package/dist/runtime/utils/keyboardEvent.mjs +781 -0
  23. package/dist/runtime/utils/style.d.ts +1 -0
  24. package/dist/runtime/utils/style.mjs +330 -0
  25. package/dist/runtime/utils/ui.d.ts +1 -0
  26. package/dist/runtime/utils/ui.mjs +35 -0
  27. package/package.json +10 -4
  28. package/README_en.md +0 -30
  29. package/dist/runtime/core/components/SvgIcon.d.ts +0 -10
  30. package/dist/runtime/core/components/SvgIcon.mjs +0 -98
  31. package/dist/runtime/core/components/editor/ImageBlock.vue +0 -175
  32. package/dist/runtime/core/components/editor/OlBlock.vue +0 -162
  33. package/dist/runtime/core/components/editor/TextBlock.vue +0 -172
  34. package/dist/runtime/core/components/editor/UlBlock.vue +0 -162
  35. package/dist/runtime/core/style/common.css +0 -496
  36. package/dist/runtime/core/style/viewer.css +0 -205
  37. package/dist/runtime/core/utils/converter.d.ts +0 -2
  38. package/dist/runtime/core/utils/converter.mjs +0 -90
  39. package/dist/runtime/core/utils/cursor.d.ts +0 -4
  40. package/dist/runtime/core/utils/cursor.mjs +0 -84
  41. package/dist/runtime/core/utils/element.d.ts +0 -3
  42. package/dist/runtime/core/utils/element.mjs +0 -40
  43. package/dist/runtime/core/utils/global.d.ts +0 -3
  44. package/dist/runtime/core/utils/global.mjs +0 -81
  45. package/dist/runtime/core/utils/index.d.ts +0 -7
  46. package/dist/runtime/core/utils/index.mjs +0 -7
  47. package/dist/runtime/core/utils/keyboard.d.ts +0 -6
  48. package/dist/runtime/core/utils/keyboard.mjs +0 -565
  49. package/dist/runtime/core/utils/style.d.ts +0 -6
  50. package/dist/runtime/core/utils/style.mjs +0 -374
  51. package/dist/runtime/core/utils/ui.d.ts +0 -4
  52. package/dist/runtime/core/utils/ui.mjs +0 -13
  53. package/dist/runtime/shared/components/DragonEditor.vue +0 -695
  54. package/dist/runtime/shared/components/DragonEditorComment.vue +0 -172
  55. package/dist/runtime/shared/components/DragonEditorNew.d.ts +0 -16
  56. package/dist/runtime/shared/components/DragonEditorNew.mjs +0 -62
  57. package/dist/runtime/shared/components/DragonEditorViewer.d.ts +0 -14
  58. package/dist/runtime/shared/components/DragonEditorViewer.mjs +0 -15
@@ -0,0 +1,132 @@
1
+ import "../type.d.ts";
2
+ export function _setCursorData(store) {
3
+ const selection = window.getSelection();
4
+ if (selection.type !== "None") {
5
+ store.setCursorData({
6
+ type: selection.type,
7
+ startNode: selection.anchorNode,
8
+ startOffset: selection.anchorOffset,
9
+ endNode: selection.focusNode,
10
+ endOffset: selection.focusOffset
11
+ });
12
+ }
13
+ }
14
+ export function _setCursor($target, startIdx) {
15
+ const range = document.createRange();
16
+ const selection = window.getSelection();
17
+ if ($target.constructor.name === "Text") {
18
+ range.setStart($target, startIdx);
19
+ } else {
20
+ if ($target.hasChildNodes() === true) {
21
+ if ($target.textContent === "") {
22
+ range.setStart($target.childNodes[startIdx], 0);
23
+ } else {
24
+ range.setStart($target.childNodes[0], startIdx);
25
+ }
26
+ } else {
27
+ range.setStart($target, startIdx);
28
+ }
29
+ }
30
+ selection.removeAllRanges();
31
+ selection.addRange(range);
32
+ }
33
+ export function _setRangeCursor($startTarget, $endTarget, startIdx, endIdx) {
34
+ const range = document.createRange();
35
+ const selection = window.getSelection();
36
+ if ($startTarget.constructor.name === "Text") {
37
+ range.setStart($startTarget, startIdx);
38
+ } else {
39
+ if ($startTarget.hasChildNodes() === true) {
40
+ if ($startTarget.textContent === "") {
41
+ range.setStart($startTarget.childNodes[startIdx], 0);
42
+ } else {
43
+ range.setStart($startTarget.childNodes[0], startIdx);
44
+ }
45
+ } else {
46
+ range.setStart($startTarget, startIdx);
47
+ }
48
+ }
49
+ if ($endTarget.constructor.name === "Text") {
50
+ range.setEnd($endTarget, endIdx);
51
+ } else {
52
+ if ($endTarget.hasChildNodes() === true) {
53
+ if ($endTarget.textContent === "") {
54
+ range.setEnd($endTarget.childNodes[endIdx], 0);
55
+ } else {
56
+ range.setEnd($endTarget.childNodes[0], endIdx);
57
+ }
58
+ } else {
59
+ range.setEnd($endTarget, endIdx);
60
+ }
61
+ }
62
+ selection.removeAllRanges();
63
+ selection.addRange(range);
64
+ }
65
+ export function _clenupCursor(store) {
66
+ _setCursorData(store);
67
+ if (store.cursorData.startNode !== store.cursorData.endNode || store.cursorData.startOffset !== store.cursorData.endOffset) {
68
+ } else {
69
+ if (store.cursorData.startNode.hasChildNodes() === true) {
70
+ _setCursor(store.cursorData.startNode.childNodes[store.cursorData.startOffset], 0);
71
+ } else {
72
+ _setCursor(store.cursorData.startNode, store.cursorData.startOffset);
73
+ }
74
+ }
75
+ }
76
+ export function _soltingCursorDataOnElement(cursorData, $element) {
77
+ const childList = $element.childNodes;
78
+ let startNode = cursorData.startNode;
79
+ let startIdx = -1;
80
+ let startOffset = cursorData.startOffset;
81
+ let endNode = cursorData.endNode;
82
+ let endIdx = -1;
83
+ let endOffset = cursorData.endOffset;
84
+ if (startNode.constructor.name === "Text") {
85
+ if (startNode.parentElement !== $element) {
86
+ startNode = startNode.parentElement;
87
+ }
88
+ }
89
+ if (endNode.constructor.name === "Text") {
90
+ if (endNode.parentElement !== $element) {
91
+ endNode = endNode.parentElement;
92
+ }
93
+ }
94
+ for (let i = 0; childList.length > i; i += 1) {
95
+ if (startIdx !== -1 && endIdx !== -1) {
96
+ break;
97
+ }
98
+ if (startNode === childList[i]) {
99
+ startIdx = i;
100
+ }
101
+ if (endNode === childList[i]) {
102
+ endIdx = i;
103
+ }
104
+ }
105
+ if (startIdx === endIdx) {
106
+ if (cursorData.startOffset > cursorData.endOffset) {
107
+ startOffset = cursorData.endOffset;
108
+ endOffset = cursorData.startOffset;
109
+ }
110
+ } else {
111
+ if (startIdx > endIdx) {
112
+ const originStartNode = startNode;
113
+ const originStartIdx = startIdx;
114
+ const originEndNode = endNode;
115
+ const originEndIdx = endIdx;
116
+ startNode = originEndNode;
117
+ startIdx = originEndIdx;
118
+ startOffset = cursorData.endOffset;
119
+ endNode = originStartNode;
120
+ endIdx = originStartIdx;
121
+ endOffset = cursorData.startOffset;
122
+ }
123
+ }
124
+ return {
125
+ startNode,
126
+ startNodeIdx: startIdx,
127
+ startOffset,
128
+ endNode,
129
+ endNodeIdx: endIdx,
130
+ endOffset
131
+ };
132
+ }
@@ -0,0 +1,3 @@
1
+ export declare function _findScrollingElement($target: HTMLElement): HTMLElement | Window;
2
+ export declare function _getParentElementIfNodeIsText($target: Node, $block: HTMLElement): Node;
3
+ export declare function _findContentEditableElement($target: Node): HTMLElement | null;
@@ -0,0 +1,39 @@
1
+ export function _findScrollingElement($target) {
2
+ if ($target.parentElement !== null) {
3
+ if ($target.scrollHeight > $target.clientHeight) {
4
+ return $target;
5
+ } else {
6
+ if ($target.parentElement.tagName === "BODY") {
7
+ return window;
8
+ } else {
9
+ return _findScrollingElement($target.parentElement);
10
+ }
11
+ }
12
+ } else {
13
+ return window;
14
+ }
15
+ }
16
+ export function _getParentElementIfNodeIsText($target, $block) {
17
+ if ($target.constructor.name === "Text") {
18
+ const $parent = $target.parentElement;
19
+ if ($parent !== $block) {
20
+ $target = $parent;
21
+ }
22
+ }
23
+ return $target;
24
+ }
25
+ export function _findContentEditableElement($target) {
26
+ if ($target.constructor.name === "Text") {
27
+ $target = $target.parentNode;
28
+ }
29
+ const $baseElement = $target;
30
+ if ($baseElement.parentElement.tagName === "BODY") {
31
+ return null;
32
+ } else {
33
+ if ($baseElement.getAttribute("contentEditable") === null) {
34
+ return _findContentEditableElement($baseElement.parentNode);
35
+ } else {
36
+ return $baseElement;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,10 @@
1
+ export declare function _elementKeyEvent(event: KeyboardEvent, store: any): void;
2
+ /**
3
+ * 핫 키 이벤트
4
+ */
5
+ export declare function _hotKeyEvent(event: KeyboardEvent, store: any): void;
6
+ /**
7
+ * 복사 & 붙여넣기 이벤트
8
+ */
9
+ export declare function copyEvent(event: KeyboardEvent, store: any): void;
10
+ export declare function pasteEvent(event: KeyboardEvent, store: any): void;