Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/ci-win/siyuan into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/dockerimage.yml
#	app/package.json
#	kernel/go.mod
#	kernel/go.sum
#	kernel/util/working.go
  • Loading branch information
Soltus committed Apr 4, 2023
2 parents ab59988 + cbddfb1 commit 5db71dd
Show file tree
Hide file tree
Showing 26 changed files with 263 additions and 80,515 deletions.
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
## v2.8.3 / 2023-04-04

### Enhancement

* [PDF export supports setting footer template](https://github.com/siyuan-note/siyuan/issues/7478)
* [Improve the style of the slash menu on the mobile](https://github.com/siyuan-note/siyuan/issues/7596)
* [Slide and pull out the left and right panel on the mobile](https://github.com/siyuan-note/siyuan/issues/7688)
* [macOS support `⌥[` to enter default characters when no text is selected](https://github.com/siyuan-note/siyuan/issues/7721)
* [Improve virtual reference split words](https://github.com/siyuan-note/siyuan/issues/7833)
* [Remove the footer `Export by SiYuan` when exporting image and PDF ](https://github.com/siyuan-note/siyuan/issues/7838)
* [Android check WebView version 75+](https://github.com/siyuan-note/siyuan/issues/7840)
* [Flashcard new/review card limit support configure to 0](https://github.com/siyuan-note/siyuan/issues/7841)
* [Remove `/` or `` when trigger AI Chat](https://github.com/siyuan-note/siyuan/issues/7845)
* [Support scaling when exporting pdf preview](https://github.com/siyuan-note/siyuan/issues/7850)
* [Browser web clipper extension show tip while clipping images](https://github.com/siyuan-note/siyuan/issues/7851)
* [Improve the menu style of the doc tree on the mobile](https://github.com/siyuan-note/siyuan/issues/7852)
* [After opening the doc on the mobile, the editor is no longer focused to avoid the pop-up of the soft keyboard](https://github.com/siyuan-note/siyuan/issues/7853)
* [Spaced repetition supports full screen mode](https://github.com/siyuan-note/siyuan/issues/7855)
* [Create a new document from the search field](https://github.com/siyuan-note/siyuan/issues/7860)
* [Prompt to search for the most recently updated block when the search keyword is empty](https://github.com/siyuan-note/siyuan/issues/7862)
* [Add interaction tips at the bottom of the search dialog](https://github.com/siyuan-note/siyuan/issues/7863)
* [Search replace generate file history](https://github.com/siyuan-note/siyuan/issues/7864)
* [The merged cells of the table no longer add a space at the end](https://github.com/siyuan-note/siyuan/issues/7866)

### Bugfix

* [PDF annotation do not follow zoom](https://github.com/siyuan-note/siyuan/issues/7740)
* [Data synchronization online check not using configured endpoint](https://github.com/siyuan-note/siyuan/issues/7831)
* [API getFile/putFile does not perform read-write lock](https://github.com/siyuan-note/siyuan/issues/7832)
* [Focused heading block export does not contain its following blocks](https://github.com/siyuan-note/siyuan/issues/7834)
* [Related PDF annotation information is not exported when exporting .sy.zip](https://github.com/siyuan-note/siyuan/issues/7836)
* [Markdown hyperlink parsing exception when using API `/api/block/*` to upsert block](https://github.com/siyuan-note/siyuan/issues/7846)
* [Exporting PDF hangs after focusing heading block](https://github.com/siyuan-note/siyuan/issues/7848)
* [The editor has not been closed after closing notebook or deleting doc on the mobile](https://github.com/siyuan-note/siyuan/issues/7854)
* [The search fails in REGEXP/SQL with order by relevance](https://github.com/siyuan-note/siyuan/issues/7861)
* [Group by Document Replace exceptions in some cases](https://github.com/siyuan-note/siyuan/issues/7865)
* [Escape character `\` were not handled correctly when importing Markdown](https://github.com/siyuan-note/siyuan/issues/7867)
* [Click search from the doc tree, pressing `Del` in the editor will delete the doc](https://github.com/siyuan-note/siyuan/issues/7868)
* [Can't choose scale in PDF](https://github.com/siyuan-note/siyuan/issues/7869)

### Refactor

* [Improve copy file stability](https://github.com/siyuan-note/siyuan/issues/7837)
* [Upgrade PDF.js](https://github.com/siyuan-note/siyuan/issues/7874)

### Development

* [Attribute View refresh data table queue](https://github.com/siyuan-note/siyuan/issues/7546)

## v2.8.2 / 2023-03-30

### Enhancement
Expand Down
2 changes: 1 addition & 1 deletion app/appx/AppxManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity Name="89C2A984.SiYuan"
ProcessorArchitecture="x64"
Publisher='CN=087C656E-C1D9-42D8-8807-CED45A74FC0F'
Version="2.8.2.0"/>
Version="2.8.3.0"/>
<Properties>
<DisplayName>SiYuan</DisplayName>
<PublisherDisplayName>云南链滴科技有限公司</PublisherDisplayName>
Expand Down
5 changes: 5 additions & 0 deletions app/src/asset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ export class Asset extends Model {
<input id="editorInkColor">
<input id="editorInkThickness">
<input id="editorInkOpacity">
<input id="download">
<input id="secondaryDownload">
<input id="editorFreeText">
<input id="openFile">
<input id="editorInk">
</div>
</div> <!-- outerContainer -->
<div id="printContainer"></div>`;
Expand Down
94 changes: 45 additions & 49 deletions app/src/asset/pdf/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class PDFViewerApplication {
get loadingBar() {
// NOTE
const bar = new ProgressBar(this.appConfig.appContainer.querySelector("#loadingBar"))
return shadow(this, 'loadingBar', bar)
return shadow(this, "loadingBar", bar);
}

get supportedMouseWheelZoomModifierKeys() {
Expand Down Expand Up @@ -894,7 +894,11 @@ class PDFViewerApplication {
}
// Set the necessary API parameters, using all the available options.
const apiParams = AppOptions.getAll(OptionKind.API);
const params = { ...apiParams, ...args };
const params = {
canvasMaxAreaInBytes: this.externalServices.canvasMaxAreaInBytes,
...apiParams,
...args,
};

if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
params.docBaseUrl ||= document.URL.split("#")[0];
Expand Down Expand Up @@ -930,18 +934,18 @@ class PDFViewerApplication {
return undefined; // Ignore errors for previously opened PDF files.
}

// NOTE
let key = 'loadingError'
let key = "loadingError";
if (reason instanceof InvalidPDFException) {
key = 'invalidFileError'
key = "invalidFileError";
} else if (reason instanceof MissingPDFException) {
key = 'missingFileError'
key = "missingFileError";
} else if (reason instanceof UnexpectedResponseException) {
key = 'unexpectedResponseError'
key = "unexpectedResponseError";
}
// NOTE
this._documentError(window.siyuan.languages[key], {message: reason?.message})
throw reason
},
}
);
}

Expand Down Expand Up @@ -1114,20 +1118,17 @@ class PDFViewerApplication {
this.toolbar?.setPagesCount(pdfDocument.numPages, false);
this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);

let baseDocumentUrl;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
baseDocumentUrl = null;
} else if (PDFJSDev.test("MOZCENTRAL")) {
baseDocumentUrl = this.baseUrl;
} else if (PDFJSDev.test("CHROME")) {
baseDocumentUrl = location.href.split("#")[0];
}
if (baseDocumentUrl && isDataScheme(baseDocumentUrl)) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
const baseUrl = location.href.split("#")[0];
// Ignore "data:"-URLs for performance reasons, even though it may cause
// internal links to not work perfectly in all cases (see bug 1803050).
baseDocumentUrl = null;
this.pdfLinkService.setDocument(
pdfDocument,
isDataScheme(baseUrl) ? null : baseUrl
);
} else {
this.pdfLinkService.setDocument(pdfDocument);
}
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
this.pdfDocumentProperties?.setDocument(pdfDocument);

const pdfViewer = this.pdfViewer;
Expand Down Expand Up @@ -2121,7 +2122,7 @@ async function loadFakeWorker() {

if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
// NOTE
window.pdfjsWorker = await import(`${Constants.PROTYLE_CDN}/js/pdf/pdf.worker.js?v=3.4.120`)
window.pdfjsWorker = await import(`${Constants.PROTYLE_CDN}/js/pdf/pdf.worker.js?v=3.5.141`)
return;
}
await loadScript(PDFWorker.workerSrc);
Expand Down Expand Up @@ -2202,23 +2203,19 @@ function webViewerInitialized(pdf) {

if (!pdf.supportsDocumentFonts) {
AppOptions.set("disableFontFace", true);
// NOTE
console.warn('Web fonts are disabled: unable to use embedded PDF fonts.')
}

if (!pdf.supportsPrinting) {
// NOTE
appConfig.toolbar?.print.classList.add("fn__hidden");
appConfig.secondaryToolbar?.printButton.classList.add("fn__hidden");
}

if (!pdf.supportsFullscreen) {
// NOTE
appConfig.secondaryToolbar?.presentationModeButton.classList.add("fn__hidden");
}

if (pdf.supportsIntegratedFind) {
// NOTE
appConfig.toolbar?.viewFind.classList.add("fn__hidden");
}

Expand Down Expand Up @@ -2488,23 +2485,21 @@ function webViewerHashchange(evt) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
// eslint-disable-next-line no-var
var webViewerFileInputChange = function (evt) {
// NOTE
// if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
// return; // Opening a new PDF file isn't supported in Presentation Mode.
// }
// const file = evt.fileInput.files[0];
//
// PDFViewerApplication.open({
// url: URL.createObjectURL(file),
// originalUrl: file.name,
// });
if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
return; // Opening a new PDF file isn't supported in Presentation Mode.
}
const file = evt.fileInput.files[0];

PDFViewerApplication.open({
url: URL.createObjectURL(file),
originalUrl: file.name,
});
};

// eslint-disable-next-line no-var
var webViewerOpenFile = function (evt) {
// NOTE
// const fileInput = PDFViewerApplication.appConfig.openFileInput;
// fileInput.click();
const fileInput = PDFViewerApplication.appConfig.openFileInput;
fileInput.click();
};
}

Expand Down Expand Up @@ -2640,12 +2635,12 @@ function webViewerPageNumberChanged(evt) {
// Ensure that the page number input displays the correct value, even if the
// value entered by the user was invalid (e.g. a floating point number).
if (
evt.value !== pdfViewer.currentPageNumber.toString() &&
evt.value !== pdfViewer.currentPageLabel
evt.value !== pdfViewer.currentPageNumber.toString() &&
evt.value !== pdfViewer.currentPageLabel
) {
pdfInstance.toolbar?.setPageNumber(
pdfViewer.currentPageNumber,
pdfViewer.currentPageLabel
pdfViewer.currentPageNumber,
pdfViewer.currentPageLabel
);
}
}
Expand Down Expand Up @@ -3102,7 +3097,7 @@ function webViewerTouchMove(evt) {
}
}

pdfInstance._centerAtPos(
PDFViewerApplication._centerAtPos(
previousScale,
(page0X + page1X) / 2,
(page0Y + page1Y) / 2
Expand Down Expand Up @@ -3132,8 +3127,8 @@ function webViewerClick(evt) {
return
}

// 点击后证快捷键可正常使用,select 也可正常使用 https://github.com/siyuan-note/siyuan/issues/7869
if (evt.target.tagName !== "SELECT") {
// 点击后证快捷键可正常使用,select 等也可正常使用 https://github.com/siyuan-note/siyuan/issues/7869
if (!["SELECT", "TEXTAREA", "INPUT"].includes(evt.target.tagName)) {
pdfInstance.pdfViewer.focus();
}

Expand All @@ -3142,9 +3137,9 @@ function webViewerClick(evt) {
}
const appConfig = pdfInstance.appConfig;
if (
pdfInstance.pdfViewer.containsElement(evt.target) ||
(appConfig.toolbar?.container.contains(evt.target) &&
!appConfig.secondaryToolbar.toggleButton.contains(evt.target)) // NOTE
pdfInstance.pdfViewer.containsElement(evt.target) ||
(appConfig.toolbar?.container.contains(evt.target) &&
!appConfig.secondaryToolbar.toggleButton.contains(evt.target)) // NOTE
) {
pdfInstance.secondaryToolbar.close();
}
Expand All @@ -3160,6 +3155,7 @@ function webViewerKeyUp(evt) {
if (evt.key === "Control") {
pdfInstance._isCtrlKeyDown = false;
}
// 快捷键高亮取消
if (evt.keyCode === 68 && pdfInstance.appConfig.toolbar.rectAnno.classList.contains('toggled')) {
pdfInstance.appConfig.toolbar.rectAnno.dispatchEvent(
new MouseEvent('click'))
Expand Down Expand Up @@ -3260,7 +3256,7 @@ function webViewerKeyDown(evt) {
isViewerInPresentationMode ||
pdfInstance.page < pdfInstance.pagesCount
) {
pdfInstance.page = pdfInstance.pagesCount;
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
handled = true;
ensureViewerFocused = true;
}
Expand Down Expand Up @@ -3519,9 +3515,9 @@ const PDFPrintServiceFactory = {
},
};

// NOTE
export {
PDFPrintServiceFactory,
PDFViewerApplication,
// NOTE
webViewerPageNumberChanged,
};
2 changes: 1 addition & 1 deletion app/src/asset/pdf/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const defaultOptions = {
workerSrc: {
/** @type {string} */
// NOTE
value: `${Constants.PROTYLE_CDN}/js/pdf/pdf.worker.js?v=3.4.120`,
value: `${Constants.PROTYLE_CDN}/js/pdf/pdf.worker.js?v=3.5.141`,
kind: OptionKind.WORKER,
},
};
Expand Down
2 changes: 1 addition & 1 deletion app/src/asset/pdf/l10n_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function formatL10nValue(text, args) {
if (!args) {
return text;
}
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
return name in args ? args[name] : "{{" + name + "}}";
});
}
Expand Down
19 changes: 12 additions & 7 deletions app/src/asset/pdf/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,26 @@ function normalize(text) {
// "X-\n" is removed because an hyphen at the end of a line
// with not a space before is likely here to mark a break
// in a word.
// The \n isn't in the original text so here y = i, n = 1 and o = 2.
positions.push([i - shift + 1, 1 + shift]);
// If X is encoded with UTF-32 then it can have a length greater than 1.
// The \n isn't in the original text so here y = i, n = X.len - 2 and
// o = X.len - 1.
const len = p5.length - 2;
positions.push([i - shift + len, 1 + shift]);
shift += 1;
shiftOrigin += 1;
eol += 1;
return p5.charAt(0);
return p5.slice(0, -2);
}

if (p6) {
// An ideographic at the end of a line doesn't imply adding an extra
// white space.
positions.push([i - shift + 1, shift]);
// A CJK can be encoded in UTF-32, hence their length isn't always 1.
const len = p6.length - 1;
positions.push([i - shift + len, shift]);
shiftOrigin += 1;
eol += 1;
return p6.charAt(0);
return p6.slice(0, -1);
}

if (p7) {
Expand Down Expand Up @@ -364,7 +369,7 @@ function getOriginalIndex(diffs, pos, len) {
* @typedef {Object} PDFFindControllerOptions
* @property {IPDFLinkService} linkService - The navigation/linking service.
* @property {EventBus} eventBus - The application event bus.
* @property {boolean} updateMatchesCountOnProgress - True if the matches
* @property {boolean} [updateMatchesCountOnProgress] - True if the matches
* count must be updated on progress or only when the last page is reached.
* The default value is `true`.
*/
Expand Down Expand Up @@ -658,7 +663,7 @@ class PDFFindController {
#convertToRegExpString(query, hasDiacritics) {
const { matchDiacritics } = this._state;
let isUnicode = false;
query = query.replace(
query = query.replaceAll(
SPECIAL_CHARS_REG_EXP,
(
match,
Expand Down
4 changes: 2 additions & 2 deletions app/src/asset/pdf/pdf_link_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class PDFLinkService {
* @returns {string} The hyperlink to the PDF object.
*/
getAnchorUrl(anchor) {
return (this.baseUrl || "") + anchor;
return this.baseUrl ? this.baseUrl + anchor : anchor;
}

/**
Expand All @@ -352,7 +352,7 @@ class PDFLinkService {
if (params.has("search")) {
this.eventBus.dispatch("findfromurlhash", {
source: this,
query: params.get("search").replace(/"/g, ""),
query: params.get("search").replaceAll('"', ""),
phraseSearch: params.get("phrase") === "true",
});
}
Expand Down
Loading

0 comments on commit 5db71dd

Please sign in to comment.