🎨 openfile

This commit is contained in:
Vanessa 2023-05-17 19:14:21 +08:00
parent cc613f7d57
commit fb6b4e48ca
6 changed files with 20 additions and 30 deletions

View File

@ -455,14 +455,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB
} }
/// #if !MOBILE /// #if !MOBILE
if (protyle.breadcrumb) { if (protyle.breadcrumb) {
const exitFocusElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="exit-focus"]'); protyle.breadcrumb.toggleExit(id === protyle.block.rootID)
if (id === protyle.block.rootID) {
exitFocusElement.classList.add("fn__none");
exitFocusElement.nextElementSibling.classList.add("fn__none");
} else {
exitFocusElement.classList.remove("fn__none");
exitFocusElement.nextElementSibling.classList.remove("fn__none");
}
} }
/// #endif /// #endif
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {

View File

@ -82,9 +82,7 @@ export class Breadcrumb {
size: window.siyuan.config.editor.dynamicLoadBlocks, size: window.siyuan.config.editor.dynamicLoadBlocks,
}, getResponse => { }, getResponse => {
onGet(getResponse, protyle, [Constants.CB_GET_HL]); onGet(getResponse, protyle, [Constants.CB_GET_HL]);
const exitFocusElement = this.element.parentElement.querySelector('[data-type="exit-focus"]'); this.toggleExit(true);
exitFocusElement.classList.add("fn__none");
exitFocusElement.nextElementSibling.classList.add("fn__none");
}); });
target.classList.add("block__icon--active"); target.classList.add("block__icon--active");
} }
@ -147,6 +145,17 @@ export class Breadcrumb {
this.mediaRecorder.startRecordingNewWavFile(); this.mediaRecorder.startRecordingNewWavFile();
} }
public toggleExit(hide: boolean) {
const exitFocusElement = this.element.parentElement.querySelector('[data-type="exit-focus"]');
if (hide) {
exitFocusElement.classList.add("fn__none");
exitFocusElement.nextElementSibling.classList.add("fn__none");
} else {
exitFocusElement.classList.remove("fn__none");
exitFocusElement.nextElementSibling.classList.remove("fn__none");
}
}
public showMenu(protyle: IProtyle, position: { x: number, y: number }) { public showMenu(protyle: IProtyle, position: { x: number, y: number }) {
let id; let id;
const cursorNodeElement = hasClosestBlock(getEditorRange(protyle.element).startContainer); const cursorNodeElement = hasClosestBlock(getEditorRange(protyle.element).startContainer);

View File

@ -48,8 +48,9 @@ export class Title {
if (window.siyuan.config.editor.displayBookmarkIcon) { if (window.siyuan.config.editor.displayBookmarkIcon) {
this.element.classList.add("protyle-wysiwyg--attr"); this.element.classList.add("protyle-wysiwyg--attr");
} }
// 标题内需要一个空格,避免首次加载出现`请输入文档名`干扰
this.element.innerHTML = `<span aria-label="${window.siyuan.languages.gutterTip2}" class="protyle-title__icon" data-type="a" data-position="right"><svg><use xlink:href="#iconFile"></use></svg></span> this.element.innerHTML = `<span aria-label="${window.siyuan.languages.gutterTip2}" class="protyle-title__icon" data-type="a" data-position="right"><svg><use xlink:href="#iconFile"></use></svg></span>
<div contenteditable="true" data-position="center" spellcheck="${window.siyuan.config.editor.spellcheck}" class="protyle-title__input" data-tip="${window.siyuan.languages._kernel[16]}"></div><div class="protyle-attr"></div>`; <div contenteditable="true" data-position="center" spellcheck="${window.siyuan.config.editor.spellcheck}" class="protyle-title__input" data-tip="${window.siyuan.languages._kernel[16]}"> </div><div class="protyle-attr"></div>`;
this.editElement = this.element.querySelector(".protyle-title__input"); this.editElement = this.element.querySelector(".protyle-title__input");
this.editElement.addEventListener("paste", (event: ClipboardEvent) => { this.editElement.addEventListener("paste", (event: ClipboardEvent) => {
event.stopPropagation(); event.stopPropagation();

View File

@ -67,6 +67,7 @@ export const getDocByScroll = (options: {
size: Constants.SIZE_GET_MAX, size: Constants.SIZE_GET_MAX,
}, response => { }, response => {
actions.push(Constants.CB_GET_ALL); actions.push(Constants.CB_GET_ALL);
options.protyle.breadcrumb?.toggleExit(false);
onGet(response, options.protyle, actions, options.scrollAttr); onGet(response, options.protyle, actions, options.scrollAttr);
if (options.cb) { if (options.cb) {
options.cb(); options.cb();
@ -79,6 +80,7 @@ export const getDocByScroll = (options: {
startID: options.scrollAttr.startId, startID: options.scrollAttr.startId,
endID: options.scrollAttr.endId, endID: options.scrollAttr.endId,
}, response => { }, response => {
options.protyle.breadcrumb?.toggleExit(true);
onGet(response, options.protyle, actions, options.scrollAttr); onGet(response, options.protyle, actions, options.scrollAttr);
if (options.cb) { if (options.cb) {
options.cb(); options.cb();

View File

@ -11,11 +11,7 @@ export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {
protyle.scroll?.element.classList.add("fn__none"); protyle.scroll?.element.classList.add("fn__none");
if (protyle.options.render.breadcrumb) { if (protyle.options.render.breadcrumb) {
protyle.breadcrumb?.element.classList.add("fn__none"); protyle.breadcrumb?.element.classList.add("fn__none");
if (protyle.block.showAll) { protyle.breadcrumb.toggleExit(true);
const exitFocusElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="exit-focus"]');
exitFocusElement.classList.add("fn__none");
exitFocusElement.nextElementSibling.classList.add("fn__none");
}
} }
protyle.preview.render(protyle); protyle.preview.render(protyle);
} else if (type === "wysiwyg") { } else if (type === "wysiwyg") {
@ -31,11 +27,7 @@ export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {
} }
if (protyle.options.render.breadcrumb) { if (protyle.options.render.breadcrumb) {
protyle.breadcrumb?.element.classList.remove("fn__none"); protyle.breadcrumb?.element.classList.remove("fn__none");
if (protyle.block.showAll) { protyle.breadcrumb.toggleExit(!protyle.block.showAll);
const exitFocusElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="exit-focus"]');
exitFocusElement.classList.remove("fn__none");
exitFocusElement.nextElementSibling.classList.remove("fn__none");
}
} }
} }
hideElements(["gutter", "toolbar", "select", "hint", "util"], protyle); hideElements(["gutter", "toolbar", "select", "hint", "util"], protyle);

View File

@ -903,14 +903,7 @@ const getArticle = (options: {
const contentRect = options.edit.protyle.contentElement.getBoundingClientRect(); const contentRect = options.edit.protyle.contentElement.getBoundingClientRect();
options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + matchElement.getBoundingClientRect().top - contentRect.top - contentRect.height / 2; options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + matchElement.getBoundingClientRect().top - contentRect.top - contentRect.height / 2;
} }
const exitFocusElement = options.edit.protyle.breadcrumb.element.parentElement.querySelector('[data-type="exit-focus"]'); options.edit.protyle.breadcrumb.toggleExit(!foldResponse.data);
if (!foldResponse.data) {
exitFocusElement.classList.add("fn__none");
exitFocusElement.nextElementSibling.classList.add("fn__none");
} else {
exitFocusElement.classList.remove("fn__none");
exitFocusElement.nextElementSibling.classList.remove("fn__none");
}
}); });
}); });
}; };