add: add link popup indent

change: mind map root text
This commit is contained in:
xiangyu 2022-05-08 09:29:16 +08:00
parent fce40cfd6b
commit 750f2b4394
4 changed files with 21 additions and 4 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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") {
/*

View File

@ -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) => {