This commit is contained in:
Vanessa 2023-03-02 11:06:33 +08:00
parent e45f5998c1
commit ecc9cebe82
2 changed files with 12 additions and 4 deletions

View file

@ -167,15 +167,15 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
value: '<iframe sandbox="allow-forms allow-presentation allow-same-origin allow-scripts allow-modals" src="" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>', value: '<iframe sandbox="allow-forms allow-presentation allow-same-origin allow-scripts allow-modals" src="" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>',
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconLanguage"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertIframeURL}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconLanguage"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertIframeURL}</span></div>`,
}, { }, {
filter: ["输入图片链接", "input image url", "shurutupianlianjie", "srtptp"], filter: ["插入图片链接", "insert image link", "charutupianlianjie", "crtptp"],
value: "![]()", value: "![]()",
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconImage"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertImgURL}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconImage"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertImgURL}</span></div>`,
}, { }, {
filter: ["输入视频链接", "shurushipinlianjie", "srsplj", "input video url"], filter: ["插入视频链接", "charushipinlianjie", "crsplj", "insert video url"],
value: '<video controls="controls" src=""></video>', value: '<video controls="controls" src=""></video>',
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconVideo"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertVideoURL}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconVideo"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertVideoURL}</span></div>`,
}, { }, {
filter: ["输入音频链接", "shuruyinpinlianjie", "sryplj", "input audio url"], filter: ["插入音频链接", "charuyinpinlianjie", "cryplj", "insert audio url"],
value: '<audio controls="controls" src=""></audio>', value: '<audio controls="controls" src=""></audio>',
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconRecord"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertAudioURL}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconRecord"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.insertAudioURL}</span></div>`,
}, { }, {

View file

@ -585,8 +585,16 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
let imgElement: HTMLElement = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement || range.startContainer as HTMLElement; let imgElement: HTMLElement = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement || range.startContainer as HTMLElement;
if (imgElement && imgElement.nodeType !== 3 && imgElement.classList.contains("img")) { if (imgElement && imgElement.nodeType !== 3 && imgElement.classList.contains("img")) {
// 已经找到图片 // 已经找到图片
} else if (imgElement.previousSibling?.nodeType !== 3 && (imgElement.previousSibling as HTMLElement).classList.contains("img")) {
// https://github.com/siyuan-note/siyuan/issues/7540
imgElement = imgElement.previousSibling as HTMLElement;
} else { } else {
imgElement = nodeElement.querySelector(".img"); Array.from(nodeElement.querySelectorAll(".img")).find((item: HTMLElement) => {
if (item.querySelector("img").getAttribute("data-src") === "") {
imgElement = item;
return true;
}
});
} }
const rect = imgElement.getBoundingClientRect(); const rect = imgElement.getBoundingClientRect();
imgMenu(protyle, range, imgElement, { imgMenu(protyle, range, imgElement, {