代码片段
让 link icon 根据锚文本来选择是否显示
需要同时用到 js 和 css
js:找到符合条件的锚文本,添加自定义属性 custom-link-icon=false
这里设定的条件为:锚文本为 数字
、*
、被 []
包裹时,不显示 link icon
function link_icon_filter() { let spans = document.querySelectorAll('span[data-type="a"]'); spans.forEach(span => { const isWrappedInBracketsOrNumber = /\[.+?\]|^\d+$/.test(span.textContent); if (span.textContent === '*' || isWrappedInBracketsOrNumber) { span.setAttribute('custom-linkicon', 'false'); } else { span.removeAttribute('custom-linkicon'); } }); } linkIconFilterInterval = setInterval(link_icon_filter, 100);
css:让有 custom-link-icon=false
的链接不显示 link icon
.protyle-wysiwyg [data-node-id] span[data-type~='a'][custom-linkicon='false']:not(:empty)::before, .protyle-wysiwyg [data-node-id] a[custom-linkicon='false']:not(:empty)::before{ display: none !important; }
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于