Add support for copying and pasting of "strong" and "em" HTML elements

This commit is contained in:
Ahmed Alaghbari 2022-11-02 00:42:59 +08:00
parent cd06bfc9c5
commit ff1da53d51
3 changed files with 40 additions and 7 deletions

View file

@ -23,13 +23,14 @@ export default class BoldInlineTool implements InlineTool {
/**
* Sanitizer Rule
* Leave <b> tags
* Leave <b> and <strong> tags
*
* @returns {object}
*/
public static get sanitize(): SanitizerConfig {
return {
b: {},
strong: {},
} as SanitizerConfig;
}

View file

@ -23,13 +23,14 @@ export default class ItalicInlineTool implements InlineTool {
/**
* Sanitizer Rule
* Leave <i> tags
* Leave <i> and <em> tags
*
* @returns {object}
*/
public static get sanitize(): SanitizerConfig {
return {
i: {},
em: {},
} as SanitizerConfig;
}

View file

@ -9,20 +9,51 @@ describe('Output sanitisation', () => {
});
context('Output should save inline formatting', () => {
it('should save initial formatting for paragraph', () => {
it('should save initial bold formatting for paragraph', () => {
cy.createEditor({
data: {
blocks: [ {
type: 'paragraph',
data: { text: '<b>Bold text</b>' },
} ],
blocks: [
{
type: 'paragraph',
data: { text: '<b>Bold text</b>' },
}, {
type: 'paragraph',
data: { text: '<strong>Important text</strong>' },
},
],
},
}).then(async editor => {
const output = await (editor as any).save();
const boldText = output.blocks[0].data.text;
const importantText = output.blocks[1].data.text;
expect(boldText).to.eq('<b>Bold text</b>');
expect(importantText).to.eq('<strong>Important text</strong>');
});
});
it('should save initial italic formatting for paragraph', () => {
cy.createEditor({
data: {
blocks: [
{
type: 'paragraph',
data: { text: '<i>Italic text</i>' },
}, {
type: 'paragraph',
data: { text: '<em>Emphasis text</em>' },
},
],
},
}).then(async editor => {
const output = await (editor as any).save();
const italicText = output.blocks[0].data.text;
const emphasisText = output.blocks[1].data.text;
expect(italicText).to.eq('<i>Italic text</i>');
expect(emphasisText).to.eq('<em>Emphasis text</em>');
});
});