diff options
author | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-07-31 15:03:33 -0500 |
---|---|---|
committer | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-07-31 15:03:33 -0500 |
commit | 1dbfa3fdeedf8bb5b49c4d19f5a1b7f0cbe87e28 (patch) | |
tree | 59bbd0eecb84513a9ee857fff701a1e6f912b72c /src/client/views/nodes/formattedText/nodes_rts.ts | |
parent | 294a710250d8a007a3cc74bf65fb49b56fc027aa (diff) | |
parent | c71d7fa4f84149bcb62246d50e06bfd1481365bc (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into menu_restructure
Diffstat (limited to 'src/client/views/nodes/formattedText/nodes_rts.ts')
-rw-r--r-- | src/client/views/nodes/formattedText/nodes_rts.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/client/views/nodes/formattedText/nodes_rts.ts b/src/client/views/nodes/formattedText/nodes_rts.ts index 1af821738..0eca6d753 100644 --- a/src/client/views/nodes/formattedText/nodes_rts.ts +++ b/src/client/views/nodes/formattedText/nodes_rts.ts @@ -66,9 +66,11 @@ export const nodes: { [index: string]: NodeSpec } = { // should hold the number 1 to 6. Parsed and serialized as `<h1>` to // `<h6>` elements. heading: { - attrs: { level: { default: 1 } }, - content: "inline*", - group: "block", + ...ParagraphNodeSpec, + attrs: { + ...ParagraphNodeSpec.attrs, + level: { default: 1 }, + }, defining: true, parseDOM: [{ tag: "h1", attrs: { level: 1 } }, { tag: "h2", attrs: { level: 2 } }, @@ -76,7 +78,18 @@ export const nodes: { [index: string]: NodeSpec } = { { tag: "h4", attrs: { level: 4 } }, { tag: "h5", attrs: { level: 5 } }, { tag: "h6", attrs: { level: 6 } }], - toDOM(node: any) { return ["h" + node.attrs.level, 0]; } + toDOM(node) { + var dom = toParagraphDOM(node) as any; + var level = node.attrs.level || 1; + dom[0] = 'h' + level; + return dom; + }, + getAttrs(dom: any) { + var attrs = getParagraphNodeAttrs(dom) as any; + var level = Number(dom.nodeName.substring(1)) || 1; + attrs.level = level; + return attrs; + } }, // :: NodeSpec A code listing. Disallows marks or non-text inline |