dragon-editor 3.5.16 → 3.5.17
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 +1 -1
- package/dist/runtime/components/DragonEditor.vue +8 -6
- package/dist/runtime/components/DragonEditorViewer.vue +1 -0
- package/dist/runtime/scss/editor.css +8 -4
- package/dist/runtime/scss/viewer.css +1 -0
- package/dist/runtime/type.d.ts +0 -2
- package/dist/runtime/utils/event/block.d.ts +1 -0
- package/dist/runtime/utils/event/block.js +25 -2
- package/dist/runtime/utils/event/keyboard.js +2 -9
- package/dist/runtime/utils/event/mouse.js +2 -1
- package/dist/runtime/utils/layout/menuBar.js +54 -52
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -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:
|
|
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 {
|
|
@@ -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:
|
|
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 {
|
package/dist/runtime/type.d.ts
CHANGED
|
@@ -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 (
|
|
10
|
+
if (event.isComposing === false) {
|
|
11
11
|
__enterEvent(event, store);
|
|
12
12
|
} else {
|
|
13
|
-
|
|
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,59 @@ 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("button", { class: ["de-btn"], onClick: () => {
|
|
43
|
+
} }, "Set")
|
|
44
|
+
]) : h(
|
|
45
|
+
"div",
|
|
46
|
+
{ class: ["de-link-heading-area"] },
|
|
47
|
+
store.value.controlStatus.anchorHeadingList.map((item) => {
|
|
48
|
+
return h(
|
|
49
|
+
"button",
|
|
50
|
+
{
|
|
51
|
+
class: ["de-btn", { "--active": store.value.controlStatus.anchorHref === `#${item.id}` }],
|
|
52
|
+
onClick: () => {
|
|
53
|
+
store.value.activeStatus.anchorInputArea = false;
|
|
54
|
+
_setAnchorTag(item.id, false, store);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
item.name
|
|
58
|
+
);
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
])
|
|
62
|
+
);
|
|
10
63
|
return h("div", { class: ["de-menu-bar"], style: { top: `${store.value.menuBarTop}px` } }, childNode);
|
|
11
64
|
}
|
|
12
65
|
function __getMenuListStructure(store) {
|
|
@@ -100,58 +153,7 @@ function __getMenuListStructure(store) {
|
|
|
100
153
|
}
|
|
101
154
|
},
|
|
102
155
|
[_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
|
-
])
|
|
156
|
+
)
|
|
155
157
|
])
|
|
156
158
|
);
|
|
157
159
|
menuGroupNode.push(
|