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
client: fix some issues
Adorian Doran0c7685ae664d
diff --git a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsxindex 27f6c66d51..1bc9f7ebf0 100644--- a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx+++ b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx@@ -1,5 +1,6 @@import { AttributeEditor as CKEditorAttributeEditor, MentionFeed, ModelElement, ModelNode, ModelPosition } from "@triliumnext/ckeditor5";import { AttributeType } from "@triliumnext/commons";+import type { Tooltip } from "bootstrap";import { createPortal } from "preact/compat";import { MutableRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "preact/hooks";@@ -105,14 +106,19 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxIconst editorRef = useRef<CKEditorApi>();const [ locale ] = useTriliumOption("locale");- const { showTooltip, hideTooltip } = useTooltip(wrapperRef, {- trigger: "click",+ // Stable config so `useTooltip`'s effect doesn't dispose/recreate the tooltip+ // on every render (it runs on each keystroke). `focus` shows the help when the+ // editor is focused; `state` below force-hides it when the attribute-detail+ // popup takes over.+ const tooltipConfig = useMemo<Partial<Tooltip.Options>>(() => ({+ trigger: "focus",html: true,title: HELP_TEXT,placement: "bottom",- offset: "0,30",-- });+ offset: "0,30"+ }), []);++ const { showTooltip, hideTooltip } = useTooltip(wrapperRef, tooltipConfig);const [ attributeDetailWidgetEl, attributeDetailWidget ] = useLegacyWidget(() => new AttributeDetailWidget());diff --git a/packages/ckeditor5-mermaid/src/mermaidui.ts b/packages/ckeditor5-mermaid/src/mermaidui.tsindex 20b26d4284..9a903d48be 100644--- a/packages/ckeditor5-mermaid/src/mermaidui.ts+++ b/packages/ckeditor5-mermaid/src/mermaidui.ts@@ -92,7 +92,7 @@ export default class MermaidUI extends Plugin {addListToDropdown( dropdownView, this._getSampleDropdownItems( samples ) );dropdownView.bind( 'isEnabled' ).to( command, 'isEnabled' );dropdownView.on( 'execute', evt => {- const source = (evt.source as { commandParam?: string }).commandParam;+ const source = (evt.source as { commandParam?: string } | undefined)?.commandParam;this._insertDiagram( { source } );} );diff --git a/packages/ckeditor5-mermaid/tests/mermaidui.ts b/packages/ckeditor5-mermaid/tests/mermaidui.tsindex 7a7fd4ef3b..3d29d713e6 100644--- a/packages/ckeditor5-mermaid/tests/mermaidui.ts+++ b/packages/ckeditor5-mermaid/tests/mermaidui.ts@@ -74,6 +74,15 @@ describe( 'MermaidUI', () => {expect( document.activeElement.tagName ).to.equal( 'TEXTAREA' );} );+ it( 'should insert exactly one diagram on the main action (no double insert)', () => {+ const dropdown = editor.ui.componentFactory.create( 'mermaid' );++ dropdown.buttonView.fire( 'execute' );++ const data = getModelData( editor.model, { withoutSelection: true } );+ expect( ( data.match( /<mermaid/g ) || [] ).length ).to.equal( 1 );+ } );+it( 'should not crash if the button is fired inside model.change()', () => {const dropdown = editor.ui.componentFactory.create( 'mermaid' );