2025-07-11 14:41:34 +02:00
|
|
|
import Vue, {
|
|
|
|
computed,
|
|
|
|
customRef,
|
|
|
|
defineAsyncComponent,
|
|
|
|
defineComponent,
|
|
|
|
effectScope,
|
|
|
|
getCurrentInstance,
|
|
|
|
getCurrentScope,
|
|
|
|
inject,
|
|
|
|
isProxy,
|
|
|
|
isReactive,
|
|
|
|
isReadonly,
|
|
|
|
isRef,
|
|
|
|
isShallow,
|
|
|
|
markRaw,
|
|
|
|
nextTick,
|
|
|
|
onActivated,
|
|
|
|
onBeforeMount,
|
|
|
|
onBeforeUnmount,
|
|
|
|
onBeforeUpdate,
|
|
|
|
onDeactivated,
|
|
|
|
onErrorCaptured,
|
|
|
|
onMounted,
|
|
|
|
onRenderTracked,
|
|
|
|
onRenderTriggered,
|
|
|
|
onScopeDispose,
|
|
|
|
onServerPrefetch,
|
|
|
|
onUnmounted,
|
|
|
|
onUpdated,
|
|
|
|
provide,
|
|
|
|
proxyRefs,
|
|
|
|
readonly,
|
|
|
|
ref,
|
|
|
|
shallowReactive,
|
|
|
|
shallowReadonly,
|
|
|
|
shallowRef,
|
|
|
|
toRaw,
|
|
|
|
toRef,
|
|
|
|
toRefs,
|
|
|
|
triggerRef,
|
|
|
|
unref,
|
|
|
|
useAttrs,
|
|
|
|
useCssModule,
|
|
|
|
useCssVars,
|
|
|
|
useListeners,
|
|
|
|
useSlots,
|
|
|
|
watch,
|
|
|
|
watchEffect,
|
|
|
|
watchPostEffect,
|
|
|
|
watchSyncEffect
|
|
|
|
} from "vue";
|
|
|
|
|
|
|
|
// Assign Vue to the global window object
|
|
|
|
window.Vue = Vue;
|
|
|
|
|
|
|
|
// Keep named exports on the Vue constructor (like UMD build in Kirby 4)
|
|
|
|
// TODO: Remove this when Panel plugins are loaded as ES modules (Kirby 6)
|
|
|
|
Object.assign(Vue, {
|
|
|
|
computed,
|
|
|
|
customRef,
|
|
|
|
defineAsyncComponent,
|
|
|
|
defineComponent,
|
|
|
|
effectScope,
|
|
|
|
getCurrentInstance,
|
|
|
|
getCurrentScope,
|
|
|
|
inject,
|
|
|
|
isProxy,
|
|
|
|
isReactive,
|
|
|
|
isReadonly,
|
|
|
|
isRef,
|
|
|
|
isShallow,
|
|
|
|
markRaw,
|
|
|
|
nextTick,
|
|
|
|
onActivated,
|
|
|
|
onBeforeMount,
|
|
|
|
onBeforeUnmount,
|
|
|
|
onBeforeUpdate,
|
|
|
|
onDeactivated,
|
|
|
|
onErrorCaptured,
|
|
|
|
onMounted,
|
|
|
|
onRenderTracked,
|
|
|
|
onRenderTriggered,
|
|
|
|
onScopeDispose,
|
|
|
|
onServerPrefetch,
|
|
|
|
onUnmounted,
|
|
|
|
onUpdated,
|
|
|
|
provide,
|
|
|
|
proxyRefs,
|
|
|
|
readonly,
|
|
|
|
ref,
|
|
|
|
shallowReactive,
|
|
|
|
shallowReadonly,
|
|
|
|
shallowRef,
|
|
|
|
toRaw,
|
|
|
|
toRef,
|
|
|
|
toRefs,
|
|
|
|
triggerRef,
|
|
|
|
unref,
|
|
|
|
useAttrs,
|
|
|
|
useCssModule,
|
|
|
|
useCssVars,
|
|
|
|
useListeners,
|
|
|
|
useSlots,
|
|
|
|
watch,
|
|
|
|
watchEffect,
|
|
|
|
watchPostEffect,
|
|
|
|
watchSyncEffect
|
|
|
|
});
|
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
window.panel = window.panel ?? {};
|
2022-06-17 17:51:59 +02:00
|
|
|
window.panel.plugins = {
|
2025-04-21 18:57:21 +02:00
|
|
|
components: {},
|
|
|
|
created: [],
|
|
|
|
icons: {},
|
|
|
|
routes: [],
|
|
|
|
textareaButtons: {},
|
|
|
|
thirdParty: {},
|
|
|
|
use: [],
|
2025-07-11 14:41:34 +02:00
|
|
|
viewButtons: {},
|
2025-04-21 18:57:21 +02:00
|
|
|
views: {},
|
|
|
|
writerMarks: {},
|
|
|
|
writerNodes: {}
|
2022-06-17 17:51:59 +02:00
|
|
|
};
|
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
window.panel.plugin = function (plugin, extensions) {
|
|
|
|
// Blocks
|
|
|
|
resolve(extensions, "blocks", (name, options) => {
|
|
|
|
if (typeof options === "string") {
|
|
|
|
options = { template: options };
|
|
|
|
}
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
window.panel.plugins.components[`k-block-type-${name}`] = {
|
|
|
|
extends: "k-block-type-default",
|
|
|
|
...options
|
|
|
|
};
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Components
|
|
|
|
resolve(extensions, "components", (name, options) => {
|
|
|
|
window.panel.plugins.components[name] = options;
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Fields
|
|
|
|
resolve(extensions, "fields", (name, options) => {
|
|
|
|
window.panel.plugins.components[`k-${name}-field`] = options;
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Icons
|
|
|
|
resolve(extensions, "icons", (name, options) => {
|
|
|
|
window.panel.plugins.icons[name] = options;
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Sections
|
|
|
|
resolve(extensions, "sections", (name, options) => {
|
|
|
|
window.panel.plugins.components[`k-${name}-section`] = {
|
|
|
|
...options,
|
|
|
|
mixins: ["section", ...(options.mixins ?? [])]
|
|
|
|
};
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-07-11 14:41:34 +02:00
|
|
|
// View Buttons
|
|
|
|
resolve(extensions, "viewButtons", (name, options) => {
|
|
|
|
window.panel.plugins.components[`k-${name}-view-button`] = options;
|
|
|
|
});
|
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// `Vue.use`
|
|
|
|
resolve(extensions, "use", (name, options) => {
|
|
|
|
window.panel.plugins.use.push(options);
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Vue `created` callback
|
|
|
|
if (extensions["created"]) {
|
|
|
|
window.panel.plugins.created.push(extensions["created"]);
|
|
|
|
}
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Login
|
|
|
|
if (extensions.login) {
|
|
|
|
window.panel.plugins.login = extensions.login;
|
|
|
|
}
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
// Textarea custom toolbar buttons
|
|
|
|
resolve(extensions, "textareaButtons", (name, options) => {
|
|
|
|
window.panel.plugins.textareaButtons[name] = options;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Third-party plugins
|
|
|
|
resolve(extensions, "thirdParty", (name, options) => {
|
|
|
|
window.panel.plugins.thirdParty[name] = options;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Writer custom marks
|
|
|
|
resolve(extensions, "writerMarks", (name, options) => {
|
|
|
|
window.panel.plugins.writerMarks[name] = options;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Writer custom nodes
|
|
|
|
resolve(extensions, "writerNodes", function (name, options) {
|
|
|
|
window.panel.plugins.writerNodes[name] = options;
|
|
|
|
});
|
2022-06-17 17:51:59 +02:00
|
|
|
};
|
|
|
|
|
2025-04-21 18:57:21 +02:00
|
|
|
const resolve = (extensions, type, callback) => {
|
|
|
|
for (const [name, options] of Object.entries(extensions[type] ?? {})) {
|
|
|
|
callback(name, options);
|
|
|
|
}
|
|
|
|
};
|