为知笔记新版本-自定义样式

9/4/2021

此內容未以你的語言提供。 以下為簡體中文。

说明

从v0.1.19开始,支持用户自定义css,控制界面。

方法:在新笔记客户端内新建一个文档,文档标题必须为 wiznote.custom,这个文档中的所有语法设置为CSS的代码块,其中定义的样式都会生效。如果想禁用此功能,只要将文档标题改为其它名称,然后重新刷新整个界面即可。

对于主界面的样式,大家可以在开发者工具中搜索所有wiznote- 开头的class,然后通过css进行覆盖即可。 对于新的编辑器样式,则可以直接在开发工具中查看相应DOM的class,然后进行覆盖。(编辑器里面的class都是静态的,不会改变)。

显示开发工具:

  • Windows/linux: Ctrl+F12
  • mac: 主菜单 | 查看 | 显示开发工具

以下是几个例子:

几个基本设置

/* 设置用户头像大小 */
.wiznote-userinfo-avatar {
  width: 100px;
  height: 100px;
}

/* 设置左面面板上我的收藏的字体 */
.wiznote-fav-tree-item .wiznote-label {
  font-size: 10px;
}

/* 设置左面面板上我的消息的字体 */
.wiznote-my-messages .wiznote-label {
  font-size: 10px;
}

/* 设置左面面板文件夹的字体 */
.wiznote-folder-tree .wiznote-label {
  font-size: 12px;
}

/* 设置左面面板文件夹的背景颜色 */
.wiznote-folder-tree {
  background-color: #223344;
}

/* 设置整个左面面板的颜色 */
.wiznote-left-pane {
  background-color: #223300;
}

根据文字设置颜色


/* 在最左面,将所有“测试”开头的节点背景改为蓝色 */
.wiznote-left-pane [label-text^="测试"] {
  background-color: blue;
}

/* 在笔记列表,将所有标题为“wiznote.custom"开头的笔记背景改为绿色 */
.wiznote-note-item [title-text^="wiznote.custom"] .wiznote-note-item-container {
  background-color: green;
  border-radius: 8px;
}

/* 在笔记列表,将所有标题为“wiznote.custom"开头的笔记字体改为黄色 */
.wiznote-note-item [title-text^="wiznote.custom"] .wiznote-note-item-container p {
  color: yellow;
}

笔记列表

/* 不显示笔记列表中的笔记所在文件夹 */
.wiznote-note-item-info {
  display: none;
}

/* 笔记列表更紧凑 */
.wiznote-note-item-container {
  padding: 2px;
}

.wiznote-note-item div[draggable="true"] {
  padding: 0;
}

.wiznote-note-item-title {
  margin: 0;
}

面板宽度

/* 设置最左面板的固定宽度 */
.wiznote-split-pane-main:first-of-type {
  width: 200px !important;
}

/* 设置笔记列表的宽度 */
.wiznote-split-pane-sub:first-of-type {
  width: 250px !important;
}

编辑器

/* 编辑器 code 样式 */
.desktop-editor .editor-main .root-container .code-line-block.editor-block * {
    font-size: 14px;
}

代码段显示行号

.editor-main .root-container > .code-block {
  counter-reset: line;
}

.editor-main .root-container > .code-block .editor-block.code-line-block {
  margin-left: 16px;
}

.editor-main .root-container > .code-block .editor-block.code-line-block:before {
  content: counter(line);
  counter-increment: line;
  position: absolute;
  left: -48px;
  top: 10px;
  z-index: var(--wiz-editor-z-block-counter);
  margin-top: -6px;
  display: block;
  width: 48px;
  padding-right: 8px;
  text-align: right;
  color: var(--editor-line-number-color);
  box-sizing: border-box;
  font-size: 12px;
  font-weight: normal;
  line-height: 12px;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 1;
}