Skip to content

Commit 754f5d7

Browse files
committed
fix(copy paste): manage tags when paste all
1 parent acfec48 commit 754f5d7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

assets/js/app.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,26 @@ global.MonsieurBizRichEditorManager = class {
686686
pasteUiElementsFromClipboard() {
687687
const clipboard = window.localStorage.getItem('monsieurBizRichEditorElementsClipboard');
688688
if (clipboard !== null) {
689-
const pastedUiElement = JSON.parse(clipboard);
689+
const pastedUiElements = JSON.parse(clipboard);
690+
let allowed = true;
691+
pastedUiElements.forEach((pastedUiElement) => {
692+
let uiElementCode = pastedUiElement.code;
693+
if (!this.elementIsAllowed(this.tags, this.config.uielements[uiElementCode].tags, this.tagsAreExclusive)) {
694+
allowed = false;
695+
return;
696+
}
697+
});
698+
699+
// Show alert message if at least one element is not allowed
700+
if (!allowed) {
701+
alert(this.config.unallowedUiElementMessage);
702+
return;
703+
}
690704

691705
if (this.uiElements.length > 0) {
692-
this.loadUiConfirmationModal(() => { this.initUiElements(pastedUiElement, () => { this.write(); }) })
706+
this.loadUiConfirmationModal(() => { this.initUiElements(pastedUiElements, () => { this.write(); }) })
693707
} else {
694-
this.initUiElements(pastedUiElement, () => { this.write(); });
708+
this.initUiElements(pastedUiElements, () => { this.write(); });
695709
}
696710
}
697711
}

src/Resources/public/js/rich-editor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)