fix: Fixed issue in Super notes where collapsible block title alignment would not persist
This commit is contained in:
@@ -11,9 +11,11 @@ import {
|
|||||||
$isElementNode,
|
$isElementNode,
|
||||||
DOMConversionMap,
|
DOMConversionMap,
|
||||||
EditorConfig,
|
EditorConfig,
|
||||||
|
ElementFormatType,
|
||||||
ElementNode,
|
ElementNode,
|
||||||
LexicalEditor,
|
LexicalEditor,
|
||||||
LexicalNode,
|
LexicalNode,
|
||||||
|
NodeKey,
|
||||||
RangeSelection,
|
RangeSelection,
|
||||||
SerializedElementNode,
|
SerializedElementNode,
|
||||||
Spread,
|
Spread,
|
||||||
@@ -35,13 +37,22 @@ export class CollapsibleTitleNode extends ElementNode {
|
|||||||
return 'collapsible-title'
|
return 'collapsible-title'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor({ formatType, key }: { formatType?: ElementFormatType; key?: NodeKey }) {
|
||||||
|
super(key)
|
||||||
|
if (formatType) {
|
||||||
|
super.setFormat(formatType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static override clone(node: CollapsibleTitleNode): CollapsibleTitleNode {
|
static override clone(node: CollapsibleTitleNode): CollapsibleTitleNode {
|
||||||
return new CollapsibleTitleNode(node.__key)
|
return new CollapsibleTitleNode({ key: node.__key })
|
||||||
}
|
}
|
||||||
|
|
||||||
override createDOM(_config: EditorConfig, editor: LexicalEditor): HTMLElement {
|
override createDOM(_config: EditorConfig, editor: LexicalEditor): HTMLElement {
|
||||||
const dom = document.createElement('summary')
|
const dom = document.createElement('summary')
|
||||||
dom.classList.add('Collapsible__title')
|
dom.classList.add('Collapsible__title')
|
||||||
|
const format = this.getFormatType()
|
||||||
|
dom.style.textAlign = format
|
||||||
dom.onclick = (event) => {
|
dom.onclick = (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
@@ -63,8 +74,8 @@ export class CollapsibleTitleNode extends ElementNode {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
static override importJSON(_serializedNode: SerializedCollapsibleTitleNode): CollapsibleTitleNode {
|
static override importJSON(serializedNode: SerializedCollapsibleTitleNode): CollapsibleTitleNode {
|
||||||
return $createCollapsibleTitleNode()
|
return $createCollapsibleTitleNode(serializedNode.format)
|
||||||
}
|
}
|
||||||
|
|
||||||
override exportJSON(): SerializedCollapsibleTitleNode {
|
override exportJSON(): SerializedCollapsibleTitleNode {
|
||||||
@@ -109,8 +120,10 @@ export class CollapsibleTitleNode extends ElementNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function $createCollapsibleTitleNode(): CollapsibleTitleNode {
|
export function $createCollapsibleTitleNode(formatType?: ElementFormatType): CollapsibleTitleNode {
|
||||||
return new CollapsibleTitleNode()
|
return new CollapsibleTitleNode({
|
||||||
|
formatType,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function $isCollapsibleTitleNode(node: LexicalNode | null | undefined): node is CollapsibleTitleNode {
|
export function $isCollapsibleTitleNode(node: LexicalNode | null | undefined): node is CollapsibleTitleNode {
|
||||||
|
|||||||
Reference in New Issue
Block a user