dragon-editor 4.0.1 → 4.0.3
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
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
</template>
|
|
64
64
|
|
|
65
65
|
<script setup>
|
|
66
|
-
import hljs from "highlight.js";
|
|
67
66
|
import { useEditorStore } from "../../store/editor";
|
|
68
67
|
import { ref, computed, nextTick } from "vue";
|
|
69
68
|
import { onClickOutside } from "@vueuse/core";
|
|
70
69
|
import { _moveCodeBlockEvent, _codeBlockShiftEnterEvent, _codeBlockTabEvent, _normalPasteEvent } from "../../utils/event";
|
|
70
|
+
import { _highlightingCode } from "../../utils/data";
|
|
71
71
|
const editorStore = useEditorStore();
|
|
72
72
|
const props = defineProps({
|
|
73
73
|
data: { type: null, required: true },
|
|
@@ -161,12 +161,11 @@ function contentKeydownEvent(event) {
|
|
|
161
161
|
async function setLanguageEvent(lang) {
|
|
162
162
|
if ($content.value !== null) {
|
|
163
163
|
const textContent = $content.value.textContent;
|
|
164
|
-
const highlights = hljs.highlight(textContent, { language: lang });
|
|
165
164
|
const newData = JSON.parse(JSON.stringify(props.data));
|
|
166
165
|
isLanguageListActive.value = false;
|
|
167
166
|
abortEdit();
|
|
168
167
|
newData.language = lang;
|
|
169
|
-
newData.textContent =
|
|
168
|
+
newData.textContent = _highlightingCode(textContent, lang);
|
|
170
169
|
emit("update", newData);
|
|
171
170
|
await nextTick();
|
|
172
171
|
setEdit();
|
|
@@ -175,9 +174,8 @@ async function setLanguageEvent(lang) {
|
|
|
175
174
|
function setStyleEvent() {
|
|
176
175
|
if ($content.value !== null) {
|
|
177
176
|
const textContent = $content.value.textContent;
|
|
178
|
-
const highlights = hljs.highlight(textContent, { language: props.data.language });
|
|
179
177
|
const newData = JSON.parse(JSON.stringify(props.data));
|
|
180
|
-
newData.textContent =
|
|
178
|
+
newData.textContent = _highlightingCode(textContent, props.data.language);
|
|
181
179
|
emit("update", newData);
|
|
182
180
|
}
|
|
183
181
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function _highlightingCode(text: string, language: string): string;
|
|
1
2
|
export declare function _arrangementNodeList(list: Node[], cursorStartNode: Node | null, cursorStartNodeOffset: number, cursorEndNode: Node | null, cursorEndNodeOffset: number): {
|
|
2
3
|
list: Node[];
|
|
3
4
|
cursorStartNode: Node | null;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import * as hljs from "highlight.js";
|
|
1
2
|
import { _isStrictlyEqualArrays } from "./index.js";
|
|
3
|
+
export function _highlightingCode(text, language) {
|
|
4
|
+
return hljs.default.highlight(text, { language }).value;
|
|
5
|
+
}
|
|
2
6
|
export function _arrangementNodeList(list, cursorStartNode, cursorStartNodeOffset, cursorEndNode, cursorEndNodeOffset) {
|
|
3
7
|
const arrangementNodeList = [];
|
|
4
8
|
list.forEach((node) => {
|