Skip to content

Commit

Permalink
Merge pull request #622 from Hi-Windom/v0.28
Browse files Browse the repository at this point in the history
V0.28
  • Loading branch information
Soltus authored Apr 9, 2024
2 parents c21761f + c84a7e5 commit cea026d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sillot",
"version": "0.28.23",
"version": "0.28.24",
"syv": "3.0.8",
"sypv": "[3.0.7, 3.0.6]",
"description": "Build Your Eternal Digital Garden",
Expand Down
2 changes: 1 addition & 1 deletion app/src/protyle/util/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const openByMobile = (uri: string, from?: string) => {
if (!existingUri) {
toolbarConsole.classList.add("fn__none");
toolbarOpenBy.classList.remove("fn__none");

toolbarOpenBy.removeAttribute("data-refBlockId"); // 避免冲突
toolbarOpenBy.addEventListener("click", () => {
toolbarOpenBy.classList.add("fn__none");
toolbarConsole.classList.remove("fn__none");
Expand Down
62 changes: 59 additions & 3 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2005,9 +2005,63 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table
}
checkFold(refBlockId, (zoomIn, action) => {
/// #if MOBILE
openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
hideKeyboardToolbar();
console.warn(`refBlockId : ${refBlockId}`); // 文档中直接点击双链
const toolbarOpenBy = document.querySelector("#toolbarOpenBy");
const toolbarConsole = document.querySelector("#toolbarConsole");
if (toolbarOpenBy && toolbarConsole) {
const existingUri = toolbarOpenBy.getAttribute("data-refBlockId");

// 只有在首次调用时才更新uri和绑定事件
if (!existingUri) {
toolbarConsole.classList.add("fn__none");
toolbarOpenBy.classList.remove("fn__none");
toolbarOpenBy.removeAttribute("data-uri"); // 避免冲突
toolbarOpenBy.addEventListener("click", () => {
toolbarOpenBy.classList.add("fn__none");
toolbarConsole.classList.remove("fn__none");
const updatedUri = toolbarOpenBy.getAttribute("data-refBlockId");
if (updatedUri) {
console.warn(`refBlockId : ${updatedUri} -> openMobileFileById() ? (toolbarOpenBy && toolbarConsole)`);
toolbarOpenBy.removeAttribute("data-refBlockId");
openMobileFileById(protyle.app, updatedUri, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
hideKeyboardToolbar();
}
});

// 更新"data-refBlockId"值
toolbarOpenBy.setAttribute("data-refBlockId", refBlockId);
if (
!toolbarOpenBy.classList.contains("flash-blue")
) {
toolbarOpenBy.classList.add("flash-blue");
setTimeout(() => {
toolbarOpenBy.classList.remove("flash-blue");
}, 200);
}
} else {
// 更新"data-refBlockId"值
toolbarOpenBy.setAttribute("data-refBlockId", refBlockId);
if (
!toolbarOpenBy.classList.contains("flash-blue")
) {
toolbarOpenBy.classList.add("flash-blue");
setTimeout(() => {
toolbarOpenBy.classList.remove("flash-blue");
}, 200);
}
}
} else {
// 如果找不到元素,则直接调用
toolbarOpenBy.removeAttribute("data-refBlockId");
console.warn(`refBlockId : ${refBlockId} -> openMobileFileById() ? not(toolbarOpenBy && toolbarConsole)`);
openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
hideKeyboardToolbar();
}
// openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
// activeBlur();
// hideKeyboardToolbar();
/// #else
if (event.shiftKey) {
openFileById({
Expand Down Expand Up @@ -2070,6 +2124,7 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table
excludeIDs: [blockElement.getAttribute("data-node-id")]
}, (response) => {
checkFold(response.data[0], (zoomIn) => {
console.warn(`response.data[0] : ${response.data[0]}`);
openMobileFileById(protyle.app, response.data[0], zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
hideKeyboardToolbar();
Expand Down Expand Up @@ -2189,6 +2244,7 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table
const embedId = embedItemElement.getAttribute("data-id");
checkFold(embedId, (zoomIn, action) => {
/// #if MOBILE
console.warn(`embedId : ${embedId}`);
openMobileFileById(protyle.app, embedId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
hideKeyboardToolbar();
Expand Down

0 comments on commit cea026d

Please sign in to comment.