Skip to content
New issue

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

Add data-id attribute to the button of the block menu #12525

Merged
merged 30 commits into from
Sep 22, 2024

Conversation

TCOTC
Copy link
Contributor

@TCOTC TCOTC commented Sep 19, 2024

给块标菜单的 button 添加 data-id 属性 #12518

菜单太多了,我已经眼花了...

我自己感觉好像没问题,但不能保证每个添加 id 的地方都是对的,以后有问题的话再改。

@TCOTC TCOTC marked this pull request as ready for review September 19, 2024 14:31
@TCOTC
Copy link
Contributor Author

TCOTC commented Sep 21, 2024

可以 Review 了

@88250 88250 requested a review from Vanessa219 September 21, 2024 08:44
icon: "iconList",
label: window.siyuan.languages.list,
accelerator: window.siyuan.config.keymap.editor.insert.list.custom,
protyle,
nodeElement,
id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这类地方就不要修改了,以前这么写可能是有用的。

Copy link
Contributor Author

@TCOTC TCOTC Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我感觉是不是因为这里用的是 id: 而不是 id?: ,所以才必须有一行 id, 。我看着没感觉有啥用:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和图片这个没有关系,这里不明白你为什么要修改。这个 id 以前这样写肯定是有用到的。你直接用这个id就行了,不要去修改它。

Copy link
Contributor Author

@TCOTC TCOTC Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turnsOneInto、turnsIntoOne、turnsInto 我搞不懂,改回去了。

不知道该怎么给子菜单添加 data-id

const breadcrumb = nodeElement.getAttribute("breadcrumb");
window.siyuan.menus.menu.append(new MenuItem({
id: "assetSubMenu",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以前写过的不能动,否则其他地方会坏

Copy link
Contributor Author

@TCOTC TCOTC Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我没搞明白这里的 assetSubMenu 起什么作用。

我看代码感觉好像是用来显示子菜单之后聚焦到输入框,但我实际在思源右键弹出块的菜单之后并没有显示子菜单:

const itemElement = window.siyuan.menus.menu.element.querySelector('[data-id="assetSubMenu"]');
itemElement.classList.add("b3-menu__item--show");
window.siyuan.menus.menu.showSubMenu(itemElement.querySelector(".b3-menu__submenu"));
window.siyuan.menus.menu.element.querySelector("textarea").focus();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

真的是有用的,有个 issue 里面不是和你说了嘛。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但必须要有唯一 id 的话我不知道怎么搞,恢复成 assetSubMenu 的话就没法用 CSS 单独选择了。

你有推荐的方案吗?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那要修改一下这里,不行的话你修改好后我再来补补

QQ_1726934690092

@TCOTC TCOTC requested a review from Vanessa219 September 21, 2024 10:37
@Vanessa219 Vanessa219 merged commit 2f37965 into siyuan-note:dev Sep 22, 2024
@Vanessa219 Vanessa219 added this to the 3.1.7 milestone Sep 22, 2024
Vanessa219 added a commit that referenced this pull request Sep 22, 2024
@88250 88250 changed the title 给块标菜单的 button 添加 data-id 属性 Add data-id attribute to the button of the block menu Sep 22, 2024
@TCOTC TCOTC deleted the dev-menu-id branch September 22, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants