Skip to content

Commit

Permalink
fix: parse data-indent attribute correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed May 14, 2024
1 parent be7055f commit 0feb81c
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions projects/ngx-editor/schema/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const paragraph: NodeSpec = {
getAttrs(dom: HTMLElement) {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand Down Expand Up @@ -72,8 +72,10 @@ const blockquote: NodeSpec = {
{
tag: 'blockquote',
getAttrs(dom: HTMLElement) {
const indent = dom.getAttribute('indent') || null;
return { indent };
const indent = dom.getAttribute('data-indent') || null;
return {
indent: parseInt(indent, 10) || null,
};
},
},
],
Expand Down Expand Up @@ -128,12 +130,12 @@ const heading: NodeSpec = {
getAttrs(dom: HTMLElement): Record<string, any> {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
level: 1,
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand All @@ -142,12 +144,12 @@ const heading: NodeSpec = {
getAttrs(dom: HTMLElement): Record<string, any> {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
level: 2,
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand All @@ -156,12 +158,12 @@ const heading: NodeSpec = {
getAttrs(dom: HTMLElement): Record<string, any> {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
level: 3,
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand All @@ -170,12 +172,12 @@ const heading: NodeSpec = {
getAttrs(dom: HTMLElement): Record<string, any> {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
level: 4,
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand All @@ -184,12 +186,12 @@ const heading: NodeSpec = {
getAttrs(dom: HTMLElement): Record<string, any> {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
level: 5,
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand All @@ -198,12 +200,12 @@ const heading: NodeSpec = {
getAttrs(dom: HTMLElement): Record<string, any> {
const { textAlign } = dom.style;
const align = dom.getAttribute('align') || textAlign || null;
const indent = dom.getAttribute('indent') || null;
const indent = dom.getAttribute('data-indent') || null;

return {
level: 6,
align,
indent,
indent: parseInt(indent, 10) || null,
};
},
},
Expand Down

0 comments on commit 0feb81c

Please sign in to comment.