Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.
/ liandi Public archive

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Aug 26, 2020
2 parents b718653 + 0069fe8 commit 6ae884b
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions app/src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class Editor extends Model {
if (data) {
switch (data.cmd) {
case "get":
this.parent.headElement.setAttribute("data-node-id", data.data.rootID)
this.parent.headElement.setAttribute("data-node-id", data.data.rootID);
if (data.callback === Constants.CB_PUT_RELOAD) {
this.reloadHTML(data.data.content);
this.saved = true;
Expand Down Expand Up @@ -289,7 +289,7 @@ export class Editor extends Model {
this.saved = false;
this.parent.headElement.classList.add("item--unsave");
if (process.env.NODE_ENV === "development") {
return
return;
}
clearTimeout(inputTimeout);
inputTimeout = window.setTimeout(() => {
Expand Down Expand Up @@ -364,7 +364,7 @@ export class Editor extends Model {
return;
}
if (data.callback === Constants.CB_GETBLOCK_EMBED) {
const blockVditorElement = this.vditore.vditor.ir.element.querySelector(`[data-block-def-id="${data.id}"]`) as HTMLElement
const blockVditorElement = this.vditore.vditor.ir.element.querySelector(`[data-block-def-id="${data.id}"]`) as HTMLElement;
blockVditorElement.setAttribute("data-render", "1");
blockVditorElement.innerHTML = data.block.content;
mathRender(blockVditorElement, {
Expand Down
2 changes: 1 addition & 1 deletion app/src/editor/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getIconByType = (type: string) => {
iconName = "vditor-icon-table";
break;
case "NodeMathBlock":
iconName = "iconMath"
iconName = "iconMath";
break;
}
return iconName;
Expand Down
24 changes: 12 additions & 12 deletions app/src/graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export class Graph extends Model {
public hlNode(id: string) {
this.nodes.forEach((item) => {
if (item.name === id) {
item.symbolSize = 30
item.symbolSize = 30;
} else {
item.symbolSize = item.originalSize
item.symbolSize = item.originalSize;
}
})
this.onGraph({nodes: this.nodes, links: this.links})
});
this.onGraph({nodes: this.nodes, links: this.links});
}

public onGraph(data: { nodes: Record<string, unknown>[], links: Record<string, unknown>[], url?: string, path?: string }) {
Expand All @@ -141,7 +141,7 @@ export class Graph extends Model {
if (nodeElement && nodeElement.getClientRects().length > 0) {
bgFade(nodeElement);
vditorElement.scrollTop = nodeElement.offsetTop - vditorElement.clientHeight / 2;
this.hlNode(params.name)
this.hlNode(params.name);
}
return true;
}
Expand All @@ -151,10 +151,10 @@ export class Graph extends Model {
} else {
this.chart.resize();
}
this.nodes = data.nodes
this.links = data.links
const labelColor = window.liandi.config.theme === "dark" ? "#d1d5da" : "#24292e"
const labelLightColor = window.liandi.config.theme === "dark" ? "#959da5" : "#6a737d"
this.nodes = data.nodes;
this.links = data.links;
const labelColor = window.liandi.config.theme === "dark" ? "#d1d5da" : "#24292e";
const labelLightColor = window.liandi.config.theme === "dark" ? "#959da5" : "#6a737d";
this.chart.setOption({
legend: {
data: [{
Expand Down Expand Up @@ -207,7 +207,7 @@ export class Graph extends Model {
}],
draggable: false,
label: {
position: 'bottom',
position: "bottom",
color: labelColor,
fontSize: 10,
formatter: (params: IEchartsFormatter) => {
Expand All @@ -228,11 +228,11 @@ export class Graph extends Model {
},
emphasis: {
lineStyle: {
color: '#f3a92f',
color: "#f3a92f",
opacity: 0.38,
},
itemStyle: {
color: '#f3a92f',
color: "#f3a92f",
}
},
edgeSymbol: ["none", "arrow"],
Expand Down
4 changes: 2 additions & 2 deletions app/src/menus/commonMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const copyBlockId = () => {
const itemData = window.liandi.menus.itemData;
clipboard.writeText(itemData.target.getAttribute("data-node-id"));
}
})
}
});
};
export const showInFolder = () => {
return new remote.MenuItem({
label: i18n[window.liandi.config.lang].showInFolder,
Expand Down
2 changes: 1 addition & 1 deletion app/src/menus/file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {remote} from "electron";
import {copyBlockId, deleteMenu, newFileMenu, newFolderMenu, renameMenu, showInFolder} from "./commonMenuItem";
import {deleteMenu, newFileMenu, newFolderMenu, renameMenu, showInFolder} from "./commonMenuItem";

export const initFolderMenu = () => {
const menu = new remote.Menu();
Expand Down
12 changes: 6 additions & 6 deletions app/src/menus/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ export const initEditorMenu = () => {
});
newWnd.addTab(tab);

newWnd.element.classList.remove("fn__flex-1")
newWnd.element.style.width = "200px"
newWnd.element.after(currentTab.parent.element)
newWnd.element.after(newWnd.element.previousElementSibling)
newWnd.element.classList.remove("fn__flex-1");
newWnd.element.style.width = "200px";
newWnd.element.after(currentTab.parent.element);
newWnd.element.after(newWnd.element.previousElementSibling);
newWnd.parent.children.find((item, index) => {
if (item.id === newWnd.id) {
const temp = item;
newWnd.parent.children[index] = newWnd.parent.children[index - 1];
newWnd.parent.children[index - 1] = temp;
return true
return true;
}
})
});
}
}));
return menu;
Expand Down
2 changes: 1 addition & 1 deletion app/src/menus/vditor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {remote, clipboard} from "electron";
import {remote} from "electron";
import {i18n} from "../i18n";
import {copyBlockId} from "./commonMenuItem";

Expand Down
24 changes: 12 additions & 12 deletions app/src/outline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ export class Outline extends Model {
case "reload":
getAllModels().editor.find((item) => {
if (data.data.url === item.url && data.data.path === item.path) {
this.render(item.vditore.vditor.ir.element)
return true
this.render(item.vditore.vditor.ir.element);
return true;
}
})
break
});
break;
}
}
}
this.element = options.tab.panelElement
this.element.classList.add("vditor-outline")
};
this.element = options.tab.panelElement;
this.element.classList.add("vditor-outline");
this.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) {
Expand All @@ -44,7 +44,7 @@ export class Outline extends Model {
}
item.vditore.vditor.ir.element.scrollTop = headingElement.offsetTop - 10;
bgFade(headingElement);
})
});
this.element.querySelectorAll(".vditor-outline__item").forEach((item) => {
item.classList.remove("vditor-outline__item--current");
});
Expand All @@ -53,16 +53,16 @@ export class Outline extends Model {
target = target.parentElement;
}
});
this.render(options.contentElement)
this.render(options.contentElement);
}

private render(contentElement: HTMLElement | string) {
if (typeof contentElement === "string") {
this.element.innerHTML = contentElement;
return
return;
}
let tocHTML = ''
Array.from(contentElement.children).forEach((item: HTMLElement, index) => {
let tocHTML = "";
Array.from(contentElement.children).forEach((item: HTMLElement) => {
if (hasClosestByHeadings(item)) {
const headingNo = parseInt(item.tagName.substring(1), 10);
const space = new Array(headingNo - 1).fill("&emsp;").join("");
Expand Down
18 changes: 9 additions & 9 deletions app/src/util/bgFade.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const bgFade = (element: HTMLElement) => {
element.style.backgroundColor = 'var(--border-color)'
element.style.borderRadius = '3px'
element.style.boxShadow = '5px 0px 0 var(--border-color), -5px 0px 0 var(--border-color)'
element.style.backgroundColor = "var(--border-color)";
element.style.borderRadius = "3px";
element.style.boxShadow = "5px 0px 0 var(--border-color), -5px 0px 0 var(--border-color)";
setTimeout(function () {
element.style.transition = 'all 2s cubic-bezier(0.4, 0, 1, 1)'
element.style.backgroundColor = 'var(--toolbar-background-color)'
element.style.boxShadow = '5px 0px 0 var(--toolbar-background-color), -5px 0px 0 var(--toolbar-background-color)'
})
element.style.transition = "all 2s cubic-bezier(0.4, 0, 1, 1)";
element.style.backgroundColor = "var(--toolbar-background-color)";
element.style.boxShadow = "5px 0px 0 var(--toolbar-background-color), -5px 0px 0 var(--toolbar-background-color)";
});
setTimeout(function () {
element.removeAttribute("style");
}, 2001)
}
}, 2001);
};
4 changes: 2 additions & 2 deletions app/src/util/newFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {showMessage} from "./message";

export const newFile = (editor?: Editor, callback?: string) => {
if (window.liandi.config.boxes.length === 0) {
showMessage(i18n[window.liandi.config.lang].newFileTip)
return
showMessage(i18n[window.liandi.config.lang].newFileTip);
return;
}

dialog({
Expand Down
6 changes: 3 additions & 3 deletions app/src/websocket/onSetTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export const onSetTheme = (theme:TTheme) => {
} else {
document.body.classList.remove("theme--dark");
}
const models = getAllModels()
const models = getAllModels();
models.editor.forEach((item) => {
item.vditore.setTheme(theme === "dark" ? "dark" : "classic", theme);
});
models.graph.forEach((item) => {
item.onGraph({nodes: item.nodes, links: item.links})
})
item.onGraph({nodes: item.nodes, links: item.links});
});
};

0 comments on commit 6ae884b

Please sign in to comment.