mirror of
https://github.com/ankitects/anki.git
synced 2025-11-07 05:07:10 -05:00
* Use async function in PlainTextInput
* Clean up PlainTextInput
* Refactor logic from {Rich,Plain}TextInput into own files
* Remove prohibited tags on content.subscribe which also parses the html
25 lines
853 B
TypeScript
25 lines
853 B
TypeScript
// 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";
|
|
import { decoratedElements } from "../DecoratedElements.svelte";
|
|
|
|
function normalizeFragment(fragment: DocumentFragment): void {
|
|
fragment.normalize();
|
|
|
|
for (const decorated of decoratedElements) {
|
|
for (const element of fragment.querySelectorAll(
|
|
decorated.tagName,
|
|
) as NodeListOf<DecoratedElement>) {
|
|
element.undecorate();
|
|
}
|
|
}
|
|
}
|
|
|
|
function getStore(): NodeStore<DocumentFragment> {
|
|
return nodeStore<DocumentFragment>(undefined, normalizeFragment);
|
|
}
|
|
|
|
export default getStore;
|