Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

10.9 KB
Raw Blame
@use "../util/tokens";

.protyle-wysiwyg, .b3-typography {
  .tabs {
    min-width: 0;
    padding: 0;
    margin: 4px 0;
    position: relative;
    // 将嵌套页签的层级限制在当前块内,避免子页签吸顶栏覆盖父页签栏。
    isolation: isolate;
    border: 1px solid var(--b3-border-color);
    border-radius: var(--b3-border-radius);

    &[data-node-id] {
      padding: 0;
      margin: 4px 0;
      border-radius: var(--b3-border-radius);
    }

    &.protyle-wysiwyg--select::after,
    &.protyle-wysiwyg--select-mode::after,
    &.protyle-wysiwyg--hl::after {
      border-radius: inherit;
    }

    &.protyle-wysiwyg--select-mode {
      border-color: var(--b3-theme-primary-lighter);
      outline: 1px solid var(--b3-theme-primary-lighter);

      &::after {
        box-shadow: none;
      }
    }
  }

  .tabs-header {
    position: sticky;
    top: 0;
    z-index: 4;
    background-color: var(--b3-theme-background);
    display: none;
    align-items: center;
    min-width: 0;
    gap: 4px;
    font-size: min(87.5%, 16px);
    border-bottom: 1px solid var(--b3-theme-background-light);
    padding: 0 4px;
    user-select: none;
  }

  .tabs-list {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    overflow: auto;
    gap: 8px;

    &::-webkit-scrollbar {
      display: none;
    }

    // 方向取自当前列表,避免外层页签的布局影响嵌套页签。
    &[aria-orientation="vertical"] {
      flex-direction: column;
      align-items: stretch;
      gap: 4px;
      flex-basis: 100%;
      max-height: 60vh;

      > .tabs-tab {
        justify-content: flex-start;
        max-width: none;
        margin: 0;
      }
    }
  }

  .tabs-divider {
    display: none;
  }

  .tabs-tab, .tabs-control {
    color: var(--b3-theme-on-surface);
    background: transparent;
    border: 0;
    border-radius: var(--b3-border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 29px;
    margin: 6px 0;
    padding: 0 8px;
    cursor: pointer;
    font: inherit;
    line-height: 22px;
    flex-shrink: 0;
    max-width: 186px;

    &:hover {
      background: var(--b3-theme-surface);
      color: var(--b3-theme-on-background);
    }

    &[aria-selected="true"] {
      color: var(--b3-theme-on-background);
      background: var(--b3-theme-primary-lightest);
      box-shadow: 0 0 0 1px var(--b3-theme-primary-lighter) inset;
    }
  }

  .tabs-tab-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre;
    pointer-events: none;
  }

  .tabs-task {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    font-size: 12px;

    svg {
      width: 16px;
      height: 16px;
    }

    &--custom {
      display: inline-grid;

      svg,
      span {
        grid-area: 1 / 1;
      }

      span {
        text-align: center;
        line-height: 16px;
        font-size: 10px;
      }
    }
  }

  .tabs-tab--dragging {
    opacity: .36;
  }

  .tabs-control {
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 4px;

    svg {
      display: block;
      width: 16px;
      height: 16px;
    }

  }

  .tab-item {
    min-width: 0;
    padding: 4px;
    position: relative;

    &.protyle-wysiwyg--select::after,
    &.protyle-wysiwyg--select-mode::after,
    &.protyle-wysiwyg--hl::after {
      border-radius: inherit;
    }

    &[data-tabs-hidden="true"] {
      display: none;
    }

    &[data-tabs-hidden]:not([data-tabs-editing="true"]) > .tab-item-info {
      display: none;
    }
  }

  .tab-item-title {
    display: block;
    font-weight: bold;
    min-height: 1.5em;
    outline: none;
  }

  .tab-item-content {
    min-width: 0;
    min-height: 1.5em;
    outline: none;

    &.dragover__bottom {
      outline: 2px solid var(--b3-theme-primary-lighter);
      outline-offset: -2px;
      border-radius: var(--b3-border-radius);
    }
  }

  .tabs-tab--editing > .tabs-tab-label {
    visibility: hidden;
  }

  .tabs-list[aria-orientation="horizontal"] > .tabs-tab--editing {
    width: 186px;
    max-width: 100%;
    justify-content: flex-start;
  }

  .tabs-title-editor {
    position: absolute;
    z-index: 5;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 0 8px;
    border-radius: var(--b3-border-radius);
    background: transparent;
    color: var(--b3-theme-on-background);
    font-size: min(87.5%, 16px);
    line-height: 22px;
    user-select: text;

    > [tabs-title] {
      margin: 0;
      padding: 0;
      min-width: 0;
      width: 100%;

      > .protyle-attr {
        display: none;
      }
    }

    .tab-item-title[spellcheck] {
      margin: 0;
      min-width: 0;
      width: 100%;
      min-height: 22px;
      font-size: inherit;
      font-weight: normal;
      opacity: 1;
      white-space: pre;
      word-break: normal;
      overflow-x: auto;
      scrollbar-width: none;

      &::-webkit-scrollbar {
        display: none;
      }

      br {
        display: none;
      }
    }
  }

  .tabs[data-tabs-ready="true"] {
    > .tabs-header {
      display: flex;
    }

    &[data-tabs-orientation="horizontal"] {
      > .tabs-header {
        margin-top: calc(-1 * tokens.token("--tabs-border-top-width"));
        margin-right: calc(-1 * tokens.token("--tabs-border-right-width"));
        margin-left: calc(-1 * tokens.token("--tabs-border-left-width"));
        border-width: inherit;
        border-style: inherit;
        border-color: transparent;
        border-bottom-width: 1px;
        border-bottom-style: solid;
        border-bottom-color: var(--b3-theme-background-light);
        border-radius: tokens.token("--tabs-border-top-left-radius") tokens.token("--tabs-border-top-right-radius") 0 0;

        &::before {
          content: "";
          position: absolute;
          top: calc(-1 * tokens.token("--tabs-border-top-width"));
          right: calc(-1 * tokens.token("--tabs-border-right-width"));
          bottom: -1px;
          left: calc(-1 * tokens.token("--tabs-border-left-width"));
          border-width: inherit;
          border-style: inherit;
          border-color: var(--b3-border-color);
          border-bottom-width: 0;
          border-radius: tokens.token("--tabs-border-top-left-radius") tokens.token("--tabs-border-top-right-radius") 0 0;
          pointer-events: none;
        }

        &::after {
          border-radius: max(0px, calc(tokens.token("--tabs-border-top-left-radius") - tokens.token("--tabs-border-top-width"))) max(0px, calc(tokens.token("--tabs-border-top-right-radius") - tokens.token("--tabs-border-top-width"))) 0 0;
        }
      }

      > .tab-item {
        margin: 0;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-left-radius: inherit;
        border-bottom-right-radius: inherit;
      }

      &.protyle-wysiwyg--select-mode > .tabs-header::before {
        border-color: var(--b3-theme-primary-lighter);
      }
    }

    &[data-tabs-orientation="vertical"] {
      display: grid;
      grid-template-columns: fit-content(min(200px, 40%)) minmax(0, 1fr);

      // 分隔线占满网格行,标题栏按内容高度吸顶,加号紧跟页签列表。
      > .tabs-divider {
        display: block;
        grid-area: 1 / 1;
        border-right: 1px solid var(--b3-border-color);
        pointer-events: none;
      }

      > .tab-item {
        grid-area: 1 / 2;
      }

      > .tabs-header {
        grid-area: 1 / 1;
        align-self: start;
        box-sizing: border-box;
        min-width: 80px;
        flex-wrap: wrap;
        align-content: start;
        align-items: stretch;
        padding-top: 6px;
        border-bottom: 0;
        border-right: 1px solid var(--b3-border-color);
        border-top-left-radius: max(0px, calc(var(--b3-border-radius) - tokens.token("--tabs-border-left-width")));
        border-bottom-left-radius: max(0px, calc(var(--b3-border-radius) - tokens.token("--tabs-border-left-width")));
      }
    }
  }
}

.protyle-wysiwyg {
  > .tab-item > .tab-item-info {
    border-bottom: 1px solid var(--b3-border-color);
  }

  .tabs-attributes {
    display: none;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
    min-width: 24px;
    max-width: 40%;
    height: 24px;
    padding: 2px 4px;
    box-sizing: border-box;
    border: 0;
    border-radius: var(--b3-border-radius);
    background: transparent;
    color: var(--b3-theme-on-surface);
    font: 12px/20px var(--b3-font-family);
    cursor: pointer;

    &:hover {
      background: var(--b3-theme-surface);
    }

    svg {
      width: 12px;
      height: 12px;
      flex-shrink: 0;
    }

    &__icon {
      display: none;
    }

    &__summary {
      display: flex;
      min-width: 0;
      gap: 6px;

      > span {
        display: flex;
        align-items: center;
        gap: 2px;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
      }
    }

    &--compact {
      flex-shrink: 0;

      .tabs-attributes__icon {
        display: block;
      }

      .tabs-attributes__summary {
        display: none;
      }
    }
  }

  .tabs-header > .tabs-attributes {
    margin-left: auto;
  }

  // 首个子块沿用普通属性样式,仅将属性移入内容区以避开吸顶栏。
  .tabs[data-tabs-ready="true"][data-tabs-orientation="horizontal"] > .tab-item >
  .tab-item-content > [data-node-id]:first-child > .protyle-attr {
    top: 0;
  }

  @media screen {
    &--attr {
      .tabs-attributes {
        display: flex;
      }

      // 原属性保留供事务读取,隐藏时不与通用属性的文本截断显示规则竞争。
      [data-tabs-attributes] > .protyle-attr {
        visibility: hidden;

        > .protyle-attr--refcount {
          visibility: visible;
        }
      }

    }
  }

  .protyle-wysiwyg--select > .tabs-header::after,
  .protyle-wysiwyg--select-mode > .tabs-header::after,
  .protyle-wysiwyg--hl > .tabs-header::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background-color: var(--b3-theme-primary-lightest);
    border-radius: inherit;
    pointer-events: none;
  }
}

@media print {
  .protyle-wysiwyg, .b3-typography {
    .tabs[data-tabs-ready="true"] {
      display: block !important;
    }

    .tabs-header, .tabs-divider {
      display: none !important;
    }

    .tab-item[data-tabs-hidden], .tab-item[data-tabs-hidden] > .tab-item-info {
      display: block !important;
    }

    .tabs-title-editor {
      position: static;
      width: auto !important;
      height: auto !important;
      clip-path: none !important;
      padding: 0;
      background: transparent;
      box-shadow: none;
      font-size: inherit;

      .tab-item-title[spellcheck] {
        font-weight: bold;
        white-space: normal;
        overflow: visible;

        br {
          display: initial;
        }
      }
    }
  }
}