snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
122 lines (121 loc) • 3.68 kB
JavaScript
import { defineComponent as v, ref as s, onMounted as h, watch as V, nextTick as y, createElementBlock as b, openBlock as x, normalizeStyle as T, normalizeClass as N, createElementVNode as k, createVNode as C, unref as _ } from "vue";
/* empty css */
import B from "../../../../base-ui/src/components/icon/icon.vue.js";
import "radix-vue";
import "clsx";
import "tailwind-merge";
import "lucide-vue-next";
import "../../../../base-ui/src/shadch-ui/button/index.js";
import "@vueuse/core";
import "../../../../base-ui/src/shadch-ui/toast/index.js";
import "../../../../../hooks/src/store/index.js";
import { useTheme as O } from "../../../../../hooks/src/common/theme.js";
import "lodash";
import "../../../../../utils/src/manager/pluginManager.js";
import * as r from "monaco-editor";
import "../../../../../utils/src/request/index.js";
import "vuedraggable";
const S = `position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 2999;`, Q = /* @__PURE__ */ v({
__name: "index",
props: {
autoToggleTheme: { type: Boolean },
bordered: { type: Boolean },
config: { default: () => ({
minimap: {
enabled: !1
},
selectOnLineNumbers: !0
}) },
language: { default: "json" },
lineNumbers: { default: "on" },
modelValue: {},
readOnly: { type: Boolean, default: !1 },
theme: { default: "vs-light" },
valueFormat: { default: "string" }
},
emits: ["update:modelValue"],
setup(m, { expose: p, emit: c }) {
const l = m, i = c, o = s(!1), u = s(null);
let e = null;
const { isDark: a } = O();
function f() {
a.value ? r.editor.setTheme("vs-dark") : r.editor.setTheme("vs-light");
}
function d(n) {
e == null || e.setValue(n || "");
}
function g(n) {
const t = e == null ? void 0 : e.getPosition();
t && (e == null || e.executeEdits("", [
{
range: new r.Range(
t.lineNumber,
t.column,
t.lineNumber,
t.column
),
text: n
}
]), e == null || e.setPosition({
...t,
column: t.column + n.length
}), e == null || e.focus());
}
return h(() => {
e = r.editor.create(u.value, {
value: n(),
...l.config,
automaticLayout: !0,
language: l.language,
lineNumbers: l.lineNumbers,
readOnly: l.readOnly,
scrollBeyondLastLine: !1,
theme: l.theme
}), l.autoToggleTheme && V(
() => a.value,
() => {
y(() => f());
},
{
immediate: !0
}
);
function n() {
return l.valueFormat === "json" && l.modelValue ? JSON.stringify(l.modelValue, null, 2) : l.modelValue ?? "";
}
e.onDidChangeModelContent(() => {
const t = e == null ? void 0 : e.getValue();
if (l.valueFormat === "json" && t) {
i("update:modelValue", JSON.parse(t));
return;
}
i("update:modelValue", t ?? "");
});
}), p({
insertText: g,
setValue: d
}), (n, t) => (x(), b("div", {
ref_key: "editContainer",
ref: u,
class: N([{ bordered: l.bordered }, "epic-code-editor relative"]),
style: T(o.value ? S : "")
}, [
k("div", {
class: "z-999 text-$epic-text-helper absolute right-4 top-2 cursor-pointer text-xl",
onClick: t[0] || (t[0] = (z) => o.value = !o.value)
}, [
C(_(B), {
name: o.value ? "icon--epic--close-fullscreen" : "icon--epic--open-fullscreen"
}, null, 8, ["name"])
])
], 6));
}
});
export {
Q as default
};