Skip to content

Commit

Permalink
OP-437 - CKEditor correction of an error for more than one textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkalon committed Aug 22, 2024
1 parent 3394bc3 commit cd46957
Showing 1 changed file with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ $(document).ready(function() {
$(element).autoComplete();
});

const ckeditorConfig = {
toolbar: [
["Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Undo", "Redo"],
["Scayt"], ["Link", "Unlink", "Anchor"],
["Image", "MediaVideo", "MediaImage", "Table", "HorizontalRule", "SpecialChar"],
["Maximize"], ["Source"], "/",
["Bold", "Italic", "Strike", "-", "RemoveFormat"],
["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote"],
["Styles", "Format", "About"]
],
enterMode: 3,
forcePasteAsPlainText: "allow-word",
allowedContent: true,
extraPlugins: ["mediaVideo", "mediaImage"],
removePlugins: ["exportpdf"],
filebrowserUploadUrl: "/admin/editor/upload-image",
bodyId: "bitbag-ckeditor",
language: "en-us"
};

let pageElements = '#bitbag_sylius_cms_plugin_page_contentElements';
let blockElements = '#bitbag_sylius_cms_plugin_block_contentElements';
let collectionHolder = $(pageElements).length ? pageElements : blockElements;
Expand Down Expand Up @@ -69,29 +89,15 @@ $(document).ready(function() {
$(element).attr('name', newConfigInputName);
$(newConfig).find('.bitbag-media-autocomplete').autoComplete();
$(newConfig).find('.sylius-autocomplete').autoComplete();
});

if (this.value === 'textarea') {
CKEDITOR.replace("configuration_textarea", {
"toolbar":[
["Cut","Copy","Paste","PasteText","PasteFromWord","-","Undo","Redo"],
["Scayt"],["Link","Unlink","Anchor"],
["Image","MediaVideo","MediaImage","Table","HorizontalRule","SpecialChar"],
["Maximize"],["Source"],"\/",["Bold","Italic","Strike","-","RemoveFormat"],
["NumberedList","BulletedList","-","Outdent","Indent","-","Blockquote"],
["Styles","Format","About"]],
"enterMode":3,
"forcePasteAsPlainText":"allow-word",
"allowedContent":true,
"extraPlugins":[
"mediaVideo","mediaImage"
],
"removePlugins":[
"exportpdf"
],
"filebrowserUploadUrl":"\/admin\/editor\/upload-image","bodyId":"bitbag-ckeditor","language":"en-us"
});
}
if (this.value === 'textarea') {
const index = target.getAttribute('data-form-collection-index');
const textareaId = `${collectionHolder}_${index}_configuration_textarea`;

element.id = textareaId;
CKEDITOR.replace(textareaId, ckeditorConfig);
}
});
}
}
});
Expand Down

0 comments on commit cd46957

Please sign in to comment.