dragon-editor 2.0.0-beta.1.4 → 2.0.0-beta.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.
Files changed (29) hide show
  1. package/README.md +72 -135
  2. package/README_en.md +14 -62
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +8 -0
  5. package/dist/runtime/core/components/SvgIcon.vue +30 -21
  6. package/dist/runtime/core/components/editor/ImageBlock.vue +174 -0
  7. package/dist/runtime/core/components/editor/TextBlock.vue +76 -31
  8. package/dist/runtime/core/components/icon/Accept.vue +5 -0
  9. package/dist/runtime/core/components/icon/ArrowDown.vue +3 -0
  10. package/dist/runtime/core/components/icon/ArrowUp.vue +3 -0
  11. package/dist/runtime/core/components/icon/Cancel.vue +5 -0
  12. package/dist/runtime/core/components/icon/Delete.vue +3 -0
  13. package/dist/runtime/core/style/common.css +260 -31
  14. package/dist/runtime/core/style/viewer.css +191 -0
  15. package/dist/runtime/core/utils/cursor.d.ts +1 -1
  16. package/dist/runtime/core/utils/cursor.mjs +16 -4
  17. package/dist/runtime/core/utils/element.mjs +8 -4
  18. package/dist/runtime/core/utils/index.d.ts +2 -3
  19. package/dist/runtime/core/utils/index.mjs +47 -6
  20. package/dist/runtime/core/utils/keyboard.d.ts +1 -1
  21. package/dist/runtime/core/utils/keyboard.mjs +264 -40
  22. package/dist/runtime/core/utils/style.d.ts +6 -2
  23. package/dist/runtime/core/utils/style.mjs +125 -30
  24. package/dist/runtime/shared/components/DragonEditor.vue +356 -157
  25. package/dist/runtime/shared/components/DragonEditorComment.vue +33 -11
  26. package/dist/runtime/shared/components/DragonEditorViewer.vue +28 -2
  27. package/package.json +1 -1
  28. package/dist/runtime/core/style/main.d.ts +0 -1
  29. package/dist/runtime/core/style/main.mjs +0 -24
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="dragon-editor">
2
+ <div class="dragon-editor --comment">
3
3
  <p class="d-text-block" :class="data.classList" contenteditable v-html="data.content" @keydown="textKeyboardEvent"
4
4
  @paste="pasteEvent" ref="$block"></p>
5
5
  </div>
@@ -17,7 +17,7 @@ import {
17
17
  getCursor,
18
18
  findEditableElement
19
19
  } from "../../core/utils/index";
20
- import { commentBlock } from "../../../types/index";
20
+ import { commentBlock, cursorSelection } from "../../../types/index";
21
21
 
22
22
  const $block = ref();
23
23
  const data = ref<commentBlock>({
@@ -29,6 +29,13 @@ const props = defineProps<{ modelValue: commentBlock }>();
29
29
  const emit = defineEmits<{
30
30
  (e: "update:modelValue", modelValue: commentBlock): void;
31
31
  }>();
32
+ const blockCursorData = ref<cursorSelection>({
33
+ type: "",
34
+ startNode: null,
35
+ startOffset: null,
36
+ endNode: null,
37
+ endOffset: null,
38
+ });
32
39
 
33
40
  data.value = unref(props.modelValue) as commentBlock;
34
41
 
@@ -58,7 +65,7 @@ function updateBlockData() {
58
65
 
59
66
  // 커서위치 재지정
60
67
  if ($block.value.innerHTML.length > 0) {
61
- const cursorData = getArrangementCursorData();
68
+ const cursorData = getArrangementCursorData(blockCursorData.value);
62
69
 
63
70
  data.value.content = $block.value.innerHTML;
64
71
  emit("update:modelValue", data.value);
@@ -69,13 +76,19 @@ function updateBlockData() {
69
76
  cursorData.length
70
77
  );
71
78
 
72
- // 태그 삭제
79
+ // 구조 검수
73
80
  $block.value.childNodes.forEach((child: ChildNode) => {
74
- if (
75
- child.constructor.name !== "Text" &&
76
- child.textContent === ""
77
- ) {
78
- child.remove();
81
+ if (child.constructor.name !== "Text") { // 텍스트가 아닐경우
82
+ if (child.constructor.name !== "HTMLBRElement") { // br 태그 유지
83
+ if (child.textContent === "") { // 빈 태그 삭제
84
+ child.remove();
85
+ } else if ((child as HTMLElement).classList.length === 0) { // 클레스 없는 엘리먼트 처리
86
+ (child as HTMLElement).insertAdjacentHTML("afterend", child.textContent as string);
87
+ child.remove();
88
+ }
89
+ } else {
90
+ (child as HTMLElement).removeAttribute("class");
91
+ }
79
92
  }
80
93
  });
81
94
  }, 100);
@@ -86,10 +99,19 @@ function updateBlockData() {
86
99
 
87
100
  function focus() {
88
101
  setCursor($block.value, 0);
102
+ blockCursorData.value = getCursor();
89
103
  }
90
104
 
91
- function setStyles(kind: string) {
92
- data.value = styleSettings(kind, data.value, $block.value);
105
+ function setStyles(kind: string, url?: string) {
106
+ data.value = styleSettings(
107
+ {
108
+ kind: kind,
109
+ blockData: data.value,
110
+ $target: $block.value,
111
+ url: url,
112
+ cursorData: blockCursorData.value
113
+ }
114
+ );
93
115
  setTimeout(() => {
94
116
  updateBlockData();
95
117
  }, 250);
@@ -1,3 +1,29 @@
1
1
  <template>
2
- <div class="editor-viewer"></div>
3
- </template>
2
+ <div class="dragon-editor-viewer">
3
+ <template v-for="(row, count) in props.content">
4
+ <p class="d-text-block" v-if="row.type === 'text'" :class="row.classList" v-html="row.content"></p>
5
+
6
+ <template v-if="row.type === 'image'">
7
+ <template v-if="row.webp"> </template>
8
+ <template v-else>
9
+ <div class="d-image-block" :class="row.classList">
10
+ <div class="d-image-area">
11
+ <img class="d-img" :src="row.src" :width="row.width" :height="row.height" :alt="row.caption" loading="lazy">
12
+ </div>
13
+ <p class="d-caption" v-if="row.caption" v-html="row.caption"></p>
14
+ </div>
15
+ </template>
16
+ </template>
17
+ </template>
18
+ </div>
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ const props = defineProps<{
23
+ content: any[];
24
+ }>();
25
+ </script>
26
+
27
+ <style>
28
+ @import "../../core/style/viewer.css";
29
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "2.0.0-beta.1.4",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "WYSIWYG editor on Nuxt.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- export const __esModule: boolean;
@@ -1,24 +0,0 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ // The require scope
4
- /******/ var __webpack_require__ = {};
5
- /******/
6
- /************************************************************************/
7
- /******/ /* webpack/runtime/make namespace object */
8
- /******/ (() => {
9
- /******/ // define __esModule on exports
10
- /******/ __webpack_require__.r = (exports) => {
11
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
12
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13
- /******/ }
14
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
15
- /******/ };
16
- /******/ })();
17
- /******/
18
- /************************************************************************/
19
- var __webpack_exports__ = {};
20
- __webpack_require__.r(__webpack_exports__);
21
- // extracted by mini-css-extract-plugin
22
-
23
- /******/ })()
24
- ;