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/text editor/tabs: tweak
Adorian Doranfd7a93c59529
diff --git a/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.ts b/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.tsindex 509d75c99e..f9c641bc3d 100644--- a/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.ts+++ b/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.ts@@ -118,4 +118,47 @@ describe("tabs layout styles", () => {expect(measure(block, alignment), alignment).toEqual(EXPECTED[alignment]);}});++ it("outlines the innermost block holding the caret and rings only a title", async () => {+ const editor = await createTestEditor([Essentials, Paragraph, Tabs]);+ const editable = editor.ui.view.editable.element as HTMLElement;+ editor.editing.view.document.isFocused = true;+ const rootStyle = document.documentElement.style;+ rootStyle.setProperty("--ck-color-focus-border", "rgb(12, 34, 56)");+ rootStyle.setProperty("--link-color", "rgb(65, 43, 21)");+ onTestFinished(() => {+ rootStyle.removeProperty("--ck-color-focus-border");+ rootStyle.removeProperty("--link-color");+ });+ const inner = `<div class="trilium-tabs">${tab("B1", "<p>b1</p>")}${tab("B2", "")}</div>`;+ editor.setData(+ `<p>Before</p><div class="trilium-tabs">${tab("A", inner)}${tab("C", "")}</div>`+ );+ const blocks = [...editable.querySelectorAll<HTMLElement>(".trilium-tabs.ck-widget")];+ const outlines = () => blocks.map(block => getComputedStyle(block).outlineColor);+ const ring = (element: Element | null) => {+ expect(element).not.toBeNull();+ const style = getComputedStyle(element as Element);+ return [style.borderTopColor, style.boxShadow, style.transitionDuration];+ };+ const select = (path: number[]) => editor.model.change(writer => {+ const root = editor.model.document.getRoot();+ if (root) {+ writer.setSelection(writer.createPositionFromPath(root, path));+ }+ });+ expect(blocks).toHaveLength(2);+ expect(outlines()).toEqual(["rgba(0, 0, 0, 0)", "rgba(0, 0, 0, 0)"]);++ select([1, 0, 1, 0, 0, 1, 0, 0]);+ const innerPanel = blocks[1].querySelector(".trilium-tab-panel");+ expect(ring(innerPanel)).toEqual(["rgba(0, 0, 0, 0)", "none", "0s"]);+ await expect.poll(outlines).toEqual(["rgba(0, 0, 0, 0)", "rgb(65, 43, 21)"]);++ select([1, 0, 0, 0]);+ const outerTitle = blocks[0].querySelector(".trilium-tab-title");+ expect(ring(outerTitle).filter((_, index) => index !== 1))+ .toEqual(["rgb(12, 34, 56)", "0s"]);+ await expect.poll(outlines).toEqual(["rgb(65, 43, 21)", "rgba(0, 0, 0, 0)"]);+ });});diff --git a/packages/ckeditor5/src/theme/tabs.css b/packages/ckeditor5/src/theme/tabs.cssindex ac6a0c2100..8b52c8fa34 100644--- a/packages/ckeditor5/src/theme/tabs.css+++ b/packages/ckeditor5/src/theme/tabs.css@@ -1,3 +1,7 @@+:where(:root) {+ --tabs-focus-border-color: var(--link-color, var(--ck-color-focus-border));+}+/* Saved HTML without a marked tab, such as a preview or a printout, reads as a sequence of titledsections. */@media screen {@@ -32,7 +36,6 @@color: var(--_tabs-title-color);font-weight: 500;cursor: pointer;- transition: color 200ms ease-out, background-color 200ms ease-out;&:hover {color: var(--_tabs-active-title-color);@@ -100,6 +103,20 @@}}+/* Outlines only the innermost block that holds the focus. */+.ck-editor__editable .trilium-tabs:has(.ck-editor__nested-editable_focused) {+ &:not(:has(.trilium-tabs .ck-editor__nested-editable_focused)) {+ outline: var(--ck-widget-outline-thickness, 3px) solid var(--tabs-focus-border-color);+ }+}++.ck-editor__editable .trilium-tabs > .trilium-tab > .trilium-tab-panel {+ &:is(.ck-editor__nested-editable_focused, :focus) {+ border-color: transparent;+ box-shadow: none;+ }+}+.ck-editor__editable .trilium-tabs > .trilium-tab > .trilium-tab-title {/* CKEditor positions the placeholder absolutely, so it does not size the title. */&.ck-placeholder::after {