Comments (10)
也许这个可以解决问题 #11109
from siyuan.
不一样,那个是右上角的消息弹窗,用的是 showMessage()
;这个 showTooltip()
是悬浮提示:
from siyuan.
https://ld246.com/article/1715069193698
from siyuan.
悬浮提示传入不同类名的作用是?
文章已在社区回复。
from siyuan.
悬浮提示传入不同类名的作用是?
举个例子,比如鼠标悬浮在超链接上的时候,会使用 showTooltip(decodeURIComponent(tip), aElement);
,此时如果能传入一个 .tooltip--url 的类名,就可以用下面这个 CSS 把除了超链接以外的悬浮提示隐藏掉:
.tooltip:not(.tooltip--url) {
display: none;
}
而且不只是超链接,用户会需要自定义其他各种地方的悬浮提示。
这样的话虽然在 tooltip.ts 里加一堆像下面这种条件判断也不是不行,但条件判断越多效率就越低,所以我建议直接从调用 showTooltip() 的地方把类名传进来
siyuan/app/src/dialog/tooltip.ts
Lines 24 to 28 in 61a89f6
从调用 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.
单独增加参数可能还不够,需要去对每一项有提示的地方进行配置。
from siyuan.
单独增加参数可能还不够,需要去对每一项有提示的地方进行配置。
默认不需要参数,需要加的时候再加就可以了。
p.s. 先把链接(和备注)的加上,有个用户的需求是隐藏除了链接和备注以外的悬浮提示
from siyuan.
加的时候也需要去配置,否则用法太隐秘了,没人知道这个特性。
后期维护也会很麻烦,比如增加一个类型,是不是需要去更新插件,插件不维护了怎么办?
from siyuan.
我感觉这个更容易维护,否则每增加一个类名就要像下面的代码这样写一种判断。
与其弄一堆 if else ,不如直接在调用函数的时候传入类名。
另外这个跟插件维不维护好像没什么关系?增加类型之后插件按需使用已有的类型就好了(如果不需要的话就用不着新增了)
siyuan/app/src/dialog/tooltip.ts
Lines 24 to 28 in 61a89f6
from siyuan.
想了想,传入类名之前也要判断,具体怎么实现还是要研究一下调用 showTooltip() 的相关代码。
这个需求也没那么迫切,暂时放着好了,等我有空研究一下再说。
from siyuan.
Related Issues (20)
- 改进剪藏 HOT 1
- Repeat the escaped content of the image title
- Improve HTML code clipping
- Remove invisible characters from file names when uploading assets HOT 5
- 右下角很多区域的按钮无法点击 HOT 4
- 改进面包屑更新 HOT 5
- Is it possible to select dev version in Siyuan? HOT 1
- search all database by "type=='db'" in sql HOT 6
- Doc-level custom sorting
- 在无头arm设备上运行,siyuannote程序会自动退出 HOT 1
- Improve custom emoji rendering on mobile
- 用户指南补充类型字段 HOT 2
- Search assets cannot open and locate file name containing `'` HOT 5
- Improve ↑/↓ moving in the table
- IFrame block does not resize when adaptive width is enabled
- Display details when exporting .sy.zip and data.zip
- 在非空白的段落块开头输入 `》` 应形成引述块
- 适配PPT的列表粘贴 HOT 5
- Displays pagination info in search results
- Does siyuan support spoiler tag? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from siyuan.