首页 > 其他分享 >思源笔记常用代码片段

思源笔记常用代码片段

时间:2024-08-25 20:47:54浏览次数:4  
标签:node 片段 思源 focus 笔记 wysiwyg protyle data block

背景色设置

:root {
    --b3-font-background1: #423a3a !important;
    --b3-font-background2: #4b3722 !important;
    --b3-font-background3: #203854c2 !important;
    --b3-font-background4: #2c5438a3 !important;
    --b3-font-background5: #4c525778 !important;
    --b3-font-background6: #1b3f758a !important;
    --b3-font-background7: #664a1c73 !important;
    --b3-font-background8: #5b1d1770 !important;
    --b3-font-background9: #541b3594 !important;
    --b3-font-background10: #6b2f6b70 !important;
    --b3-font-background11: #2f4c264f!important;
    --b3-font-background12: #72390f54 !important;
    --b3-font-background13: #3c3c3cd9 !important;
}

文字加粗颜色

.b3-typography strong, .b3-typography span[data-type~=strong], .protyle-wysiwyg strong, .protyle-wysiwyg span[data-type~=strong] {
    font-weight: 500;
    color: #73a6ff;
}

引用块美化

.b3-typography blockquote, .b3-typography .bq, .protyle-wysiwyg blockquote, .protyle-wysiwyg .bq {
    padding: 4px;
    border-left: 0.25em solid #0b960e !important;
    background-color: var(--b3-list-hover);
    margin: 4px 0;
}

底部栏颜色

.status {
    background-color: #3C3C3C;
}

.status * {
    color: #Dadada;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Cascadia Mono', 'Cascadia Code', 'Microsoft YaHei UI';
}

网址链接

.protyle-wysiwyg [data-node-id] span[data-type~=a] {
    color: #7badff;
    border-bottom: 1px solid var(--b3-border-color);
}

题头图

.protyle-background__img {
opacity:1 !important;
}

引用快字体颜色

.b3-typography blockquote, .b3-typography .bq, .protyle-wysiwyg blockquote, .protyle-wysiwyg .bq {
    padding: 4px;
    color: #DADADA !important;
    border-left: 0.25em solid #0b960e !important;
    background-color: var(--b3-list-hover);
    margin: 4px 0;
}

修改图片亮度

.b3-typography .img, .protyle-wysiwyg .img {
    display: inline-block;
    text-align: center;
    vertical-align: top;
    margin: 0 auto;
    max-width: 100%;
    user-select: none;
    word-break: keep-all;
    white-space: nowrap;
    filter: brightness(0.75);
}

大纲字体大小

.fn__flex-column.layout__dockr .file-tree {
  font-size: 13px !important;
}

代码块字体样式

.b3-typography .hljs, .protyle-wysiwyg .hljs {
    font-family: Consolas !important;
}

.hljs-comment {
    font-size: 13px;
}

钉住的同时显示 icon 和标题 CSS 片段

/* 钉住的同时显示 icon 和标题 CSS片段 */
.layout-tab-bar .item.item--pin .item__text {
    width: auto;
    max-width: none;
    display: flex !important;
}

类似 logseq 的层次子弹线 CSS 片段

/* 类似 logseq 的层次子弹线 CSS片段 */
/* REF https://github.com/svchord/Rem-Craft */
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.protyle-action{
    color:rgb(70, 110, 220);;
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.protyle-action svg{
    margin:0;
    width:16px;
    height:16px;
    padding:0px 0px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.list:has(.block-focus)>.li::after{
    content:"";
    display:block;
    position:absolute;
    pointer-events:none;
    width:34px;
    left:-18px;
    top:-20px;
    border-style:solid;
    border-color:rgb(70, 110, 220);;
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.list:has(.block-focus)>.li:not(:has(.block-focus))::after{
    bottom:-2px;
    border-width:0 0 0 2px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.list:has(.block-focus)>.li:has(.block-focus)::after{
    height:38px;
    border-radius:0 0 0 8px;
    border-width:0 0 2px 2px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.list:has(.block-focus)>.li:has(.block-focus)~.li:not(:has(.block-focus))::after{
    border-color:rgba(0,0,0,0)
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.list:has(.block-focus)>.li[data-subtype=o]::after{
    width:24px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>.list:has(.block-focus)>.li[data-subtype=t]::after{
    width:28px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id]::after{
    content:"";
    display:block;
    position:absolute;
    pointer-events:none;
    width:34px;
    left:-18px;
    top:-20px;
    border-style:solid;
    border-color:rgb(70, 110, 220);
    top:20px;
    height:calc(100% + 4px);
    border-width:0 0 0 2px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id]:has(+.list)::after{
    height:auto;
    bottom:0
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id][data-type=NodeHeading]::after{
    top:0;
    height:185%
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id].list:has(.block-focus)::after,.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id].list:has(.block-focus)~[data-node-id]::after,.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id].bq:has(.block-focus)::after,.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id].bq:has(.block-focus)~[data-node-id]::after,.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id].sb:has(.block-focus)::after,.protyle-wysiwyg [data-node-id].li:has(.block-focus)>[data-node-id].sb:has(.block-focus)~[data-node-id]::after{
    border-color:rgba(0,0,0,0)
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[fold="1"]>[data-node-id]::after,.protyle-wysiwyg [data-node-id].li:has(.block-focus):has(>.block-focus)>[data-node-id]::after{
    border-color:rgba(0,0,0,0)
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=o]:has(.block-focus)>.list:has(.block-focus)>.li::after{
    top:-10px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=o]:has(.block-focus)>.list:has(.block-focus)>.li:has(.block-focus)::after{
    height:28px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=t]:has(.block-focus)>.protyle-action{
    color:rgb(70, 110, 220);;
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=t]:has(.block-focus)>.protyle-action svg{
    margin:0;
    width:14px;
    height:14px;
    padding:0px 0px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=t]:has(.block-focus)>.list:has(.block-focus)>.li::after{
    top:-14px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=t]:has(.block-focus)>.list:has(.block-focus)>.li:has(.block-focus)::after{
    height:32px
}
.protyle-wysiwyg [data-node-id].li:has(.block-focus)[data-subtype=t]:has(.block-focus).protyle-task--done>.list:has(.block-focus)>.li::after{
    border-color:rgba(139, 139, 139)
}

类似 logseq 的层次子弹线 JS 片段

/* 类似 logseq 的层次子弹线 JS片段 */
/**
 * 获得指定块位于的编辑区
 * @params {HTMLElement}
 * @return {HTMLElement} 光标所在块位于的编辑区
 * @return {null} 光标不在块内
 */
function getTargetEditor(block) {
    while (block != null && !block.classList.contains('protyle-wysiwyg')) block = block.parentElement;
    return block;
}

/**
 * 获得焦点所在的块
 * @return {HTMLElement} 光标所在块
 * @return {null} 光标不在块内
 */
function getFocusedBlock() {
    if (document.activeElement.classList.contains('protyle-wysiwyg')) {
        let block = window.getSelection()?.focusNode?.parentElement; // 当前光标
        while (block != null && block.dataset.nodeId == null) block = block.parentElement;
        return block;
    }
}

function focusHandler() {
    /* 获取当前编辑区 */
    let block = getFocusedBlock(); // 当前光标所在块
    /* 当前块已经设置焦点 */
    if (block?.classList.contains(`block-focus`)) return;

    /* 当前块未设置焦点 */
    const editor = getTargetEditor(block); // 当前光标所在块位于的编辑区
    if (editor) {
        editor.querySelectorAll(`.block-focus`).forEach((element) => element.classList.remove(`block-focus`));
        block.classList.add(`block-focus`);
        // setSelector(block);
    }
}

function bulletMain() {
    // 跟踪当前所在块
    window.addEventListener('mouseup', focusHandler, true);
    window.addEventListener('keyup', focusHandler, true);
}

(async () => {
    bulletMain();
    console.log('加载子弹线成功')
})();

去除图片后的多余空行 CSS 片段

/* 去除图片后的多余空行 CSS片段 */
.b3-typography .img:not([style]), .protyle-wysiwyg .img:not([style]) {
   display:inline-block;
}

代码块字体设置

.b3-list-item {
    line-height: 35px !important;
    min-height: 28px;
    padding: 0 4px;
    display: flex;
    cursor: pointer;
    align-items: center;
    position: relative;
    background-color: rgba(0,0,0,0);
    text-align: left;
    border: 0;
    color: var(--b3-theme-on-background);
    margin: 1px 8px;
}

.b3-typography blockquote, .b3-typography .bq, .protyle-wysiwyg blockquote, .protyle-wysiwyg .bq {
    padding: 4px;
    color: black;
    border-left: 0.25em solid #ffffff;
    background-color: var(--b3-list-hover);
    margin: 4px 0;
}

虚线备注

/* 虚线备注 CSS片段 https://github.com/TCOTC/siyuan-css-dashed-line-memo */
.b3-typography span[data-type~=inline-memo], .protyle-wysiwyg span[data-type~=inline-memo] {
    background-color: transparent;
    border-bottom: 2px dashed var(--b3-theme-primary) !important;
}

隐藏大纲前面的块标记 H

.sy__outline .b3-list-item__graphic {
    display: none;
}

行间距

.protyle-wysiwyg>.p {
 	line-height: 2.3;  /*段落块的行间距,段间距的话前面该改成margin*/
 }

文档树块间距

.b3-list-item {
    line-height: 35px !important;
    min-height: 28px;
    padding: 0 4px;
    display: flex;
    cursor: pointer;
    align-items: center;
    position: relative;
    background-color: rgba(0,0,0,0);
    text-align: left;
    border: 0;
    color: var(--b3-theme-on-background);
    margin: 1px 8px;
}

.b3-typography blockquote, .b3-typography .bq, .protyle-wysiwyg blockquote, .protyle-wysiwyg .bq {
    padding: 4px;
    color: black;
    border-left: 0.25em solid #ffffff;
    background-color: var(--b3-list-hover);
    margin: 4px 0;
}

标题居中

.protyle-title__input {
    text-align: center;
}

plugin-custom-fonts-style

/* Twemoji Mozilla: https://github.com/mozilla/twemoji-colr */
@font-face {
    font-family: "Twemoji Mozilla";
    font-style: normal;
    src: url("plugins/custom-fonts/static/fonts/Twemoji.Mozilla/Twemoji.Mozilla-0.7.0.ttf");
}


:root {
    --b3-font-family-emoji: "Twemoji Mozilla", "Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI", "Apple Color Emoji", "Noto Color Emoji", "Android Emoji";
}

标签:node,片段,思源,focus,笔记,wysiwyg,protyle,data,block
From: https://www.cnblogs.com/LuneNorth/p/18379512

相关文章

  • UE5学习笔记17-让人物的视线和鼠标移动时的方向一致,并且不让人物模型旋转,只改变视线方
    一、创建标准动画帧    1.我想让人物在装备武器后根据鼠标的移动方向改变人物的视线方向,并且人物模型不会改变朝向    2.我的动画中存在一个四个方向瞄准的动画,将左下,坐上,左转,右上,右下,右转,中上,中下,中,的动画的某一帧保留,具体流程如下(记得复制一份动画资源,可......
  • 算法笔记|Day34动态规划VII
    算法笔记|Day34动态规划VII☆☆☆☆☆leetcode198.打家劫舍题目分析代码☆☆☆☆☆leetcode213.打家劫舍II题目分析代码☆☆☆☆☆leetcode337.打家劫舍III题目分析代码☆☆☆☆☆leetcode198.打家劫舍题目链接:leetcode198.打家劫舍题目分析1.dp数组含义:d......
  • AC 自动机 学习笔记
    前言本来时今年寒假学的,当时回家比较早没学完也没学明白,打模拟赛却多次用到,所以重学一下。原理与定义即字典树(trie树)加\(fail\)指针,\(fail\)指针等同于kmp的\(next\)数组,匹配前缀的最长后缀,\(fail\)指针单独拎出来构成一颗失配树(fail树)。插入同trie树,全部插完后......
  • CMake构建学习笔记5-libtiff库的构建
    libtiff是一个开源库,用于读写TIFF(TaggedImageFileFormat)文件。使用CMake进行构建的关键指令如下所示:#配置CMakecmake..-G"$Generator"-Ax64`-DCMAKE_BUILD_TYPE=RelWithDebInfo`-DCMAKE_PREFIX_PATH="$InstallDir"`-DCMAKE_INSTALL_PREFIX="$In......
  • SpringBoot文档之JSON的阅读笔记
    ReferenceCoreFeaturesJSON支持Gson、Jackson、JSON-B。SpringBoot提供了组件spring-boot-starter-json。注解,如下:@JsonComponent@JsonMixin重要的类,如下:JsonSerializerJsonDeserializerKeyDeserializerJsonObjectSerializerJsonObjectDeserializer参......
  • 消息队列-RabbitMQ学习笔记(一)
    1.什么是消息队列消息队列(MessageQueue,简称MQ)是一种用于在应用程序之间传递消息的技术,通常在分布式系统中使用。它提供了一种异步通信机制,使得应用程序可以通过发送和接收消息来进行数据交换。消息队列可以用来存储消息,这就涉及到消息队列的三个关键字:存储、消息、队列......
  • 诺埃尔的读书笔记1
    是诺埃尔。纯诺埃尔。很少来这里。随便写点什么。手打。写评论未必会波及到书里的每一篇文章。比如今天就是讲短篇集子里的5/9。《飞行家》/作者双雪涛/理想国文库/东北短篇集胡乱配文(引自《切格瓦拉》):Don'taskshouldfireburning,askcolddarkalsothere;Don'taskt......
  • 机器学习详解-第二章-实践方法论-学习笔记-[DataWhale X 李宏毅苹果书 X AI夏令营]
    在调整模型的过程中可能会遇到许多问题,这里为了处理这些问题(前期初学情况),从而给出了一个章节用于学习相关的技巧。1.模型偏差模型偏差可能会影响模型训练,我们在训练的时候,将所有的函数集合在一起得到一个函数的集合,但是这个函数的集合大小是我们不确定的,可能会因为太小,其中的......
  • 算法的学习笔记—包含 min 函数的栈(牛客JZ30)
    ......
  • SpringBoot文档之开源软件依赖的阅读笔记
    DependencyVersions维护开源软件清单,并不是一个轻松、愉快的工作。很好奇SpringBoot的开发团队使用什么方式来管理、维护依赖清单,完成兼容性验证工作等。ManagedDependencyCoordinatesSpringBoot集成的开源软件的清单,以及版本号。VersionProperties比如使用${acti......