From 750f2b439482ed033ee101a0168d600676d35a12 Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Sun, 8 May 2022 09:29:16 +0800 Subject: [PATCH] add: add link popup indent change: mind map root text --- addon/chrome/content/bubbleMap.html | 2 +- addon/chrome/content/mindMap.html | 2 +- src/events.ts | 12 ++++++++++++ src/views.ts | 9 +++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/addon/chrome/content/bubbleMap.html b/addon/chrome/content/bubbleMap.html index 38ebfff..6f727c6 100644 --- a/addon/chrome/content/bubbleMap.html +++ b/addon/chrome/content/bubbleMap.html @@ -151,7 +151,7 @@ } function setData(nodes){ - const nodeDataArray = [{ key: 999, text: "Knowledge", parent: undefined }] + const nodeDataArray = [{ key: 999, text: "📄", parent: undefined }] const linkDataArray = [] for (const node of nodes) { const parent = node.parent.model.id === -1? 999:node.parent.model.id; diff --git a/addon/chrome/content/mindMap.html b/addon/chrome/content/mindMap.html index b4b2cee..e8472c6 100644 --- a/addon/chrome/content/mindMap.html +++ b/addon/chrome/content/mindMap.html @@ -241,7 +241,7 @@ function setData(nodes){ const data = { class: "go.TreeModel", - nodeDataArray: [{ key: 999, text: "Knowledge", parent: undefined }], + nodeDataArray: [{ key: 999, text: "📄", parent: undefined }], }; const colors = [] for (const node of nodes) { diff --git a/src/events.ts b/src/events.ts index 3b3c4b3..8f0a6c4 100644 --- a/src/events.ts +++ b/src/events.ts @@ -279,6 +279,7 @@ class AddonEvents extends AddonBase { buttonParam.push({ id: `knowledge-addlink-popup-${node.model.endIndex}`, text: node.model.name, + rank: node.model.rank, eventType: "addToKnowledgeLine", }); } @@ -312,6 +313,17 @@ class AddonEvents extends AddonBase { ); message.content.editorInstance._knowledgeSelectionInitialized = true; } + // Title indent + const _window = message.content.editorInstance._iframeWindow; + const style = _window.document.createElement("style"); + style.innerHTML = ` + h2 {text-indent: 10px} + h3 {text-indent: 20px} + h4 {text-indent: 30px} + h5 {text-indent: 40px} + h6 {text-indent: 50px} + `; + _window.document.body.append(style); message.content.editorInstance._knowledgeUIInitialized = true; } else if (message.type === "enterWorkspace") { /* diff --git a/src/views.ts b/src/views.ts index 500a882..1064d36 100644 --- a/src/views.ts +++ b/src/views.ts @@ -102,7 +102,7 @@ class AddonViews extends AddonBase { async addEditorPopup( editorInstances: EditorInstance, id: string, - buttons: { id: string; text: string; eventType: string }[], + buttons: { id: string; text: string; rank: number; eventType: string }[], parentDropDown: Element ) { // Use Zotero.Notes._editorInstances to find current opened note editor @@ -115,10 +115,15 @@ class AddonViews extends AddonBase { } const popup = _document.createElement("div"); popup.setAttribute("class", "popup"); + popup.setAttribute("style", "right: -100px;"); popup.setAttribute("id", id); for (let buttonParam of buttons) { const button = _document.createElement("button"); button.setAttribute("class", "option"); + button.setAttribute( + "style", + `text-indent: ${(buttonParam.rank - 1) * 5}px;` + ); button.setAttribute("id", buttonParam.id); button.setAttribute("eventType", buttonParam.eventType); button.innerHTML = buttonParam.text; @@ -243,7 +248,7 @@ class AddonViews extends AddonBase { const span4 = document.createElement("span"); span4.setAttribute("class", "cell-text"); span4.setAttribute("style", "margin-left: 6px;"); - span4.innerHTML = "Knowledge"; + span4.innerHTML = "Open Workspace"; span1.append(span2, span3, span4); treeRow.append(span1); treeRow.addEventListener("click", (e) => {