dragon-editor 3.2.1 → 3.2.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
3
  "configKey": "dragon-editor",
4
- "version": "3.2.1"
4
+ "version": "3.2.2"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addComponent, addTypeTemplate, installModule } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponent, addTypeTemplate, installModule, addPluginTemplate } from '@nuxt/kit';
2
2
 
3
3
  const module = defineNuxtModule({
4
4
  meta: {
@@ -20,6 +20,11 @@ const module = defineNuxtModule({
20
20
  write: true
21
21
  });
22
22
  await installModule("@pinia/nuxt");
23
+ addPluginTemplate({
24
+ src: resolver.resolve("./runtime/plugin.mjs"),
25
+ filename: "hljs.plugin.mjs"
26
+ });
27
+ nuxt.options.build.transpile.push("highlight.js");
23
28
  }
24
29
  });
25
30
 
@@ -92,14 +92,14 @@
92
92
  <option v-for="(item, i) in _getCodeBlockTheme()" :value="item.code" :key="`codeBlockTheme-${i}`">{{ item.text }}</option>
93
93
  </select>
94
94
  </div>
95
- <!--
95
+
96
96
  <div v-if="['code'].includes(curruntType) === true" class="de-col">
97
97
  <p class="de-name">Language :</p>
98
98
  <select class="de-selector" v-model="codeblockLanguage" @change="codeblockLanguageChangeEvent">
99
99
  <option v-for="(item, i) in _getCodeBlockLanguage()" :value="item.code" :key="`codeBlockLanuage-${i}`">{{ item.text }}</option>
100
100
  </select>
101
101
  </div>
102
- -->
102
+
103
103
  <div v-if="['list'].includes(curruntType) === true" class="de-col">
104
104
  <p class="de-name">List Style :</p>
105
105
  <select class="de-selector" v-model="listBlockStyle" @change="listBlockStyleChangeEvent">
@@ -0,0 +1,2 @@
1
+ declare function _default(nuxtApp: any): void;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import hljs from "highlight.js";
2
+
3
+ export default (nuxtApp) => {
4
+ nuxtApp.vueApp.provide("hljs", hljs);
5
+ nuxtApp.provide("hljs", hljs);
6
+ };
@@ -37,10 +37,12 @@ export const useEditorStore = defineStore("editorStore", {
37
37
  this.controlBar.$element = value;
38
38
  },
39
39
  controlBarActive() {
40
- const currentRect = this.$currentBlock.getBoundingClientRect();
41
- this.controlBar.active = true;
42
- this.controlBar.x = Math.floor(currentRect.x + currentRect.width / 2);
43
- this.controlBar.y = Math.floor(currentRect.y - 50);
40
+ if (this.$currentBlock !== null) {
41
+ const currentRect = this.$currentBlock.getBoundingClientRect();
42
+ this.controlBar.active = true;
43
+ this.controlBar.x = Math.floor(currentRect.x + currentRect.width / 2);
44
+ this.controlBar.y = Math.floor(currentRect.y - 50);
45
+ }
44
46
  },
45
47
  controlBarDeactive() {
46
48
  this.controlBar.active = false;
@@ -1,4 +1,5 @@
1
1
  import { _getBlockType } from "./block.mjs";
2
+ import hljs from "highlight.js";
2
3
  import "../type.d.ts";
3
4
  export function _getCodeBlockTheme() {
4
5
  return [
@@ -134,6 +135,9 @@ export function _setCodeBlockLanguage(store, lang) {
134
135
  if (type === "code") {
135
136
  const $langText = $element.querySelector(".de-language");
136
137
  const $code = $element.querySelector(".de-code-content");
138
+ const convert = hljs.highlight($code.textContent ?? "", { language: lang });
139
+ $langText.textContent = convert._top.name ?? "";
140
+ $code.innerHTML = convert.value;
137
141
  }
138
142
  }
139
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt3!",
5
5
  "repository": {
6
6
  "type": "git",