feat: add labels and blockquotes to clear format (#261)
This commit is contained in:
@@ -73,6 +73,7 @@ export const setupCustomBehavior = ({
|
||||
openSourceCodeModal,
|
||||
setImage,
|
||||
editorType,
|
||||
imageUrls,
|
||||
}) => (editor) => {
|
||||
// image upload button
|
||||
editor.ui.registry.addButton(tinyMCE.buttons.imageUploadButton, {
|
||||
@@ -129,13 +130,14 @@ export const setupCustomBehavior = ({
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const checkRelativeUrl = (imageUrls) => (editor) => {
|
||||
editor.on('ExecCommand', (e) => {
|
||||
if (e.command === 'mceFocus') {
|
||||
module.replaceStaticwithAsset(editor, imageUrls);
|
||||
}
|
||||
if (e.command === 'RemoveFormat') {
|
||||
editor.formatter.remove('blockquote');
|
||||
editor.formatter.remove('label');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -180,7 +182,6 @@ export const editorConfig = ({
|
||||
min_height: minHeight,
|
||||
contextmenu: 'link table',
|
||||
document_base_url: lmsEndpointUrl,
|
||||
init_instance_callback: module.checkRelativeUrl(module.fetchImageUrls(images)),
|
||||
imagetools_cors_hosts: [removeProtocolFromUrl(lmsEndpointUrl), removeProtocolFromUrl(studioEndpointUrl)],
|
||||
imagetools_toolbar: imageToolbar,
|
||||
formats: { label: { inline: 'label' } },
|
||||
@@ -190,6 +191,7 @@ export const editorConfig = ({
|
||||
openImgModal,
|
||||
openSourceCodeModal,
|
||||
setImage: setSelection,
|
||||
imageUrls: module.fetchImageUrls(images),
|
||||
}),
|
||||
toolbar,
|
||||
plugins,
|
||||
|
||||
@@ -120,14 +120,6 @@ describe('TinyMceEditor hooks', () => {
|
||||
expect(content).toEqual('<img src="/static/soME_ImagE_URl1"/> <a href="/static/soMEImagEURl">testing link</a>');
|
||||
});
|
||||
});
|
||||
describe('checkRelativeUrl', () => {
|
||||
test('it calls editor.on', () => {
|
||||
const editor = { on: jest.fn() };
|
||||
const imageUrls = ['soMEImagEURl1'];
|
||||
module.checkRelativeUrl(imageUrls)(editor);
|
||||
expect(editor.on).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('editorConfig', () => {
|
||||
const props = {
|
||||
@@ -211,10 +203,6 @@ describe('TinyMceEditor hooks', () => {
|
||||
expect(output.initialValue).toBe(textValue);
|
||||
});
|
||||
|
||||
// test('It configures plugins and toolbars correctly', () => {
|
||||
// expect(output.init.plugins).toEqual('autoresize');
|
||||
// expect(output.init.toolbar).toEqual(`${pluginConfig().toolbar} | customLabelButton`);
|
||||
// });
|
||||
it('calls setupCustomBehavior on setup', () => {
|
||||
expect(output.init.setup).toEqual(
|
||||
setupCustomBehavior({
|
||||
@@ -223,6 +211,7 @@ describe('TinyMceEditor hooks', () => {
|
||||
openImgModal: props.openImgModal,
|
||||
openSourceCodeModal: props.openSourceCodeModal,
|
||||
setImage: props.setSelection,
|
||||
imageUrls: module.fetchImageUrls(props.images),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user