mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
feat(Editor): add method to change block type
This commit is contained in:
parent
cbd8881e78
commit
fe30d243d3
1 changed files with 15 additions and 0 deletions
|
@ -2455,6 +2455,21 @@ class Squire {
|
|||
return frag;
|
||||
}
|
||||
|
||||
changeBlockType(
|
||||
tag: string = this._config.blockTag,
|
||||
attrs: Record<string, string> | null = this._config.blockAttributes
|
||||
) {
|
||||
return this.modifyBlocks((frag) => {
|
||||
const walker = getBlockWalker(frag, this._root);
|
||||
const output = document.createDocumentFragment();
|
||||
let node;
|
||||
while ((node = walker.nextNode())) {
|
||||
output.appendChild(createElement(tag, attrs, [empty(node)]));
|
||||
}
|
||||
return output;
|
||||
});
|
||||
};
|
||||
|
||||
makeUnorderedList(): Squire {
|
||||
this.modifyBlocks((frag) => this._makeList(frag, 'UL'));
|
||||
return this.focus();
|
||||
|
|
Loading…
Reference in a new issue