diff --git a/src/converters/fromDraftjs.test.js b/src/converters/fromDraftjs.test.js index dbdbea2..43b01cf 100644 --- a/src/converters/fromDraftjs.test.js +++ b/src/converters/fromDraftjs.test.js @@ -455,37 +455,42 @@ describe('convertFromDraftJS parsing draftjs blockquote', () => { // const draftjs = { // blocks: [ // { -// key: 'jrnb', -// text: 'Trasporto delle persone con difficoltà motorie ai seggi\nIl Comune di Cavriago, in collaborazione con l’Associazione “NOI CON VOI”, organizza il trasporto delle persone disabili mediante il pulmino adibito appositamente a tale servizio.\nIl servizio verrà effettuato nei seguenti orari:\nSABATO 8 GIUGNO dalle 15.00 alle 17.00\nDOMENICA 9 GIUGNO dalle 10.00 alle 12.00.\nIl trasporto dovrà essere prenotato direttamente all’associazione al numero 333 5383663 (Ines).\n', -// type: 'callout', +// data: {}, // depth: 0, -// inlineStyleRanges: [ -// { -// offset: 0, -// length: 56, -// style: 'BOLD', -// }, +// entityRanges: [ // { -// offset: 116, -// length: 13, -// style: 'BOLD', +// key: 0, +// length: 5, +// offset: 18, // }, +// ], +// inlineStyleRanges: [ // { -// offset: 285, -// length: 81, +// length: 5, +// offset: 6, // style: 'BOLD', // }, // { -// offset: 443, -// length: 11, -// style: 'BOLD', +// length: 5, +// offset: 12, +// style: 'TEXT_LARGER', // }, // ], -// entityRanges: [], -// data: {}, +// key: 'i5b8', +// text: 'Testo testo testo testo ', +// type: 'unstyled', // }, // ], -// entityMap: {}, +// entityMap: { +// 0: { +// data: { +// dataElement: '', +// url: 'http://www.google.it', +// }, +// mutability: 'MUTABLE', +// type: 'LINK', +// }, +// }, // }; // describe('with html converter', () => { // const result = converFromDraftJS(draftjs); diff --git a/src/converters/slate.js b/src/converters/slate.js index 86ca84f..487b88a 100644 --- a/src/converters/slate.js +++ b/src/converters/slate.js @@ -65,6 +65,7 @@ const bTagDeserializer = (el) => { const spanTagDeserializer = (el) => { const style = (el.getAttribute('style') || '').replace(/\s/g, ''); + const className = el.getAttribute('class'); let children = el.childNodes; if (children.length === 1) { const child = children[0]; @@ -95,7 +96,11 @@ const spanTagDeserializer = (el) => { // Handle Google Docs' formatting children = jsx('element', { type: 'sup' }, children); } - return jsx('fragment', {}, children); + const data = jsx('fragment', {}, children); + if (className === 'text-larger') { + data[0]['style-text-larger'] = true; + } + return data; } }; diff --git a/src/converters/slate.test.js b/src/converters/slate.test.js index 6bdb899..d445acb 100644 --- a/src/converters/slate.test.js +++ b/src/converters/slate.test.js @@ -168,6 +168,19 @@ describe('slateTextBlock processing a paragraph', () => { }); }); +describe('slateTextBlock processing a simple span block', () => { + const elem = elementFromString('large text'); + + test('will have a formated block', () => { + const result = slateTextBlock(elem); + const valueElement = result.value[0]; + expect(valueElement).toEqual({ + 'style-text-larger': true, + text: 'large text', + }); + }); +}); + describe('slateTextBlock processing a simple pre block', () => { const elem = elementFromString( '
Plone Foundation: https://plone.org/
',