Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(ckeditor5): fix references: Element -> ModelElement
Elian Doran4ae3272cdfa5
diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.tsindex cc3db23c44..aa123d7732 100644--- a/packages/ckeditor5/src/index.ts+++ b/packages/ckeditor5/src/index.ts@@ -5,7 +5,7 @@ import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } frimport "./translation_overrides.js";export { EditorWatchdog } from "ckeditor5";export { PREMIUM_PLUGINS } from "./plugins.js";-export type { EditorConfig, MentionFeed, MentionFeedObjectItem, Node, Position, Element, WatchdogConfig } from "ckeditor5";+export type { EditorConfig, MentionFeed, MentionFeedObjectItem, Node, Position, ModelElement, WatchdogConfig } from "ckeditor5";export type { TemplateDefinition } from "ckeditor5-premium-features";export { default as buildExtraCommands } from "./extra_slash_commands.js";diff --git a/packages/ckeditor5/src/plugins/indent_block_shortcut.ts b/packages/ckeditor5/src/plugins/indent_block_shortcut.tsindex ce00462a5e..8eb282aada 100644--- a/packages/ckeditor5/src/plugins/indent_block_shortcut.ts+++ b/packages/ckeditor5/src/plugins/indent_block_shortcut.ts@@ -2,7 +2,7 @@* https://github.com/zadam/trilium/issues/978*/-import { DocumentFragment, Element, Plugin, Position } from "ckeditor5";+import { DocumentFragment, ModelElement, Plugin, Position } from "ckeditor5";export default class IndentBlockShortcutPlugin extends Plugin {@@ -28,7 +28,7 @@ export default class IndentBlockShortcutPlugin extends Plugin {// in table TAB should switch cellsisInTable() {- let el: Position | Element | DocumentFragment | null = this.editor.model.document.selection.getFirstPosition();+ let el: Position | ModelElement | DocumentFragment | null = this.editor.model.document.selection.getFirstPosition();while (el) {if ("name" in el && el.name === 'tableCell') {diff --git a/packages/ckeditor5/src/plugins/move_block_updown.ts b/packages/ckeditor5/src/plugins/move_block_updown.tsindex 32a5c39a10..3346f66d9a 100644--- a/packages/ckeditor5/src/plugins/move_block_updown.ts+++ b/packages/ckeditor5/src/plugins/move_block_updown.ts@@ -2,7 +2,7 @@* https://github.com/TriliumNext/Trilium/issues/1002*/-import { Command, DocumentSelection, Element, Node, Plugin, Range } from 'ckeditor5';+import { Command, DocumentSelection, ModelElement, Node, Plugin, Range } from 'ckeditor5';export default class MoveBlockUpDownPlugin extends Plugin {init() {@@ -46,7 +46,7 @@ export default class MoveBlockUpDownPlugin extends Plugin {abstract class MoveBlockUpDownCommand extends Command {- abstract getSibling(selectedBlock: Element): Node | null;+ abstract getSibling(selectedBlock: ModelElement): Node | null;abstract get offset(): "before" | "after";override execute() {@@ -107,7 +107,7 @@ abstract class MoveBlockUpDownCommand extends Command {getSelectedBlocks(selection: DocumentSelection) {const blocks = [...selection.getSelectedBlocks()];- const resolved: Element[] = [];+ const resolved: ModelElement[] = [];// Selects elements (such as Mermaid) when there are no blocksif (!blocks.length) {@@ -118,10 +118,10 @@ abstract class MoveBlockUpDownCommand extends Command {}for (const block of blocks) {- let el: Element = block;+ let el: ModelElement = block;// Traverse up until the parent is the root ($root) or there is no parentwhile (el.parent && el.parent.name !== '$root') {- el = el.parent as Element;+ el = el.parent as ModelElement;}resolved.push(el);}@@ -140,7 +140,7 @@ abstract class MoveBlockUpDownCommand extends Command {class MoveBlockUpCommand extends MoveBlockUpDownCommand {- getSibling(selectedBlock: Element) {+ getSibling(selectedBlock: ModelElement) {return selectedBlock.previousSibling;}@@ -153,7 +153,7 @@ class MoveBlockUpCommand extends MoveBlockUpDownCommand {class MoveBlockDownCommand extends MoveBlockUpDownCommand {/** @override */- getSibling(selectedBlock: Element) {+ getSibling(selectedBlock: ModelElement) {return selectedBlock.nextSibling;}diff --git a/packages/ckeditor5/src/plugins/referencelink.ts b/packages/ckeditor5/src/plugins/referencelink.tsindex a790eb0a15..7569d2fa6b 100644--- a/packages/ckeditor5/src/plugins/referencelink.ts+++ b/packages/ckeditor5/src/plugins/referencelink.ts@@ -1,4 +1,4 @@-import { Command, Element, LinkEditing, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget } from "ckeditor5";+import { Command, ModelElement, LinkEditing, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget } from "ckeditor5";export default class ReferenceLink extends Plugin {static get requires() {@@ -32,7 +32,7 @@ class ReferenceLinkCommand extends Command {override refresh() {const model = this.editor.model;const selection = model.document.selection;- this.isEnabled = selection.focus !== null && model.schema.checkChild(selection.focus.parent as Element, 'reference');+ this.isEnabled = selection.focus !== null && model.schema.checkChild(selection.focus.parent as ModelElement, 'reference');}}diff --git a/packages/ckeditor5/src/plugins/syntax_highlighting/index.ts b/packages/ckeditor5/src/plugins/syntax_highlighting/index.tsindex 18c5fae9c5..5257ca7610 100644--- a/packages/ckeditor5/src/plugins/syntax_highlighting/index.ts+++ b/packages/ckeditor5/src/plugins/syntax_highlighting/index.ts@@ -1,4 +1,4 @@-import type { Element, Position, Writer } from "ckeditor5";+import type { ModelElement, Position, Writer } from "ckeditor5";import type { Node, Editor } from "ckeditor5";import { Plugin } from "ckeditor5";@@ -77,9 +77,9 @@ export default class SyntaxHighlighting extends Plugin {// See// https://github.com/ckeditor/ckeditor5/blob/b53d2a4b49679b072f4ae781ac094e7e831cfb14/packages/ckeditor5-block-quote/src/blockquoteediting.js#L54const changes = document.differ.getChanges();- let dirtyCodeBlocks = new Set<Element>();+ let dirtyCodeBlocks = new Set<ModelElement>();- function lookForCodeBlocks(node: Element | Node) {+ function lookForCodeBlocks(node: ModelElement | Node) {if (!("getChildren" in node)) {return;}@@ -91,7 +91,7 @@ export default class SyntaxHighlighting extends Plugin {if (child.is("element", "codeBlock")) {dirtyCodeBlocks.add(child);- } else if ((child as Element).childCount > 0) {+ } else if ((child as ModelElement).childCount > 0) {lookForCodeBlocks(child);}}@@ -100,7 +100,7 @@ export default class SyntaxHighlighting extends Plugin {for (const change of changes) {dbg("change " + JSON.stringify(change));- if ("name" in change && change.name !== "paragraph" && change.name !== "codeBlock" && change?.position?.nodeAfter && (change.position.nodeAfter as Element).childCount > 0) {+ if ("name" in change && change.name !== "paragraph" && change.name !== "codeBlock" && change?.position?.nodeAfter && (change.position.nodeAfter as ModelElement).childCount > 0) {/** We need to look for code blocks recursively, as they can be placed within a <div> due to* general HTML support or normally underneath other elements such as tables, blockquotes, etc.@@ -115,7 +115,7 @@ export default class SyntaxHighlighting extends Plugin {// etc (the postfixer won't get later changes for those).if (codeBlock) {log("dirtying inserted codeBlock " + JSON.stringify(codeBlock.toJSON()));- dirtyCodeBlocks.add(codeBlock as Element);+ dirtyCodeBlocks.add(codeBlock as ModelElement);}} else if (change.type == "remove" && change.name == "codeBlock" && change.position) {// An existing codeblock was removed, do nothing. Note the@@ -149,7 +149,7 @@ export default class SyntaxHighlighting extends Plugin {* the formatting would be stored with the note and it would need a* way to remove that formatting when editing back the note.*/- highlightCodeBlock(codeBlock: Element, writer: Writer) {+ highlightCodeBlock(codeBlock: ModelElement, writer: Writer) {log("highlighting codeblock " + JSON.stringify(codeBlock.toJSON()));const model = codeBlock.root.document?.model;if (!model) {