dragon-editor 3.8.0 → 3.8.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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/DragonEditor.d.vue.ts +2 -1
- package/dist/runtime/components/DragonEditor.vue +10 -1
- package/dist/runtime/components/DragonEditor.vue.d.ts +2 -1
- package/dist/runtime/type.d.mts +1 -1
- package/dist/runtime/utils/event/block.js +16 -7
- package/dist/runtime/utils/event/keyboard.js +16 -11
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -10,13 +10,14 @@ declare function setDecoration(style: DEDecoration): void;
|
|
|
10
10
|
declare function setAlign(align: DETextalign): void;
|
|
11
11
|
declare function changeEditorData(data: DEContentData): void;
|
|
12
12
|
declare function updateLayout(): void;
|
|
13
|
+
declare function checkDataEmpty(data?: DEContentData): boolean;
|
|
13
14
|
declare const __VLS_export: import("vue").DefineComponent<DEOption, {
|
|
14
15
|
addBlock: typeof addBlock;
|
|
15
16
|
setDecoration: typeof setDecoration;
|
|
16
17
|
setAlign: typeof setAlign;
|
|
17
18
|
changeEditorData: typeof changeEditorData;
|
|
18
19
|
updateLayout: typeof updateLayout;
|
|
19
|
-
checkDataEmpty:
|
|
20
|
+
checkDataEmpty: typeof checkDataEmpty;
|
|
20
21
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
22
|
"update:modelValue": (data: DEContentData) => any;
|
|
22
23
|
uploadImageEvent: (file: File) => any;
|
|
@@ -181,6 +181,15 @@ function updateLayout() {
|
|
|
181
181
|
_eidtorMountEvent(editorStore);
|
|
182
182
|
}, 500);
|
|
183
183
|
}
|
|
184
|
+
function checkDataEmpty(data) {
|
|
185
|
+
let suitable = false;
|
|
186
|
+
if (data !== void 0) {
|
|
187
|
+
suitable = _checkDataEmpty(data);
|
|
188
|
+
} else {
|
|
189
|
+
suitable = _checkDataEmpty(props.modelValue);
|
|
190
|
+
}
|
|
191
|
+
return suitable;
|
|
192
|
+
}
|
|
184
193
|
onMounted(() => {
|
|
185
194
|
_eidtorMountEvent(editorStore);
|
|
186
195
|
});
|
|
@@ -193,7 +202,7 @@ defineExpose({
|
|
|
193
202
|
setAlign,
|
|
194
203
|
changeEditorData,
|
|
195
204
|
updateLayout,
|
|
196
|
-
checkDataEmpty
|
|
205
|
+
checkDataEmpty
|
|
197
206
|
});
|
|
198
207
|
</script>
|
|
199
208
|
|
|
@@ -10,13 +10,14 @@ declare function setDecoration(style: DEDecoration): void;
|
|
|
10
10
|
declare function setAlign(align: DETextalign): void;
|
|
11
11
|
declare function changeEditorData(data: DEContentData): void;
|
|
12
12
|
declare function updateLayout(): void;
|
|
13
|
+
declare function checkDataEmpty(data?: DEContentData): boolean;
|
|
13
14
|
declare const __VLS_export: import("vue").DefineComponent<DEOption, {
|
|
14
15
|
addBlock: typeof addBlock;
|
|
15
16
|
setDecoration: typeof setDecoration;
|
|
16
17
|
setAlign: typeof setAlign;
|
|
17
18
|
changeEditorData: typeof changeEditorData;
|
|
18
19
|
updateLayout: typeof updateLayout;
|
|
19
|
-
checkDataEmpty:
|
|
20
|
+
checkDataEmpty: typeof checkDataEmpty;
|
|
20
21
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
22
|
"update:modelValue": (data: DEContentData) => any;
|
|
22
23
|
uploadImageEvent: (file: File) => any;
|
package/dist/runtime/type.d.mts
CHANGED
|
@@ -115,7 +115,7 @@ interface DragonEditor {
|
|
|
115
115
|
setTextAlign: (type: DETextalign) => void;
|
|
116
116
|
changeEditorData: (data: DEContentData) => void;
|
|
117
117
|
updateLayout: () => void;
|
|
118
|
-
checkDataEmpty: () => boolean;
|
|
118
|
+
checkDataEmpty: (data?: DEContentData) => boolean;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
interface DETextBlock {
|
|
@@ -81,20 +81,29 @@ export function _checkNeedNewBlock(event, store) {
|
|
|
81
81
|
if ($target !== null) {
|
|
82
82
|
const $element = $target;
|
|
83
83
|
if ($element.classList.contains("js-de-body") === true) {
|
|
84
|
+
const bodyRect = $element.getBoundingClientRect();
|
|
84
85
|
const blockList = $element.querySelectorAll(".de-block");
|
|
85
86
|
const $targetBlock = blockList[blockList.length - 1];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
let isAllowed = true;
|
|
88
|
+
switch (true) {
|
|
89
|
+
case event.clientX > bodyRect.left + bodyRect.width - 20:
|
|
90
|
+
case event.clientX < bodyRect.left + 20:
|
|
91
|
+
isAllowed = false;
|
|
92
|
+
}
|
|
93
|
+
if (isAllowed === true) {
|
|
94
|
+
if ($targetBlock.classList.contains("de-text-block") === true) {
|
|
95
|
+
if ($targetBlock.textContent === "") {
|
|
96
|
+
$targetBlock.focus();
|
|
97
|
+
} else {
|
|
98
|
+
const $block = _createTextBlock(_getDefaultBlockData("text"));
|
|
99
|
+
$targetBlock.insertAdjacentElement("afterend", $block);
|
|
100
|
+
$block.focus();
|
|
101
|
+
}
|
|
89
102
|
} else {
|
|
90
103
|
const $block = _createTextBlock(_getDefaultBlockData("text"));
|
|
91
104
|
$targetBlock.insertAdjacentElement("afterend", $block);
|
|
92
105
|
$block.focus();
|
|
93
106
|
}
|
|
94
|
-
} else {
|
|
95
|
-
const $block = _createTextBlock(_getDefaultBlockData("text"));
|
|
96
|
-
$targetBlock.insertAdjacentElement("afterend", $block);
|
|
97
|
-
$block.focus();
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
109
|
}
|
|
@@ -67,13 +67,18 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
67
67
|
if (store.value.controlStatus.$currentBlock !== null) {
|
|
68
68
|
const lineList = value.split("\n");
|
|
69
69
|
const blockList = [];
|
|
70
|
-
const unorderListReg = new RegExp("^( +)?(
|
|
70
|
+
const unorderListReg = new RegExp("^( +)?(\\+|\\*|-)(?= )( )");
|
|
71
71
|
const orderListReg = new RegExp("^( +)?(\\d+.)(?= )( )");
|
|
72
72
|
const codeBlockReg = new RegExp("^```");
|
|
73
73
|
let tempData = null;
|
|
74
74
|
let isCodeBlock = false;
|
|
75
75
|
lineList.forEach((text, lineIndex) => {
|
|
76
76
|
switch (true) {
|
|
77
|
+
case new RegExp("^(---|___|\\*\\*\\*)").test(text):
|
|
78
|
+
blockList.push({
|
|
79
|
+
type: "divider"
|
|
80
|
+
});
|
|
81
|
+
break;
|
|
77
82
|
case (codeBlockReg.test(text) || isCodeBlock === true):
|
|
78
83
|
if (isCodeBlock === false) {
|
|
79
84
|
const startLineText = text.split("```");
|
|
@@ -106,7 +111,7 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
106
111
|
break;
|
|
107
112
|
case orderListReg.test(text):
|
|
108
113
|
const olSplitText = text.split(new RegExp("\\d+.(?= )"));
|
|
109
|
-
const olDepth = olSplitText[0].length / 4;
|
|
114
|
+
const olDepth = Math.floor(olSplitText[0].length / 4);
|
|
110
115
|
if (tempData === null) {
|
|
111
116
|
tempData = {
|
|
112
117
|
type: "list",
|
|
@@ -128,7 +133,7 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
128
133
|
});
|
|
129
134
|
if (nextLine !== void 0) {
|
|
130
135
|
const nextOlSplitText = nextLine.split(new RegExp("\\d+.(?= )"));
|
|
131
|
-
const nextOlDepth = nextOlSplitText[0].length / 4;
|
|
136
|
+
const nextOlDepth = Math.floor(nextOlSplitText[0].length / 4);
|
|
132
137
|
if (orderListReg.test(nextLine) === false) {
|
|
133
138
|
blockList.push(tempData);
|
|
134
139
|
tempData = null;
|
|
@@ -146,8 +151,8 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
146
151
|
}
|
|
147
152
|
break;
|
|
148
153
|
case unorderListReg.test(text):
|
|
149
|
-
const ulSplitText = text.split(new RegExp("
|
|
150
|
-
const ulDepth = ulSplitText[0].length / 4;
|
|
154
|
+
const ulSplitText = text.split(new RegExp("\\+|\\*|-"));
|
|
155
|
+
const ulDepth = Math.floor(ulSplitText[0].length / 4);
|
|
151
156
|
if (tempData === null) {
|
|
152
157
|
tempData = {
|
|
153
158
|
type: "list",
|
|
@@ -168,8 +173,8 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
168
173
|
textContent: ___replaceTextData(ulSplitText[1].trim())
|
|
169
174
|
});
|
|
170
175
|
if (nextLine !== void 0) {
|
|
171
|
-
const nextUlSplitText = nextLine.split(new RegExp("
|
|
172
|
-
const nextUlDepth = nextUlSplitText[0].length / 4;
|
|
176
|
+
const nextUlSplitText = nextLine.split(new RegExp("\\+|\\*|-"));
|
|
177
|
+
const nextUlDepth = Math.floor(nextUlSplitText[0].length / 4);
|
|
173
178
|
if (unorderListReg.test(nextLine) === false) {
|
|
174
179
|
blockList.push(tempData);
|
|
175
180
|
tempData = null;
|
|
@@ -192,7 +197,7 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
192
197
|
level: 3,
|
|
193
198
|
id: _generateId(),
|
|
194
199
|
classList: [],
|
|
195
|
-
textContent: text.substring(4)
|
|
200
|
+
textContent: ___replaceTextData(text.substring(4))
|
|
196
201
|
});
|
|
197
202
|
break;
|
|
198
203
|
case new RegExp("^##(?= )").test(text):
|
|
@@ -201,7 +206,7 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
201
206
|
level: 2,
|
|
202
207
|
id: _generateId(),
|
|
203
208
|
classList: [],
|
|
204
|
-
textContent: text.substring(3)
|
|
209
|
+
textContent: ___replaceTextData(text.substring(3))
|
|
205
210
|
});
|
|
206
211
|
break;
|
|
207
212
|
case new RegExp("^#(?= )").test(text):
|
|
@@ -210,7 +215,7 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
210
215
|
level: 1,
|
|
211
216
|
id: _generateId(),
|
|
212
217
|
classList: [],
|
|
213
|
-
textContent: text.substring(2)
|
|
218
|
+
textContent: ___replaceTextData(text.substring(2))
|
|
214
219
|
});
|
|
215
220
|
break;
|
|
216
221
|
default:
|
|
@@ -244,7 +249,7 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
251
|
function ___replaceTextData(text) {
|
|
247
|
-
return text.replaceAll(new RegExp("(`)([^`]+)(`)", "g"), `<span class="de-code">$2</span>`).replaceAll(new RegExp("(
|
|
252
|
+
return text.replaceAll("<", "<").replaceAll(">", ">").replaceAll(new RegExp("(`)([^`]+)(`)", "g"), `<span class="de-code">$2</span>`).replaceAll(new RegExp("(\\*\\*)([^\\*]+)(?=\\*\\*)(\\*\\*)", "g"), `<span class="de-bold">$2</span>`).replaceAll(new RegExp("(\\_\\_)([^\\_]+)(?=\\_\\_)(\\_\\_)", "g"), `<span class="de-bold">$2</span>`).replaceAll(new RegExp("(\\~\\~)([^\\~]+)(?=\\~\\~)(\\~\\~)", "g"), `<span class="de-strikethrough">$2</span>`).replaceAll(new RegExp("(\\*)([^\\*]+)(?=\\*)(\\*)", "g"), `<span class="de-italic">$2</span>`).replaceAll(new RegExp("(\\_)([^\\_]+)(?=\\_)(\\_)", "g"), `<span class="de-italic">$2</span>`).replaceAll(new RegExp("(\\[)([^\\[\\]]+)(\\])(?=\\()(\\()([^\\(\\)]+)(?=\\))(\\))", "g"), `<a class="de-link" href="$5" target="_blank">$2</a>`);
|
|
248
253
|
}
|
|
249
254
|
function __enterEvent(event, store) {
|
|
250
255
|
if (event.shiftKey === true) {
|