Git Product home page Git Product logo

Comments (10)

Vanessa219 avatar Vanessa219 commented on September 26, 2024

也许这个可以解决问题 #11109

from siyuan.

TCOTC avatar TCOTC commented on September 26, 2024

不一样,那个是右上角的消息弹窗,用的是 showMessage() ;这个 showTooltip() 是悬浮提示:

image

from siyuan.

TCOTC avatar TCOTC commented on September 26, 2024

https://ld246.com/article/1715069193698

image

from siyuan.

Vanessa219 avatar Vanessa219 commented on September 26, 2024

悬浮提示传入不同类名的作用是?
文章已在社区回复。

from siyuan.

TCOTC avatar TCOTC commented on September 26, 2024

悬浮提示传入不同类名的作用是?

举个例子,比如鼠标悬浮在超链接上的时候,会使用 showTooltip(decodeURIComponent(tip), aElement); ,此时如果能传入一个 .tooltip--url 的类名,就可以用下面这个 CSS 把除了超链接以外的悬浮提示隐藏掉:

.tooltip:not(.tooltip--url) {
    display: none;
}

而且不只是超链接,用户会需要自定义其他各种地方的悬浮提示。

这样的话虽然在 tooltip.ts 里加一堆像下面这种条件判断也不是不行,但条件判断越多效率就越低,所以我建议直接从调用 showTooltip() 的地方把类名传进来

if (target.getAttribute("data-inline-memo-content")) {
messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161
} else {
messageElement.classList.remove("tooltip--memo");
}

从调用 showTooltip() 的地方传入类名后,在 tooltip.ts 里大概像这样处理:(不知道这段代码逻辑对不对哈)

if (toolTipClass !== "") {
    messageElement.classList.add(toolTipClass);
} else {
    // 获取所有其他的类名
    const otherClasses = Array.from(messageElement.classList).filter(className => className !== 'tooltip');
    // 移除所有其他的类名
    otherClasses.forEach(className => messageElement.classList.remove(className));
}

from siyuan.

Vanessa219 avatar Vanessa219 commented on September 26, 2024

单独增加参数可能还不够,需要去对每一项有提示的地方进行配置。

from siyuan.

TCOTC avatar TCOTC commented on September 26, 2024

单独增加参数可能还不够,需要去对每一项有提示的地方进行配置。

默认不需要参数,需要加的时候再加就可以了。

p.s. 先把链接(和备注)的加上,有个用户的需求是隐藏除了链接和备注以外的悬浮提示

from siyuan.

Vanessa219 avatar Vanessa219 commented on September 26, 2024

加的时候也需要去配置,否则用法太隐秘了,没人知道这个特性。
后期维护也会很麻烦,比如增加一个类型,是不是需要去更新插件,插件不维护了怎么办?

from siyuan.

TCOTC avatar TCOTC commented on September 26, 2024

我感觉这个更容易维护,否则每增加一个类名就要像下面的代码这样写一种判断。

与其弄一堆 if else ,不如直接在调用函数的时候传入类名。

另外这个跟插件维不维护好像没什么关系?增加类型之后插件按需使用已有的类型就好了(如果不需要的话就用不着新增了)

if (target.getAttribute("data-inline-memo-content")) {
messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161
} else {
messageElement.classList.remove("tooltip--memo");
}

from siyuan.

TCOTC avatar TCOTC commented on September 26, 2024

想了想,传入类名之前也要判断,具体怎么实现还是要研究一下调用 showTooltip() 的相关代码。

这个需求也没那么迫切,暂时放着好了,等我有空研究一下再说。

from siyuan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.