Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Handle sub/sup paste from microsoft word
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Jul 27, 2020
1 parent 5e61ad9 commit 13349a9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/editor/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,20 @@ export const inlineTagDeserializer = (attrs) => (editor, el) => {

export const spanDeserializer = (editor, el) => {
const style = el.getAttribute('style') || '';
if (style.indexOf('vertical-align:super') > -1) {

// SUB
if (style.replace(/\s/g, '').indexOf('vertical-align:sub') > -1) {
const children = Array.from(el.childNodes)
.map((el) => deserialize(editor, el))
.flat();
const attrs = { sub: true };
return children.map((child) => {
return jsx('text', attrs, child);
});
}

// SUP
if (style.replace(/\s/g, '').indexOf('vertical-align:super') > -1) {
const children = Array.from(el.childNodes)
.map((el) => deserialize(editor, el))
.flat();
Expand All @@ -91,6 +104,7 @@ export const spanDeserializer = (editor, el) => {
return jsx('text', attrs, child);
});
}

const children = Array.from(el.childNodes)
.map((el) => {
console.log('el', el);
Expand Down

0 comments on commit 13349a9

Please sign in to comment.