mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Improve export PDF window https://github.com/siyuan-note/siyuan/issues/10711
This commit is contained in:
parent
9ff9303672
commit
bdbd7e13c9
2 changed files with 23 additions and 10 deletions
|
|
@ -855,19 +855,32 @@ app.whenReady().then(() => {
|
||||||
}
|
}
|
||||||
data.filePaths = result.filePaths;
|
data.filePaths = result.filePaths;
|
||||||
data.webContentsId = event.sender.id;
|
data.webContentsId = event.sender.id;
|
||||||
getWindowByContentId(event.sender.id).getParentWindow().send("siyuan-export-pdf", data);
|
const wnd = getWindowByContentId(event.sender.id);
|
||||||
|
if (!wnd) {
|
||||||
|
// 文档已经被删除的情况下关闭窗口,下同
|
||||||
|
event.sender.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const parentWnd = wnd.getParentWindow();
|
||||||
|
if (!parentWnd) {
|
||||||
|
event.sender.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentWnd.send("siyuan-export-pdf", data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ipcMain.on("siyuan-export-newwindow", (event, data) => {
|
ipcMain.on("siyuan-export-newwindow", (event, data) => {
|
||||||
const parentWnd = getWindowByContentId(event.sender.id);
|
const parentWnd = getWindowByContentId(event.sender.id);
|
||||||
|
const parentWndBounds = parentWnd.getBounds();
|
||||||
|
const parentWndScreen = screen.getDisplayNearestPoint({x: parentWndBounds.x, y: parentWndBounds.y});
|
||||||
|
parentWndScreen.size.width;
|
||||||
|
|
||||||
// The PDF/Word export preview window automatically adjusts according to the size of the main window https://github.com/siyuan-note/siyuan/issues/10554
|
// The PDF/Word export preview window automatically adjusts according to the size of the main window https://github.com/siyuan-note/siyuan/issues/10554
|
||||||
const printWin = new BrowserWindow({
|
const printWin = new BrowserWindow({
|
||||||
parent: parentWnd,
|
|
||||||
modal: false,
|
|
||||||
show: true,
|
show: true,
|
||||||
width: Math.floor(parentWnd.getBounds().width * 0.8),
|
width: parentWndScreen.size.width * 0.9,
|
||||||
height: Math.floor(parentWnd.getBounds().height * 0.8),
|
height: parentWndScreen.size.height * 0.9,
|
||||||
resizable: false,
|
resizable: true,
|
||||||
frame: "darwin" === process.platform,
|
frame: "darwin" === process.platform,
|
||||||
icon: path.join(appDir, "stage", "icon-large.png"),
|
icon: path.join(appDir, "stage", "icon-large.png"),
|
||||||
titleBarStyle: "hidden",
|
titleBarStyle: "hidden",
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
}
|
}
|
||||||
} else if (tempElement.content.querySelector("table")) {
|
} else if (tempElement.content.querySelector("table")) {
|
||||||
tempElement.content.querySelectorAll("tr").forEach(item => {
|
tempElement.content.querySelectorAll("tr").forEach(item => {
|
||||||
values.push([])
|
values.push([]);
|
||||||
Array.from(item.children).forEach(cell => {
|
Array.from(item.children).forEach(cell => {
|
||||||
values[values.length - 1].push({
|
values[values.length - 1].push({
|
||||||
text: {content: cell.textContent},
|
text: {content: cell.textContent},
|
||||||
|
|
@ -50,7 +50,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
const avID = blockElement.dataset.avId;
|
const avID = blockElement.dataset.avId;
|
||||||
const id = blockElement.dataset.nodeId;
|
const id = blockElement.dataset.nodeId;
|
||||||
let currentRowElement: Element;
|
let currentRowElement: Element;
|
||||||
const firstColIndex = cellElements[0].getAttribute("data-col-id")
|
const firstColIndex = cellElements[0].getAttribute("data-col-id");
|
||||||
values.find(rowItem => {
|
values.find(rowItem => {
|
||||||
if (!currentRowElement) {
|
if (!currentRowElement) {
|
||||||
currentRowElement = cellElements[0].parentElement;
|
currentRowElement = cellElements[0].parentElement;
|
||||||
|
|
@ -63,9 +63,9 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
||||||
let cellElement: HTMLElement;
|
let cellElement: HTMLElement;
|
||||||
rowItem.find(cellValue => {
|
rowItem.find(cellValue => {
|
||||||
if (!cellElement) {
|
if (!cellElement) {
|
||||||
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement
|
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
|
||||||
} else {
|
} else {
|
||||||
cellElement = cellElement.nextElementSibling as HTMLElement
|
cellElement = cellElement.nextElementSibling as HTMLElement;
|
||||||
}
|
}
|
||||||
if (!cellElement.classList.contains("av__cell")) {
|
if (!cellElement.classList.contains("av__cell")) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue