mirror of
https://github.com/codex-team/editor.js
synced 2024-06-29 10:50:23 +02:00
Add support for copying and pasting of "strong" and "em" HTML elements
This commit is contained in:
parent
cd06bfc9c5
commit
ff1da53d51
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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>');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue