vue-codemirror6 0.1.3 → 0.3.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/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. Unrelated to [surmon-china's vue-codemirror](https://github.com/surmon-china/vue-codemirror), it is for CodeMirror6.
|
|
10
10
|
|
|
11
|
+
If you are using Vue2, please use `0.1.2`. (The component itself supports both, but the script generated by vue-demi can only output one)
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
This component can handle bidirectional binding by `v-model` like a general Vue component.
|
|
@@ -3,10 +3,7 @@ import type { Extension } from '@codemirror/state';
|
|
|
3
3
|
import type { LanguageSupport } from '@codemirror/language';
|
|
4
4
|
import type { Diagnostic } from '@codemirror/lint';
|
|
5
5
|
import type { StyleSpec } from 'style-mod';
|
|
6
|
-
declare const _default: import("vue
|
|
7
|
-
context: SetupContext<{}>;
|
|
8
|
-
editor: Ref<Element | undefined>;
|
|
9
|
-
}> & import("@vue/composition-api").Data, {}, {}, {
|
|
6
|
+
declare const _default: import("vue-demi").DefineComponent<{
|
|
10
7
|
/** Model value */
|
|
11
8
|
modelValue: {
|
|
12
9
|
type: StringConstructor;
|
|
@@ -83,45 +80,85 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
83
80
|
default: undefined;
|
|
84
81
|
};
|
|
85
82
|
}, {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
84
|
+
editor: Ref<Element | undefined>;
|
|
85
|
+
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, import("vue-demi").EmitsOptions, "update:modelValue" | "update", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
86
|
+
/** Model value */
|
|
87
|
+
modelValue: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
default: string;
|
|
89
90
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
lang: LanguageSupport;
|
|
96
|
-
linter: Diagnostic[];
|
|
97
|
-
} & {}> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
|
|
98
|
-
modelValue: string;
|
|
91
|
+
/**
|
|
92
|
+
* Theme
|
|
93
|
+
*
|
|
94
|
+
* @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
|
|
95
|
+
*/
|
|
99
96
|
theme: {
|
|
100
|
-
|
|
97
|
+
type: PropType<{
|
|
98
|
+
[selector: string]: StyleSpec;
|
|
99
|
+
}>;
|
|
100
|
+
default: undefined;
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
phrases: Record<string, string>;
|
|
107
|
-
lang: LanguageSupport;
|
|
108
|
-
linter: Diagnostic[];
|
|
109
|
-
} & {}, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
110
|
-
context: SetupContext<{}>;
|
|
111
|
-
editor: Ref<Element | undefined>;
|
|
112
|
-
}>, import("@vue/composition-api").Data, {}, {}, {}, {}, {}, {
|
|
113
|
-
modelValue: string;
|
|
114
|
-
theme: {
|
|
115
|
-
[selector: string]: StyleSpec;
|
|
102
|
+
/** Dark Mode */
|
|
103
|
+
dark: {
|
|
104
|
+
type: BooleanConstructor;
|
|
105
|
+
default: boolean;
|
|
116
106
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Readonly
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
|
|
111
|
+
*/
|
|
112
|
+
readonly: {
|
|
113
|
+
type: BooleanConstructor;
|
|
114
|
+
default: boolean;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Editable
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
|
|
120
|
+
*/
|
|
121
|
+
editable: {
|
|
122
|
+
type: BooleanConstructor;
|
|
123
|
+
default: boolean;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Additional Extension
|
|
127
|
+
*
|
|
128
|
+
* @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
129
|
+
*/
|
|
130
|
+
extensions: {
|
|
131
|
+
type: PropType<Extension[]>;
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Language Phreses
|
|
136
|
+
*
|
|
137
|
+
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
138
|
+
*/
|
|
139
|
+
phrases: {
|
|
140
|
+
type: PropType<Record<string, string>>;
|
|
141
|
+
default: undefined;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* CodeMirror Language
|
|
145
|
+
*
|
|
146
|
+
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
147
|
+
*/
|
|
148
|
+
lang: {
|
|
149
|
+
type: PropType<LanguageSupport>;
|
|
150
|
+
default: undefined;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* CodeMirror Linter
|
|
154
|
+
*
|
|
155
|
+
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
156
|
+
*/
|
|
157
|
+
linter: {
|
|
158
|
+
type: PropType<Diagnostic[]>;
|
|
159
|
+
default: undefined;
|
|
160
|
+
};
|
|
161
|
+
}>>, {
|
|
125
162
|
modelValue: string;
|
|
126
163
|
theme: {
|
|
127
164
|
[selector: string]: StyleSpec;
|
|
@@ -133,7 +170,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
133
170
|
phrases: Record<string, string>;
|
|
134
171
|
lang: LanguageSupport;
|
|
135
172
|
linter: Diagnostic[];
|
|
136
|
-
}
|
|
173
|
+
}>;
|
|
137
174
|
/** CodeMirror Component */
|
|
138
175
|
export default _default;
|
|
139
176
|
//# sourceMappingURL=CodeMirror.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAe,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIzE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAe,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIzE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;;IAavC,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;IApEH,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;;;;;;;;;;AA/EP,2BAA2B;AAC3B,wBA+MG"}
|
|
@@ -2,7 +2,15 @@ import { defineComponent, ref, computed, watch, onMounted, onUnmounted, install
|
|
|
2
2
|
import { EditorState } from "@codemirror/state";
|
|
3
3
|
import { EditorView } from "@codemirror/view";
|
|
4
4
|
import { merge, compact } from "lodash";
|
|
5
|
-
|
|
5
|
+
import { openBlock, createElementBlock, withDirectives, createElementVNode, renderSlot, vShow } from "vue";
|
|
6
|
+
var _export_sfc = (sfc, props) => {
|
|
7
|
+
const target = sfc.__vccOpts || sfc;
|
|
8
|
+
for (const [key, val] of props) {
|
|
9
|
+
target[key] = val;
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
const _sfc_main = defineComponent({
|
|
6
14
|
name: "CodeMirror",
|
|
7
15
|
model: {
|
|
8
16
|
prop: "modelValue",
|
|
@@ -113,74 +121,20 @@ var __vue2_script = defineComponent({
|
|
|
113
121
|
};
|
|
114
122
|
}
|
|
115
123
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
var _c = _vm._self._c || _h;
|
|
120
|
-
return _c("div", { ref: "editor", staticClass: "vue-codemirror" }, [_c("aside", { directives: [{ name: "show", rawName: "v-show", value: !_vm.context.slots.default, expression: "!context.slots.default" }] }, [_vm._t("default")], 2)]);
|
|
124
|
+
const _hoisted_1 = {
|
|
125
|
+
ref: "editor",
|
|
126
|
+
class: "vue-codemirror"
|
|
121
127
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (functionalTemplate) {
|
|
131
|
-
options.functional = true;
|
|
132
|
-
}
|
|
133
|
-
if (scopeId) {
|
|
134
|
-
options._scopeId = "data-v-" + scopeId;
|
|
135
|
-
}
|
|
136
|
-
var hook;
|
|
137
|
-
if (moduleIdentifier) {
|
|
138
|
-
hook = function(context) {
|
|
139
|
-
context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
|
|
140
|
-
if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
|
|
141
|
-
context = __VUE_SSR_CONTEXT__;
|
|
142
|
-
}
|
|
143
|
-
if (injectStyles) {
|
|
144
|
-
injectStyles.call(this, context);
|
|
145
|
-
}
|
|
146
|
-
if (context && context._registeredComponents) {
|
|
147
|
-
context._registeredComponents.add(moduleIdentifier);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
options._ssrRegister = hook;
|
|
151
|
-
} else if (injectStyles) {
|
|
152
|
-
hook = shadowMode ? function() {
|
|
153
|
-
injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
|
|
154
|
-
} : injectStyles;
|
|
155
|
-
}
|
|
156
|
-
if (hook) {
|
|
157
|
-
if (options.functional) {
|
|
158
|
-
options._injectStyles = hook;
|
|
159
|
-
var originalRender = options.render;
|
|
160
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
161
|
-
hook.call(context);
|
|
162
|
-
return originalRender(h, context);
|
|
163
|
-
};
|
|
164
|
-
} else {
|
|
165
|
-
var existing = options.beforeCreate;
|
|
166
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
exports: scriptExports,
|
|
171
|
-
options
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
const __cssModules = {};
|
|
175
|
-
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
|
|
176
|
-
function __vue2_injectStyles(context) {
|
|
177
|
-
for (let o in __cssModules) {
|
|
178
|
-
this[o] = __cssModules[o];
|
|
179
|
-
}
|
|
128
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
129
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
130
|
+
withDirectives(createElementVNode("aside", null, [
|
|
131
|
+
renderSlot(_ctx.$slots, "default")
|
|
132
|
+
], 512), [
|
|
133
|
+
[vShow, !_ctx.context.slots.default]
|
|
134
|
+
])
|
|
135
|
+
], 512);
|
|
180
136
|
}
|
|
181
|
-
var CodeMirror = /* @__PURE__ */
|
|
182
|
-
return __component__.exports;
|
|
183
|
-
}();
|
|
137
|
+
var CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
184
138
|
/**
|
|
185
139
|
* Vue CodeMirror6 Component
|
|
186
140
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("lodash"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","lodash","vue"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o.CodeMirror={},o.VueDemi,o.state,o.view,o.lodash,o.Vue))})(this,function(o,t,s,f,m,i){"use strict";var p=(e,u)=>{const d=e.__vccOpts||e;for(const[r,c]of u)d[r]=c;return d};const V=t.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:void 0},dark:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:void 0},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Array,default:void 0}},emits:["update:modelValue","update"],setup(e,u){const d=t.ref(),r=t.ref(e.modelValue),c=t.ref(e.dark),y=u.emit,h=t.computed(()=>{const a=[f.EditorView.updateListener.of(l=>{y("update",l)}),f.EditorView.theme(e.theme||{},{dark:c.value}),e.phrases?s.EditorState.phrases.of(e.phrases):void 0,e.lang,e.readonly?s.EditorState.readOnly.of(e.readonly):void 0,e.editable?f.EditorView.editable.of(e.editable):void 0];return e.linter&&m.merge(a,e.linter),e.extensions&&m.merge(a,e.extensions),m.compact(a)});let n;return t.watch(r,a=>{if(n.composing)return;const l=n.state.selection;n.setState(s.EditorState.create({doc:a,extensions:h.value,selection:l}))}),t.watch(c,()=>{n.setState(s.EditorState.create({doc:r.value,extensions:h.value}))}),t.onMounted(()=>{const a=!r.value&&d.value?d.value.childNodes[0].innerText:r.value;n=new f.EditorView({state:s.EditorState.create({doc:a,extensions:h.value}),parent:d.value,dispatch:l=>{n.update([l]),!l.changes.empty&&(r.value=n.state.doc.toString(),y("update:modelValue",r.value))}})}),t.onUnmounted(()=>n.destroy()),{context:u,editor:d}}}),S={ref:"editor",class:"vue-codemirror"};function _(e,u,d,r,c,y){return i.openBlock(),i.createElementBlock("div",S,[i.withDirectives(i.createElementVNode("aside",null,[i.renderSlot(e.$slots,"default")],512),[[i.vShow,!e.context.slots.default]])],512)}var v=p(V,[["render",_]]);/**
|
|
2
2
|
* Vue CodeMirror6 Component
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author Logue {@link logue@hotmail.co.jp}
|
|
6
6
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
7
7
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
8
|
-
*/
|
|
8
|
+
*/t.install();const E=e=>{e.component("CodeMirror",v)};o.CodeMirror=v,o.default=v,o.install=E,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "vue-codemirror6",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "CodeMirror6 Component for
|
|
4
|
+
"version": "0.3.2",
|
|
5
|
+
"description": "CodeMirror6 Component for vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
8
8
|
"vue",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"code-editor",
|
|
12
12
|
"text-editor",
|
|
13
13
|
"vue2",
|
|
14
|
+
"vue3",
|
|
14
15
|
"web-editor",
|
|
15
16
|
"vue-plugin",
|
|
16
17
|
"vue-component",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"@types/node": "^17.0.23",
|
|
88
89
|
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
|
89
90
|
"@typescript-eslint/parser": "^5.18.0",
|
|
90
|
-
"@
|
|
91
|
+
"@vitejs/plugin-vue": "^2.3.1",
|
|
91
92
|
"@vue/eslint-config-typescript": "^10.0.0",
|
|
92
93
|
"eslint": "^8.12.0",
|
|
93
94
|
"eslint-config-google": "^0.14.0",
|
|
@@ -110,8 +111,7 @@
|
|
|
110
111
|
"rimraf": "^3.0.2",
|
|
111
112
|
"typescript": "^4.6.3",
|
|
112
113
|
"vite": "^2.9.1",
|
|
113
|
-
"
|
|
114
|
-
"vue": "^2.6.14",
|
|
114
|
+
"vue": "^3.2.31",
|
|
115
115
|
"vue-eslint-parser": "^8.3.0",
|
|
116
116
|
"vue-template-compiler": "^2.6.14",
|
|
117
117
|
"vue-tsc": "^0.33.9"
|