We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
希望可以让 confirm API 可以访问对应 dialog 对象,这样可以为这个功能拓展很多。不仅仅是显示文本,还可以和自己传入的 html element 交互。 @Vanessa219
confirm
import {isMobile} from "../util/functions"; import {Dialog} from "./index"; export const confirmDialog = (title: string, text: string, confirm?: () => void, cancel?: () => void) => { const dialog = new Dialog({ title, content: `<div class="b3-dialog__content"> <div class="ft__breakword">${text}</div> </div> <div class="b3-dialog__action"> <button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div> <button class="b3-button b3-button--text" id="confirmDialogConfirmBtn">${window.siyuan.languages.confirm}</button> </div>`, width: isMobile() ? "92vw" : "520px", }); const btnsElement = dialog.element.querySelectorAll(".b3-button"); btnsElement[0].addEventListener("click", () => { if (cancel) { cancel(); } dialog.destroy(); }); btnsElement[1].addEventListener("click", () => { if (confirm) { confirm(); } dialog.destroy(); }); };
为 confirm(); 和 cancel(); 传入 div.ft__breakword HTMLElement 参数。
confirm();
cancel();
div.ft__breakword
export const confirmDialog = (title: string, text: string, confirm?: (ele?: HTMLElement) => void, cancel?: (ele?: HTMLElement) => void) => { const dialog = new Dialog({ title, content: `<div class="b3-dialog__content"> <div class="ft__breakword">${text}</div> </div> <div class="b3-dialog__action"> <button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div> <button class="b3-button b3-button--text" id="confirmDialogConfirmBtn">${window.siyuan.languages.confirm}</button> </div>`, width: isMobile() ? "92vw" : "520px", }); const target: HTMLElement = dialog.element.querySelector(".b3-dialog__content>div.ft__breakword"); const btnsElement = dialog.element.querySelectorAll(".b3-button"); btnsElement[0].addEventListener("click", () => { if (cancel) { cancel(target); } dialog.destroy(); }); btnsElement[1].addEventListener("click", () => { if (confirm) { confirm(target); } dialog.destroy(); }); };
No response
The text was updated successfully, but these errors were encountered:
dialog
element
siyuan-note/petal@3fd934c
🎨 fix #8851
e3ec694
ca747f5
Vanessa219
No branches or pull requests
In what scenarios do you need this feature?
希望可以让
confirm
API 可以访问对应 dialog 对象,这样可以为这个功能拓展很多。不仅仅是显示文本,还可以和自己传入的 html element 交互。@Vanessa219
Describe the optimal solution
为
confirm();
和cancel();
传入div.ft__breakword
HTMLElement 参数。Describe the candidate solution
No response
Other information
No response
The text was updated successfully, but these errors were encountered: