@nextcloud/vue
Version:
Nextcloud vue components
67 lines (66 loc) • 1.89 kB
JavaScript
import { l as logger } from "./logger.mjs";
window._vue_richtext_widgets ??= {};
window._registerWidget ??= (id, callback, onDestroy, props) => {
registerWidget(id, callback, onDestroy, props);
};
function registerWidget(id, callback, onDestroy = () => {
}, props) {
const propsWithDefaults = {
hasInteractiveView: true,
fullWidth: false,
isResizable: false,
...props
};
if (window._vue_richtext_widgets[id]) {
logger.error(`[ReferencePicker]: Widget for id ${id} already registered`);
return;
}
window._vue_richtext_widgets[id] = {
id,
callback,
onDestroy,
...propsWithDefaults
};
}
function renderWidget(el, options) {
const { richObjectType, richObject, accessible, interactive } = options;
if (richObjectType === "open-graph") {
return;
}
if (!window._vue_richtext_widgets[richObjectType]) {
logger.error("Widget for rich object type " + richObjectType + " not registered");
return;
}
window._vue_richtext_widgets[richObjectType].callback(el, { richObjectType, richObject, accessible, interactive });
}
function destroyWidget(richObjectType, el) {
if (richObjectType === "open-graph") {
return;
}
if (!window._vue_richtext_widgets[richObjectType]) {
return;
}
window._vue_richtext_widgets[richObjectType].onDestroy(el);
}
function isWidgetRegistered(id) {
return !!window._vue_richtext_widgets[id];
}
function hasInteractiveView(id) {
return !!window._vue_richtext_widgets[id]?.hasInteractiveView;
}
function hasFullWidth(id) {
return !!window._vue_richtext_widgets[id]?.fullWidth;
}
function isResizable(id) {
return !!window._vue_richtext_widgets[id]?.isResizable;
}
export {
renderWidget as a,
hasFullWidth as b,
isResizable as c,
destroyWidget as d,
hasInteractiveView as h,
isWidgetRegistered as i,
registerWidget as r
};
//# sourceMappingURL=widgets.mjs.map