2022-03-31 03:17:13 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
|
|
|
import type { DecoratedElement } from "../../editable/decorated";
|
|
|
|
import type { NodeStore } from "../../sveltelib/node-store";
|
|
|
|
import { nodeStore } from "../../sveltelib/node-store";
|
2022-10-27 01:11:36 +02:00
|
|
|
import { decoratedElements } from "../decorated-elements";
|
2022-03-31 03:17:13 +02:00
|
|
|
|
|
|
|
function normalizeFragment(fragment: DocumentFragment): void {
|
|
|
|
fragment.normalize();
|
|
|
|
|
|
|
|
for (const decorated of decoratedElements) {
|
2022-11-28 00:33:04 +01:00
|
|
|
for (
|
|
|
|
const element of fragment.querySelectorAll(
|
|
|
|
decorated.tagName,
|
|
|
|
) as NodeListOf<DecoratedElement>
|
|
|
|
) {
|
2022-03-31 03:17:13 +02:00
|
|
|
element.undecorate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStore(): NodeStore<DocumentFragment> {
|
|
|
|
return nodeStore<DocumentFragment>(undefined, normalizeFragment);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default getStore;
|