adsasd
This commit is contained in:
@@ -319,6 +319,8 @@
|
||||
|
||||
const modal = editor.Modal;
|
||||
if (!modal) return;
|
||||
if (editor.__bridgeRteModalOpen) return;
|
||||
editor.__bridgeRteModalOpen = true;
|
||||
|
||||
const doc = document;
|
||||
const container = doc.createElement('div');
|
||||
@@ -498,10 +500,14 @@
|
||||
if (component.set) {
|
||||
component.set('content', html);
|
||||
component.trigger && component.trigger('change:content');
|
||||
component.trigger && component.trigger('change:components');
|
||||
}
|
||||
if (component.view && component.view.render) {
|
||||
component.view.render();
|
||||
}
|
||||
if (editor && typeof editor.trigger === 'function') {
|
||||
editor.trigger('component:update', component);
|
||||
}
|
||||
} catch {}
|
||||
modal.close();
|
||||
});
|
||||
@@ -512,6 +518,16 @@
|
||||
|
||||
modal.setTitle('Richtext Editor');
|
||||
modal.setContent(container);
|
||||
const mdl = modal.getModel && modal.getModel();
|
||||
if (mdl && typeof mdl.set === 'function') {
|
||||
mdl.set('closeOnEsc', false);
|
||||
mdl.set('closeOnClick', false);
|
||||
}
|
||||
if (typeof modal.onceClose === 'function') {
|
||||
modal.onceClose(() => {
|
||||
editor.__bridgeRteModalOpen = false;
|
||||
});
|
||||
}
|
||||
modal.open();
|
||||
};
|
||||
|
||||
@@ -581,7 +597,7 @@
|
||||
});
|
||||
if (!(rte.get && rte.get('bridge-open-richtext'))) {
|
||||
rte.add('bridge-open-richtext', {
|
||||
icon: 'RTE',
|
||||
icon: '<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M4 20h4l10-10-4-4L4 16v4zm14.7-11.3c.4-.4.4-1 0-1.4l-2-2c-.4-.4-1-.4-1.4 0l-1.3 1.3 4 4 1.7-1.9z" fill="currentColor"/></svg>',
|
||||
attributes: { title: 'Richtext Editor' },
|
||||
result: () => {
|
||||
const component = editor.getSelected && editor.getSelected();
|
||||
@@ -614,13 +630,33 @@
|
||||
'bridge-placeholder',
|
||||
]);
|
||||
|
||||
editor.on('component:selected', (model) => ensureTextToolbarButton(editor, model));
|
||||
let lastTextSelection = { id: null, ts: 0 };
|
||||
editor.on('component:selected', (model) => {
|
||||
ensureTextToolbarButton(editor, model);
|
||||
if (!model || !model.is || !model.is('text')) return;
|
||||
const now = Date.now();
|
||||
if (lastTextSelection.id === model.cid && (now - lastTextSelection.ts) < 450) {
|
||||
openRichTextModal(editor, model);
|
||||
}
|
||||
lastTextSelection = { id: model.cid, ts: now };
|
||||
});
|
||||
editor.on('component:add', (model) => ensureTextToolbarButton(editor, model));
|
||||
editor.on('component:dblclick', (model) => {
|
||||
if (model && model.is && model.is('text')) {
|
||||
openRichTextModal(editor, model);
|
||||
}
|
||||
});
|
||||
editor.on('canvas:frame:load', () => {
|
||||
const body = editor.Canvas && editor.Canvas.getBody && editor.Canvas.getBody();
|
||||
if (!body || body.__bridgeRteDblclickBound) return;
|
||||
body.__bridgeRteDblclickBound = true;
|
||||
body.addEventListener('dblclick', () => {
|
||||
const selected = editor.getSelected && editor.getSelected();
|
||||
if (selected && selected.is && selected.is('text')) {
|
||||
openRichTextModal(editor, selected);
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
};
|
||||
|
||||
const loadDynamicFonts = async () => {
|
||||
|
||||
Reference in New Issue
Block a user