codemirror-editor-vue3
Advanced tools
Comparing version
@@ -1,4 +0,4 @@ | ||
import { defineComponent as S, ref as y, onMounted as L, markRaw as T, watch as x, unref as v, openBlock as b, createElementBlock as E, computed as I, nextTick as G, shallowRef as Z, getCurrentInstance as q, onBeforeUnmount as K, normalizeClass as Q, normalizeStyle as X, createBlock as Y, resolveDynamicComponent as ee, mergeProps as te } from "vue"; | ||
import { defineComponent as M, ref as y, onMounted as j, markRaw as L, watch as x, unref as v, openBlock as b, createElementBlock as S, computed as T, nextTick as G, shallowRef as Z, getCurrentInstance as q, onBeforeUnmount as K, normalizeClass as Q, normalizeStyle as X, createBlock as Y, resolveDynamicComponent as ee, mergeProps as te } from "vue"; | ||
import "codemirror/lib/codemirror.css"; | ||
import R from "codemirror"; | ||
import H from "codemirror"; | ||
import "codemirror/addon/merge/merge.css"; | ||
@@ -8,4 +8,4 @@ import "codemirror/addon/merge/merge.js"; | ||
import "codemirror/addon/mode/simple.js"; | ||
!window.CodeMirror && (window.CodeMirror = R); | ||
const _ = window.CodeMirror || R, oe = S({ | ||
!window.CodeMirror && (window.CodeMirror = H); | ||
const _ = window.CodeMirror || H, oe = M({ | ||
name: "DefaultMode", | ||
@@ -44,3 +44,3 @@ props: { | ||
const r = y(), t = y(null), n = () => { | ||
t.value = T( | ||
t.value = L( | ||
_.fromTextArea(r.value, e.options) | ||
@@ -50,5 +50,5 @@ ), o("update:cminstance", t.value); | ||
() => e.cminstance, | ||
(s) => { | ||
(a) => { | ||
var f; | ||
s && ((f = e.cminstance) == null || f.setValue(e.value || e.content)), o("ready", v(t)), i == null || i(); | ||
a && ((f = e.cminstance) == null || f.setValue(e.value || e.content)), o("ready", v(t)), i == null || i(); | ||
}, | ||
@@ -58,3 +58,3 @@ { deep: !0 } | ||
}; | ||
return L(() => { | ||
return j(() => { | ||
n(); | ||
@@ -66,3 +66,3 @@ }), { | ||
} | ||
}), A = (e, o) => { | ||
}), I = (e, o) => { | ||
const r = e.__vccOpts || e; | ||
@@ -74,3 +74,3 @@ for (const [t, n] of o) | ||
function ae(e, o, r, t, n, i) { | ||
return b(), E("textarea", { | ||
return b(), S("textarea", { | ||
ref: "textarea", | ||
@@ -81,3 +81,3 @@ name: e.$props.name, | ||
} | ||
const F = /* @__PURE__ */ A(oe, [["render", ae]]); | ||
const V = /* @__PURE__ */ I(oe, [["render", ae]]); | ||
window.diff_match_patch = ne; | ||
@@ -87,3 +87,3 @@ window.DIFF_DELETE = -1; | ||
window.DIFF_EQUAL = 0; | ||
const se = S({ | ||
const se = M({ | ||
name: "MergeMode", | ||
@@ -103,7 +103,7 @@ props: { | ||
const r = y(), t = y(), n = () => { | ||
r.value = T( | ||
r.value = L( | ||
_.MergeView(t.value, e.options) | ||
), o("update:cminstance", r.value), o("ready", r); | ||
}; | ||
return L(() => { | ||
return j(() => { | ||
n(); | ||
@@ -117,5 +117,5 @@ }), { | ||
function ce(e, o, r, t, n, i) { | ||
return b(), E("div", le, null, 512); | ||
return b(), S("div", le, null, 512); | ||
} | ||
const ie = /* @__PURE__ */ A(se, [["render", ce]]); | ||
const ie = /* @__PURE__ */ I(se, [["render", ce]]); | ||
var ue = /* @__PURE__ */ ((e) => (e.info = "info", e.warning = "warning", e.error = "error", e))(ue || {}); | ||
@@ -126,3 +126,3 @@ function de() { | ||
} | ||
function Te(e) { | ||
function Le(e) { | ||
return `#link#${JSON.stringify(e)}#link#`; | ||
@@ -134,4 +134,4 @@ } | ||
for (t = o.exec(e); t; ) { | ||
const n = document.createElement("a"), i = JSON.parse(t[1]), s = Object.entries(i); | ||
for (const [f, u] of s) | ||
const n = document.createElement("a"), i = JSON.parse(t[1]), a = Object.entries(i); | ||
for (const [f, u] of a) | ||
n.setAttribute(f, u); | ||
@@ -146,3 +146,3 @@ n.className = "editor_custom_link", n.innerHTML = "logDownload", r.push({ | ||
} | ||
function Ie(e = "", o = "info") { | ||
function Te(e = "", o = "info") { | ||
return `#log<${o}>log#${e}#log<${o}>log#`; | ||
@@ -156,3 +156,3 @@ } | ||
for (n = t.exec(e); n; ) { | ||
const s = n[0].replace(/\r\n/g, ` | ||
const a = n[0].replace(/\r\n/g, ` | ||
`).split(` | ||
@@ -164,5 +164,5 @@ `), u = n[2].replace(/\r\n/g, ` | ||
let d = 0; | ||
for (let l = 0; l < s.length; l++) { | ||
const p = s[l], k = u[l], w = m.cloneNode(!1); | ||
w.innerText = k, o.push({ | ||
for (let l = 0; l < a.length; l++) { | ||
const p = a[l], $ = u[l], w = m.cloneNode(!1); | ||
w.innerText = $, o.push({ | ||
start: n.index + d, | ||
@@ -178,3 +178,3 @@ end: n.index + d + p.length, | ||
} | ||
function Ae(e, o) { | ||
function Ie(e, o) { | ||
return `[${de()}] <${o}> ${e}`; | ||
@@ -186,3 +186,3 @@ } | ||
} | ||
const M = [ | ||
const C = [ | ||
{ | ||
@@ -209,3 +209,3 @@ regex: /(\[.*?\])([ \t]*)(<error>[ \t])(.+)/, | ||
start: [ | ||
...M, | ||
...C, | ||
{ | ||
@@ -217,3 +217,3 @@ regex: /.*/, | ||
error: [ | ||
...M, | ||
...C, | ||
{ | ||
@@ -225,3 +225,3 @@ regex: /.*/, | ||
info: [ | ||
...M, | ||
...C, | ||
{ | ||
@@ -233,3 +233,3 @@ regex: /.*/, | ||
warning: [ | ||
...M, | ||
...C, | ||
{ | ||
@@ -265,3 +265,3 @@ regex: /.*\[/, | ||
}); | ||
const me = S({ | ||
const me = M({ | ||
name: "CodemirrorFclog", | ||
@@ -292,10 +292,10 @@ props: { | ||
setup(e, { emit: o }) { | ||
const r = y(), t = y(null), n = (s = e.cminstance) => { | ||
s.getAllMarks().forEach((c) => c.clear()); | ||
const u = s.getValue(), m = [].concat(pe(u)).concat(ge(u)); | ||
const r = y(), t = y(null), n = (a = e.cminstance) => { | ||
a.getAllMarks().forEach((c) => c.clear()); | ||
const u = a.getValue(), m = [].concat(pe(u)).concat(ge(u)); | ||
for (let c = 0; c < m.length; c++) { | ||
const d = m[c]; | ||
s.markText( | ||
s.posFromIndex(d.start), | ||
s.posFromIndex(d.end), | ||
a.markText( | ||
a.posFromIndex(d.start), | ||
a.posFromIndex(d.end), | ||
{ replacedWith: d.node } | ||
@@ -305,15 +305,15 @@ ); | ||
}, i = () => { | ||
var s; | ||
t.value = T( | ||
var a; | ||
t.value = L( | ||
_.fromTextArea(r.value, e.options) | ||
), o("update:cminstance", v(t)), (s = t.value) == null || s.on("change", n); | ||
), o("update:cminstance", v(t)), (a = t.value) == null || a.on("change", n); | ||
}; | ||
return x( | ||
() => e.cminstance, | ||
(s) => { | ||
(a) => { | ||
var f; | ||
s && (n(e.cminstance), (f = e.cminstance) == null || f.setValue(e.value), o("ready", t)); | ||
a && (n(e.cminstance), (f = e.cminstance) == null || f.setValue(e.value), o("ready", t)); | ||
}, | ||
{ deep: !0, immediate: !0 } | ||
), L(() => { | ||
), j(() => { | ||
i(); | ||
@@ -327,3 +327,3 @@ }), { | ||
function he(e, o, r, t, n, i) { | ||
return b(), E("textarea", { | ||
return b(), S("textarea", { | ||
ref: "textarea", | ||
@@ -334,3 +334,3 @@ name: e.$props.name, | ||
} | ||
const ve = /* @__PURE__ */ A(me, [["render", he]]), z = { | ||
const ve = /* @__PURE__ */ I(me, [["render", he]]), R = { | ||
"update:value": () => !0, | ||
@@ -364,3 +364,3 @@ change: (e, o) => ({ value: e, cm: o }), | ||
}), e; | ||
}, ke = { ...z, ...we() }, j = { | ||
}, ke = { ...R, ...we() }, O = { | ||
mode: "text", | ||
@@ -389,3 +389,3 @@ // Language mode | ||
}) => { | ||
const i = I( | ||
const i = T( | ||
() => { | ||
@@ -395,3 +395,3 @@ var u; | ||
} | ||
), s = () => { | ||
), a = () => { | ||
const u = []; | ||
@@ -401,3 +401,3 @@ return Object.keys(t == null ? void 0 : t.vnode.props).forEach((m) => { | ||
const c = m.replace(m[2], m[2].toLowerCase()).slice(2); | ||
!z[c] && u.push(c); | ||
!R[c] && u.push(c); | ||
} | ||
@@ -415,3 +415,3 @@ }), u; | ||
const u = {}; | ||
s().filter((c) => !u[c] && (u[c] = !0)).forEach((c) => { | ||
a().filter((c) => !u[c] && (u[c] = !0)).forEach((c) => { | ||
i.value.on(c, (...d) => { | ||
@@ -429,3 +429,3 @@ r(c, ...d); | ||
}) { | ||
const t = y(null), n = y(null), i = I( | ||
const t = y(null), n = y(null), i = T( | ||
() => { | ||
@@ -435,3 +435,3 @@ var l; | ||
} | ||
), s = () => { | ||
), a = () => { | ||
G(() => { | ||
@@ -444,4 +444,4 @@ var l; | ||
t.value = String(l).replace("px", ""), n.value = String(p).replace("px", ""); | ||
const k = n.value; | ||
(w = i.value) == null || w.setSize(t.value, k); | ||
const $ = n.value; | ||
(w = i.value) == null || w.setSize(t.value, $); | ||
}, u = () => { | ||
@@ -452,5 +452,5 @@ var p; | ||
}, m = () => { | ||
var p, k, w; | ||
var p, $, w; | ||
const l = (p = i.value) == null ? void 0 : p.getDoc().getHistory(); | ||
(k = r.value) == null || k.initialize(), u(), (w = i.value) == null || w.getDoc().setHistory(l); | ||
($ = r.value) == null || $.initialize(), u(), (w = i.value) == null || w.getDoc().setHistory(l); | ||
}, c = () => { | ||
@@ -464,3 +464,3 @@ const l = document.querySelector( | ||
reload: m, | ||
refresh: s, | ||
refresh: a, | ||
resize: f, | ||
@@ -470,6 +470,6 @@ destroy: u, | ||
reviseStyle: () => { | ||
if (s(), !c()) | ||
if (a(), !c()) | ||
return; | ||
const l = setInterval(() => { | ||
c() ? s() : clearInterval(l); | ||
c() ? a() : clearInterval(l); | ||
}, 60), p = setTimeout(() => { | ||
@@ -481,3 +481,3 @@ clearInterval(l), clearTimeout(p); | ||
} | ||
const H = /* @__PURE__ */ S({ | ||
const F = /* @__PURE__ */ M({ | ||
__name: "index", | ||
@@ -491,7 +491,7 @@ props: { | ||
type: Object, | ||
default: () => j | ||
default: () => O | ||
}, | ||
globalOptions: { | ||
type: Object, | ||
default: () => j | ||
default: () => O | ||
}, | ||
@@ -541,16 +541,16 @@ placeholder: { | ||
setup(e, { expose: o, emit: r }) { | ||
var N, V; | ||
var N, A; | ||
const t = e; | ||
typeof Object.assign != "function" && Object.defineProperty(Object, "assign", { | ||
value(a, g) { | ||
if (a == null) | ||
value(s) { | ||
if (s == null) | ||
throw new TypeError("Cannot convert undefined or null to object"); | ||
const h = Object(a); | ||
for (let $ = 1; $ < arguments.length; $++) { | ||
const C = arguments[$]; | ||
if (C != null) | ||
for (const O in C) | ||
Object.prototype.hasOwnProperty.call(C, O) && (h[O] = C[O]); | ||
const g = Object(s); | ||
for (let h = 1; h < arguments.length; h++) { | ||
const k = arguments[h]; | ||
if (k != null) | ||
for (const E in k) | ||
Object.prototype.hasOwnProperty.call(k, E) && (g[E] = k[E]); | ||
} | ||
return h; | ||
return g; | ||
}, | ||
@@ -560,12 +560,12 @@ writable: !0, | ||
}); | ||
const n = y(null), i = y(""), s = Z(F), f = y({ | ||
...j, | ||
const n = y(null), i = y(""), a = Z(V), f = y({ | ||
...O, | ||
...t.globalOptions, | ||
...t.options | ||
}), u = q(), m = t.name || ((V = (N = u == null ? void 0 : u.parent) == null ? void 0 : N.type) == null ? void 0 : V.name) || void 0, c = y(null), d = I( | ||
}), u = q(), m = t.name || ((A = (N = u == null ? void 0 : u.parent) == null ? void 0 : N.type) == null ? void 0 : A.name) || void 0, c = y(null), d = T( | ||
() => { | ||
var a; | ||
return t.merge ? (a = v(n)) == null ? void 0 : a.editor() : v(n); | ||
var s; | ||
return t.merge ? (s = v(n)) == null ? void 0 : s.editor() : v(n); | ||
} | ||
), { refresh: l, resize: p, destroy: k, containerHeight: w, reviseStyle: B } = _e({ | ||
), { refresh: l, resize: p, destroy: $, containerHeight: w, reviseStyle: B } = _e({ | ||
props: t, | ||
@@ -581,7 +581,7 @@ cminstance: n, | ||
}), D = () => { | ||
t.unseenLines !== void 0 && t.marker !== void 0 && t.unseenLines.forEach((a) => { | ||
var h, $; | ||
const g = (h = n.value) == null ? void 0 : h.lineInfo(a); | ||
($ = n.value) == null || $.setGutterMarker( | ||
a, | ||
t.unseenLines !== void 0 && t.marker !== void 0 && t.unseenLines.forEach((s) => { | ||
var h, k; | ||
const g = (h = n.value) == null ? void 0 : h.lineInfo(s); | ||
(k = n.value) == null || k.setGutterMarker( | ||
s, | ||
"breakpoints", | ||
@@ -591,11 +591,11 @@ g != null && g.gutterMarkers ? null : t.marker() | ||
}); | ||
}, U = (a) => { | ||
var h, $; | ||
}, U = (s) => { | ||
var h, k; | ||
const g = (h = n.value) == null ? void 0 : h.getValue(); | ||
a !== g && (($ = n.value) == null || $.setValue(a), i.value = a, B()), D(); | ||
s !== g && ((k = n.value) == null || k.setValue(s), i.value = s, B()), D(); | ||
}, W = () => { | ||
P(), D(), p(t.width, t.height), r("ready", n.value), x( | ||
[() => t.width, () => t.height], | ||
([a, g]) => { | ||
p(a, g); | ||
([s, g]) => { | ||
p(s, g); | ||
}, | ||
@@ -606,14 +606,14 @@ { deep: !0 } | ||
if (t.options.mode === "fclog" || t.options.mode === "log") { | ||
s.value = ve; | ||
a.value = ve; | ||
return; | ||
} | ||
if (t.merge) { | ||
s.value = ie; | ||
a.value = ie; | ||
return; | ||
} | ||
s.value = F; | ||
a.value = V; | ||
}; | ||
return x( | ||
() => t.options, | ||
(a) => { | ||
(s) => { | ||
var g; | ||
@@ -623,3 +623,3 @@ for (const h in t.options) | ||
h, | ||
v(a[h]) | ||
v(s[h]) | ||
); | ||
@@ -630,19 +630,7 @@ }, | ||
() => t.value, | ||
(a) => { | ||
U(a); | ||
(s) => { | ||
U(s); | ||
} | ||
), x( | ||
() => t.placeholder, | ||
(a) => { | ||
var g; | ||
(g = d.value) == null || g.setOption("placeholder", a); | ||
} | ||
), x( | ||
() => t.merge, | ||
(a) => { | ||
J(); | ||
}, | ||
{ immediate: !0 } | ||
), K(() => { | ||
k(); | ||
), x(() => t.merge, J, { immediate: !0 }), K(() => { | ||
$(); | ||
}), o({ | ||
@@ -652,9 +640,9 @@ cminstance: n, | ||
refresh: l, | ||
destroy: k | ||
}), (a, g) => (b(), E("div", { | ||
destroy: $ | ||
}), (s, g) => (b(), S("div", { | ||
class: Q(["codemirror-container", { | ||
merge: a.$props.merge, | ||
bordered: a.$props.border || a.$props.merge && !t.originalStyle, | ||
"width-auto": !a.$props.width || a.$props.width == "100%", | ||
"height-auto": !a.$props.height || a.$props.height == "100%", | ||
merge: s.$props.merge, | ||
bordered: s.$props.border || s.$props.merge && !t.originalStyle, | ||
"width-auto": !s.$props.width || s.$props.width == "100%", | ||
"height-auto": !s.$props.height || s.$props.height == "100%", | ||
"original-style": t.originalStyle | ||
@@ -666,3 +654,3 @@ }]), | ||
}, [ | ||
(b(), Y(ee(v(s)), te({ | ||
(b(), Y(ee(v(a)), te({ | ||
ref_key: "presetRef", | ||
@@ -674,4 +662,4 @@ ref: c, | ||
}, { | ||
...a.$props, | ||
...a.$attrs, | ||
...s.$props, | ||
...s.$attrs, | ||
options: f.value, | ||
@@ -684,3 +672,3 @@ name: v(m), | ||
}); | ||
const be = (e, o) => (o && o.options && (H.props.globalOptions.default = () => o.options), e.component((o == null ? void 0 : o.componentName) || "Codemirror", H), e), Ne = window.CodeMirror || _, Ve = be; | ||
const z = (e, o) => (o && o.options && (F.props.globalOptions.default = () => o.options), e.component((o == null ? void 0 : o.componentName) || "Codemirror", F), e), Ne = window.CodeMirror || _, Ae = z, Ve = z; | ||
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 { | ||
@@ -750,9 +738,10 @@ position: relative; | ||
Ne as CodeMirror, | ||
Ve as GlobalCmComponent, | ||
H as VueCodemirror, | ||
Te as createLinkMark, | ||
Ae as createLog, | ||
Ie as createLogMark, | ||
Ae as GlobalCmComponent, | ||
Ve as InstallCodemirro, | ||
F as VueCodemirror, | ||
Le as createLinkMark, | ||
Ie as createLog, | ||
Te as createLogMark, | ||
De as createTitle, | ||
H as default, | ||
F as default, | ||
pe as getLinkMarks, | ||
@@ -759,0 +748,0 @@ de as getLocalTime, |
@@ -21,7 +21,8 @@ import type { App } from "vue"; | ||
* const app = createApp(App); | ||
* app.use(GlobalCmComponent, { componentName: "customCodemirrorComponentName" }); | ||
* app.use(InstallCodemirro, { componentName: "customCodemirrorComponentName" }); | ||
*/ | ||
declare const GlobalCmComponent: (app: App, config?: InstallConfig) => App<any>; | ||
declare const InstallCodemirro: (app: App, config?: InstallConfig) => App<any>; | ||
export * from "./src/components/presetMode/log/utils"; | ||
export { CodeMirror, GlobalCmComponent, VueCodemirror }; | ||
export { CodeMirror, GlobalCmComponent, InstallCodemirro, VueCodemirror }; | ||
export default VueCodemirror; |
@@ -1,2 +0,2 @@ | ||
import { EditorConfiguration } from "codemirror"; | ||
import type { EditorConfiguration } from "codemirror"; | ||
export declare interface CmProps { | ||
@@ -3,0 +3,0 @@ value: string; |
{ | ||
"name": "codemirror-editor-vue3", | ||
"description": "CodeMirror component for Vue3", | ||
"version": "2.3.0-beta1", | ||
"version": "2.3.0-beta2", | ||
"license": "MIT", | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"type": "module", | ||
@@ -46,4 +48,4 @@ "types": "./dist/packages/index.d.ts", | ||
"build:types": "tsc --emitDeclarationOnly vite build", | ||
"publish-pkg": "vite build && git push && git push --tags && npm publish && npm run deploy-docs", | ||
"publish-beta": "vite build && npm publish --tag=beta", | ||
"publish-pkg": "npm run release && vite build && git push && git push --tags && npm publish && npm run deploy-docs", | ||
"publish-beta": "npm run release && vite build && npm publish --tag=beta", | ||
"docs-dev": "vitepress dev docs --open", | ||
@@ -54,3 +56,4 @@ "docs-build": "vitepress build docs", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
"release": "node scripts/release.js", | ||
"release": "node scripts/release.cjs", | ||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", | ||
"tsc": "tsc" | ||
@@ -63,4 +66,4 @@ }, | ||
"peerDependencies": { | ||
"vue": "3.x", | ||
"codemirror": "5.x", | ||
"vue": "^3.x", | ||
"codemirror": "^5.x", | ||
"diff-match-patch": "^1.0.5" | ||
@@ -67,0 +70,0 @@ }, |
@@ -19,11 +19,11 @@ [](https://github.com/RennCheung/codemirror-editor-vue3/stargazers) | ||
```bash | ||
npm install codemirror-editor-vue3 codemirror@5.6.0 -S | ||
npm install codemirror-editor-vue3 codemirror@5.x -S | ||
``` | ||
```bash | ||
yarn add codemirror-editor-vue3 codemirror@5.6.0 | ||
yarn add codemirror-editor-vue3 codemirror@5.x | ||
``` | ||
```bash | ||
pnpm i codemirror-editor-vue3 codemirror@5.6.0 -S | ||
pnpm i codemirror-editor-vue3 codemirror@^5.65.12 -S | ||
``` | ||
@@ -34,3 +34,3 @@ | ||
```bash | ||
npm install @types/codemirror@5.60.5 -D | ||
npm install @types/codemirror -D | ||
``` | ||
@@ -47,6 +47,6 @@ | ||
import App from "./App.vue"; | ||
import { GlobalCmComponent } from "codemirror-editor-vue3"; | ||
import { InstallCodemirro } from "codemirror-editor-vue3"; | ||
const app = createApp(App); | ||
app.use(GlobalCmComponent); | ||
app.use(InstallCodemirro); | ||
app.mount("#app"); | ||
@@ -58,3 +58,3 @@ ``` | ||
```js | ||
app.use(GlobalCmComponent, { componentName: "customName" }); | ||
app.use(InstallCodemirro, { componentName: "customName" }); | ||
``` | ||
@@ -61,0 +61,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
83062
7.37%19
5.56%1624
-0.61%1
Infinity%