codemirror-editor-vue3
Advanced tools
Comparing version 2.0.6 to 2.1.0-beta
@@ -20,5 +20,5 @@ var __defProp = Object.defineProperty; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
import _CodeMirror from "codemirror"; | ||
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"; | ||
import _CodeMirror from "codemirror"; | ||
import "codemirror/addon/merge/merge.css"; | ||
@@ -28,2 +28,4 @@ import "codemirror/addon/merge/merge.js"; | ||
import "codemirror/addon/mode/simple.js"; | ||
!window.CodeMirror && (window.CodeMirror = _CodeMirror); | ||
const CodeMirror$1 = window.CodeMirror || _CodeMirror; | ||
var _export_sfc = (sfc, props) => { | ||
@@ -36,3 +38,2 @@ const target = sfc.__vccOpts || sfc; | ||
}; | ||
const CodeMirror$3 = window.CodeMirror || _CodeMirror; | ||
const _sfc_main$3 = defineComponent({ | ||
@@ -74,3 +75,3 @@ name: "DefaultMode", | ||
const initialize = () => { | ||
_cminstance.value = markRaw(CodeMirror$3.fromTextArea(textarea.value, props.options)); | ||
_cminstance.value = markRaw(CodeMirror$1.fromTextArea(textarea.value, props.options)); | ||
emit("update:cminstance", _cminstance.value); | ||
@@ -102,3 +103,2 @@ const unwatch = watch(() => props.cminstance, (val) => { | ||
var Default = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$2]]); | ||
const CodeMirror$2 = (window == null ? void 0 : window.CodeMirror) || _CodeMirror; | ||
window.diff_match_patch = DiffMatchPatch; | ||
@@ -125,3 +125,3 @@ window.DIFF_DELETE = -1; | ||
const initialize = () => { | ||
_cminstance.value = markRaw(CodeMirror$2.MergeView(mergeView.value, props.options)); | ||
_cminstance.value = markRaw(CodeMirror$1.MergeView(mergeView.value, props.options)); | ||
emit("update:cminstance", _cminstance.value); | ||
@@ -219,3 +219,3 @@ emit("ready", _cminstance); | ||
} | ||
function createLog(log, type = "") { | ||
function createLog(log, type) { | ||
const now = getLocalTime(); | ||
@@ -226,4 +226,4 @@ return `[${now}] <${type}> ${log}`; | ||
const arr = new Array(Math.max(symbolLength || 15, 5)); | ||
const wraptext = arr.join(symbol || "="); | ||
return `${wraptext}${title}${wraptext}`; | ||
const wrapText = arr.join(symbol || "="); | ||
return `${wrapText}${title}${wrapText}`; | ||
} | ||
@@ -247,3 +247,3 @@ const startRegex = [ | ||
]; | ||
_CodeMirror.defineSimpleMode("fclog", { | ||
CodeMirror$1.defineSimpleMode("fclog", { | ||
start: [ | ||
@@ -278,3 +278,3 @@ ...startRegex, | ||
}); | ||
_CodeMirror.defineSimpleMode("log", { | ||
CodeMirror$1.defineSimpleMode("log", { | ||
start: [ | ||
@@ -295,3 +295,2 @@ { | ||
}); | ||
const CodeMirror$1 = window.CodeMirror || _CodeMirror; | ||
const _sfc_main$1 = defineComponent({ | ||
@@ -551,2 +550,6 @@ name: "CodemirrorFclog", | ||
}, | ||
originalStyle: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
keepCursorInEnd: { | ||
@@ -691,5 +694,6 @@ type: Boolean, | ||
merge: _ctx.$props.merge, | ||
bordered: _ctx.$props.border || _ctx.$props.merge, | ||
bordered: _ctx.$props.border || _ctx.$props.merge && !props.originalStyle, | ||
"width-auto": !_ctx.$props.width || _ctx.$props.width == "100%", | ||
"height-auto": !_ctx.$props.height || _ctx.$props.height == "100%" | ||
"height-auto": !_ctx.$props.height || _ctx.$props.height == "100%", | ||
"original-style": props.originalStyle | ||
}]), | ||
@@ -725,3 +729,3 @@ style: normalizeStyle({ | ||
}; | ||
const CodeMirror = window.CodeMirror || _CodeMirror; | ||
const CodeMirror = window.CodeMirror || CodeMirror$1; | ||
const GlobalCmComponent = install; | ||
@@ -750,39 +754,39 @@ 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 { | ||
} | ||
.CodeMirror-lines .CodeMirror-placeholder.CodeMirror-line-like { | ||
.codemirror-container .editor_custom_link { | ||
cursor: pointer; | ||
color: #1474f1; | ||
text-decoration: underline; | ||
} | ||
.codemirror-container .editor_custom_link:hover { | ||
color: #04b4fa; | ||
} | ||
.codemirror-container:not(.original-style) .CodeMirror-lines .CodeMirror-placeholder.CodeMirror-line-like { | ||
color: #666; | ||
} | ||
.CodeMirror, | ||
.CodeMirror-merge-pane { | ||
.codemirror-container:not(.original-style) .CodeMirror, | ||
.codemirror-container:not(.original-style) .CodeMirror-merge-pane { | ||
height: 100%; | ||
font-family: consolas !important; | ||
} | ||
.CodeMirror-merge, | ||
.CodeMirror-merge-right .CodeMirror { | ||
.codemirror-container:not(.original-style) .CodeMirror-merge, | ||
.codemirror-container:not(.original-style) .CodeMirror-merge-right .CodeMirror { | ||
height: 100%; | ||
border: none !important; | ||
} | ||
.editor_custom_link { | ||
cursor: pointer; | ||
color: #1474f1; | ||
text-decoration: underline; | ||
} | ||
.editor_custom_link:hover { | ||
color: #04b4fa; | ||
} | ||
.c-editor--log__error { | ||
.codemirror-container:not(.original-style) .c-editor--log__error { | ||
color: #bb0606; | ||
font-weight: bold; | ||
} | ||
.c-editor--log__info { | ||
.codemirror-container:not(.original-style) .c-editor--log__info { | ||
color: #333333; | ||
font-weight: bold; | ||
} | ||
.c-editor--log__warning { | ||
.codemirror-container:not(.original-style) .c-editor--log__warning { | ||
color: #ee9900; | ||
} | ||
.c-editor--log__success { | ||
.codemirror-container:not(.original-style) .c-editor--log__success { | ||
color: #669600; | ||
} | ||
.cm-header, | ||
.cm-strong { | ||
.codemirror-container:not(.original-style) .cm-header, | ||
.codemirror-container:not(.original-style) .cm-strong { | ||
font-weight: bold; | ||
@@ -789,0 +793,0 @@ } |
@@ -1,6 +0,6 @@ | ||
var Me=Object.defineProperty,Ce=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var H=(s,m,t)=>m in s?Me(s,m,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[m]=t,C=(s,m)=>{for(var t in m||(m={}))Ee.call(m,t)&&H(s,t,m[t]);if(R)for(var t of R(m))Se.call(m,t)&&H(s,t,m[t]);return s},P=(s,m)=>Ce(s,be(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,xe,ve,Oe,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 k;l&&((k=e.cminstance)==null||k.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[k,f]of l)r.setAttribute(k,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,` | ||
var _e=Object.defineProperty,Me=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var H=Object.getOwnPropertySymbols;var Ce=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var P=(s,t,w)=>t in s?_e(s,t,{enumerable:!0,configurable:!0,writable:!0,value:w}):s[t]=w,b=(s,t)=>{for(var w in t||(t={}))Ce.call(t,w)&&P(s,w,t[w]);if(H)for(var w of H(t))Se.call(t,w)&&P(s,w,t[w]);return s},z=(s,t)=>Me(s,be(t));(function(s,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue"),require("codemirror/lib/codemirror.css"),require("codemirror"),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","vue","codemirror/lib/codemirror.css","codemirror","codemirror/addon/merge/merge.css","codemirror/addon/merge/merge.js","diff-match-patch","codemirror/addon/mode/simple.js"],t):(s=typeof globalThis!="undefined"?globalThis:s||self,t(s["codemirror-editor-vue3"]={},s.Vue,null,s.codemirror,null,null,s.DiffMatchPatch))})(this,function(s,t,w,q,Ee,xe,U){"use strict";function T(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var L=T(q),W=T(U);!window.CodeMirror&&(window.CodeMirror=L.default);const C=window.CodeMirror||L.default;var v=(e,o)=>{const a=e.__vccOpts||e;for(const[n,r]of o)a[n]=r;return a};const G=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(C.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}}}),J=["name","placeholder"];function Z(e,o,a,n,r,u){return t.openBlock(),t.createElementBlock("textarea",{ref:"textarea",name:e.$props.name,placeholder:e.$props.placeholder},null,8,J)}var D=v(G,[["render",Z]]);window.diff_match_patch=W.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(C.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 I(){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 A(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 B(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(` | ||
`),f=r[2].replace(/\r\n/g,` | ||
`).split(` | ||
`),y=document.createElement("span"),d=r[1];y.className=`c-editor--log__${d}`;let p=0;for(let i=0;i<l.length;i++){const g=l[i],_=f[i],$=y.cloneNode(!1);$.innerText=_,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(d=>d.clear());const f=l.getValue(),y=[].concat(I(f)).concat(A(f));for(let d=0;d<y.length;d++){const p=y[d];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 k;l&&(r(e.cminstance),(k=e.cminstance)==null||k.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(y=>{if(y.startsWith("on")){const d=y.replace(y[2],y[2].toLowerCase()).slice(2);!N[d]&&f.push(d)}}),f};return{listenerEvents:()=>{u.value.on("change",d=>{const p=d.getValue();p!==r.value&&(r.value=p,a("update:value",r.value),a("input",r.value),Promise.resolve().then(()=>{a("change",r.value,d)}),e.keepCursorInEnd&&ue(d))});const f={};l().filter(d=>!f[d]&&(f[d]=!0)).forEach(d=>{u.value.on(d,(...p)=>{a(d,...p)})})}}};function me({props:e,cminstance:o,presetRef:a}){const n=t.ref(null),r=t.ref(null),u=t.computed(()=>{var i;return e.merge?(i=t.unref(o))==null?void 0:i.editor():t.unref(o)}),l=()=>{t.nextTick(()=>{var i;(i=u.value)==null||i.refresh()})},k=(i=e.width,g=e.height)=>{var $;n.value=String(i).replace("px",""),r.value=String(g).replace("px","");const _=r.value;($=u.value)==null||$.setSize(n.value,_)},f=()=>{var g;const i=(g=u.value)==null?void 0:g.getWrapperElement();i==null||i.remove()},y=()=>{var g,_,$;const i=(g=u.value)==null?void 0:g.getDoc().getHistory();(_=a.value)==null||_.initialize(),f(),($=u.value)==null||$.getDoc().setHistory(i)},d=()=>{const i=document.querySelector(".CodeMirror-gutters");return(i==null?void 0:i.style.left.replace("px",""))!=="0"};return{reload:y,refresh:l,resize:k,destroy:f,containerHeight:r,reviseStyle:()=>{if(l(),!d())return;const i=setInterval(()=>{d()?l():clearInterval(i)},60),g=setTimeout(()=>{clearInterval(i),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(c,h){if(c==null)throw new TypeError("Cannot convert undefined or null to object");const w=Object(c);for(let M=1;M<arguments.length;M++){const x=arguments[M];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),k=t.ref(C(C(C({},O),n.globalOptions),n.options)),f=t.getCurrentInstance(),y=n.name||((F=(V=f==null?void 0:f.parent)==null?void 0:V.type)==null?void 0:F.name)||void 0,d=t.ref(null),p=t.computed(()=>{var c;return n.merge?(c=t.unref(r))==null?void 0:c.editor():t.unref(r)}),{refresh:i,resize:g,destroy:_,containerHeight:$,reviseStyle:ye}=me({props:n,cminstance:r,presetRef:d}),{listenerEvents:ke}=fe({props:n,cminstance:r,emit:a,internalInstance:f,content:u}),B=()=>{n.unseenLines!==void 0&&n.marker!==void 0&&n.unseenLines.forEach(c=>{var w,M;const h=(w=r.value)==null?void 0:w.lineInfo(c);(M=r.value)==null||M.setGutterMarker(c,"breakpoints",(h==null?void 0:h.gutterMarkers)?null:n.marker())})},we=c=>{var w,M;const h=(w=r.value)==null?void 0:w.getValue();c!==h&&((M=r.value)==null||M.setValue(c),u.value=c,ye()),B()},$e=()=>{ke(),B(),g(),a("ready",r.value),t.watch([()=>n.width,()=>n.height],([c,h])=>{g(c,h)},{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,c=>{var h;for(const w in n.options)(h=p.value)==null||h.setOption(w,t.unref(c[w]))},{deep:!0}),t.watch(()=>n.value,c=>{we(c)}),t.watch(()=>n.placeholder,c=>{var h;(h=p.value)==null||h.setOption("placeholder",c)}),t.watch(()=>n.merge,c=>{_e()},{immediate:!0}),t.onBeforeUnmount(()=>{_()}),o({cminstance:r,resize:g,refresh:i,destroy:_}),(c,h)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["codemirror-container",{merge:c.$props.merge,bordered:c.$props.border||c.$props.merge,"width-auto":!c.$props.width||c.$props.width=="100%","height-auto":!c.$props.height||c.$props.height=="100%"}]),style:t.normalizeStyle({height:t.unref($)+"px"})},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(l)),t.mergeProps({ref_key:"presetRef",ref:d,cminstance:r.value,"onUpdate:cminstance":h[0]||(h[0]=w=>r.value=w),style:{height:"100%"}},P(C(C({},c.$props),c.$attrs),{options:k.value,name:t.unref(y),content:u.value}),{onReady:$e}),null,16,["cminstance"]))],6))}});var je="";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 { | ||
`),h=document.createElement("span"),d=r[1];h.className=`c-editor--log__${d}`;let m=0;for(let i=0;i<l.length;i++){const p=l[i],_=f[i],$=h.cloneNode(!1);$.innerText=_,o.push({start:r.index+m,end:r.index+m+p.length,node:$}),m=m+p.length+1}r=n.exec(e)}}return a(),o}function ne(e,o){return`[${I()}] <${o}> ${e}`}function re(e,o,a){const r=new Array(Math.max(o||15,5)).join(a||"=");return`${r}${e}${r}`}const S=[{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.defineSimpleMode("fclog",{start:[...S,{regex:/.*/,token:"hr"}],error:[...S,{regex:/.*/,token:"error.strong"}],info:[...S,{regex:/.*/,token:"bracket"}],warning:[...S,{regex:/.*\[/,token:"comment"}]}),C.defineSimpleMode("log",{start:[{regex:/^[=]+[^=]*[=]+/,token:"strong"},{regex:/([^\w])([A-Z][\w]*)/,token:["","string"]},{regex:/(^[A-Z][\w]*)/,token:"string"}]});const oe=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(d=>d.clear());const f=l.getValue(),h=[].concat(A(f)).concat(B(f));for(let d=0;d<h.length;d++){const m=h[d];l.markText(l.posFromIndex(m.start),l.posFromIndex(m.end),{replacedWith:m.node})}},u=()=>{var l;n.value=t.markRaw(C.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}}}),ae=["name","placeholder"];function se(e,o,a,n,r,u){return t.openBlock(),t.createElementBlock("textarea",{ref:"textarea",name:e.$props.name,placeholder:e.$props.placeholder},null,8,ae)}var ce=v(oe,[["render",se]]);const N={"update:value":e=>e,change:(e,o)=>({value:e,cm:o}),input:e=>e,ready:e=>e},le=["changes","scroll","beforeChange","cursorActivity","keyHandled","inputRead","electricInput","beforeSelectionChange","viewportChange","swapDoc","gutterClick","gutterContextMenu","focus","blur","refresh","optionChange","scrollCursorIntoView","update"],ie=()=>{const e={};return le.forEach(o=>{e[o]=(...a)=>a}),e},O={mode:"text",theme:"default",lineNumbers:!0,smartIndent:!0,indentUnit:2};function de(e){Promise.resolve().then(()=>{const o=e.getScrollInfo();e.scrollTo(o.left,o.height)})}const ue=({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 d=h.replace(h[2],h[2].toLowerCase()).slice(2);!N[d]&&f.push(d)}}),f};return{listenerEvents:()=>{u.value.on("change",d=>{const m=d.getValue();m!==r.value&&(r.value=m,a("update:value",r.value),a("input",r.value),Promise.resolve().then(()=>{a("change",r.value,d)}),e.keepCursorInEnd&&de(d))});const f={};l().filter(d=>!f[d]&&(f[d]=!0)).forEach(d=>{u.value.on(d,(...m)=>{a(d,...m)})})}}};function fe({props:e,cminstance:o,presetRef:a}){const n=t.ref(null),r=t.ref(null),u=t.computed(()=>{var i;return e.merge?(i=t.unref(o))==null?void 0:i.editor():t.unref(o)}),l=()=>{t.nextTick(()=>{var i;(i=u.value)==null||i.refresh()})},y=(i=e.width,p=e.height)=>{var $;n.value=String(i).replace("px",""),r.value=String(p).replace("px","");const _=r.value;($=u.value)==null||$.setSize(n.value,_)},f=()=>{var p;const i=(p=u.value)==null?void 0:p.getWrapperElement();i==null||i.remove()},h=()=>{var p,_,$;const i=(p=u.value)==null?void 0:p.getDoc().getHistory();(_=a.value)==null||_.initialize(),f(),($=u.value)==null||$.getDoc().setHistory(i)},d=()=>{const i=document.querySelector(".CodeMirror-gutters");return(i==null?void 0:i.style.left.replace("px",""))!=="0"};return{reload:h,refresh:l,resize:y,destroy:f,containerHeight:r,reviseStyle:()=>{if(l(),!d())return;const i=setInterval(()=>{d()?l():clearInterval(i)},60),p=setTimeout(()=>{clearInterval(i),clearTimeout(p)},400)}}}const E=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},originalStyle:{type:Boolean,default:!1},keepCursorInEnd:{type:Boolean,default:!1},merge:{type:Boolean,default:!1},name:{type:String,default:""},marker:{type:Function,default:()=>null},unseenLines:{type:Array,default:()=>[]}},emits:b(b({},N),ie()),setup(e,{expose:o,emit:a}){var F,R;const n=e;typeof Object.assign!="function"&&Object.defineProperty(Object,"assign",{value(c,g){if(c==null)throw new TypeError("Cannot convert undefined or null to object");const k=Object(c);for(let M=1;M<arguments.length;M++){const x=arguments[M];if(x!=null)for(const j in x)Object.prototype.hasOwnProperty.call(x,j)&&(k[j]=x[j])}return k},writable:!0,configurable:!0});const r=t.ref(null),u=t.ref(""),l=t.shallowRef(D),y=t.ref(b(b(b({},O),n.globalOptions),n.options)),f=t.getCurrentInstance(),h=n.name||((R=(F=f==null?void 0:f.parent)==null?void 0:F.type)==null?void 0:R.name)||void 0,d=t.ref(null),m=t.computed(()=>{var c;return n.merge?(c=t.unref(r))==null?void 0:c.editor():t.unref(r)}),{refresh:i,resize:p,destroy:_,containerHeight:$,reviseStyle:he}=fe({props:n,cminstance:r,presetRef:d}),{listenerEvents:ye}=ue({props:n,cminstance:r,emit:a,internalInstance:f,content:u}),V=()=>{n.unseenLines!==void 0&&n.marker!==void 0&&n.unseenLines.forEach(c=>{var k,M;const g=(k=r.value)==null?void 0:k.lineInfo(c);(M=r.value)==null||M.setGutterMarker(c,"breakpoints",(g==null?void 0:g.gutterMarkers)?null:n.marker())})},ke=c=>{var k,M;const g=(k=r.value)==null?void 0:k.getValue();c!==g&&((M=r.value)==null||M.setValue(c),u.value=c,he()),V()},we=()=>{ye(),V(),p(),a("ready",r.value),t.watch([()=>n.width,()=>n.height],([c,g])=>{p(c,g)},{deep:!0})},$e=()=>{if(n.options.mode==="fclog"||n.options.mode==="log"){l.value=ce;return}if(n.merge){l.value=Y;return}l.value=D};return t.watch(()=>n.options,c=>{var g;for(const k in n.options)(g=m.value)==null||g.setOption(k,t.unref(c[k]))},{deep:!0}),t.watch(()=>n.value,c=>{ke(c)}),t.watch(()=>n.placeholder,c=>{var g;(g=m.value)==null||g.setOption("placeholder",c)}),t.watch(()=>n.merge,c=>{$e()},{immediate:!0}),t.onBeforeUnmount(()=>{_()}),o({cminstance:r,resize:p,refresh:i,destroy:_}),(c,g)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["codemirror-container",{merge:c.$props.merge,bordered:c.$props.border||c.$props.merge&&!n.originalStyle,"width-auto":!c.$props.width||c.$props.width=="100%","height-auto":!c.$props.height||c.$props.height=="100%","original-style":n.originalStyle}]),style:t.normalizeStyle({height:t.unref($)+"px"})},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(l)),t.mergeProps({ref_key:"presetRef",ref:d,cminstance:r.value,"onUpdate:cminstance":g[0]||(g[0]=k=>r.value=k),style:{height:"100%"}},z(b(b({},c.$props),c.$attrs),{options:y.value,name:t.unref(h),content:u.value}),{onReady:we}),null,16,["cminstance"]))],6))}});var ve="";const me=(e,o)=>(o&&o.options&&(E.props.globalOptions.default=()=>o.options),e.component((o==null?void 0:o.componentName)||"Codemirror",E),e),pe=window.CodeMirror||C,ge=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 { | ||
position: relative; | ||
@@ -27,41 +27,41 @@ display: inline-block; | ||
} | ||
.CodeMirror-lines .CodeMirror-placeholder.CodeMirror-line-like { | ||
.codemirror-container .editor_custom_link { | ||
cursor: pointer; | ||
color: #1474f1; | ||
text-decoration: underline; | ||
} | ||
.codemirror-container .editor_custom_link:hover { | ||
color: #04b4fa; | ||
} | ||
.codemirror-container:not(.original-style) .CodeMirror-lines .CodeMirror-placeholder.CodeMirror-line-like { | ||
color: #666; | ||
} | ||
.CodeMirror, | ||
.CodeMirror-merge-pane { | ||
.codemirror-container:not(.original-style) .CodeMirror, | ||
.codemirror-container:not(.original-style) .CodeMirror-merge-pane { | ||
height: 100%; | ||
font-family: consolas !important; | ||
} | ||
.CodeMirror-merge, | ||
.CodeMirror-merge-right .CodeMirror { | ||
.codemirror-container:not(.original-style) .CodeMirror-merge, | ||
.codemirror-container:not(.original-style) .CodeMirror-merge-right .CodeMirror { | ||
height: 100%; | ||
border: none !important; | ||
} | ||
.editor_custom_link { | ||
cursor: pointer; | ||
color: #1474f1; | ||
text-decoration: underline; | ||
} | ||
.editor_custom_link:hover { | ||
color: #04b4fa; | ||
} | ||
.c-editor--log__error { | ||
.codemirror-container:not(.original-style) .c-editor--log__error { | ||
color: #bb0606; | ||
font-weight: bold; | ||
} | ||
.c-editor--log__info { | ||
.codemirror-container:not(.original-style) .c-editor--log__info { | ||
color: #333333; | ||
font-weight: bold; | ||
} | ||
.c-editor--log__warning { | ||
.codemirror-container:not(.original-style) .c-editor--log__warning { | ||
color: #ee9900; | ||
} | ||
.c-editor--log__success { | ||
.codemirror-container:not(.original-style) .c-editor--log__success { | ||
color: #669600; | ||
} | ||
.cm-header, | ||
.cm-strong { | ||
.codemirror-container:not(.original-style) .cm-header, | ||
.codemirror-container:not(.original-style) .cm-strong { | ||
font-weight: bold; | ||
} | ||
`),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"}); | ||
`),s.CodeMirror=pe,s.GlobalCmComponent=ge,s.VueCodemirror=E,s.createLinkMark=ee,s.createLog=ne,s.createLogMark=te,s.createTitle=re,s.default=E,s.getLinkMarks=A,s.getLocalTime=I,s.getLogMark=B,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module"}); |
@@ -1,2 +0,1 @@ | ||
import _CodeMirror from "codemirror"; | ||
import type { App } from "vue"; | ||
@@ -16,3 +15,3 @@ import type { EditorConfiguration, Editor } from "codemirror"; | ||
} | ||
declare const CodeMirror: typeof _CodeMirror; | ||
declare const CodeMirror: typeof import("codemirror"); | ||
/** | ||
@@ -19,0 +18,0 @@ * Use global components. |
@@ -44,2 +44,6 @@ import type { Ref, PropType } from "vue"; | ||
}; | ||
originalStyle: { | ||
type: PropType<boolean>; | ||
default: boolean; | ||
}; | ||
keepCursorInEnd: { | ||
@@ -75,2 +79,3 @@ type: PropType<boolean>; | ||
height: string | number | null; | ||
originalStyle: boolean; | ||
keepCursorInEnd: boolean; | ||
@@ -627,2 +632,3 @@ merge: boolean; | ||
height?: unknown; | ||
originalStyle?: unknown; | ||
keepCursorInEnd?: unknown; | ||
@@ -641,2 +647,3 @@ merge?: unknown; | ||
height: string | number | null; | ||
originalStyle: boolean; | ||
keepCursorInEnd: boolean; | ||
@@ -657,2 +664,3 @@ merge: boolean; | ||
height: string | number | null; | ||
originalStyle: boolean; | ||
keepCursorInEnd: boolean; | ||
@@ -659,0 +667,0 @@ merge: boolean; |
@@ -11,2 +11,3 @@ export interface MarkStates { | ||
} | ||
export declare type logErrorTypes = keyof typeof logErrorType; | ||
/** | ||
@@ -35,4 +36,6 @@ * Get Local time, format: HH:mm:ss | ||
* Create a controllable log output type. | ||
* @param { string } text - contents | ||
* @param { string } type - Log type: 'info' | 'warning' | 'error' | ||
*/ | ||
export declare function createLogMark(text?: string, type?: keyof typeof logErrorType): string; | ||
export declare function createLogMark(text?: string, type?: logErrorTypes): string; | ||
/** | ||
@@ -45,2 +48,4 @@ * Gets the text of the current tag and returns an array of nodes. | ||
* Create log text with time and type | ||
* @param { string } log - Log contents | ||
* @param { string } type - Log type: 'info' | 'warning' | 'error' | ||
* @example | ||
@@ -52,3 +57,3 @@ * | ||
*/ | ||
export declare function createLog(log: string, type?: logErrorType | string): string; | ||
export declare function createLog(log: string, type: logErrorTypes): string; | ||
/** | ||
@@ -55,0 +60,0 @@ * Create a custom format title. |
{ | ||
"name": "codemirror-editor-vue3", | ||
"description": "CodeMirror component for Vue3", | ||
"version": "2.0.6", | ||
"version": "2.1.0-beta", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
[![GitHub stars](https://img.shields.io/github/stars/RennCheung/codemirror-editor-vue3)](https://github.com/RennCheung/codemirror-editor-vue3/stargazers) | ||
[![npm downloads](https://img.shields.io/npm/dt/codemirror-editor-vue3)](https://github.com/RennCheung/codemirror-editor-vue3) | ||
[![GitHub issues](https://img.shields.io/github/issues/RennCheung/codemirror-editor-vue3)](https://github.com/RennCheung/codemirror-editor-vue3/issues) | ||
@@ -3,0 +4,0 @@ [![GitHub forks](https://img.shields.io/github/forks/RennCheung/codemirror-editor-vue3)](https://github.com/RennCheung/codemirror-editor-vue3/network) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1882
128
88782
3