dragon-editor 3.5.16 → 3.5.18

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
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=3.0.0"
5
5
  },
6
6
  "configKey": "dragon-editor",
7
- "version": "3.5.16",
7
+ "version": "3.5.18",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -47,12 +47,10 @@ const editorStore = ref<DragonEditorStore>({
47
47
  imageResizeEvent: false,
48
48
  },
49
49
  eventStatus: {
50
- preComposing: false,
51
50
  imageResizeEventStartX: 0,
52
51
  imageResizeEventType: "left",
53
52
  imageResizeEventEndX: 0,
54
53
  imageResizeCurrentWidth: 0,
55
- keyboardEnterCount: 0,
56
54
  },
57
55
  controlStatus: {
58
56
  isMobile: false,
@@ -379,12 +377,15 @@ defineExpose({
379
377
  .dragon-editor.--mobile .de-menu-bar .de-menu-wrap {
380
378
  overflow-x: auto;
381
379
  }
380
+ .dragon-editor.--mobile .de-menu-bar .de-link-exit-area {
381
+ left: auto;
382
+ right: 0;
383
+ }
382
384
  .dragon-editor .de-body {
383
385
  display: flex;
384
386
  flex-direction: column;
385
- gap: 4px;
386
387
  min-height: 500px;
387
- padding: 20px;
388
+ padding: 16px 20px;
388
389
  line-height: 1.6;
389
390
  }
390
391
  .dragon-editor .de-menu-bar {
@@ -400,6 +401,7 @@ defineExpose({
400
401
  }
401
402
  .dragon-editor .de-menu-bar .de-menu-wrap {
402
403
  display: flex;
404
+ overflow-x: auto;
403
405
  }
404
406
  .dragon-editor .de-menu-bar .de-col {
405
407
  display: flex;
@@ -462,14 +464,13 @@ defineExpose({
462
464
  display: none;
463
465
  position: absolute;
464
466
  top: calc(100% + 1px);
465
- left: 50%;
467
+ left: 205px;
466
468
  width: 200px;
467
469
  background: #fff;
468
470
  border: 1px solid #ccc;
469
471
  border-top: 0;
470
472
  border-radius: 0 0 var(--radius-default) var(--radius-default);
471
473
  z-index: 1000;
472
- transform: translateX(-50%);
473
474
  }
474
475
  .dragon-editor .de-menu-bar .de-link-exit-area.--active {
475
476
  display: block;
@@ -548,6 +549,7 @@ defineExpose({
548
549
  }
549
550
  .dragon-editor .de-block {
550
551
  width: 100%;
552
+ padding: 2px 0;
551
553
  box-sizing: border-box;
552
554
  }
553
555
  .dragon-editor .de-text-block {
@@ -563,6 +565,7 @@ defineExpose({
563
565
  }
564
566
  .dragon-editor .de-heading-block {
565
567
  min-height: 1.6em;
568
+ font-weight: bold;
566
569
  word-break: break-all;
567
570
  outline: 0;
568
571
  }
@@ -201,6 +201,7 @@ function structure(): VNode {
201
201
  }
202
202
  .dragon-editor-viewer .de-block {
203
203
  width: 100%;
204
+ padding: 2px 0;
204
205
  box-sizing: border-box;
205
206
  }
206
207
  .dragon-editor-viewer .de-text-block {
@@ -210,6 +211,7 @@ function structure(): VNode {
210
211
  }
211
212
  .dragon-editor-viewer .de-heading-block {
212
213
  min-height: 1.6em;
214
+ font-weight: bold;
213
215
  word-break: break-all;
214
216
  outline: 0;
215
217
  }
@@ -166,12 +166,15 @@
166
166
  .dragon-editor.--mobile .de-menu-bar .de-menu-wrap {
167
167
  overflow-x: auto;
168
168
  }
169
+ .dragon-editor.--mobile .de-menu-bar .de-link-exit-area {
170
+ left: auto;
171
+ right: 0;
172
+ }
169
173
  .dragon-editor .de-body {
170
174
  display: flex;
171
175
  flex-direction: column;
172
- gap: 4px;
173
176
  min-height: 500px;
174
- padding: 20px;
177
+ padding: 16px 20px;
175
178
  line-height: 1.6;
176
179
  }
177
180
  .dragon-editor .de-menu-bar {
@@ -187,6 +190,7 @@
187
190
  }
188
191
  .dragon-editor .de-menu-bar .de-menu-wrap {
189
192
  display: flex;
193
+ overflow-x: auto;
190
194
  }
191
195
  .dragon-editor .de-menu-bar .de-col {
192
196
  display: flex;
@@ -249,14 +253,13 @@
249
253
  display: none;
250
254
  position: absolute;
251
255
  top: calc(100% + 1px);
252
- left: 50%;
256
+ left: 205px;
253
257
  width: 200px;
254
258
  background: #fff;
255
259
  border: 1px solid #ccc;
256
260
  border-top: 0;
257
261
  border-radius: 0 0 var(--radius-default) var(--radius-default);
258
262
  z-index: 1000;
259
- transform: translateX(-50%);
260
263
  }
261
264
  .dragon-editor .de-menu-bar .de-link-exit-area.--active {
262
265
  display: block;
@@ -335,6 +338,7 @@
335
338
  }
336
339
  .dragon-editor .de-block {
337
340
  width: 100%;
341
+ padding: 2px 0;
338
342
  box-sizing: border-box;
339
343
  }
340
344
  .dragon-editor .de-text-block {
@@ -350,6 +354,7 @@
350
354
  }
351
355
  .dragon-editor .de-heading-block {
352
356
  min-height: 1.6em;
357
+ font-weight: bold;
353
358
  word-break: break-all;
354
359
  outline: 0;
355
360
  }
@@ -166,6 +166,7 @@
166
166
  }
167
167
  .dragon-editor-viewer .de-block {
168
168
  width: 100%;
169
+ padding: 2px 0;
169
170
  box-sizing: border-box;
170
171
  }
171
172
  .dragon-editor-viewer .de-text-block {
@@ -175,6 +176,7 @@
175
176
  }
176
177
  .dragon-editor-viewer .de-heading-block {
177
178
  min-height: 1.6em;
179
+ font-weight: bold;
178
180
  word-break: break-all;
179
181
  outline: 0;
180
182
  }
@@ -43,12 +43,10 @@ interface DragonEditorStore {
43
43
  imageResizeEvent: boolean;
44
44
  };
45
45
  eventStatus: {
46
- preComposing: boolean;
47
46
  imageResizeEventStartX: number;
48
47
  imageResizeEventType: "right" | "left";
49
48
  imageResizeEventEndX: number;
50
49
  imageResizeCurrentWidth: number;
51
- keyboardEnterCount: number;
52
50
  };
53
51
  controlStatus: {
54
52
  isMobile: boolean;
@@ -4,3 +4,4 @@ export declare function _imageResizeEventStart(event: Event, store: Ref<DragonEd
4
4
  export declare function _imageResizeEvent(event: Event, store: Ref<DragonEditorStore>): void;
5
5
  export declare function _imageResizeEventEnd(event: Event, store: Ref<DragonEditorStore>): void;
6
6
  export declare function _moveBlock(type: "up" | "down", store: Ref<DragonEditorStore>): void;
7
+ export declare function _checkNeedNewBlock(event: MouseEvent, store: Ref<DragonEditorStore>): void;
@@ -1,5 +1,5 @@
1
- import { _updateModelData } from "./index.js";
2
- import { _updateCurrentBlock } from "../node/index.js";
1
+ import { _updateModelData, _getDefaultBlockData } from "./index.js";
2
+ import { _updateCurrentBlock, _createTextBlock } from "../node/index.js";
3
3
  export function _imageResizeEventStart(event, store) {
4
4
  const $target = event.target;
5
5
  if ($target !== null) {
@@ -76,3 +76,26 @@ export function _moveBlock(type, store) {
76
76
  _updateModelData(store);
77
77
  }
78
78
  }
79
+ export function _checkNeedNewBlock(event, store) {
80
+ const $target = event.target;
81
+ if ($target !== null) {
82
+ const $element = $target;
83
+ if ($element.classList.contains("js-de-body") === true) {
84
+ const blockList = $element.querySelectorAll(".de-block");
85
+ const $targetBlock = blockList[blockList.length - 1];
86
+ if ($targetBlock.classList.contains("de-text-block") === true) {
87
+ if ($targetBlock.textContent === "") {
88
+ $targetBlock.focus();
89
+ } else {
90
+ const $block = _createTextBlock(_getDefaultBlockData("text"));
91
+ $targetBlock.insertAdjacentElement("afterend", $block);
92
+ $block.focus();
93
+ }
94
+ } else {
95
+ const $block = _createTextBlock(_getDefaultBlockData("text"));
96
+ $targetBlock.insertAdjacentElement("afterend", $block);
97
+ $block.focus();
98
+ }
99
+ }
100
+ }
101
+ }
@@ -7,16 +7,11 @@ export function _contentKeydownEvent(event, store) {
7
7
  _updateCursorData(store);
8
8
  switch (event.key) {
9
9
  case "Enter":
10
- if (store.value.eventStatus.preComposing === false && event.isComposing === false) {
10
+ if (event.isComposing === false) {
11
11
  __enterEvent(event, store);
12
12
  } else {
13
- if (store.value.eventStatus.keyboardEnterCount % 2 === 0) {
14
- __enterEvent(event, store);
15
- } else {
16
- event.preventDefault();
17
- }
13
+ event.preventDefault();
18
14
  }
19
- store.value.eventStatus.keyboardEnterCount += 1;
20
15
  break;
21
16
  case "Backspace":
22
17
  __backspaceEvent(event, store);
@@ -41,7 +36,6 @@ export function _contentKeydownEvent(event, store) {
41
36
  break;
42
37
  }
43
38
  _hotKeyEvent(event, store);
44
- store.value.eventStatus.preComposing = event.isComposing;
45
39
  }
46
40
  export async function _contentPasteEvent(event, store) {
47
41
  event.preventDefault();
@@ -1335,7 +1329,6 @@ export function _contentKeyupEvent(event, store) {
1335
1329
  _updateCurrentBlock(event, store);
1336
1330
  _updateCursorData(store);
1337
1331
  __checkBlock(store);
1338
- store.value.eventStatus.keyboardEnterCount = 0;
1339
1332
  clearTimeout(contentKeyupEvent);
1340
1333
  contentKeyupEvent = setTimeout(() => {
1341
1334
  _updateModelData(store);
@@ -1,9 +1,10 @@
1
- import { _updateCursorData, _imageResizeEventStart, _imageResizeEvent, _imageResizeEventEnd } from "./index.js";
1
+ import { _updateCursorData, _imageResizeEventStart, _imageResizeEvent, _imageResizeEventEnd, _checkNeedNewBlock } from "./index.js";
2
2
  import { _getCurrentBlock, _updateCurrentBlock, _updateHeadingBlockList } from "../node/index.js";
3
3
  import { _updateAnchorTagValue } from "../style/index.js";
4
4
  export function _contentMouseupEvent(event, store) {
5
5
  _updateCurrentBlock(event, store);
6
6
  _updateCursorData(store);
7
+ _checkNeedNewBlock(event, store);
7
8
  }
8
9
  export function _contentMousedownEvnet(event, store) {
9
10
  _imageResizeEventStart(event, store);
@@ -7,6 +7,67 @@ export function _getMenuBarVNodeStructure(store) {
7
7
  const childNode = [];
8
8
  childNode.push(__getMenuListStructure(store));
9
9
  childNode.push(__getBlockListStructure(store));
10
+ childNode.push(
11
+ h("div", { class: ["de-link-exit-area", "js-de-link-exit-area", { "--active": store.value.activeStatus.anchorInputArea }] }, [
12
+ h("div", { class: ["de-btn-area"] }, [
13
+ h(
14
+ "button",
15
+ {
16
+ class: ["de-btn", { "--active": store.value.controlStatus.anchorTabType === "url" }],
17
+ onClick: () => {
18
+ store.value.controlStatus.anchorTabType = "url";
19
+ }
20
+ },
21
+ "Text"
22
+ ),
23
+ h(
24
+ "button",
25
+ {
26
+ class: ["de-btn", { "--active": store.value.controlStatus.anchorTabType === "heading" }],
27
+ onClick: () => {
28
+ store.value.controlStatus.anchorTabType = "heading";
29
+ }
30
+ },
31
+ "Heading"
32
+ )
33
+ ]),
34
+ store.value.controlStatus.anchorTabType === "url" ? h("div", { class: ["de-link-text-area"] }, [
35
+ h("input", {
36
+ class: ["de-input", { "--error": store.value.controlStatus.anchorValidation === false }],
37
+ value: store.value.controlStatus.anchorHref,
38
+ onChange: (event) => {
39
+ store.value.controlStatus.anchorHref = event.currentTarget.value;
40
+ }
41
+ }),
42
+ h(
43
+ "button",
44
+ {
45
+ class: ["de-btn"],
46
+ onClick: () => {
47
+ _setAnchorTag(store.value.controlStatus.anchorHref, true, store);
48
+ }
49
+ },
50
+ "Set"
51
+ )
52
+ ]) : h(
53
+ "div",
54
+ { class: ["de-link-heading-area"] },
55
+ store.value.controlStatus.anchorHeadingList.map((item) => {
56
+ return h(
57
+ "button",
58
+ {
59
+ class: ["de-btn", { "--active": store.value.controlStatus.anchorHref === `#${item.id}` }],
60
+ onClick: () => {
61
+ store.value.activeStatus.anchorInputArea = false;
62
+ _setAnchorTag(item.id, false, store);
63
+ }
64
+ },
65
+ item.name
66
+ );
67
+ })
68
+ )
69
+ ])
70
+ );
10
71
  return h("div", { class: ["de-menu-bar"], style: { top: `${store.value.menuBarTop}px` } }, childNode);
11
72
  }
12
73
  function __getMenuListStructure(store) {
@@ -100,58 +161,7 @@ function __getMenuListStructure(store) {
100
161
  }
101
162
  },
102
163
  [_getIconNode("remove-link")]
103
- ),
104
- h("div", { class: ["de-link-exit-area", "js-de-link-exit-area", { "--active": store.value.activeStatus.anchorInputArea }] }, [
105
- h("div", { class: ["de-btn-area"] }, [
106
- h(
107
- "button",
108
- {
109
- class: ["de-btn", { "--active": store.value.controlStatus.anchorTabType === "url" }],
110
- onClick: () => {
111
- store.value.controlStatus.anchorTabType = "url";
112
- }
113
- },
114
- "Text"
115
- ),
116
- h(
117
- "button",
118
- {
119
- class: ["de-btn", { "--active": store.value.controlStatus.anchorTabType === "heading" }],
120
- onClick: () => {
121
- store.value.controlStatus.anchorTabType = "heading";
122
- }
123
- },
124
- "Heading"
125
- )
126
- ]),
127
- store.value.controlStatus.anchorTabType === "url" ? h("div", { class: ["de-link-text-area"] }, [
128
- h("input", {
129
- class: ["de-input", { "--error": store.value.controlStatus.anchorValidation === false }],
130
- value: store.value.controlStatus.anchorHref,
131
- onChange: (event) => {
132
- store.value.controlStatus.anchorHref = event.currentTarget.value;
133
- }
134
- }),
135
- h("button", { class: ["de-btn"], onClick: () => {
136
- } }, "Set")
137
- ]) : h(
138
- "div",
139
- { class: ["de-link-heading-area"] },
140
- store.value.controlStatus.anchorHeadingList.map((item) => {
141
- return h(
142
- "button",
143
- {
144
- class: ["de-btn", { "--active": store.value.controlStatus.anchorHref === `#${item.id}` }],
145
- onClick: () => {
146
- store.value.activeStatus.anchorInputArea = false;
147
- _setAnchorTag(item.id, false, store);
148
- }
149
- },
150
- item.name
151
- );
152
- })
153
- )
154
- ])
164
+ )
155
165
  ])
156
166
  );
157
167
  menuGroupNode.push(
@@ -3,7 +3,6 @@ import { _findContentEditableElement, _findPoverTextNode } from "../node/index.j
3
3
  export function _setAnchorTag(url, isOutsideLink, store) {
4
4
  if (store.value.controlStatus.previousCorsorData !== null && store.value.controlStatus.$currentBlock !== null) {
5
5
  const cursorData = store.value.controlStatus.previousCorsorData;
6
- const $block = store.value.controlStatus.$currentBlock;
7
6
  const typeIgnoreList = ["image", "code", "custom"];
8
7
  const hrefValue = isOutsideLink === true ? url : `#${url}`;
9
8
  const $element = _findContentEditableElement(cursorData.startNode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.5.16",
3
+ "version": "3.5.18",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt3!",
5
5
  "repository": {
6
6
  "type": "git",