codemirror-editor-vue3
Advanced tools
Comparing version
@@ -21,3 +21,3 @@ var __defProp = Object.defineProperty; | ||
import _CodeMirror from "codemirror"; | ||
import { defineComponent, ref, onMounted, markRaw, watch, unref, openBlock, createElementBlock, nextTick, getCurrentInstance, onBeforeUnmount, normalizeClass, normalizeStyle, createBlock, resolveDynamicComponent, mergeProps } from "vue"; | ||
import { defineComponent, ref, onMounted, markRaw, watch, unref, openBlock, createElementBlock, computed, nextTick, shallowRef, getCurrentInstance, onBeforeUnmount, normalizeClass, normalizeStyle, createBlock, resolveDynamicComponent, mergeProps } from "vue"; | ||
import "codemirror/lib/codemirror.css"; | ||
@@ -91,3 +91,3 @@ import "codemirror/addon/merge/merge.css"; | ||
const _hoisted_1$2 = ["name", "placeholder"]; | ||
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) { | ||
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { | ||
return openBlock(), createElementBlock("textarea", { | ||
@@ -99,3 +99,3 @@ ref: "textarea", | ||
} | ||
var Default = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]); | ||
var Default = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$2]]); | ||
const CodeMirror$2 = (window == null ? void 0 : window.CodeMirror) || _CodeMirror; | ||
@@ -131,2 +131,3 @@ window.diff_match_patch = DiffMatchPatch; | ||
return { | ||
mergeView, | ||
initialize | ||
@@ -137,6 +138,6 @@ }; | ||
const _hoisted_1$1 = { ref: "mergeView" }; | ||
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { | ||
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { | ||
return openBlock(), createElementBlock("div", _hoisted_1$1, null, 512); | ||
} | ||
var Merge = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]); | ||
var Merge = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1]]); | ||
var logErrorType; | ||
@@ -352,3 +353,3 @@ (function(logErrorType2) { | ||
const _hoisted_1 = ["name", "placeholder"]; | ||
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { | ||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { | ||
return openBlock(), createElementBlock("textarea", { | ||
@@ -360,3 +361,3 @@ ref: "textarea", | ||
} | ||
var FcLog = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]); | ||
var FcLog = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]); | ||
const componentsEvts = { | ||
@@ -415,2 +416,6 @@ "update:value": (value) => value, | ||
}) => { | ||
const realCm = computed(() => { | ||
var _a; | ||
return props.merge ? (_a = unref(cminstance)) == null ? void 0 : _a.editor() : unref(cminstance); | ||
}); | ||
const getBindEvents = () => { | ||
@@ -427,3 +432,3 @@ const evts = []; | ||
const listenerEvents = () => { | ||
cminstance.value.on("change", (cm) => { | ||
realCm.value.on("change", (cm) => { | ||
const currentVal = cm.getValue(); | ||
@@ -443,3 +448,3 @@ if (currentVal === content.value) | ||
bindEvts.filter((e) => !tmpEvents[e] && (tmpEvents[e] = true)).forEach((event) => { | ||
cminstance.value.on(event, (...args) => { | ||
realCm.value.on(event, (...args) => { | ||
emit(event, ...args); | ||
@@ -460,6 +465,10 @@ }); | ||
const containerHeight = ref(null); | ||
const realCm = computed(() => { | ||
var _a; | ||
return props.merge ? (_a = unref(cminstance)) == null ? void 0 : _a.editor() : unref(cminstance); | ||
}); | ||
const refresh = () => { | ||
nextTick(() => { | ||
var _a; | ||
(_a = cminstance.value) == null ? void 0 : _a.refresh(); | ||
(_a = realCm.value) == null ? void 0 : _a.refresh(); | ||
}); | ||
@@ -472,7 +481,7 @@ }; | ||
const cmHeight = containerHeight.value; | ||
(_a = cminstance.value) == null ? void 0 : _a.setSize(containerWidth.value, cmHeight); | ||
(_a = realCm.value) == null ? void 0 : _a.setSize(containerWidth.value, cmHeight); | ||
}; | ||
const destroy = () => { | ||
var _a; | ||
const element = (_a = cminstance.value) == null ? void 0 : _a.getWrapperElement(); | ||
const element = (_a = realCm.value) == null ? void 0 : _a.getWrapperElement(); | ||
element == null ? void 0 : element.remove(); | ||
@@ -482,6 +491,6 @@ }; | ||
var _a, _b, _c; | ||
const history = (_a = cminstance.value) == null ? void 0 : _a.getDoc().getHistory(); | ||
const history = (_a = realCm.value) == null ? void 0 : _a.getDoc().getHistory(); | ||
(_b = presetRef.value) == null ? void 0 : _b.initialize(); | ||
destroy(); | ||
(_c = cminstance.value) == null ? void 0 : _c.getDoc().setHistory(history); | ||
(_c = realCm.value) == null ? void 0 : _c.getDoc().setHistory(history); | ||
}; | ||
@@ -514,32 +523,3 @@ const isStyleChaotic = () => { | ||
} | ||
if (typeof Object.assign !== "function") { | ||
Object.defineProperty(Object, "assign", { | ||
value(target, varArgs) { | ||
if (target == null) { | ||
throw new TypeError("Cannot convert undefined or null to object"); | ||
} | ||
const to = Object(target); | ||
for (let index2 = 1; index2 < arguments.length; index2++) { | ||
const nextSource = arguments[index2]; | ||
if (nextSource != null) { | ||
for (const nextKey in nextSource) { | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
const _sfc_main = defineComponent({ | ||
name: "CodemirrorEditor", | ||
components: { | ||
Default, | ||
Merge, | ||
FcLog | ||
}, | ||
const _sfc_main = /* @__PURE__ */ defineComponent({ | ||
props: { | ||
@@ -596,9 +576,34 @@ value: { | ||
emits: __spreadValues(__spreadValues({}, componentsEvts), getCmEvts()), | ||
setup(props, { emit }) { | ||
setup(__props, { expose, emit }) { | ||
var _a, _b; | ||
const props = __props; | ||
if (typeof Object.assign !== "function") { | ||
Object.defineProperty(Object, "assign", { | ||
value(target, varArgs) { | ||
if (target == null) { | ||
throw new TypeError("Cannot convert undefined or null to object"); | ||
} | ||
const to = Object(target); | ||
for (let index2 = 1; index2 < arguments.length; index2++) { | ||
const nextSource = arguments[index2]; | ||
if (nextSource != null) { | ||
for (const nextKey in nextSource) { | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
const cminstance = ref(null); | ||
const content = ref(""); | ||
const presetModeName = ref("Default"); | ||
const presetModeName = shallowRef(Default); | ||
const cmOptions = ref(__spreadValues(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), props.globalOptions), props.options)); | ||
const internalInstance = getCurrentInstance(); | ||
const instanceName = props.name || ((_b = (_a = internalInstance == null ? void 0 : internalInstance.parent) == null ? void 0 : _a.type) == null ? void 0 : _b.name) || void 0; | ||
const presetRef = ref(null); | ||
@@ -647,15 +652,16 @@ const { refresh, resize, destroy, containerHeight, reviseStyle } = useViewControl({ | ||
if (props.options.mode === "fclog" || props.options.mode === "log") { | ||
presetModeName.value = "FcLog"; | ||
presetModeName.value = FcLog; | ||
return; | ||
} | ||
if (props.merge) { | ||
presetModeName.value = "Merge"; | ||
presetModeName.value = Merge; | ||
return; | ||
} | ||
presetModeName.value = "Default"; | ||
presetModeName.value = Default; | ||
}; | ||
watch(() => props.options, (val) => { | ||
var _a2; | ||
const realCm = props.merge ? (_a2 = unref(cminstance)) == null ? void 0 : _a2.editor() : unref(cminstance); | ||
for (const key in props.options) { | ||
(_a2 = cminstance.value) == null ? void 0 : _a2.setOption(key, val[key]); | ||
realCm.setOption(key, unref(val[key])); | ||
} | ||
@@ -672,41 +678,35 @@ }, { deep: true }); | ||
}); | ||
return { | ||
presetModeName, | ||
cmOptions, | ||
expose({ | ||
cminstance, | ||
content, | ||
ready, | ||
resize, | ||
refresh, | ||
containerHeight, | ||
instanceName: props.name || ((_b = (_a = internalInstance == null ? void 0 : internalInstance.parent) == null ? void 0 : _a.type) == null ? void 0 : _b.name) || void 0, | ||
presetRef | ||
destroy | ||
}); | ||
return (_ctx, _cache) => { | ||
return openBlock(), createElementBlock("div", { | ||
class: normalizeClass(["codemirror-container", { | ||
merge: _ctx.$props.merge, | ||
bordered: _ctx.$props.border || _ctx.$props.merge, | ||
"width-auto": !_ctx.$props.width || _ctx.$props.width == "100%", | ||
"height-auto": !_ctx.$props.height || _ctx.$props.height == "100%" | ||
}]), | ||
style: normalizeStyle({ | ||
height: unref(containerHeight) + "px" | ||
}) | ||
}, [ | ||
(openBlock(), createBlock(resolveDynamicComponent(unref(presetModeName)), mergeProps({ | ||
ref_key: "presetRef", | ||
ref: presetRef, | ||
cminstance: cminstance.value, | ||
"onUpdate:cminstance": _cache[0] || (_cache[0] = ($event) => cminstance.value = $event), | ||
style: { "height": "100%" } | ||
}, __spreadProps(__spreadValues(__spreadValues({}, _ctx.$props), _ctx.$attrs), { | ||
options: cmOptions.value, | ||
name: unref(instanceName), | ||
content: content.value | ||
}), { onReady: ready }), null, 16, ["cminstance"])) | ||
], 6); | ||
}; | ||
} | ||
}); | ||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { | ||
return openBlock(), createElementBlock("div", { | ||
class: normalizeClass(["codemirror-container", { | ||
merge: _ctx.$props.merge, | ||
bordered: _ctx.$props.border || _ctx.$props.merge, | ||
"width-auto": !_ctx.$props.width || _ctx.$props.width == "100%", | ||
"height-auto": !_ctx.$props.height || _ctx.$props.height == "100%" | ||
}]), | ||
style: normalizeStyle({ | ||
height: _ctx.containerHeight + "px" | ||
}) | ||
}, [ | ||
(openBlock(), createBlock(resolveDynamicComponent(_ctx.presetModeName), mergeProps({ | ||
ref: "presetRef", | ||
cminstance: _ctx.cminstance, | ||
"onUpdate:cminstance": _cache[0] || (_cache[0] = ($event) => _ctx.cminstance = $event), | ||
style: { "height": "100%" } | ||
}, __spreadProps(__spreadValues(__spreadValues({}, _ctx.$props), _ctx.$attrs), { | ||
options: _ctx.cmOptions, | ||
name: _ctx.instanceName, | ||
content: _ctx.content | ||
}), { onReady: _ctx.ready }), null, 16, ["cminstance", "onReady"])) | ||
], 6); | ||
} | ||
var VueCodemirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); | ||
var index = ""; | ||
@@ -716,6 +716,6 @@ const install = (app, config) => { | ||
if (config.options) { | ||
VueCodemirror.props.globalOptions.default = () => config.options; | ||
_sfc_main.props.globalOptions.default = () => config.options; | ||
} | ||
} | ||
app.component((config == null ? void 0 : config.componentName) || "Codemirror", VueCodemirror); | ||
app.component((config == null ? void 0 : config.componentName) || "Codemirror", _sfc_main); | ||
return app; | ||
@@ -787,2 +787,2 @@ }; | ||
`); | ||
export { CodeMirror, GlobalCmComponent, VueCodemirror, createLinkMark, createLog, createLogMark, createTitle, VueCodemirror as default, getLinkMarks, getLocalTime, getLogMark, logErrorType }; | ||
export { CodeMirror, GlobalCmComponent, _sfc_main as VueCodemirror, createLinkMark, createLog, createLogMark, createTitle, _sfc_main as default, getLinkMarks, getLocalTime, getLogMark, logErrorType }; |
@@ -1,6 +0,6 @@ | ||
var ke=Object.defineProperty,we=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var Me=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var B=(c,f,t)=>f in c?ke(c,f,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[f]=t,M=(c,f)=>{for(var t in f||(f={}))Me.call(f,t)&&B(c,t,f[t]);if(A)for(var t of A(f))Ce.call(f,t)&&B(c,t,f[t]);return c},V=(c,f)=>we(c,$e(f));(function(c,f){typeof exports=="object"&&typeof module!="undefined"?f(exports,require("codemirror"),require("vue"),require("codemirror/lib/codemirror.css"),require("codemirror/addon/merge/merge.css"),require("codemirror/addon/merge/merge.js"),require("diff-match-patch"),require("codemirror/addon/mode/simple.js")):typeof define=="function"&&define.amd?define(["exports","codemirror","vue","codemirror/lib/codemirror.css","codemirror/addon/merge/merge.css","codemirror/addon/merge/merge.js","diff-match-patch","codemirror/addon/mode/simple.js"],f):(c=typeof globalThis!="undefined"?globalThis:c||self,f(c["codemirror-editor-vue3"]={},c.codemirror,c.Vue,null,null,null,c.DiffMatchPatch))})(this,function(c,f,t,be,_e,ve,F){"use strict";function j(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var C=j(f),R=j(F),_=(e,n)=>{const o=e.__vccOpts||e;for(const[a,r]of n)o[a]=r;return o};const H=window.CodeMirror||C.default,P=t.defineComponent({name:"DefaultMode",props:{name:{type:String,default:`cm-textarea-${+new Date}`},value:{type:String,default:""},content:{type:String,default:""},options:{type:Object,default:()=>({})},cminstance:{type:Object,default:()=>null},placeholder:{type:String,default:""}},emits:{ready:e=>e,"update:cminstance":e=>e},setup(e,{emit:n}){const o=t.ref(),a=t.ref(null),r=()=>{a.value=t.markRaw(H.fromTextArea(o.value,e.options)),n("update:cminstance",a.value);const l=t.watch(()=>e.cminstance,i=>{var u;i&&((u=e.cminstance)==null||u.setValue(e.value||e.content)),n("ready",t.unref(a)),l==null||l()},{deep:!0})};return t.onMounted(()=>{r()}),{textarea:o,initialize:r}}}),z=["name","placeholder"];function q(e,n,o,a,r,l){return t.openBlock(),t.createElementBlock("textarea",{ref:"textarea",name:e.$props.name,placeholder:e.$props.placeholder},null,8,z)}var U=_(P,[["render",q]]);const W=(window==null?void 0:window.CodeMirror)||C.default;window.diff_match_patch=R.default,window.DIFF_DELETE=-1,window.DIFF_INSERT=1,window.DIFF_EQUAL=0;const G=t.defineComponent({name:"MergeMode",props:{options:{type:Object,default:()=>({})},cminstance:{type:Object,default:()=>({})}},emits:["update:cminstance","ready"],setup(e,{emit:n}){const o=t.ref(),a=t.ref(),r=()=>{o.value=t.markRaw(W.MergeView(a.value,e.options)),n("update:cminstance",o.value),n("ready",o)};return t.onMounted(()=>{r()}),{initialize:r}}}),J={ref:"mergeView"};function Z(e,n,o,a,r,l){return t.openBlock(),t.createElementBlock("div",J,null,512)}var K=_(G,[["render",Z]]);c.logErrorType=void 0,function(e){e.info="info",e.warning="warning",e.error="error"}(c.logErrorType||(c.logErrorType={}));function x(){const e=new Date,n=e.getHours()<10?`0${e.getHours()}`:e.getHours(),o=e.getMinutes()<10?`0${e.getMinutes()}`:e.getMinutes(),a=e.getSeconds()<10?`0${e.getSeconds()}`:e.getSeconds();return`${n}:${o}:${a}`}function Q(e){return`#link#${JSON.stringify(e)}#link#`}function L(e){const n=/#link#(.+)#link#/g,o=[];let a;for(a=n.exec(e);a;){const r=document.createElement("a"),l=JSON.parse(a[1]),i=Object.entries(l);for(const[u,g]of i)r.setAttribute(u,g);r.className="editor_custom_link",r.innerHTML="logDownload",o.push({start:a.index,end:a.index+a[0].length,node:r}),a=n.exec(e)}return o}function X(e="",n="info"){return`#log<${n}>log#${e}#log<${n}>log#`}function T(e){const n=[];function o(){const a=/#log<(\w*)>log#((.|\r\n|\n)*?)#log<(\w*)>log#/g;let r;for(r=a.exec(e);r;){const i=r[0].replace(/\r\n/g,` | ||
var _e=Object.defineProperty,Me=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var H=(s,m,t)=>m in s?_e(s,m,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[m]=t,C=(s,m)=>{for(var t in m||(m={}))be.call(m,t)&&H(s,t,m[t]);if(R)for(var t of R(m))Ee.call(m,t)&&H(s,t,m[t]);return s},P=(s,m)=>Me(s,Ce(m));(function(s,m){typeof exports=="object"&&typeof module!="undefined"?m(exports,require("codemirror"),require("vue"),require("codemirror/lib/codemirror.css"),require("codemirror/addon/merge/merge.css"),require("codemirror/addon/merge/merge.js"),require("diff-match-patch"),require("codemirror/addon/mode/simple.js")):typeof define=="function"&&define.amd?define(["exports","codemirror","vue","codemirror/lib/codemirror.css","codemirror/addon/merge/merge.css","codemirror/addon/merge/merge.js","diff-match-patch","codemirror/addon/mode/simple.js"],m):(s=typeof globalThis!="undefined"?globalThis:s||self,m(s["codemirror-editor-vue3"]={},s.codemirror,s.Vue,null,null,null,s.DiffMatchPatch))})(this,function(s,m,t,Se,xe,ve,z){"use strict";function L(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var b=L(m),q=L(z),v=(e,o)=>{const a=e.__vccOpts||e;for(const[n,r]of o)a[n]=r;return a};const U=window.CodeMirror||b.default,W=t.defineComponent({name:"DefaultMode",props:{name:{type:String,default:`cm-textarea-${+new Date}`},value:{type:String,default:""},content:{type:String,default:""},options:{type:Object,default:()=>({})},cminstance:{type:Object,default:()=>null},placeholder:{type:String,default:""}},emits:{ready:e=>e,"update:cminstance":e=>e},setup(e,{emit:o}){const a=t.ref(),n=t.ref(null),r=()=>{n.value=t.markRaw(U.fromTextArea(a.value,e.options)),o("update:cminstance",n.value);const u=t.watch(()=>e.cminstance,l=>{var y;l&&((y=e.cminstance)==null||y.setValue(e.value||e.content)),o("ready",t.unref(n)),u==null||u()},{deep:!0})};return t.onMounted(()=>{r()}),{textarea:a,initialize:r}}}),G=["name","placeholder"];function J(e,o,a,n,r,u){return t.openBlock(),t.createElementBlock("textarea",{ref:"textarea",name:e.$props.name,placeholder:e.$props.placeholder},null,8,G)}var T=v(W,[["render",J]]);const Z=(window==null?void 0:window.CodeMirror)||b.default;window.diff_match_patch=q.default,window.DIFF_DELETE=-1,window.DIFF_INSERT=1,window.DIFF_EQUAL=0;const K=t.defineComponent({name:"MergeMode",props:{options:{type:Object,default:()=>({})},cminstance:{type:Object,default:()=>({})}},emits:["update:cminstance","ready"],setup(e,{emit:o}){const a=t.ref(),n=t.ref(),r=()=>{a.value=t.markRaw(Z.MergeView(n.value,e.options)),o("update:cminstance",a.value),o("ready",a)};return t.onMounted(()=>{r()}),{mergeView:n,initialize:r}}}),Q={ref:"mergeView"};function X(e,o,a,n,r,u){return t.openBlock(),t.createElementBlock("div",Q,null,512)}var Y=v(K,[["render",X]]);s.logErrorType=void 0,function(e){e.info="info",e.warning="warning",e.error="error"}(s.logErrorType||(s.logErrorType={}));function D(){const e=new Date,o=e.getHours()<10?`0${e.getHours()}`:e.getHours(),a=e.getMinutes()<10?`0${e.getMinutes()}`:e.getMinutes(),n=e.getSeconds()<10?`0${e.getSeconds()}`:e.getSeconds();return`${o}:${a}:${n}`}function ee(e){return`#link#${JSON.stringify(e)}#link#`}function I(e){const o=/#link#(.+)#link#/g,a=[];let n;for(n=o.exec(e);n;){const r=document.createElement("a"),u=JSON.parse(n[1]),l=Object.entries(u);for(const[y,f]of l)r.setAttribute(y,f);r.className="editor_custom_link",r.innerHTML="logDownload",a.push({start:n.index,end:n.index+n[0].length,node:r}),n=o.exec(e)}return a}function te(e="",o="info"){return`#log<${o}>log#${e}#log<${o}>log#`}function A(e){const o=[];function a(){const n=/#log<(\w*)>log#((.|\r\n|\n)*?)#log<(\w*)>log#/g;let r;for(r=n.exec(e);r;){const l=r[0].replace(/\r\n/g,` | ||
`).split(` | ||
`),g=r[2].replace(/\r\n/g,` | ||
`),f=r[2].replace(/\r\n/g,` | ||
`).split(` | ||
`),d=document.createElement("span"),p=r[1];d.className=`c-editor--log__${p}`;let s=0;for(let m=0;m<i.length;m++){const w=i[m],y=g[m],S=d.cloneNode(!1);S.innerText=y,n.push({start:r.index+s,end:r.index+s+w.length,node:S}),s=s+w.length+1}r=a.exec(e)}}return o(),n}function Y(e,n=""){return`[${x()}] <${n}> ${e}`}function ee(e,n,o){const r=new Array(Math.max(n||15,5)).join(o||"=");return`${r}${e}${r}`}const v=[{regex:/(\[.*?\])([ \t]*)(<error>[ \t])(.+)/,token:["tag","","error.strong","error.strong"],sol:!0},{regex:/(\[.*?\])([ \t]*)(<info>)(.+)(.?)/,token:["tag","","bracket","bracket","hr"],sol:!0},{regex:/(\[.*?\])([ \t]*)(<warning>)(.+)(.?)/,token:["tag","","comment","comment","hr"],sol:!0}];C.default.defineSimpleMode("fclog",{start:[...v,{regex:/.*/,token:"hr"}],error:[...v,{regex:/.*/,token:"error.strong"}],info:[...v,{regex:/.*/,token:"bracket"}],warning:[...v,{regex:/.*\[/,token:"comment"}]}),C.default.defineSimpleMode("log",{start:[{regex:/^[=]+[^=]*[=]+/,token:"strong"},{regex:/([^\w])([A-Z][\w]*)/,token:["","string"]},{regex:/(^[A-Z][\w]*)/,token:"string"}]});const te=window.CodeMirror||C.default,ne=t.defineComponent({name:"CodemirrorFclog",props:{value:{type:String,default:""},name:{type:String,default:`cm-textarea-${+new Date}`},options:{type:Object,default:()=>({})},cminstance:{type:Object,default:()=>({})},placeholder:{type:String,default:""}},emits:["update:cminstance","ready"],setup(e,{emit:n}){const o=t.ref(),a=t.ref(null),r=(i=e.cminstance)=>{i.getAllMarks().forEach(p=>p.clear());const g=i.getValue(),d=[].concat(L(g)).concat(T(g));for(let p=0;p<d.length;p++){const s=d[p];i.markText(i.posFromIndex(s.start),i.posFromIndex(s.end),{replacedWith:s.node})}},l=()=>{var i;a.value=t.markRaw(te.fromTextArea(o.value,e.options)),n("update:cminstance",t.unref(a)),(i=a.value)==null||i.on("change",r)};return t.watch(()=>e.cminstance,i=>{var u;i&&(r(e.cminstance),(u=e.cminstance)==null||u.setValue(e.value),n("ready",a))},{deep:!0,immediate:!0}),t.onMounted(()=>{l()}),{initialize:l,textarea:o}}}),re=["name","placeholder"];function oe(e,n,o,a,r,l){return t.openBlock(),t.createElementBlock("textarea",{ref:"textarea",name:e.$props.name,placeholder:e.$props.placeholder},null,8,re)}var ae=_(ne,[["render",oe]]);const D={"update:value":e=>e,change:(e,n)=>({value:e,cm:n}),input:e=>e,ready:e=>e},ce=["changes","scroll","beforeChange","cursorActivity","keyHandled","inputRead","electricInput","beforeSelectionChange","viewportChange","swapDoc","gutterClick","gutterContextMenu","focus","blur","refresh","optionChange","scrollCursorIntoView","update"],se=()=>{const e={};return ce.forEach(n=>{e[n]=(...o)=>o}),e},O={mode:"text",theme:"default",lineNumbers:!0,smartIndent:!0,indentUnit:2};function ie(e){Promise.resolve().then(()=>{const n=e.getScrollInfo();e.scrollTo(n.left,n.height)})}const le=({props:e,cminstance:n,emit:o,internalInstance:a,content:r})=>{const l=()=>{const u=[];return Object.keys(a==null?void 0:a.vnode.props).forEach(g=>{if(g.startsWith("on")){const d=g.replace(g[2],g[2].toLowerCase()).slice(2);!D[d]&&u.push(d)}}),u};return{listenerEvents:()=>{n.value.on("change",d=>{const p=d.getValue();p!==r.value&&(r.value=p,o("update:value",r.value),o("input",r.value),Promise.resolve().then(()=>{o("change",r.value,d)}),e.keepCursorInEnd&&ie(d))});const u={};l().filter(d=>!u[d]&&(u[d]=!0)).forEach(d=>{n.value.on(d,(...p)=>{o(d,...p)})})}}};function de({props:e,cminstance:n,presetRef:o}){const a=t.ref(null),r=t.ref(null),l=()=>{t.nextTick(()=>{var s;(s=n.value)==null||s.refresh()})},i=(s=e.width,m=e.height)=>{var y;a.value=String(s).replace("px",""),r.value=String(m).replace("px","");const w=r.value;(y=n.value)==null||y.setSize(a.value,w)},u=()=>{var m;const s=(m=n.value)==null?void 0:m.getWrapperElement();s==null||s.remove()},g=()=>{var m,w,y;const s=(m=n.value)==null?void 0:m.getDoc().getHistory();(w=o.value)==null||w.initialize(),u(),(y=n.value)==null||y.getDoc().setHistory(s)},d=()=>{const s=document.querySelector(".CodeMirror-gutters");return(s==null?void 0:s.style.left.replace("px",""))!=="0"};return{reload:g,refresh:l,resize:i,destroy:u,containerHeight:r,reviseStyle:()=>{if(l(),!d())return;const s=setInterval(()=>{d()?l():clearInterval(s)},60),m=setTimeout(()=>{clearInterval(s),clearTimeout(m)},400)}}}typeof Object.assign!="function"&&Object.defineProperty(Object,"assign",{value(e,n){if(e==null)throw new TypeError("Cannot convert undefined or null to object");const o=Object(e);for(let a=1;a<arguments.length;a++){const r=arguments[a];if(r!=null)for(const l in r)Object.prototype.hasOwnProperty.call(r,l)&&(o[l]=r[l])}return o},writable:!0,configurable:!0});const ue=t.defineComponent({name:"CodemirrorEditor",components:{Default:U,Merge:K,FcLog:ae},props:{value:{type:String,default:""},options:{type:Object,default:()=>O},globalOptions:{type:Object,default:()=>O},placeholder:{type:String,default:""},border:{type:Boolean,default:!1},width:{type:[String,Number],default:null},height:{type:[String,Number],default:null},keepCursorInEnd:{type:Boolean,default:!1},merge:{type:Boolean,default:!1},name:{type:String,default:""},marker:{type:Function,default:()=>null},unseenLines:{type:Array,default:()=>[]}},emits:M(M({},D),se()),setup(e,{emit:n}){var N,I;const o=t.ref(null),a=t.ref(""),r=t.ref("Default"),l=t.ref(M(M(M({},O),e.globalOptions),e.options)),i=t.getCurrentInstance(),u=t.ref(null),{refresh:g,resize:d,destroy:p,containerHeight:s,reviseStyle:m}=de({props:e,cminstance:o,presetRef:u}),{listenerEvents:w}=le({props:e,cminstance:o,emit:n,internalInstance:i,content:a}),y=()=>{e.unseenLines!==void 0&&e.marker!==void 0&&e.unseenLines.forEach(h=>{var $,b;const k=($=o.value)==null?void 0:$.lineInfo(h);(b=o.value)==null||b.setGutterMarker(h,"breakpoints",(k==null?void 0:k.gutterMarkers)?null:e.marker())})},S=h=>{var $,b;const k=($=o.value)==null?void 0:$.getValue();h!==k&&((b=o.value)==null||b.setValue(h),a.value=h,m()),y()},he=()=>{w(),y(),d(),n("ready",o.value),t.watch([()=>e.width,()=>e.height],([h,k])=>{d(h,k)},{deep:!0})},ye=()=>{if(e.options.mode==="fclog"||e.options.mode==="log"){r.value="FcLog";return}if(e.merge){r.value="Merge";return}r.value="Default"};return t.watch(()=>e.options,h=>{var k;for(const $ in e.options)(k=o.value)==null||k.setOption($,h[$])},{deep:!0}),t.watch(()=>e.value,h=>{S(h)}),t.watch(()=>e.merge,h=>{ye()},{immediate:!0}),t.onBeforeUnmount(()=>{p()}),{presetModeName:r,cmOptions:l,cminstance:o,content:a,ready:he,resize:d,refresh:g,containerHeight:s,instanceName:e.name||((I=(N=i==null?void 0:i.parent)==null?void 0:N.type)==null?void 0:I.name)||void 0,presetRef:u}}});function fe(e,n,o,a,r,l){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["codemirror-container",{merge:e.$props.merge,bordered:e.$props.border||e.$props.merge,"width-auto":!e.$props.width||e.$props.width=="100%","height-auto":!e.$props.height||e.$props.height=="100%"}]),style:t.normalizeStyle({height:e.containerHeight+"px"})},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.presetModeName),t.mergeProps({ref:"presetRef",cminstance:e.cminstance,"onUpdate:cminstance":n[0]||(n[0]=i=>e.cminstance=i),style:{height:"100%"}},V(M(M({},e.$props),e.$attrs),{options:e.cmOptions,name:e.instanceName,content:e.content}),{onReady:e.ready}),null,16,["cminstance","onReady"]))],6)}var E=_(ue,[["render",fe]]),Ee="";const me=(e,n)=>(n&&n.options&&(E.props.globalOptions.default=()=>n.options),e.component((n==null?void 0:n.componentName)||"Codemirror",E),e),ge=window.CodeMirror||C.default,pe=me;function styleInject(css,ref){if(ref===void 0){ref={}}var insertAt=ref.insertAt;if(!css||typeof document==="undefined"){return}var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");style.type="text/css";if(insertAt==="top"){if(head.firstChild){head.insertBefore(style,head.firstChild)}else{head.appendChild(style)}}else{head.appendChild(style)}if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))}};styleInject(`.codemirror-container { | ||
`),h=document.createElement("span"),i=r[1];h.className=`c-editor--log__${i}`;let p=0;for(let c=0;c<l.length;c++){const g=l[c],M=f[c],_=h.cloneNode(!1);_.innerText=M,o.push({start:r.index+p,end:r.index+p+g.length,node:_}),p=p+g.length+1}r=n.exec(e)}}return a(),o}function ne(e,o=""){return`[${D()}] <${o}> ${e}`}function re(e,o,a){const r=new Array(Math.max(o||15,5)).join(a||"=");return`${r}${e}${r}`}const E=[{regex:/(\[.*?\])([ \t]*)(<error>[ \t])(.+)/,token:["tag","","error.strong","error.strong"],sol:!0},{regex:/(\[.*?\])([ \t]*)(<info>)(.+)(.?)/,token:["tag","","bracket","bracket","hr"],sol:!0},{regex:/(\[.*?\])([ \t]*)(<warning>)(.+)(.?)/,token:["tag","","comment","comment","hr"],sol:!0}];b.default.defineSimpleMode("fclog",{start:[...E,{regex:/.*/,token:"hr"}],error:[...E,{regex:/.*/,token:"error.strong"}],info:[...E,{regex:/.*/,token:"bracket"}],warning:[...E,{regex:/.*\[/,token:"comment"}]}),b.default.defineSimpleMode("log",{start:[{regex:/^[=]+[^=]*[=]+/,token:"strong"},{regex:/([^\w])([A-Z][\w]*)/,token:["","string"]},{regex:/(^[A-Z][\w]*)/,token:"string"}]});const oe=window.CodeMirror||b.default,ae=t.defineComponent({name:"CodemirrorFclog",props:{value:{type:String,default:""},name:{type:String,default:`cm-textarea-${+new Date}`},options:{type:Object,default:()=>({})},cminstance:{type:Object,default:()=>({})},placeholder:{type:String,default:""}},emits:["update:cminstance","ready"],setup(e,{emit:o}){const a=t.ref(),n=t.ref(null),r=(l=e.cminstance)=>{l.getAllMarks().forEach(i=>i.clear());const f=l.getValue(),h=[].concat(I(f)).concat(A(f));for(let i=0;i<h.length;i++){const p=h[i];l.markText(l.posFromIndex(p.start),l.posFromIndex(p.end),{replacedWith:p.node})}},u=()=>{var l;n.value=t.markRaw(oe.fromTextArea(a.value,e.options)),o("update:cminstance",t.unref(n)),(l=n.value)==null||l.on("change",r)};return t.watch(()=>e.cminstance,l=>{var y;l&&(r(e.cminstance),(y=e.cminstance)==null||y.setValue(e.value),o("ready",n))},{deep:!0,immediate:!0}),t.onMounted(()=>{u()}),{initialize:u,textarea:a}}}),se=["name","placeholder"];function ce(e,o,a,n,r,u){return t.openBlock(),t.createElementBlock("textarea",{ref:"textarea",name:e.$props.name,placeholder:e.$props.placeholder},null,8,se)}var le=v(ae,[["render",ce]]);const N={"update:value":e=>e,change:(e,o)=>({value:e,cm:o}),input:e=>e,ready:e=>e},ie=["changes","scroll","beforeChange","cursorActivity","keyHandled","inputRead","electricInput","beforeSelectionChange","viewportChange","swapDoc","gutterClick","gutterContextMenu","focus","blur","refresh","optionChange","scrollCursorIntoView","update"],de=()=>{const e={};return ie.forEach(o=>{e[o]=(...a)=>a}),e},O={mode:"text",theme:"default",lineNumbers:!0,smartIndent:!0,indentUnit:2};function ue(e){Promise.resolve().then(()=>{const o=e.getScrollInfo();e.scrollTo(o.left,o.height)})}const fe=({props:e,cminstance:o,emit:a,internalInstance:n,content:r})=>{const u=t.computed(()=>{var f;return e.merge?(f=t.unref(o))==null?void 0:f.editor():t.unref(o)}),l=()=>{const f=[];return Object.keys(n==null?void 0:n.vnode.props).forEach(h=>{if(h.startsWith("on")){const i=h.replace(h[2],h[2].toLowerCase()).slice(2);!N[i]&&f.push(i)}}),f};return{listenerEvents:()=>{u.value.on("change",i=>{const p=i.getValue();p!==r.value&&(r.value=p,a("update:value",r.value),a("input",r.value),Promise.resolve().then(()=>{a("change",r.value,i)}),e.keepCursorInEnd&&ue(i))});const f={};l().filter(i=>!f[i]&&(f[i]=!0)).forEach(i=>{u.value.on(i,(...p)=>{a(i,...p)})})}}};function me({props:e,cminstance:o,presetRef:a}){const n=t.ref(null),r=t.ref(null),u=t.computed(()=>{var c;return e.merge?(c=t.unref(o))==null?void 0:c.editor():t.unref(o)}),l=()=>{t.nextTick(()=>{var c;(c=u.value)==null||c.refresh()})},y=(c=e.width,g=e.height)=>{var _;n.value=String(c).replace("px",""),r.value=String(g).replace("px","");const M=r.value;(_=u.value)==null||_.setSize(n.value,M)},f=()=>{var g;const c=(g=u.value)==null?void 0:g.getWrapperElement();c==null||c.remove()},h=()=>{var g,M,_;const c=(g=u.value)==null?void 0:g.getDoc().getHistory();(M=a.value)==null||M.initialize(),f(),(_=u.value)==null||_.getDoc().setHistory(c)},i=()=>{const c=document.querySelector(".CodeMirror-gutters");return(c==null?void 0:c.style.left.replace("px",""))!=="0"};return{reload:h,refresh:l,resize:y,destroy:f,containerHeight:r,reviseStyle:()=>{if(l(),!i())return;const c=setInterval(()=>{i()?l():clearInterval(c)},60),g=setTimeout(()=>{clearInterval(c),clearTimeout(g)},400)}}}const S=t.defineComponent({props:{value:{type:String,default:""},options:{type:Object,default:()=>O},globalOptions:{type:Object,default:()=>O},placeholder:{type:String,default:""},border:{type:Boolean,default:!1},width:{type:[String,Number],default:null},height:{type:[String,Number],default:null},keepCursorInEnd:{type:Boolean,default:!1},merge:{type:Boolean,default:!1},name:{type:String,default:""},marker:{type:Function,default:()=>null},unseenLines:{type:Array,default:()=>[]}},emits:C(C({},N),de()),setup(e,{expose:o,emit:a}){var V,F;const n=e;typeof Object.assign!="function"&&Object.defineProperty(Object,"assign",{value(d,k){if(d==null)throw new TypeError("Cannot convert undefined or null to object");const w=Object(d);for(let $=1;$<arguments.length;$++){const x=arguments[$];if(x!=null)for(const j in x)Object.prototype.hasOwnProperty.call(x,j)&&(w[j]=x[j])}return w},writable:!0,configurable:!0});const r=t.ref(null),u=t.ref(""),l=t.shallowRef(T),y=t.ref(C(C(C({},O),n.globalOptions),n.options)),f=t.getCurrentInstance(),h=n.name||((F=(V=f==null?void 0:f.parent)==null?void 0:V.type)==null?void 0:F.name)||void 0,i=t.ref(null),{refresh:p,resize:c,destroy:g,containerHeight:M,reviseStyle:_}=me({props:n,cminstance:r,presetRef:i}),{listenerEvents:ye}=fe({props:n,cminstance:r,emit:a,internalInstance:f,content:u}),B=()=>{n.unseenLines!==void 0&&n.marker!==void 0&&n.unseenLines.forEach(d=>{var w,$;const k=(w=r.value)==null?void 0:w.lineInfo(d);($=r.value)==null||$.setGutterMarker(d,"breakpoints",(k==null?void 0:k.gutterMarkers)?null:n.marker())})},ke=d=>{var w,$;const k=(w=r.value)==null?void 0:w.getValue();d!==k&&(($=r.value)==null||$.setValue(d),u.value=d,_()),B()},we=()=>{ye(),B(),c(),a("ready",r.value),t.watch([()=>n.width,()=>n.height],([d,k])=>{c(d,k)},{deep:!0})},$e=()=>{if(n.options.mode==="fclog"||n.options.mode==="log"){l.value=le;return}if(n.merge){l.value=Y;return}l.value=T};return t.watch(()=>n.options,d=>{var w;const k=n.merge?(w=t.unref(r))==null?void 0:w.editor():t.unref(r);for(const $ in n.options)k.setOption($,t.unref(d[$]))},{deep:!0}),t.watch(()=>n.value,d=>{ke(d)}),t.watch(()=>n.merge,d=>{$e()},{immediate:!0}),t.onBeforeUnmount(()=>{g()}),o({cminstance:r,resize:c,refresh:p,destroy:g}),(d,k)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["codemirror-container",{merge:d.$props.merge,bordered:d.$props.border||d.$props.merge,"width-auto":!d.$props.width||d.$props.width=="100%","height-auto":!d.$props.height||d.$props.height=="100%"}]),style:t.normalizeStyle({height:t.unref(M)+"px"})},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(l)),t.mergeProps({ref_key:"presetRef",ref:i,cminstance:r.value,"onUpdate:cminstance":k[0]||(k[0]=w=>r.value=w),style:{height:"100%"}},P(C(C({},d.$props),d.$attrs),{options:y.value,name:t.unref(h),content:u.value}),{onReady:we}),null,16,["cminstance"]))],6))}});var Oe="";const pe=(e,o)=>(o&&o.options&&(S.props.globalOptions.default=()=>o.options),e.component((o==null?void 0:o.componentName)||"Codemirror",S),e),ge=window.CodeMirror||b.default,he=pe;function styleInject(css,ref){if(ref===void 0){ref={}}var insertAt=ref.insertAt;if(!css||typeof document==="undefined"){return}var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");style.type="text/css";if(insertAt==="top"){if(head.firstChild){head.insertBefore(style,head.firstChild)}else{head.appendChild(style)}}else{head.appendChild(style)}if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))}};styleInject(`.codemirror-container { | ||
position: relative; | ||
@@ -66,2 +66,2 @@ display: inline-block; | ||
} | ||
`),c.CodeMirror=ge,c.GlobalCmComponent=pe,c.VueCodemirror=E,c.createLinkMark=Q,c.createLog=Y,c.createLogMark=X,c.createTitle=ee,c.default=E,c.getLinkMarks=L,c.getLocalTime=x,c.getLogMark=T,Object.defineProperty(c,"__esModule",{value:!0}),c[Symbol.toStringTag]="Module"}); | ||
`),s.CodeMirror=ge,s.GlobalCmComponent=he,s.VueCodemirror=S,s.createLinkMark=ee,s.createLog=ne,s.createLogMark=te,s.createTitle=re,s.default=S,s.getLinkMarks=I,s.getLocalTime=D,s.getLogMark=A,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module"}); |
import _CodeMirror from "codemirror"; | ||
import type { App } from "vue"; | ||
import type { EditorConfiguration } from "codemirror"; | ||
import type { EditorConfiguration, Editor } from "codemirror"; | ||
import VueCodemirror from "./src/components/index.vue"; | ||
interface CmComp { | ||
cminstance: Editor; | ||
resize: (width?: string | number | null, height?: string | number | null) => void; | ||
refresh: () => void; | ||
destroy: () => void; | ||
} | ||
export declare type CmComponentRef = CmComp | null; | ||
declare interface InstallConfig { | ||
@@ -6,0 +13,0 @@ options: EditorConfiguration; |
import type { Ref, PropType } from "vue"; | ||
import type { Editor, EditorConfiguration } from "codemirror"; | ||
declare const _default: import("vue").DefineComponent<{ | ||
declare const _sfc_main: import("vue").DefineComponent<{ | ||
value: { | ||
@@ -65,4 +65,18 @@ type: PropType<string>; | ||
}, { | ||
presetModeName: Ref<"Default" | "Merge" | "FcLog">; | ||
cmOptions: any; | ||
props: Readonly<{ | ||
[x: string & `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined; | ||
value: string; | ||
options: EditorConfiguration; | ||
globalOptions: EditorConfiguration; | ||
placeholder: string; | ||
border: boolean; | ||
width: string | number | null; | ||
height: string | number | null; | ||
keepCursorInEnd: boolean; | ||
merge: boolean; | ||
name: string; | ||
marker: () => HTMLElement; | ||
unseenLines: any[]; | ||
}>; | ||
emit: ((event: string, ...args: unknown[]) => void) & ((event: string, ...args: any[]) => void) & ((event: number, ...args: unknown[]) => void) & ((event: number, ...args: any[]) => void); | ||
cminstance: Ref<{ | ||
@@ -307,8 +321,22 @@ hasFocus: () => boolean; | ||
content: Ref<string>; | ||
ready: () => void; | ||
presetModeName: import("vue").ShallowRef<import("vue").ComponentOptions<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, any, any, any>> | import("vue").ShallowRef<import("vue").FunctionalComponent<any, any>> | import("vue").ShallowRef<{ | ||
new (...args: any[]): any; | ||
__isFragment?: undefined; | ||
__isTeleport?: undefined; | ||
__isSuspense?: undefined; | ||
}>; | ||
cmOptions: any; | ||
internalInstance: import("vue").ComponentInternalInstance | null; | ||
instanceName: string | undefined; | ||
presetRef: Ref<null>; | ||
refresh: () => void; | ||
resize: (width?: string | number | null, height?: string | number | null) => void; | ||
refresh: () => void; | ||
destroy: () => void; | ||
containerHeight: Ref<Nullable<string>>; | ||
instanceName: string | undefined; | ||
presetRef: Ref<null>; | ||
reviseStyle: () => void; | ||
listenerEvents: () => void; | ||
unseenLineMarkers: () => void; | ||
onCodeChange: (newVal: string) => void; | ||
ready: () => void; | ||
handlePresetModeName: () => void; | ||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, { | ||
@@ -337,7 +365,6 @@ [x: string]: any; | ||
} & { | ||
name: string; | ||
value: string; | ||
options: EditorConfiguration; | ||
globalOptions: EditorConfiguration; | ||
placeholder: string; | ||
globalOptions: EditorConfiguration; | ||
border: boolean; | ||
@@ -348,2 +375,3 @@ width: string | number | null; | ||
merge: boolean; | ||
name: string; | ||
marker: () => HTMLElement; | ||
@@ -354,7 +382,6 @@ unseenLines: any[]; | ||
}, { | ||
name: string; | ||
value: string; | ||
options: EditorConfiguration; | ||
globalOptions: EditorConfiguration; | ||
placeholder: string; | ||
globalOptions: EditorConfiguration; | ||
border: boolean; | ||
@@ -365,5 +392,6 @@ width: string | number | null; | ||
merge: boolean; | ||
name: string; | ||
marker: () => HTMLElement; | ||
unseenLines: any[]; | ||
}>; | ||
export default _default; | ||
export default _sfc_main; |
@@ -42,8 +42,8 @@ import type { PropType } from "vue"; | ||
} & { | ||
value: string; | ||
options: EditorConfiguration; | ||
placeholder: string; | ||
name: string; | ||
value: string; | ||
content: string; | ||
options: EditorConfiguration; | ||
cminstance: Nullable<Editor>; | ||
placeholder: string; | ||
} & {}> & { | ||
@@ -53,9 +53,9 @@ onReady?: ((instance: Editor) => any) | undefined; | ||
}, { | ||
value: string; | ||
options: EditorConfiguration; | ||
placeholder: string; | ||
name: string; | ||
value: string; | ||
content: string; | ||
options: EditorConfiguration; | ||
cminstance: Nullable<Editor>; | ||
placeholder: string; | ||
}>; | ||
export default _default; |
@@ -34,7 +34,7 @@ import type { PropType } from "vue"; | ||
} & { | ||
name: string; | ||
value: string; | ||
options: Record<string, any>; | ||
placeholder: string; | ||
name: string; | ||
cminstance: Nullable<Editor>; | ||
placeholder: string; | ||
} & {}> & { | ||
@@ -44,8 +44,8 @@ onReady?: ((...args: any[]) => any) | undefined; | ||
}, { | ||
name: string; | ||
value: string; | ||
options: Record<string, any>; | ||
placeholder: string; | ||
name: string; | ||
cminstance: Nullable<Editor>; | ||
placeholder: string; | ||
}>; | ||
export default _default; |
@@ -13,2 +13,3 @@ import type { Editor, EditorConfiguration } from "codemirror"; | ||
}, { | ||
mergeView: import("vue").Ref<HTMLElement | undefined>; | ||
initialize: () => void; | ||
@@ -15,0 +16,0 @@ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:cminstance" | "ready")[], "ready" | "update:cminstance", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{ |
import type { Editor } from "codemirror"; | ||
import type { ComponentInternalInstance, Ref } from "vue"; | ||
import type { MergeView } from "codemirror/addon/merge/merge"; | ||
import type { CmProps } from '../..src/types/props'; | ||
declare type UseEventsParams = { | ||
props: CmProps; | ||
cminstance: Ref<Editor>; | ||
cminstance: Ref<Editor | MergeView>; | ||
emit: ((event: "ready", cm: Editor) => void) & ((event: "update:value", value: string) => void) & ((event: "change", value: string, cm: Editor) => void) & ((event: "input", value: string) => void) & ((event: string, ...args: any[]) => void); | ||
@@ -8,0 +9,0 @@ internalInstance: Nullable<ComponentInternalInstance>; |
import type { Ref } from "vue"; | ||
import type { Editor } from "codemirror"; | ||
import type { MergeView } from "codemirror/addon/merge/merge"; | ||
import type { CmProps } from '../..src/types/props'; | ||
export declare type UseViewControlParams = { | ||
props: CmProps; | ||
cminstance: Ref<Nullable<Editor>>; | ||
cminstance: Ref<Nullable<Editor | MergeView>>; | ||
presetRef: Ref<Nullable<{ | ||
@@ -8,0 +9,0 @@ initialize: () => void; |
{ | ||
"name": "codemirror-editor-vue3", | ||
"description": "CodeMirror component for Vue3", | ||
"version": "2.0.4-beta", | ||
"version": "2.0.4-beta1", | ||
"license": "MIT", | ||
@@ -55,4 +55,4 @@ "files": [ | ||
"build:types": "tsc --emitDeclarationOnly vite build", | ||
"publish": "git push && git push --tags && npm publish && npm run deploy-docs", | ||
"publish-beta": "npm publish --tag=beta", | ||
"publish": "vite build && git push && git push --tags && npm publish && npm run deploy-docs", | ||
"publish-beta": "vite build && npm publish --tag=beta", | ||
"docs-dev": "vitepress dev docs --open", | ||
@@ -59,0 +59,0 @@ "docs-build": "vitepress build docs", |
74084
3.09%1587
2.45%