An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
@use "../util/mixin" as *;
@use "inline";
@use "task";
.protyle-wysiwyg,
.b3-typography {
// 脑图初始化前仍显示原始节点,列表标记沿用普通列表的图标尺寸。
.mindmap-item > .protyle-action > svg {
display: block;
width: 34px;
height: max(14px, 1em - 4px);
}
[data-type="NodeList"][data-mindmap-view-rendered="true"]:not([fold="1"]),
[data-type="NodeMindmap"][data-mindmap-view-rendered="true"]:not([fold="1"]) {
height: auto !important;
max-width: 100%;
box-sizing: border-box;
}
[data-type="NodeList"][data-mindmap-view-rendered="true"] > [data-type="NodeListItem"],
[data-type="NodeMindmap"][data-mindmap-view-rendered="true"] > .mindmap-item[data-type="NodeMindmapItem"][data-node-id],
[data-type="NodeMindmap"][data-mindmap-view-rendered="true"] > .li[data-type="NodeMindmapItem"][data-node-id] {
display: none;
}
}
.mindmap-view {
--mindmap-node-text-color: initial;
--mindmap-node-semantic-color: initial;
--b3-task-completed-color: initial;
position: relative;
display: flex;
flex-direction: column;
width: 100%;
height: var(--mindmap-view-height, 460px);
min-height: min(260px, var(--mindmap-view-height, 260px));
box-sizing: border-box;
// 画布由内部视口裁剪,外侧尺寸把手保持可见。
overflow: visible;
border: 1px solid var(--b3-border-color);
border-radius: var(--b3-border-radius);
background: var(--b3-theme-background);
color: var(--b3-theme-on-background);
text-align: left;
font-size: 14px;
line-height: 1.5;
outline: none;
&--active {
outline: 1px solid var(--b3-theme-primary);
}
&__selection-input {
position: absolute;
z-index: 3;
min-height: 28px;
white-space: pre-wrap;
overflow-wrap: anywhere;
pointer-events: none;
opacity: 0;
}
&--nested {
width: 260px;
--mindmap-view-height: 260px;
pointer-events: none;
> .mindmap-view__toolbar {
display: none;
}
}
&__preview-block.protyle-wysiwyg--hl {
position: relative;
}
[hidden] {
display: none !important;
}
&.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
max-height: none;
border: 0;
border-radius: 0;
z-index: 8;
}
&__toolbar {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 5;
opacity: 0;
pointer-events: none;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
overflow: visible;
}
&.fullscreen &__toolbar,
&--locked &__toolbar,
&--pan &__toolbar,
&--active &__toolbar,
&:hover &__toolbar,
&__toolbar:focus-within {
opacity: 1;
}
&.fullscreen &__toolbar .block__icon,
&--locked &__toolbar .block__icon,
&--pan &__toolbar .block__icon,
&--active &__toolbar .block__icon,
&:hover &__toolbar .block__icon,
&__toolbar:focus-within .block__icon,
&.fullscreen &__toolbar-group,
&--locked &__toolbar-group,
&--pan &__toolbar-group,
&--active &__toolbar-group,
&:hover &__toolbar-group,
&__toolbar:focus-within &__toolbar-group {
pointer-events: auto;
}
&__toolbar-group {
@include protyle-toolbar-surface($shadow: none);
position: relative;
align-items: center;
flex-wrap: wrap;
justify-content: flex-end;
min-width: 0;
gap: 8px;
padding: 4px;
}
&__spacer {
flex: 1;
}
&:hover &__resize,
&__resize.touch-resize-active {
opacity: 1;
}
&.fullscreen &__resize {
display: none;
}
&--locked &__viewport {
touch-action: pan-y;
}
&--locked &__fold,
&--locked &__add-child,
&--locked &__add-bridge {
display: none;
}
&__level-control {
position: relative;
flex-shrink: 0;
&:focus-within {
outline: 1px solid var(--b3-theme-primary);
border-radius: var(--b3-border-radius);
}
}
&__level-select {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
pointer-events: auto;
}
&__zoom {
flex-shrink: 0;
min-width: 34px;
color: var(--b3-theme-on-surface);
text-align: center;
font-size: 11px;
font-variant-numeric: tabular-nums;
user-select: none;
}
&__zoom-control {
display: flex;
align-items: center;
align-self: stretch;
flex-shrink: 0;
pointer-events: auto;
&:hover .mindmap-view__zoom-actions,
&:focus-within .mindmap-view__zoom-actions {
display: flex;
}
}
&__zoom-actions {
@include protyle-toolbar-surface;
position: absolute;
top: calc(100% - 4px);
right: 4px;
display: none;
align-items: center;
gap: 8px;
padding: 8px;
width: max-content;
.block__icon {
gap: 4px;
white-space: nowrap;
}
.b3-slider {
width: 100px;
}
}
&__viewport {
position: relative;
flex: 1;
min-height: 0;
overflow: hidden;
border-radius: inherit;
cursor: default;
touch-action: pan-y;
user-select: none;
@media screen {
// 画布独立参与绘制,编辑菜单和工具栏位于视口外侧。
contain: paint;
}
&--dragging {
cursor: grabbing;
}
&--line-hover {
cursor: pointer;
}
}
&--active &__viewport,
&.fullscreen:not(.mindmap-view--locked) &__viewport {
touch-action: none;
}
&__canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
&__document-viewport {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
color: var(--b3-theme-primary);
border: 1px solid currentColor;
border-radius: var(--b3-border-radius);
overflow: hidden;
background-image: radial-gradient(circle, currentColor 1px, transparent 1px),
radial-gradient(circle, currentColor 1px, transparent 1px);
background-image: radial-gradient(circle, color-mix(in srgb, currentColor 35%, transparent) 1px, transparent 1px),
radial-gradient(circle, color-mix(in srgb, currentColor 35%, transparent) 1px, transparent 1px);
// 横纵点线组成 96px 大格,每 12px 一点;网格固定于取景框,不随导图缩放。
background-size: 12px 96px, 96px 12px;
background-position: center;
box-sizing: border-box;
z-index: 4;
&::before,
&::after {
content: "";
position: absolute;
opacity: .5;
}
&::before {
top: 0;
bottom: 0;
left: 50%;
border-left: 1px dashed currentColor;
transform: translateX(-50%);
}
&::after {
left: 0;
right: 0;
top: 50%;
border-top: 1px dashed currentColor;
transform: translateY(-50%);
}
}
&__selection-box {
position: absolute;
pointer-events: none;
border: 1px solid var(--b3-theme-primary);
background: var(--b3-theme-primary-lightest);
box-sizing: border-box;
z-index: 5;
}
&__viewport--pan {
cursor: grab;
.mindmap-view__world {
pointer-events: none;
}
&.mindmap-view__viewport--dragging {
cursor: grabbing;
}
}
&__world {
position: absolute;
left: 0;
top: 0;
width: 0;
height: 0;
transform-origin: 0 0;
// 平移在视口捕获指针,光标状态不必向全部节点继承。
cursor: default;
}
&__node {
position: absolute;
min-width: 32px;
max-width: 300px;
width: max-content;
min-height: 32px;
padding: 4px 6px;
box-sizing: border-box;
border: 0;
border-radius: var(--b3-border-radius);
background: transparent;
color: var(--b3-theme-on-background);
font-size: 16px;
line-height: 1.5;
cursor: default;
&:focus-visible {
outline: 1px solid var(--b3-theme-primary);
outline-offset: 2px;
}
&:hover:not(.mindmap-view__node--dragging):not(.mindmap-view__node--editing):not(.mindmap-view__node--selected) {
box-shadow: inset 0 0 0 2px var(--b3-list-hover);
}
&--virtual {
font-weight: 600;
background: var(--b3-theme-surface);
box-shadow: inset 0 0 0 1px var(--b3-border-color);
transition: background-color 120ms ease, box-shadow 120ms ease;
&:hover:not(.mindmap-view__node--dragging):not(.mindmap-view__node--editing):not(.mindmap-view__node--selected):not(.mindmap-view__node--relation) {
background: var(--b3-list-hover);
box-shadow: inset 0 0 0 1px var(--b3-border-color);
}
}
&--untitled:not(.mindmap-view__node--editing) {
width: 32px;
min-width: 32px;
height: 32px;
min-height: 32px;
padding: 0;
> .mindmap-view__content {
display: grid;
place-items: center;
min-width: 0;
min-height: 0;
width: 100%;
height: 100%;
&::before {
content: "";
width: 4px;
height: 4px;
border-radius: 50%;
background: currentColor;
opacity: .45;
}
}
}
&--selected:not([data-mindmap-drop])::after {
content: " ";
position: absolute;
inset: 0;
z-index: 3;
pointer-events: none;
border-radius: var(--b3-border-radius);
background-color: var(--b3-theme-primary-lightest);
box-shadow: inset 0 0 0 1px var(--b3-theme-primary-lighter);
}
&--relation {
box-shadow: inset 0 0 0 2px var(--b3-theme-primary);
}
&--drag-ready {
outline: 2px solid var(--b3-theme-primary);
outline-offset: 2px;
}
&--dragging {
opacity: .35;
cursor: grabbing;
}
&--editing {
z-index: 3;
cursor: text;
user-select: text;
}
&[data-mindmap-drop="child"] {
box-shadow: inset 0 0 0 3px var(--b3-theme-primary-lighter);
background: var(--b3-theme-primary-lightest) !important;
}
&[data-mindmap-drop="before"]::before,
&[data-mindmap-drop="after"]::after {
content: "";
position: absolute;
z-index: 6;
pointer-events: none;
right: -5px;
left: -5px;
height: 3px;
border-radius: 2px;
background: var(--b3-theme-primary-lighter);
}
&[data-mindmap-drop="before"]::before {
top: -8px;
}
&[data-mindmap-drop="after"]::after {
bottom: -8px;
}
}
&__content {
@include inline.interactive-marks;
// 有独立底色的组合标记保留自身配色,普通链接和标签沿用所在内容的前景。
span[data-type~="a"]:not([data-type~="mark"], [data-type~="search-mark"], [data-type~="kbd"]) {
color: var(--mindmap-node-semantic-color, var(--b3-protyle-inline-link-color));
}
span[data-type~="tag"]:not([data-type~="mark"], [data-type~="search-mark"], [data-type~="kbd"]) {
color: var(--mindmap-node-semantic-color, var(--b3-protyle-inline-tag-color));
}
min-width: 0;
min-height: 24px;
overflow-wrap: anywhere;
// 公式整体换行,节点加宽后可恢复为一行,不拆开 KaTeX 内部的排版单元。
.mindmap-view & span[data-type~="inline-math"] {
display: inline-block;
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
vertical-align: middle;
white-space: nowrap;
overflow-wrap: normal;
word-break: normal;
}
.mindmap-view__node:not(.mindmap-view__node--editing) > &--empty:not(.mindmap-view__editor) {
> * {
display: none;
}
&::before {
content: attr(data-placeholder);
color: var(--mindmap-node-text-color, var(--b3-theme-on-surface-light));
}
}
> .p,
> .p.mindmap-view__preview-block {
margin: 0;
padding: 0;
font-size: inherit;
line-height: inherit;
}
img,
video,
iframe {
max-width: 100%;
}
&.protyle,
.protyle {
overflow: visible;
min-height: 24px;
max-height: none;
background: transparent;
border: 0;
border-radius: 0;
box-shadow: none;
font-size: inherit;
}
.protyle-content,
.protyle-wysiwyg[spellcheck] {
overflow: visible;
min-height: 24px;
padding: 0 !important;
background: transparent;
font-size: inherit !important;
line-height: inherit;
}
.protyle-wysiwyg > .p[data-node-id] {
margin: 0;
padding: 0;
line-height: inherit;
[spellcheck] {
min-height: 1.5em;
}
}
.protyle-attr,
.protyle-gutters {
display: none;
}
}
&__node--colored {
--b3-task-completed-color: var(--mindmap-node-text-color);
--mindmap-node-semantic-color: currentColor;
}
&__node--colored > .mindmap-view__content {
// 默认的列表正文和删除线沿用节点前景,手动行内颜色仍由正文自身决定。
.li,
s,
span[data-type~="s"] {
color: var(--mindmap-node-text-color);
}
.bq,
.callout {
color: var(--mindmap-node-text-color, var(--b3-theme-on-surface));
}
.protyle-wysiwyg--empty:empty::before {
color: var(--mindmap-node-text-color, var(--b3-empty-color));
}
}
&__theme-preview {
width: 48px;
flex-basis: 48px;
}
&__theme-menu .b3-menu__label {
min-width: 0;
}
&__node[data-task] {
display: grid;
// 空任务正文也保留输入宽度,确保光标能落入编辑器。
grid-template-columns: max-content minmax(1em, 1fr);
column-gap: 6px;
align-items: start;
> .mindmap-view__content {
grid-column: 2;
grid-row: 1;
}
}
&__task {
position: relative;
display: flex;
align-items: center;
justify-content: center;
grid-column: 1;
grid-row: 1;
justify-self: start;
margin-top: calc((1.5em - max(14px, 1em - 4px)) / 2);
padding: 0;
border: 0;
border-radius: var(--b3-border-radius);
background: transparent;
color: var(--mindmap-node-text-color, var(--b3-theme-on-surface));
font: inherit;
cursor: pointer;
transition: var(--b3-transition);
&::after {
@include protyle-list-action-background(var(--b3-border-radius));
}
&:hover:not(:disabled) {
@include protyle-list-action-hover;
}
&:disabled {
cursor: default;
}
&:focus-visible {
outline: 1px solid var(--b3-theme-primary);
}
svg {
width: max(14px, 1em - 4px);
height: max(14px, 1em - 4px);
display: block;
position: relative;
z-index: 1;
fill: currentColor;
pointer-events: none;
}
}
&__node.protyle-task--done:not([data-task="/"]) > .mindmap-view__content {
> .p {
@include task.completed-text;
}
&.mindmap-view__editor .protyle-wysiwyg > .p {
@include task.completed-text;
}
}
// 内层画布为按内容撑开的节点提供固有宽度,避免百分比宽度循环计算后塌缩。
&__editor .mindmap-view {
min-width: 260px;
}
&__editor .protyle-content[data-padding-mode] {
container-type: normal;
}
&__preview-block {
position: relative;
}
&__text {
min-height: 1.5em;
white-space: break-spaces;
word-break: break-word;
&--trailing-newline::after {
content: "\200b";
}
}
&__root-title-host {
position: relative;
}
&__root-title-measure {
display: block;
visibility: hidden;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
&__root-title {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
min-width: 0;
padding: 0;
margin: 0;
border: 0;
outline: none;
resize: none;
overflow: hidden;
box-sizing: border-box;
font: inherit;
color: inherit;
background: transparent;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
&__fold {
position: absolute;
z-index: 1;
right: -19px;
top: calc(50% - 9px);
min-width: 18px;
width: 18px;
height: 18px;
padding: 2px;
border: 1px solid var(--b3-border-color);
border-radius: 50%;
background: var(--b3-theme-background);
visibility: hidden;
font-size: 10px;
box-sizing: border-box;
justify-content: center;
svg {
width: 14px;
height: 14px;
}
&--closed {
visibility: visible;
svg {
display: none;
}
}
&:not(.mindmap-view__fold--closed) .mindmap-view__fold-count {
display: none;
}
}
&__add-child {
position: absolute;
right: -19px;
top: calc(50% - 9px);
min-width: 18px;
width: 18px;
height: 18px;
padding: 2px;
border: 1px solid var(--b3-border-color);
border-radius: 50%;
background: var(--b3-theme-surface);
visibility: hidden;
opacity: 0;
cursor: pointer;
box-sizing: border-box;
justify-content: center;
svg {
width: 14px;
height: 14px;
}
}
// 按节点完整高度连接悬停区域,经过按钮边缘时也保持加号可见。
&__add-bridge {
position: absolute;
left: 100%;
top: 0;
bottom: 0;
width: 19px;
visibility: hidden;
}
&__node--branch > &__add-child {
right: -39px;
}
&__node--branch > &__add-bridge {
width: 39px;
}
&__node:not(.mindmap-view__node--root) {
> .mindmap-view__fold {
top: calc(100% - 6px);
}
> .mindmap-view__add-child {
top: calc(100% - 6px);
}
> .mindmap-view__add-bridge {
bottom: -14px;
// 补齐右下角斜向移出的路径,避免鼠标先落到连线上而收起操作按钮。
&::before {
content: "";
position: absolute;
right: 100%;
bottom: 0;
width: 12px;
height: 14px;
}
}
}
&__node--selected > &__add-child,
&__node--selected > &__fold,
&__node--selected > &__add-bridge,
&__node--line-hover > &__add-child,
&__node--line-hover > &__fold,
&__node--line-hover > &__add-bridge,
&__node:hover > &__add-child,
&__node:hover > &__fold,
&__node:focus-within > &__fold,
&__node:focus-within > &__add-child,
&__node:hover > &__add-bridge,
&__node:focus-within > &__add-bridge {
visibility: visible;
opacity: 1;
}
&__node.mindmap-view__node--hide-controls > &__add-child,
&__node.mindmap-view__node--hide-controls > &__add-bridge {
visibility: hidden;
opacity: 0;
}
&__ghost {
z-index: 5;
opacity: .5;
pointer-events: none;
}
&__relation {
position: absolute;
max-width: 180px;
padding: 2px 6px;
overflow: hidden;
transform: translate(-50%, -50%);
border: 0;
border-radius: 10px;
background: var(--b3-theme-background);
color: var(--b3-theme-primary);
font: inherit;
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
&--hover {
box-shadow: inset 0 0 0 1px var(--b3-theme-primary);
}
&--selected {
outline: inset 0 0 0 2px solid var(--b3-theme-primary);
}
}
&__node--summary {
max-width: 240px;
white-space: normal;
overflow-wrap: anywhere;
}
&__summary-editor {
position: absolute;
width: 240px;
z-index: 6;
}
&__route-handle {
position: absolute;
z-index: 4;
width: 20px;
height: 20px;
padding: 0;
border: 0;
transform: translate(-50%, -50%);
background: transparent;
touch-action: none;
&::before {
content: "";
display: block;
width: 8px;
height: 8px;
margin: auto;
border: 1px solid var(--b3-theme-primary);
border-radius: 2px;
background: var(--b3-theme-background);
box-sizing: border-box;
}
&:hover::before,
&:focus-visible::before {
background: var(--b3-theme-primary);
}
}
&__viewport--route-invalid &__route-handle::before {
border-color: var(--b3-theme-error);
}
&__route-endpoint {
width: 12px;
height: 12px;
cursor: crosshair;
&::before {
width: 10px;
height: 10px;
border-radius: 50%;
}
&[data-endpoint="to"]::before {
background: var(--b3-theme-primary);
}
}
&__route-status {
position: absolute;
bottom: 72px;
left: 50%;
z-index: 6;
transform: translateX(-50%);
max-width: calc(100% - 32px);
padding: 4px 8px;
border-radius: var(--b3-border-radius);
background: var(--b3-theme-background);
color: var(--b3-theme-on-surface);
font-size: 12px;
pointer-events: none;
}
&__inspector {
@include protyle-toolbar-surface($shadow: 0 0 0 1px var(--b3-border-color));
position: absolute;
left: 50%;
right: auto;
transform: translateX(-50%);
bottom: 8px;
z-index: 6;
width: 244px;
min-width: 0;
max-width: calc(100% - 16px);
padding: 4px;
box-sizing: border-box;
overflow-x: auto;
overflow-y: hidden;
align-items: center;
flex-wrap: nowrap;
> button,
> select {
flex-shrink: 0;
}
}
&__relation-editor {
width: 160px;
cursor: text;
z-index: 6;
outline: 1px solid var(--b3-theme-primary);
border-radius: var(--b3-border-radius);
}
&__inspector--node {
display: grid;
grid-template-columns: repeat(8, minmax(0, 1fr));
justify-items: center;
}
&__inspector--line {
align-items: center;
flex-wrap: nowrap;
gap: 0;
.mindmap-view__palette {
margin: 0;
}
> .b3-select {
max-width: 100px;
min-width: 0;
}
}
&__inspector--relation {
width: max-content;
.mindmap-view__palette-row {
width: 176px;
flex-shrink: 0;
}
}
&__node-more {
order: 2;
}
&__tooltip {
// 本地提示保留脑图内的定位和边界约束,供编辑器及导出页面共同使用。
position: absolute;
z-index: 7;
max-width: calc(100% - 16px);
max-height: calc(100% - 8px);
pointer-events: none;
}
&__color-probe {
position: absolute;
width: 0;
height: 0;
visibility: hidden;
pointer-events: none;
}
&__palette-row {
display: grid;
grid-template-columns: repeat(var(--mindmap-toolbar-columns, 8), minmax(0, 1fr));
align-items: start;
justify-items: center;
min-width: 0;
width: 100%;
.mindmap-view__palette {
display: grid;
grid-auto-flow: column;
grid-auto-columns: calc(100% / var(--mindmap-palette-columns));
grid-column: span var(--mindmap-palette-columns);
justify-items: center;
width: 100%;
order: 0;
scrollbar-width: none;
overscroll-behavior: contain;
scroll-snap-type: x mandatory;
scroll-padding-left: max(0px, calc((100% / var(--mindmap-palette-columns) - 26px) / 2));
&[data-scrolling] {
scroll-snap-type: none;
}
> .color__square {
scroll-snap-align: start;
}
}
}
&__palette {
display: flex;
flex-wrap: nowrap;
order: 1;
min-width: 0;
overflow-x: auto;
flex-shrink: 1;
.color__square {
flex-shrink: 0;
}
}
&__node-width {
display: grid;
grid-template-columns: repeat(8, minmax(0, 1fr));
align-items: center;
justify-items: center;
width: 100%;
flex-shrink: 0;
.b3-text-field {
grid-column: span 2;
// 两侧控件按相同外边界排列,滑块左右留白随列宽保持一致。
width: calc(50% + 26px);
max-width: 100%;
min-width: 0;
}
.b3-slider {
grid-column: span 4;
width: 100%;
min-width: 0;
margin: 0;
box-sizing: border-box;
}
.color__square {
flex-shrink: 0;
}
}
&__inspector-popover {
@include protyle-toolbar-surface;
position: absolute;
z-index: 7;
display: flex;
flex-direction: column;
width: max-content;
max-width: calc(100% - 16px);
gap: 4px;
padding: 4px;
box-sizing: border-box;
overflow: auto;
.mindmap-view__palette {
max-width: 100%;
}
.mindmap-view__node-width {
min-width: 0;
flex-shrink: 1;
}
}
}
@media (any-pointer: coarse) {
.mindmap-view__route-endpoint {
width: 28px;
height: 28px;
}
}
@media print {
.mindmap-view {
break-inside: avoid;
outline: none;
height: var(--mindmap-view-print-height, 420px);
min-height: 0;
&__toolbar,
&__resize,
&__inspector,
&__tooltip,
&__route-handle,
&__route-status,
&__selection-box,
&__selection-input,
&__document-viewport,
&__inspector-popover,
&__add-bridge,
&__fold,
&__add-child {
display: none !important;
}
&__node--selected,
&__summary--selected,
&__relation--selected {
outline: none;
}
}
}