Eliminiate vertical jump with directives

This commit is contained in:
Zef Hemel
2022-12-19 11:50:48 +01:00
parent 7b764a94fa
commit d032672076
4 changed files with 134 additions and 53 deletions
+21
View File
@@ -40,6 +40,27 @@ export class LinkWidget extends WidgetType {
}
}
export class HtmlWidget extends WidgetType {
constructor(
readonly html: string,
readonly className?: string,
readonly onClick?: (e: MouseEvent) => void,
) {
super();
}
toDOM(): HTMLElement {
const el = document.createElement("span");
if (this.className) {
el.className = this.className;
}
if (this.onClick) {
el.addEventListener("click", this.onClick);
}
el.innerHTML = this.html;
return el;
}
}
export function decoratorStateField(
stateToDecoratorMapper: (state: EditorState) => DecorationSet,
) {