nuxt-monaco-editor 1.3.2 → 1.4.0-alpha.0
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/CHANGELOG.md +7 -0
- package/dist/i18n/cs.json +1186 -624
- package/dist/i18n/de.json +1221 -659
- package/dist/i18n/es.json +1226 -664
- package/dist/i18n/fr.json +1223 -661
- package/dist/i18n/it.json +1225 -663
- package/dist/i18n/ja.json +1226 -664
- package/dist/i18n/ko.json +1227 -665
- package/dist/i18n/pl.json +1194 -632
- package/dist/i18n/pt-BR.json +1226 -664
- package/dist/i18n/qps-ploc.json +742 -180
- package/dist/i18n/ru.json +1229 -667
- package/dist/i18n/tr.json +1214 -652
- package/dist/i18n/zh-hans.json +1234 -672
- package/dist/i18n/zh-hant.json +1228 -666
- package/dist/module.json +4 -4
- package/dist/module.mjs +4 -6
- package/dist/runtime/MonacoDiffEditor.client.vue +10 -10
- package/dist/runtime/MonacoEditor.client.vue +7 -7
- package/dist/runtime/composables.d.ts +2 -7
- package/dist/runtime/composables.js +31 -3
- package/package.json +16 -14
- package/dist/runtime/plugin-dev.client.d.ts +0 -2
- package/dist/runtime/plugin-dev.client.js +0 -33
- package/dist/runtime/plugin-prod.client.d.ts +0 -2
- package/dist/runtime/plugin-prod.client.js +0 -33
package/dist/module.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "nuxt-monaco-editor",
|
|
3
3
|
"configKey": "monacoEditor",
|
|
4
4
|
"compatibility": {
|
|
5
|
-
"nuxt": ">=3.1.0"
|
|
5
|
+
"nuxt": ">=3.1.0 ^4"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.4.0-alpha.0",
|
|
8
8
|
"builder": {
|
|
9
|
-
"@nuxt/module-builder": "1.0.
|
|
10
|
-
"unbuild": "3.
|
|
9
|
+
"@nuxt/module-builder": "1.0.2",
|
|
10
|
+
"unbuild": "3.6.0"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { createResolver, defineNuxtModule, addVitePlugin,
|
|
2
|
+
import { createResolver, defineNuxtModule, addVitePlugin, addComponent, addImports } from '@nuxt/kit';
|
|
3
3
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
@@ -31,7 +31,7 @@ const plugin = (options, nuxtOptions) => ({
|
|
|
31
31
|
rewrittenMonacoFiles.set(id, code);
|
|
32
32
|
return { code };
|
|
33
33
|
}
|
|
34
|
-
if (vsPath
|
|
34
|
+
if (vsPath?.endsWith(".js")) {
|
|
35
35
|
const path = vsPath.replace(/\.js$/, "");
|
|
36
36
|
let code = (await fs.readFile(id, "utf-8")).replace(/import \* as nls from '.+nls\.js(\?v=.+)?';/g, `import * as nls from '${nlsPath}';`).replace(/(?<!function )localize\(/g, `localize('${path}', `);
|
|
37
37
|
if (options.removeSourceMaps) {
|
|
@@ -45,7 +45,7 @@ const plugin = (options, nuxtOptions) => ({
|
|
|
45
45
|
}
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
if (vsPath
|
|
48
|
+
if (vsPath?.endsWith(".js")) {
|
|
49
49
|
let code = await fs.readFile(id, "utf-8");
|
|
50
50
|
if (options.removeSourceMaps) {
|
|
51
51
|
code = code.replace(/\/\/# sourceMappingURL=.+\.js\.map/g, "");
|
|
@@ -74,11 +74,10 @@ const module = defineNuxtModule({
|
|
|
74
74
|
meta: {
|
|
75
75
|
name: "nuxt-monaco-editor",
|
|
76
76
|
configKey: "monacoEditor",
|
|
77
|
-
compatibility: { nuxt: ">=3.1.0" }
|
|
77
|
+
compatibility: { nuxt: ">=3.1.0 ^4" }
|
|
78
78
|
},
|
|
79
79
|
defaults: getDefaults,
|
|
80
80
|
setup(options, nuxt) {
|
|
81
|
-
const isDev = nuxt.options.dev;
|
|
82
81
|
const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
|
|
83
82
|
const { resolve } = createResolver(runtimeDir);
|
|
84
83
|
nuxt.options.build.transpile.push(runtimeDir);
|
|
@@ -97,7 +96,6 @@ const module = defineNuxtModule({
|
|
|
97
96
|
}
|
|
98
97
|
});
|
|
99
98
|
});
|
|
100
|
-
addPlugin(isDev ? resolve("plugin-dev.client") : resolve("plugin-prod.client"));
|
|
101
99
|
addComponent({ name: options.componentName.codeEditor, filePath: resolve("MonacoEditor.client.vue") });
|
|
102
100
|
addComponent({ name: options.componentName.diffEditor, filePath: resolve("MonacoDiffEditor.client.vue") });
|
|
103
101
|
addImports({ name: "useMonaco", as: "useMonaco", from: resolve("composables") });
|
|
@@ -19,14 +19,20 @@ const props = defineProps({
|
|
|
19
19
|
const emit = defineEmits(["update:modelValue", "load"]);
|
|
20
20
|
const isLoading = ref(true);
|
|
21
21
|
const editorElement = shallowRef();
|
|
22
|
-
const monaco = useMonaco();
|
|
23
|
-
let editor;
|
|
24
|
-
let originalModel;
|
|
25
|
-
let modifiedModel;
|
|
26
22
|
const editorRef = shallowRef();
|
|
27
23
|
const defaultOptions = {
|
|
28
24
|
automaticLayout: true
|
|
29
25
|
};
|
|
26
|
+
defineExpose({
|
|
27
|
+
/**
|
|
28
|
+
* Monaco editor instance
|
|
29
|
+
*/
|
|
30
|
+
$editor: editorRef
|
|
31
|
+
});
|
|
32
|
+
const monaco = await useMonaco();
|
|
33
|
+
let editor;
|
|
34
|
+
let originalModel;
|
|
35
|
+
let modifiedModel;
|
|
30
36
|
watch(() => [props.original, props.modelValue], () => {
|
|
31
37
|
if (originalModel.getValue() !== props.original || modifiedModel.getValue() !== props.modelValue) {
|
|
32
38
|
originalModel.setValue(props.original);
|
|
@@ -52,12 +58,6 @@ watch(() => props.lang, () => {
|
|
|
52
58
|
watch(() => props.options, () => {
|
|
53
59
|
editor?.updateOptions(defu(props.options, defaultOptions));
|
|
54
60
|
});
|
|
55
|
-
defineExpose({
|
|
56
|
-
/**
|
|
57
|
-
* Monaco editor instance
|
|
58
|
-
*/
|
|
59
|
-
$editor: editorRef
|
|
60
|
-
});
|
|
61
61
|
watch(editorElement, (newValue, oldValue) => {
|
|
62
62
|
if (!editorElement.value || oldValue) {
|
|
63
63
|
return;
|
|
@@ -19,10 +19,16 @@ const isLoading = ref(true);
|
|
|
19
19
|
const lang = computed(() => props.lang || props.options.language);
|
|
20
20
|
const editorRef = shallowRef();
|
|
21
21
|
const editorElement = ref();
|
|
22
|
-
const monaco = useMonaco();
|
|
23
22
|
const defaultOptions = {
|
|
24
23
|
automaticLayout: true
|
|
25
24
|
};
|
|
25
|
+
defineExpose({
|
|
26
|
+
/**
|
|
27
|
+
* Monaco editor instance
|
|
28
|
+
*/
|
|
29
|
+
$editor: editorRef
|
|
30
|
+
});
|
|
31
|
+
const monaco = await useMonaco();
|
|
26
32
|
let editor;
|
|
27
33
|
let model;
|
|
28
34
|
watch(() => props.modelValue, () => {
|
|
@@ -55,12 +61,6 @@ watch(editorElement, (newValue, oldValue) => {
|
|
|
55
61
|
isLoading.value = false;
|
|
56
62
|
emit("load", editor);
|
|
57
63
|
});
|
|
58
|
-
defineExpose({
|
|
59
|
-
/**
|
|
60
|
-
* Monaco editor instance
|
|
61
|
-
*/
|
|
62
|
-
$editor: editorRef
|
|
63
|
-
});
|
|
64
64
|
onBeforeUnmount(() => {
|
|
65
65
|
editor?.dispose();
|
|
66
66
|
model?.dispose();
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare
|
|
3
|
-
/**
|
|
4
|
-
* Get `monaco` namespace
|
|
5
|
-
* @returns `monaco` namespace: if unavailable (server-side), returns `null`
|
|
6
|
-
*/
|
|
7
|
-
export declare const useMonaco: () => typeof Monaco | null;
|
|
1
|
+
import type Monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
|
+
export declare function useMonaco(): Promise<typeof Monaco>;
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
let monacoPromise = null;
|
|
2
|
+
export function useMonaco() {
|
|
3
|
+
if (import.meta.server) {
|
|
4
|
+
return Promise.reject(new Error("monaco-editor cannot be loaded on server"));
|
|
5
|
+
}
|
|
6
|
+
if (!monacoPromise) {
|
|
7
|
+
monacoPromise = (async () => {
|
|
8
|
+
if (!self.MonacoEnvironment) self.MonacoEnvironment = {};
|
|
9
|
+
if (!self.MonacoEnvironment.getWorker) {
|
|
10
|
+
self.MonacoEnvironment.getWorker = (_moduleId, label) => {
|
|
11
|
+
const getWorkerModuleURL = (moduleUrl) => new URL(
|
|
12
|
+
import.meta.dev ? `/node_modules/monaco-editor/esm/vs/${moduleUrl}.js?worker` : `${useNuxtApp().$config.app.baseURL}/_nuxt/nuxt-monaco-editor/vs/${moduleUrl}.js`.replace(/\/\//g, "/"),
|
|
13
|
+
import.meta.url
|
|
14
|
+
);
|
|
15
|
+
const workerMap = {
|
|
16
|
+
json: "language/json/json.worker",
|
|
17
|
+
css: "language/css/css.worker",
|
|
18
|
+
html: "language/html/html.worker",
|
|
19
|
+
typescript: "language/typescript/ts.worker",
|
|
20
|
+
javascript: "language/typescript/ts.worker"
|
|
21
|
+
};
|
|
22
|
+
const workerUrl = workerMap[label] || "editor/editor.worker";
|
|
23
|
+
return new Worker(getWorkerModuleURL(workerUrl), { type: "module" });
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const monaco = await import("monaco-editor");
|
|
27
|
+
return monaco;
|
|
28
|
+
})();
|
|
29
|
+
}
|
|
30
|
+
return monacoPromise;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/e-chan1007/nuxt-monaco-editor.git"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.4.0-alpha.0",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"exports": {
|
|
@@ -45,36 +45,38 @@
|
|
|
45
45
|
"loc:build": "jiti scripts/build-loc.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@nuxt/kit": "^
|
|
48
|
+
"@nuxt/kit": "^4.0.3",
|
|
49
49
|
"defu": "^6.1.4",
|
|
50
|
-
"vite-plugin-static-copy": "^3.
|
|
50
|
+
"vite-plugin-static-copy": "^3.1.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@commitlint/cli": "^19.8.1",
|
|
54
54
|
"@commitlint/config-conventional": "^19.8.1",
|
|
55
|
-
"@nuxt/
|
|
56
|
-
"@nuxt/
|
|
57
|
-
"@nuxt/
|
|
55
|
+
"@nuxt/content": "^3.6.3",
|
|
56
|
+
"@nuxt/eslint-config": "^1.8.0",
|
|
57
|
+
"@nuxt/module-builder": "1.0.2",
|
|
58
|
+
"@nuxt/test-utils": "3.19.2",
|
|
58
59
|
"@vue/test-utils": "^2.4.6",
|
|
59
|
-
"
|
|
60
|
+
"better-sqlite3": "^12.2.0",
|
|
61
|
+
"eslint": "^9.33.0",
|
|
60
62
|
"execa": "^9.6.0",
|
|
61
63
|
"happy-dom": "^18.0.1",
|
|
62
64
|
"husky": "^9.1.7",
|
|
63
|
-
"jiti": "^2.
|
|
65
|
+
"jiti": "^2.5.1",
|
|
64
66
|
"monaco-editor": "^0.52.2",
|
|
65
|
-
"nuxt": "^
|
|
67
|
+
"nuxt": "^4.0.3",
|
|
66
68
|
"nuxt-content-twoslash": "^0.1.2",
|
|
67
69
|
"pinst": "^3.0.0",
|
|
68
|
-
"playwright": "^1.
|
|
69
|
-
"playwright-core": "^1.
|
|
70
|
+
"playwright": "^1.54.2",
|
|
71
|
+
"playwright-core": "^1.54.2",
|
|
70
72
|
"remark-cli": "^12.0.1",
|
|
71
73
|
"remark-lint": "^10.0.1",
|
|
72
74
|
"remark-preset-lint-recommended": "^7.0.1",
|
|
73
|
-
"shadcn-docs-nuxt": "
|
|
75
|
+
"shadcn-docs-nuxt": "patch:shadcn-docs-nuxt@npm%3A1.1.2#~/.yarn/patches/shadcn-docs-nuxt-npm-1.1.2-b9d2f65cf2.patch",
|
|
74
76
|
"standard-version": "^9.5.0",
|
|
75
|
-
"typescript": "^5.
|
|
77
|
+
"typescript": "^5.9.2",
|
|
76
78
|
"vitest": "^3.2.4",
|
|
77
|
-
"vue-tsc": "^
|
|
79
|
+
"vue-tsc": "^3.0.5"
|
|
78
80
|
},
|
|
79
81
|
"peerDependencies": {
|
|
80
82
|
"monaco-editor": "*"
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { _useMonacoState } from "./composables.js";
|
|
2
|
-
import { defineNuxtPlugin } from "#imports";
|
|
3
|
-
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
4
|
-
const getWorkerModule = (moduleUrl, label) => {
|
|
5
|
-
return new Worker(new URL("/node_modules/monaco-editor/esm/vs/" + moduleUrl + ".js?worker", import.meta.url), {
|
|
6
|
-
name: label,
|
|
7
|
-
type: "module"
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
self.MonacoEnvironment = {
|
|
11
|
-
getWorker(workerId, label) {
|
|
12
|
-
switch (label) {
|
|
13
|
-
case "json":
|
|
14
|
-
return getWorkerModule("language/json/json.worker", label);
|
|
15
|
-
case "css":
|
|
16
|
-
case "scss":
|
|
17
|
-
case "less":
|
|
18
|
-
return getWorkerModule("language/css/css.worker", label);
|
|
19
|
-
case "html":
|
|
20
|
-
case "handlebars":
|
|
21
|
-
case "razor":
|
|
22
|
-
return getWorkerModule("language/html/html.worker", label);
|
|
23
|
-
case "typescript":
|
|
24
|
-
case "javascript":
|
|
25
|
-
return getWorkerModule("language/typescript/ts.worker", label);
|
|
26
|
-
default:
|
|
27
|
-
return getWorkerModule("editor/editor.worker", label);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const monacoState = _useMonacoState();
|
|
32
|
-
monacoState.value = await import("monaco-editor");
|
|
33
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { _useMonacoState } from "./composables.js";
|
|
2
|
-
import { defineNuxtPlugin } from "#imports";
|
|
3
|
-
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
4
|
-
const getWorkerModule = (moduleUrl, label) => {
|
|
5
|
-
return new Worker(new URL(`${nuxtApp.$config.app.baseURL}/_nuxt/nuxt-monaco-editor/vs/${moduleUrl}.js`.replace(/\/\//g, "/"), import.meta.url), {
|
|
6
|
-
name: label,
|
|
7
|
-
type: "module"
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
self.MonacoEnvironment = {
|
|
11
|
-
getWorker(workerId, label) {
|
|
12
|
-
switch (label) {
|
|
13
|
-
case "json":
|
|
14
|
-
return getWorkerModule("language/json/json.worker", label);
|
|
15
|
-
case "css":
|
|
16
|
-
case "scss":
|
|
17
|
-
case "less":
|
|
18
|
-
return getWorkerModule("language/css/css.worker", label);
|
|
19
|
-
case "html":
|
|
20
|
-
case "handlebars":
|
|
21
|
-
case "razor":
|
|
22
|
-
return getWorkerModule("language/html/html.worker", label);
|
|
23
|
-
case "typescript":
|
|
24
|
-
case "javascript":
|
|
25
|
-
return getWorkerModule("language/typescript/ts.worker", label);
|
|
26
|
-
default:
|
|
27
|
-
return getWorkerModule("editor/editor.worker", label);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const monacoState = _useMonacoState();
|
|
32
|
-
monacoState.value = await import("monaco-editor");
|
|
33
|
-
});
|