This commit is contained in:
Vanessa 2023-10-01 10:27:07 +08:00
parent c3212235b7
commit e8359edebc
4 changed files with 22 additions and 22 deletions

View file

@ -16,16 +16,16 @@ export const getAllEditor = () => {
const models = getAllModels(); const models = getAllModels();
const editors: Protyle[] = []; const editors: Protyle[] = [];
models.editor.forEach(item => { models.editor.forEach(item => {
editors.push(item.editor) editors.push(item.editor);
}) });
models.search.forEach(item => { models.search.forEach(item => {
editors.push(item.edit) editors.push(item.edit);
}) });
models.custom.forEach(item => { models.custom.forEach(item => {
if (item.data?.editor instanceof Protyle) { if (item.data?.editor instanceof Protyle) {
editors.push(item.data.editor) editors.push(item.data.editor);
} }
}) });
models.backlink.forEach(item => { models.backlink.forEach(item => {
item.editors.forEach(editorItem => { item.editors.forEach(editorItem => {
editors.push(editorItem); editors.push(editorItem);
@ -33,12 +33,12 @@ export const getAllEditor = () => {
}); });
window.siyuan.dialogs.forEach(item => { window.siyuan.dialogs.forEach(item => {
if (item.editor) { if (item.editor) {
editors.push(item.editor) editors.push(item.editor);
} }
}); });
window.siyuan.blockPanels.forEach(item => { window.siyuan.blockPanels.forEach(item => {
item.editors.forEach(editorItem => { item.editors.forEach(editorItem => {
editors.push(editorItem) editors.push(editorItem);
}); });
}); });
return editors; return editors;

View file

@ -328,7 +328,7 @@ export const openMenuPanel = (options: {
avPanelElement.remove(); avPanelElement.remove();
} else { } else {
// 优先关闭资源文件搜索 // 优先关闭资源文件搜索
hideElements(["util"], options.protyle) hideElements(["util"], options.protyle);
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
event.preventDefault(); event.preventDefault();
@ -680,7 +680,7 @@ export const openMenuPanel = (options: {
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (type === "addAssetExist") { } else if (type === "addAssetExist") {
const rect = target.getBoundingClientRect() const rect = target.getBoundingClientRect();
options.protyle.toolbar.showAssets(options.protyle, {x: rect.right, y: rect.bottom, w: target.parentElement.clientWidth + 8, h: rect.height}, (url) => { options.protyle.toolbar.showAssets(options.protyle, {x: rect.right, y: rect.bottom, w: target.parentElement.clientWidth + 8, h: rect.height}, (url) => {
let value: IAVCellAssetValue; let value: IAVCellAssetValue;
if (Constants.SIYUAN_ASSETS_IMAGE.includes(pathPosix().extname(url).toLowerCase())) { if (Constants.SIYUAN_ASSETS_IMAGE.includes(pathPosix().extname(url).toLowerCase())) {
@ -688,13 +688,13 @@ export const openMenuPanel = (options: {
type: "image", type: "image",
content: url, content: url,
name: "" name: ""
} };
} else { } else {
value = { value = {
type: "file", type: "file",
content: url, content: url,
name: pathPosix().basename(url).substring(0, Constants.SIZE_LINK_TEXT_MAX) name: pathPosix().basename(url).substring(0, Constants.SIZE_LINK_TEXT_MAX)
} };
} }
updateAssetCell({ updateAssetCell({
protyle: options.protyle, protyle: options.protyle,

View file

@ -1577,9 +1577,9 @@ export class Toolbar {
if (event.key === "Enter") { if (event.key === "Enter") {
if (!isEmpty) { if (!isEmpty) {
const currentURL = this.subElement.querySelector(".b3-list-item--focus").getAttribute("data-value") const currentURL = this.subElement.querySelector(".b3-list-item--focus").getAttribute("data-value");
if (avCB) { if (avCB) {
avCB(currentURL) avCB(currentURL);
} else { } else {
hintRenderAssets(currentURL, protyle); hintRenderAssets(currentURL, protyle);
} }
@ -1625,9 +1625,9 @@ export class Toolbar {
const listItemElement = hasClosestByClassName(target, "b3-list-item"); const listItemElement = hasClosestByClassName(target, "b3-list-item");
if (listItemElement) { if (listItemElement) {
event.stopPropagation(); event.stopPropagation();
const currentURL = listItemElement.getAttribute("data-value") const currentURL = listItemElement.getAttribute("data-value");
if (avCB) { if (avCB) {
avCB(currentURL) avCB(currentURL);
} else { } else {
hintRenderAssets(currentURL, protyle); hintRenderAssets(currentURL, protyle);
} }

View file

@ -76,15 +76,15 @@ const getContentByInlineHTML = (range: Range, cb: (content: string) => void) =>
let html = ""; let html = "";
Array.from(range.cloneContents().childNodes).forEach((item: HTMLElement) => { Array.from(range.cloneContents().childNodes).forEach((item: HTMLElement) => {
if (item.nodeType === 3) { if (item.nodeType === 3) {
html += item.textContent html += item.textContent;
} else { } else {
html += item.outerHTML html += item.outerHTML;
} }
}) });
fetchPost("/api/block/getDOMText", {dom: html}, (response) => { fetchPost("/api/block/getDOMText", {dom: html}, (response) => {
cb(response.data) cb(response.data);
}) });
} };
export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => { editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => {