This commit is contained in:
parent
d67cca7942
commit
a687331bdf
4 changed files with 22 additions and 11 deletions
|
@ -14,7 +14,7 @@
|
|||
<svg id="toolbarFile" class="toolbar__icon">
|
||||
<use xlink:href="#iconMenu"></use>
|
||||
</svg>
|
||||
<input readonly class="toolbar__title b3-text-field fn__hidden" id="toolbarName">
|
||||
<input class="toolbar__title b3-text-field fn__hidden" id="toolbarName">
|
||||
<svg id="toolbarEdit" class="toolbar__icon fn__hidden">
|
||||
<use xlink:href="#iconEdit"></use>
|
||||
</svg>
|
||||
|
|
|
@ -68,7 +68,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =
|
|||
},
|
||||
after: (editor) => {
|
||||
// protyle 仅初始化一次,后续更新时会对 url 等再次复制
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || document.querySelector("#toolbarEdit use").getAttribute("xlink:href") === "#iconEdit") {
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
|
||||
disabledProtyle(editor.protyle);
|
||||
} else {
|
||||
enableProtyle(editor.protyle);
|
||||
|
|
|
@ -92,11 +92,21 @@ export const initFramework = () => {
|
|||
const editElement = document.getElementById("toolbarEdit");
|
||||
if (window.siyuan.config.readonly) {
|
||||
editElement.classList.add("fn__none");
|
||||
}
|
||||
const inputElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||
const editIconElement = editElement.querySelector("use");
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
|
||||
inputElement.readOnly = true;
|
||||
editIconElement.setAttribute("xlink:href", "#iconEdit");
|
||||
} else {
|
||||
const editIconElement = editElement.querySelector("use");
|
||||
editElement.addEventListener(getEventName(), () => {
|
||||
const inputElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||
if (editIconElement.getAttribute("xlink:href") === "#iconEdit") {
|
||||
inputElement.readOnly = false;
|
||||
editIconElement.setAttribute("xlink:href", "#iconPreview");
|
||||
}
|
||||
editElement.addEventListener(getEventName(), () => {
|
||||
const isReadonly = editIconElement.getAttribute("xlink:href") === "#iconPreview"
|
||||
window.siyuan.config.editor.readOnly = isReadonly;
|
||||
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, () => {
|
||||
if (!isReadonly) {
|
||||
enableProtyle(window.siyuan.mobileEditor.protyle);
|
||||
inputElement.readOnly = false;
|
||||
editIconElement.setAttribute("xlink:href", "#iconPreview");
|
||||
|
@ -105,8 +115,9 @@ export const initFramework = () => {
|
|||
inputElement.readOnly = true;
|
||||
editIconElement.setAttribute("xlink:href", "#iconEdit");
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
scrimElement.addEventListener(getEventName(), () => {
|
||||
closePanel();
|
||||
});
|
||||
|
@ -141,10 +152,10 @@ const initEditorName = () => {
|
|||
const inputElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||
inputElement.setAttribute("placeholder", window.siyuan.languages._kernel[16]);
|
||||
inputElement.addEventListener("focus", () => {
|
||||
hideKeyboardToolbar();
|
||||
hideKeyboardToolbar();
|
||||
});
|
||||
inputElement.addEventListener("blur", () => {
|
||||
if (window.siyuan.config.readonly || document.querySelector("#toolbarEdit use").getAttribute("xlink:href") === "#iconEdit") {
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
|
||||
return;
|
||||
}
|
||||
if (!validateName(inputElement.value)) {
|
||||
|
|
|
@ -1649,7 +1649,7 @@ export class WYSIWYG {
|
|||
}
|
||||
|
||||
const menuElement = hasClosestByClassName(event.target, "protyle-action__menu");
|
||||
if (menuElement && !protyle.disabled) {
|
||||
if (menuElement) {
|
||||
protyle.gutter.renderMenu(protyle, menuElement.parentElement.parentElement);
|
||||
const rect = menuElement.getBoundingClientRect();
|
||||
window.siyuan.menus.menu.popup({
|
||||
|
|
Loading…
Add table
Reference in a new issue