From 990df07d6d0fcb2ebe10820799ae14cefa6bc830 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 24 Mar 2023 15:52:27 +0800 Subject: [PATCH 1/4] :art: https://github.com/siyuan-note/siyuan/issues/7692 --- app/src/protyle/export/index.ts | 65 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts index 89e9170769..6e7653176b 100644 --- a/app/src/protyle/export/index.ts +++ b/app/src/protyle/export/index.ts @@ -117,12 +117,6 @@ const renderPDF = (id: string) => { left: 0; } - #preview > .code-block, - #preview > [data-type="NodeMathBlock"] { - margin-left: auto; - margin-right: auto; - } - #preview.exporting { position: inherit; max-width: none; @@ -136,11 +130,7 @@ const renderPDF = (id: string) => { width: 0; height: 0; } - pre code { - max-height: none !important; - word-break: break-all !important; - white-space: pre-wrap !important; - } + .protyle-wysiwyg { height: 100%; overflow: auto; @@ -237,22 +227,52 @@ const renderPDF = (id: string) => { let pdfLeft = 0; let pdfTop = 0; const previewElement = document.getElementById('preview'); - const setLineNumberWidth = (element) => { + const fixBlockWidth = () => { + const isLandscape = document.querySelector("#landscape").checked; + let width = 800 + switch (document.querySelector("#action #pageSize").value) { + case "A3": + width = isLandscape ? 1587.84 : 1122.24 + break; + case "A4": + width = isLandscape ? 1122.24 : 793.92 + break; + case "A5": + width = isLandscape ? 793.92 : 559.68 + break; + case "Legal": + width = isLandscape ? 1344: 816 + break; + case "Letter": + width = isLandscape ? 1056 : 816 + break; + case "Tabloid": + width = isLandscape ? 1632 : 1056 + break; + } + previewElement.style.width = width + "px"; + width = width - parseFloat(previewElement.style.paddingLeft) * 96 * 2; // 为保持代码块宽度一致,全部都进行宽度设定 https://github.com/siyuan-note/siyuan/issues/7692 previewElement.querySelectorAll('.hljs').forEach((item) => { // 强制换行 https://ld246.com/article/1679228783553 item.parentElement.setAttribute("linewrap", "true"); item.parentElement.style.width = ""; - item.parentElement.style.width = item.parentElement.clientWidth + "px"; + item.parentElement.style.width = Math.min(item.parentElement.clientWidth, width) + "px"; item.removeAttribute('data-render'); }) Protyle.highlightRender(previewElement, "${servePath}/stage/protyle"); previewElement.querySelectorAll('[data-type="NodeMathBlock"]').forEach((item) => { item.style.width = ""; - item.style.width = item.clientWidth + "px"; + item.style.width = Math.min(item.clientWidth, width) + "px"; item.removeAttribute('data-render'); }) Protyle.mathRender(previewElement, "${servePath}/stage/protyle", true); + previewElement.querySelectorAll("table").forEach(item => { + if (item.clientWidth > item.parentElement.clientWidth) { + item.style.zoom = (item.parentElement.clientWidth / item.clientWidth).toFixed(2) - 0.01; + item.parentElement.style.overflow = "hidden"; + } + }) } const setPadding = () => { const isLandscape = document.querySelector("#landscape").checked; @@ -287,12 +307,7 @@ const renderPDF = (id: string) => { } document.getElementById('preview').style.padding = pdfTop + "in " + pdfLeft + "in"; setTimeout(() => { - previewElement.querySelectorAll("table").forEach(item => { - if (item.clientWidth > item.parentElement.clientWidth) { - item.style.zoom = (item.parentElement.clientWidth / item.clientWidth).toFixed(2) - 0.01; - item.parentElement.style.overflow = "hidden"; - } - }) + fixBlockWidth(); }, 300); } const fetchPost = (url, data, cb) => { @@ -314,7 +329,6 @@ const renderPDF = (id: string) => { Protyle.mindmapRender(previewElement, "${servePath}/stage/protyle"); Protyle.abcRender(previewElement, "${servePath}/stage/protyle"); Protyle.plantumlRender(previewElement, "${servePath}/stage/protyle"); - setLineNumberWidth(document.querySelector("#action #pageSize")); } fetchPost("/api/export/exportPreviewHTML", { id: "${id}", @@ -389,9 +403,8 @@ const renderPDF = (id: string) => { actionElement.querySelector("#scale").addEventListener("input", () => { actionElement.querySelector("#scaleTip").innerText = actionElement.querySelector("#scale").value; }) - const pageSizeElement = actionElement.querySelector("#pageSize") - pageSizeElement.addEventListener('change', () => { - setLineNumberWidth(pageSizeElement); + actionElement.querySelector("#pageSize").addEventListener('change', () => { + fixBlockWidth(); }); actionElement.querySelector("#marginsType").addEventListener('change', () => { setPadding(); @@ -428,11 +441,11 @@ const renderPDF = (id: string) => { rootId: "${id}", rootTitle: response.data.name, }) - actionElement.remove(); previewElement.classList.add("exporting"); previewElement.style.paddingTop = "6px"; previewElement.style.paddingBottom = "0"; - setLineNumberWidth(pageSizeElement); + fixBlockWidth(); + actionElement.remove(); }); setPadding(); renderPreview(response.data.content); From 68ccb5e75c7e2ca949b8efcbcc3fa222690c55e2 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 24 Mar 2023 16:20:17 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:memo:=20=E6=94=AF=E6=8C=81=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=86=85=E9=85=8D=E7=BD=AE=E4=BA=BA=E5=B7=A5=E6=99=BA?= =?UTF-8?q?=E8=83=BD=20https://github.com/siyuan-note/siyuan/issues/7714?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230304000547-ibldj1z.sy | 235 ++---------------- .../20230303235619-ex5l63e.sy | 230 ++--------------- .../20230304000829-9jwu3po.sy | 229 ++--------------- 3 files changed, 67 insertions(+), 627 deletions(-) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z.sy index c1d9fae39d..064f8c10d4 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20230304000547-ibldj1z.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20230304000547-ibldj1z", "title": "Artificial Intelligence", - "updated": "20230308213745" + "updated": "20230324161818" }, "Children": [ { @@ -28,12 +28,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213723-q8a5kbd", - "updated": "20230308213723" + "updated": "20230324161738" }, "Children": [ { "Type": "NodeText", - "Data": "Currently only supports text dialogue through " + "Data": "Supports text dialogue through " }, { "Type": "NodeTextMark", @@ -43,7 +43,7 @@ }, { "Type": "NodeText", - "Data": " Chat API, only supported on the desktop." + "Data": " Chat API." } ] }, @@ -70,7 +70,7 @@ }, "Properties": { "id": "20230308213723-r46h6mw", - "updated": "20230308213739" + "updated": "20230324161818" }, "Children": [ { @@ -114,7 +114,7 @@ }, "Properties": { "id": "20230308213723-obctww8", - "updated": "20230308213723" + "updated": "20230324161801" }, "Children": [ { @@ -122,217 +122,30 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213723-rerhr3p", - "updated": "20230308213723" + "updated": "20230324161801" }, "Children": [ { "Type": "NodeText", - "Data": "Configure environment variables" - } - ] - }, - { - "ID": "20230308213723-pyed7a2", - "Type": "NodeList", - "ListData": {}, - "Properties": { - "id": "20230308213723-pyed7a2", - "updated": "20230308213723" - }, - "Children": [ - { - "ID": "20230308213723-lakya6i", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213723-lakya6i", - "updated": "20230308213723" - }, - "Children": [ - { - "ID": "20230308213723-2sruo2o", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213723-2sruo2o", - "updated": "20230308213723" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_KEY" - }, - { - "Type": "NodeText", - "Data": "​ specifies the API Key (required)" - } - ] - } - ] + "Data": "Configure in " }, { - "ID": "20230308213723-5vfosvz", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213723-5vfosvz", - "updated": "20230308213723" - }, - "Children": [ - { - "ID": "20230308213723-cxomjan", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213723-cxomjan", - "updated": "20230308213723" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_TIMEOUT" - }, - { - "Type": "NodeText", - "Data": "​ specifies the timeout time (seconds), the default is 30 seconds (optional)" - } - ] - } - ] + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Settings" }, { - "ID": "20230308213723-fj3oskr", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213723-fj3oskr", - "updated": "20230308213723" - }, - "Children": [ - { - "ID": "20230308213723-pvngelo", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213723-pvngelo", - "updated": "20230308213723" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_PROXY" - }, - { - "Type": "NodeText", - "Data": "​ specifies the proxy, the default is empty, that is, no proxy is used (optional)" - } - ] - } - ] + "Type": "NodeText", + "Data": "​ - " }, { - "ID": "20230308213723-objm7mx", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213723-objm7mx", - "updated": "20230308213723" - }, - "Children": [ - { - "ID": "20230308213723-x64pmnz", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213723-x64pmnz", - "updated": "20230308213723" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_MAX_TOKENS" - }, - { - "Type": "NodeText", - "Data": "​ specifies the number of tokens, the default is 0, that is, the default value of the model is used (optional)" - } - ] - } - ] + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "AI" }, { - "ID": "20230308213723-fi8mg6o", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213723-fi8mg6o", - "updated": "20230308213723" - }, - "Children": [ - { - "ID": "20230308213723-11ww633", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213723-11ww633", - "updated": "20230308213723" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_BASE_URL" - }, - { - "Type": "NodeText", - "Data": "​ specifies the base address of the API server, the default is " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "https://api.openai.com/v1" - }, - { - "Type": "NodeText", - "Data": "​ (optional)" - } - ] - } - ] + "Type": "NodeText", + "Data": "​" } ] } @@ -349,7 +162,7 @@ }, "Properties": { "id": "20230308213723-5m7aqfs", - "updated": "20230308213730" + "updated": "20230324161809" }, "Children": [ { @@ -357,12 +170,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213723-i5y2zf5", - "updated": "20230308213730" + "updated": "20230324161809" }, "Children": [ { "Type": "NodeText", - "Data": "After restarting, you can use " + "Data": "Use " }, { "Type": "NodeTextMark", @@ -388,7 +201,7 @@ }, "Properties": { "id": "20230308213723-la05np0", - "updated": "20230308213739" + "updated": "20230324161818" }, "Children": [ { @@ -396,12 +209,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213723-mjv4wg6", - "updated": "20230308213739" + "updated": "20230324161818" }, "Children": [ { "Type": "NodeText", - "Data": "You can also perform more operations through the block menu " + "Data": "Perform more operations through the block menu " }, { "Type": "NodeTextMark", diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e.sy index afa62f1813..9724b4a8de 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20230303235619-ex5l63e.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20230303235619-ex5l63e", "title": "人工智能", - "updated": "20230308213530" + "updated": "20230324161605" }, "Children": [ { @@ -28,12 +28,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230303235639-lx58u3y", - "updated": "20230304000315" + "updated": "20230324161449" }, "Children": [ { "Type": "NodeText", - "Data": "目前仅支持通过 " + "Data": "通过 " }, { "Type": "NodeTextMark", @@ -43,7 +43,7 @@ }, { "Type": "NodeText", - "Data": " Chat API 实现文本对话,仅在桌面端支持。" + "Data": " Chat API 实现文本对话。" } ] }, @@ -70,7 +70,7 @@ }, "Properties": { "id": "20230303235749-kurfjky", - "updated": "20230308213454" + "updated": "20230324161605" }, "Children": [ { @@ -114,7 +114,7 @@ }, "Properties": { "id": "20230303235819-0o648f9", - "updated": "20230305102554" + "updated": "20230324161532" }, "Children": [ { @@ -122,216 +122,30 @@ "Type": "NodeParagraph", "Properties": { "id": "20230303235819-87dmjqq", - "updated": "20230303235822" + "updated": "20230324161532" }, "Children": [ { "Type": "NodeText", - "Data": "配置环境变量" - } - ] - }, - { - "ID": "20230303235950-z00ou0r", - "Type": "NodeList", - "ListData": {}, - "Properties": { - "id": "20230303235950-z00ou0r", - "updated": "20230305102554" - }, - "Children": [ - { - "ID": "20230303235950-3rcai2b", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230303235950-3rcai2b", - "updated": "20230303235950" - }, - "Children": [ - { - "ID": "20230303235950-4femf1q", - "Type": "NodeParagraph", - "Properties": { - "id": "20230303235950-4femf1q", - "updated": "20230303235950" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_KEY" - }, - { - "Type": "NodeText", - "Data": "​​ 指定 API Key(必须)" - } - ] - } - ] + "Data": "在 " }, { - "ID": "20230303235950-l6o3a5a", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230303235950-l6o3a5a", - "updated": "20230305102554" - }, - "Children": [ - { - "ID": "20230303235950-zfhft7e", - "Type": "NodeParagraph", - "Properties": { - "id": "20230303235950-zfhft7e", - "updated": "20230305102554" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_TIMEOUT" - }, - { - "Type": "NodeText", - "Data": "​​ 指定超时时间(秒),默认为 30 秒(可选)" - } - ] - } - ] + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "设置" }, { - "ID": "20230303235950-ukul5sa", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230303235950-ukul5sa", - "updated": "20230303235950" - }, - "Children": [ - { - "ID": "20230303235950-7srjdql", - "Type": "NodeParagraph", - "Properties": { - "id": "20230303235950-7srjdql", - "updated": "20230303235950" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_PROXY" - }, - { - "Type": "NodeText", - "Data": "​​ 指定代理,默认为空,即不使用代理(可选)" - } - ] - } - ] + "Type": "NodeText", + "Data": "​ - " }, { - "ID": "20230303235950-5y60wvh", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230303235950-5y60wvh", - "updated": "20230304171349" - }, - "Children": [ - { - "ID": "20230303235950-ffevwk8", - "Type": "NodeParagraph", - "Properties": { - "id": "20230303235950-ffevwk8", - "updated": "20230304171349" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_MAX_TOKENS" - }, - { - "Type": "NodeText", - "Data": "​​​ 指定 tokens 数量,默认为 0,即使用模型默认值(可选)" - } - ] - } - ] + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "AI" }, { - "ID": "20230308213215-ichxvb3", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213215-ichxvb3" - }, - "Children": [ - { - "ID": "20230308213215-uyvki9p", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213215-uyvki9p", - "updated": "20230308213337" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_BASE_URL" - }, - { - "Type": "NodeText", - "Data": "​ 指定 API 服务端基础地址,默认为 " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "https://api.openai.com/v1" - }, - { - "Type": "NodeText", - "Data": "​(可选)" - } - ] - } - ] + "Type": "NodeText", + "Data": "​ 中进行相关配置" } ] } @@ -348,7 +162,7 @@ }, "Properties": { "id": "20230303235958-fxi5kan", - "updated": "20230308213418" + "updated": "20230324161605" }, "Children": [ { @@ -356,12 +170,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230303235958-1ksxnm3", - "updated": "20230308213418" + "updated": "20230324161605" }, "Children": [ { "Type": "NodeText", - "Data": "重启后即可使用 " + "Data": "使用 " }, { "Type": "NodeTextMark", @@ -370,7 +184,7 @@ }, { "Type": "NodeText", - "Data": "​​ 唤起对话框,输入提问或者需求后确认" + "Data": "​ 唤起对话框,输入提问或者需求后确认" } ] } diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po.sy index 4f18a78fe8..40c8184f82 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20230304000829-9jwu3po.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20230304000829-9jwu3po", "title": "人工智能", - "updated": "20230308213648" + "updated": "20230324161714" }, "Children": [ { @@ -28,12 +28,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213628-td1ykoz", - "updated": "20230308213628" + "updated": "20230324161633" }, "Children": [ { "Type": "NodeText", - "Data": "目前僅支持通過 " + "Data": "支持通過 " }, { "Type": "NodeTextMark", @@ -43,7 +43,7 @@ }, { "Type": "NodeText", - "Data": " Chat API 實現文本對話,僅在桌面端支持。" + "Data": " Chat API 實現文本對話。" } ] }, @@ -70,7 +70,7 @@ }, "Properties": { "id": "20230308213628-fkt9ihv", - "updated": "20230308213648" + "updated": "20230324161714" }, "Children": [ { @@ -114,7 +114,7 @@ }, "Properties": { "id": "20230308213628-2bnvc4r", - "updated": "20230308213628" + "updated": "20230324161706" }, "Children": [ { @@ -122,217 +122,30 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213628-m4d5rpm", - "updated": "20230308213628" + "updated": "20230324161706" }, "Children": [ { "Type": "NodeText", - "Data": "配置環境變量" - } - ] - }, - { - "ID": "20230308213628-qpozqny", - "Type": "NodeList", - "ListData": {}, - "Properties": { - "id": "20230308213628-qpozqny", - "updated": "20230308213628" - }, - "Children": [ - { - "ID": "20230308213628-2vi7j3h", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213628-2vi7j3h", - "updated": "20230308213628" - }, - "Children": [ - { - "ID": "20230308213628-tmkbk2e", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213628-tmkbk2e", - "updated": "20230308213628" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_KEY" - }, - { - "Type": "NodeText", - "Data": "​ 指定 API Key(必須)" - } - ] - } - ] + "Data": "在 " }, { - "ID": "20230308213628-1desi9f", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213628-1desi9f", - "updated": "20230308213628" - }, - "Children": [ - { - "ID": "20230308213628-sk97619", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213628-sk97619", - "updated": "20230308213628" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_TIMEOUT" - }, - { - "Type": "NodeText", - "Data": "​ 指定超時時間(秒),默認為 30 秒(可選)" - } - ] - } - ] + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "設置" }, { - "ID": "20230308213628-4jq7xca", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213628-4jq7xca", - "updated": "20230308213628" - }, - "Children": [ - { - "ID": "20230308213628-k0f3rx6", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213628-k0f3rx6", - "updated": "20230308213628" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_PROXY" - }, - { - "Type": "NodeText", - "Data": "​ 指定代理,默認為空,即不使用代理(可選)" - } - ] - } - ] + "Type": "NodeText", + "Data": "​ - " }, { - "ID": "20230308213628-hn7rn67", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213628-hn7rn67", - "updated": "20230308213628" - }, - "Children": [ - { - "ID": "20230308213628-iqb8u0o", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213628-iqb8u0o", - "updated": "20230308213628" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_MAX_TOKENS" - }, - { - "Type": "NodeText", - "Data": "​ 指定 tokens 數量,默認為 0,即使用模型默認值(可選)" - } - ] - } - ] + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "AI" }, { - "ID": "20230308213628-lt8tt00", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20230308213628-lt8tt00", - "updated": "20230308213628" - }, - "Children": [ - { - "ID": "20230308213628-knxr1iu", - "Type": "NodeParagraph", - "Properties": { - "id": "20230308213628-knxr1iu", - "updated": "20230308213628" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "SIYUAN_OPENAI_API_BASE_URL" - }, - { - "Type": "NodeText", - "Data": "​ 指定 API 服務端基礎地址,默認為 " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "https://api.openai.com/v1" - }, - { - "Type": "NodeText", - "Data": "​(可選)" - } - ] - } - ] + "Type": "NodeText", + "Data": "​ 中進行相關配置" } ] } @@ -349,7 +162,7 @@ }, "Properties": { "id": "20230308213628-x6hemjt", - "updated": "20230308213642" + "updated": "20230324161714" }, "Children": [ { @@ -357,12 +170,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20230308213628-hqonun0", - "updated": "20230308213642" + "updated": "20230324161714" }, "Children": [ { "Type": "NodeText", - "Data": "重啟後即可使用 " + "Data": "使用 " }, { "Type": "NodeTextMark", From 7c7b649923f56f781f2af9ad0582c99748796f5f Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 24 Mar 2023 16:37:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?:bug:=20=E5=B5=8C=E5=85=A5=E5=9D=97=20SQL?= =?UTF-8?q?=20=E8=84=9A=E6=9C=AC=E4=B8=AD=E5=AD=98=E5=9C=A8=E6=8D=A2?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E6=97=A0=E6=B3=95=E5=AF=BC=E5=87=BA=20Fix=20?= =?UTF-8?q?https://github.com/siyuan-note/siyuan/issues/7771?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/export.go | 2 ++ kernel/model/render.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/kernel/model/export.go b/kernel/model/export.go index 3a4c17b5a5..4ef74b48d3 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -1561,6 +1561,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool, var defMd string stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr() stmt = html.UnescapeString(stmt) + stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n") embedBlocks := searchEmbedBlock(n.ID, stmt, nil, 0, false) if 1 > len(embedBlocks) { return ast.WalkContinue @@ -1875,6 +1876,7 @@ func resolveFootnotesDefs(refFootnotes *[]*refAsFootnotes, rootID string, blockR } else if ast.NodeBlockQueryEmbed == n.Type { stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr() stmt = html.UnescapeString(stmt) + stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n") sqlBlocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit) for _, b := range sqlBlocks { subNodes := renderBlockMarkdownR0(b.ID, &rendered) diff --git a/kernel/model/render.go b/kernel/model/render.go index 10198ea25f..1c9ccc3bd4 100644 --- a/kernel/model/render.go +++ b/kernel/model/render.go @@ -18,6 +18,7 @@ package model import ( "bytes" + "github.com/88250/lute/editor" "regexp" "strings" @@ -203,6 +204,7 @@ func renderBlockMarkdownR0(id string, rendered *[]string) (ret []*ast.Node) { if ast.NodeBlockQueryEmbed == n.Type { stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr() stmt = html.UnescapeString(stmt) + stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n") sqlBlocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit) for _, sqlBlock := range sqlBlocks { subNodes := renderBlockMarkdownR0(sqlBlock.ID, rendered) From 4ca9c0f57a3ead1d45582e404a54812116db14a8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 24 Mar 2023 16:54:02 +0800 Subject: [PATCH 4/4] :art: fix https://github.com/siyuan-note/siyuan/issues/7746 --- app/src/protyle/toolbar/index.ts | 63 +++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index fc3039058d..12a30f08a3 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -41,6 +41,7 @@ import {InlineMemo} from "./InlineMemo"; import {mathRender} from "../markdown/mathRender"; import {linkMenu} from "../../menus/protyle"; import {addScript} from "../util/addScript"; +import {confirmDialog} from "../../dialog/confirmDialog"; export class Toolbar { public element: HTMLElement; @@ -1333,12 +1334,13 @@ export class Toolbar { html += `
${item.content}`; /// #if !BROWSER - html += ` + html += ` -
`; - /// #else - html += ""; +`; /// #endif + html += ` + +`; }); if (html === "") { html = `
  • ${window.siyuan.languages.emptyContent}
  • `; @@ -1360,14 +1362,20 @@ export class Toolbar { `; const listElement = this.subElement.querySelector(".b3-list"); const previewElement = this.subElement.firstElementChild.lastElementChild; - previewTemplate(listElement.firstElementChild.getAttribute("data-value"), previewElement, protyle.block.parentID); + let previewPath = listElement.firstElementChild.getAttribute("data-value") + previewTemplate(previewPath, previewElement, protyle.block.parentID); listElement.addEventListener("mouseover", (event) => { const target = event.target as HTMLElement; const hoverItemElement = hasClosestByClassName(target, "b3-list-item"); if (!hoverItemElement) { return; } - previewTemplate(hoverItemElement.getAttribute("data-value"), previewElement, protyle.block.parentID); + const currentPath = hoverItemElement.getAttribute("data-value") + if (previewPath === currentPath) { + return; + } + previewPath = currentPath + previewTemplate(previewPath, previewElement, protyle.block.parentID); }); const inputElement = this.subElement.querySelector("input"); inputElement.addEventListener("keydown", (event: KeyboardEvent) => { @@ -1379,7 +1387,12 @@ export class Toolbar { if (!isEmpty) { const currentElement = upDownHint(listElement, event); if (currentElement) { - previewTemplate(currentElement.getAttribute("data-value"), previewElement, protyle.block.parentID); + const currentPath = currentElement.getAttribute("data-value") + if (previewPath === currentPath) { + return; + } + previewPath = currentPath + previewTemplate(previewPath, previewElement, protyle.block.parentID); } } if (event.key === "Enter") { @@ -1405,7 +1418,12 @@ export class Toolbar { searchHTML += `
    ${item.content}
    `; }); listElement.innerHTML = searchHTML || `
  • ${window.siyuan.languages.emptyContent}
  • `; - previewTemplate(response.data.blocks[0]?.path, previewElement, protyle.block.parentID); + const currentPath = response.data.blocks[0]?.path + if (previewPath === currentPath) { + return; + } + previewPath = currentPath + previewTemplate(previewPath, previewElement, protyle.block.parentID); }); }); this.subElement.lastElementChild.addEventListener("click", (event) => { @@ -1416,14 +1434,38 @@ export class Toolbar { event.stopPropagation(); return; } - /// #if !BROWSER const iconElement = hasClosestByClassName(target, "b3-list-item__action"); - if (iconElement) { + /// #if !BROWSER + if (iconElement && iconElement.getAttribute("data-type") === "open") { openBy(iconElement.parentElement.getAttribute("data-value"), "folder"); event.stopPropagation(); return; } /// #endif + if (iconElement && iconElement.getAttribute("data-type") === "remove") { + confirmDialog(window.siyuan.languages.remove, window.siyuan.languages.confirmDelete + "?", () => { + fetchPost("/api/search/removeTemplate", {path: iconElement.parentElement.getAttribute("data-value")}, () => { + if (iconElement.parentElement.parentElement.childElementCount === 1) { + iconElement.parentElement.parentElement.innerHTML = `
  • ${window.siyuan.languages.emptyContent}
  • `; + previewTemplate("", previewElement, protyle.block.parentID); + } else { + if (iconElement.parentElement.classList.contains("b3-list-item--focus")) { + const sideElement = iconElement.parentElement.previousElementSibling || iconElement.parentElement.nextElementSibling; + sideElement.classList.add("b3-list-item--focus"); + const currentPath = sideElement.getAttribute("data-value") + if (previewPath === currentPath) { + return; + } + previewPath = currentPath + previewTemplate(previewPath, previewElement, protyle.block.parentID); + } + iconElement.parentElement.remove(); + } + }); + }); + event.stopPropagation(); + return; + } const previousElement = hasClosestByAttribute(target, "data-type", "previous"); if (previousElement) { inputElement.dispatchEvent(new KeyboardEvent("keydown", {key: "ArrowUp"})); @@ -1446,6 +1488,7 @@ export class Toolbar { this.subElement.classList.remove("fn__none"); this.subElementCloseCB = undefined; setPosition(this.subElement, rangePosition.left, rangePosition.top + 18, Constants.SIZE_TOOLBAR_HEIGHT); + (this.subElement.firstElementChild as HTMLElement).style.maxHeight = (window.innerHeight - this.subElement.getBoundingClientRect().top - 16) + "px"; this.element.classList.add("fn__none"); inputElement.select(); });