Skip to content

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

27.0 KB
Raw Blame
@use "../util/mixin";
@use "inline";
@use "tabs";
@use "task";

// 导出样式可使用原始方向属性,支持未执行脚本的静态内容。
$block-rtl-selector: ".protyle-block--rtl" !default;

// 任务点击保持隐藏布局,正文编辑时恢复引用块;折叠的列表项和标题保留定位内容。
.protyle-wysiwyg[data-backlink-hide-reference]:is(:not(:focus-within), [data-backlink-task-focus]) {
  [data-backlink-reference]:not([fold="1"]):not(.li[fold="1"] *) {
    display: none !important;
  }

  .li[data-backlink-reference-list]:not([fold="1"]):not(.li[fold="1"] *) {
    min-height: 0;

    &::before,
    > .protyle-action,
    > .protyle-attr {
      display: none !important;
    }

    > [data-node-id] {
      margin-left: 0 !important;
      margin-right: 0 !important;
    }
  }
}

.protyle-cross-block-preview {
  pointer-events: none;

  &__selection {
    background-color: var(--b3-theme-primary-lighter);
  }
}

.protyle-cross-block-source {
  position: fixed !important;
  opacity: 0;
  pointer-events: none;
}

.protyle-wysiwyg,
.table__cell-rich {
  padding: 16px 16px 16px 24px;
  box-sizing: border-box;
  // 移除三击无法选中整个 https://github.com/siyuan-note/siyuan/issues/8511
  user-select: auto;
  overflow-x: clip;

  &--empty:empty::before {
    color: var(--b3-empty-color);
    content: attr(placeholder);
    cursor: text;
  }

  .protyle-breadcrumb__bar {
    font-size: 14px;
  }

  .sy__backlink & > .protyle-breadcrumb__bar {
    user-select: none;
  }

  &:focus {
    outline: none;
  }

  [contenteditable="true"] {
    cursor: text;
  }

  [data-node-id],
  [data-table-cell-node] {
    position: relative;

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

    &[data-type="NodeHeading"] {
      & > .protyle-heading-number__measure {
        position: absolute;
        visibility: hidden;
        white-space: pre;
        color: var(--b3-theme-on-surface-light);
        pointer-events: none;
      }
    }

    &.dragover {
      &__left::after,
      &__right::after,
      &__top::after,
      &__bottom::after {
        content: '';
        position: absolute;
        background-color: var(--b3-theme-primary-lighter);
        pointer-events: none;
      }

      &__top::after,
      &__bottom::after {
        left: 0;
        right: 0;
        height: 4px;
      }

      &__top::after {
        top: -4px;
      }

      &__bottom::after {
        bottom: -4px;
        top: auto;
      }

      &__left::after,
      &__right::after {
        top: 0;
        bottom: 0;
        width: 4px;
      }

      &__left::after {
        left: -4px;
      }

      &__right::after {
        right: -4px;
      }

      &.li,
      &.list,
      &.sb {
        background-color: var(--b3-theme-primary-lightest);
        border-radius: 4px;
      }
    }

    &[custom-riff-decks] {
      box-shadow: 2px 0 0 0 var(--b3-protyle-inline-mark-background) inset;
    }

    [spellcheck],
    [data-table-cell-content] {
      min-height: 1.625em;
      word-break: break-word;
      // https://github.com/siyuan-note/siyuan/issues/10483
      white-space: break-spaces;

      &:focus {
        outline: none;
      }
    }

    &.hr {
      cursor: pointer;

      & > div {
        padding-left: 100%;
        position: relative;
        min-height: 1.625em;

        &::after {
          position: absolute;
          content: " ";
          height: calc(1em / 16);
          background-color: var(--b3-theme-background-light);
          width: calc(100% - 1px);
          left: 0;
          top: calc(1.625em / 2);
        }
      }
    }

    &.list {
      padding: 0;
      display: flex;
      flex-direction: column;

      & > .li:first-child {
        margin-top: 0;
      }

      & > div:nth-last-child(2) {
        margin-bottom: 0;
      }
    }

    &.li {
      padding: 0;
      display: flex;
      flex-direction: column;
      min-height: calc(1.625em + 8px);

      &::before {
        content: "";
        position: absolute;
        border-left: .5px solid var(--b3-theme-background-light);
        left: 17px;
        height: calc(100% - 1em * 1.625 - 12px);
        top: calc(1em * 1.625 + 12px);
      }

      &:hover::before {
        border-left-color: var(--b3-scroll-color);
      }

      & > [data-node-id],
      & > [data-table-cell-node] {
        margin-left: 34px;
      }

      > [data-type="NodeIFrame"],
      > [data-type="NodeWidget"] {
        max-width: calc(100% - 34px);
      }

      & > [data-node-id]:not(.p):not(.code-block),
      & > [data-table-cell-node]:not(.p):not(.code-block) {
        padding-right: 0;
      }

      & > div:nth-child(2) {
        margin-top: 0;
      }

      & > div:nth-last-child(2) {
        margin-bottom: 0;
      }

      &[fold="1"] {
        &::before {
          content: none;
        }

        & > .protyle-action::after {
          background-color: var(--b3-list-hover);
        }

        & > div:nth-child(2) {
          margin-bottom: 0;
        }

        & > div:nth-child(3):not(.protyle-attr),
        & > div:nth-child(3) ~ div:not(.protyle-attr) {
          display: none;
        }
      }

      & > .protyle-action {
        left: 0;
        position: absolute;
        width: 34px;
        top: 0;
        transition: var(--b3-transition);
        color: var(--b3-theme-on-surface);
        justify-content: center;
        display: flex;
        align-items: center;
        word-break: keep-all;
        height: calc(1.625em + 8px);
        line-height: calc(1.625em + 8px);

        & ~ [data-type="NodeHeading"] {
          &.h1 {
            line-height: calc(1.625em / 1.75);
          }

          &.h2 {
            line-height: calc(1.625em / 1.55);
          }

          &.h3 {
            line-height: calc(1.625em / 1.38);
          }

          &.h4 {
            line-height: calc(1.625em / 1.25);
          }

          &.h5 {
            line-height: calc(1.625em / 1.13);
          }

          &.h6 {
            line-height: 1.625em;
          }

          & > [spellcheck] {
            min-height: 1lh;
          }
        }

        &::after {
          @include mixin.protyle-list-action-background;
        }

        svg {
          width: 34px;
          height: max(14px, 1em - 4px);
          display: block;
          z-index: 1;
          position: relative;
          pointer-events: none;
        }

        &--order::after,
        &--task::after {
          border-radius: var(--b3-border-radius);
        }
      }

      & > div[fold="1"][data-type="NodeHeading"]::before {
        left: -6px;
        height: 7px;
        width: 7px;
        margin-top: -4px;
      }
    }

    &#{$block-rtl-selector} {
      .li:not([data-auto-direction]) > .protyle-action,
      &:not([data-auto-direction]) > .protyle-action {
        right: 0;
        left: auto;
        direction: rtl;
      }

      .li:not([data-auto-direction]) > [data-node-id],
      .li:not([data-auto-direction]) > [data-table-cell-node],
      &:not([data-auto-direction]) > [data-node-id],
      &:not([data-auto-direction]) > [data-table-cell-node] {
        margin-right: 34px;
        margin-left: 0;
      }

      .li:not([data-auto-direction])::before,
      &:not([data-auto-direction])::before {
        right: 17px;
        left: auto;
      }

      &.dragover__top--sibling::before,
      &.dragover__bottom--sibling::before,
      &.dragover__top--child::before,
      &.dragover__bottom--child::before {
        left: auto;
        right: calc(var(--drag-indent) / 2);
        transform: translateX(50%);
      }

      &.dragover__top--sibling::after,
      &.dragover__bottom--sibling::after,
      &.dragover__top--child::after,
      &.dragover__bottom--child::after {
        left: auto;
        right: var(--drag-line-left);
      }
    }

    &.li[data-auto-direction] {
      & > .protyle-action {
        left: auto;
        right: auto;
        inset-inline-start: 0;
        direction: inherit;
      }

      & > [data-node-id],
      & > [data-table-cell-node] {
        margin-left: 34px;
        margin-right: 0;
      }

      &[data-auto-list-direction="rtl"] > [data-node-id],
      &[data-auto-list-direction="rtl"] > [data-table-cell-node] {
        margin-left: 0;
        margin-right: 34px;
      }

      &::before {
        left: auto;
        right: auto;
        inset-inline-start: 17px;
      }

      &:is(.dragover__top--sibling, .dragover__bottom--sibling, .dragover__top--child, .dragover__bottom--child) {
        &::before {
          left: auto;
          right: auto;
          inset-inline-start: calc(var(--drag-indent) / 2);
          transform: translateX(-50%);
        }

        &[data-auto-list-direction="rtl"]::before {
          transform: translateX(50%);
        }

        &::after {
          left: auto;
          right: auto;
          inset-inline-start: var(--drag-line-left);
          inset-inline-end: 0;
        }
      }
    }

    &.dragover__top--sibling::before,
    &.dragover__bottom--sibling::before,
    &.dragover__top--child::before,
    &.dragover__bottom--child::before {
      content: '';
      position: absolute;
      left: calc(var(--drag-indent) / 2);
      transform: translateX(-50%);
      width: calc(var(--drag-indent) * 0.75);
      height: max(3px, calc(var(--drag-indent) / 12));
      border-radius: max(1px, calc(var(--drag-indent) / 30));
      pointer-events: none;
      border-left: none;
      background: var(--drag-base-bg);
      box-shadow: var(--drag-guides);
    }

    &.dragover__top--sibling::after,
    &.dragover__bottom--sibling::after,
    &.dragover__top--child::after,
    &.dragover__bottom--child::after {
      content: '';
      position: absolute;
      right: 0;
      height: 4px;
      // 横向插入线使用独立颜色变量,避免与 ::before 目标标记共用 --drag-base-bg 导致半透明叠加变深
      background-color: var(--drag-line-bg);
      pointer-events: none;
      left: var(--drag-line-left);
    }

    &.dragover__top--sibling::before,
    &.dragover__top--child::before {
      top: -4px;
    }

    &.dragover__bottom--sibling::before,
    &.dragover__bottom--child::before {
      top: auto;
      bottom: -4px;
    }

    &.dragover__top--sibling::after,
    &.dragover__top--child::after {
      top: -4px;
    }

    &.dragover__bottom--sibling::after,
    &.dragover__bottom--child::after {
      bottom: -4px;
    }

    &.sb {
      display: flex;
      flex-direction: column;
      padding: 0;
      max-width: 100%;

      &[data-sb-layout="col"] {
        flex-direction: row;
        // nowrap:子块宽度用 calc(%) 计算时,容器缩窄通过 flex-shrink 等比收缩而非换行掉落
        flex-wrap: nowrap;
        justify-content: flex-start;

        & > div {
          // 默认 1 1 0:未拖拽的子块均分填满超级块;容器缩窄时也可收缩
          // 拖拽后由 inline style 覆盖为 flex:0 1 auto + calc(%),锁定比例
          flex: 1 1 0;
          box-sizing: border-box;
          min-width: 0;
          max-width: 100%;

          &:nth-last-child(2),
          &:last-child {
            margin-right: 0;
          }
        }

        > .sb__resize {
          align-self: stretch;
          // 手柄不参与收缩,保持拖拽热区宽度恒定
          flex: 0 0 auto;
          width: 2px;
          border-radius: var(--b3-border-radius);
          cursor: col-resize;
          touch-action: none;
          opacity: 0;
          margin-right: 16px;
          background-color: var(--b3-theme-primary-light);
          // 透明覆盖层扩展点击热区,让 4px 的细手柄也能轻松点中
          position: relative;
          z-index: 5;

          &::before {
            content: "";
            position: absolute;
            top: 0;
            bottom: 0;
            left: -8px;
            right: -8px;
            z-index: -1;
          }

          &:hover {
            opacity: 1;
          }
        }

        // 拖拽中的百分比提示(复用 protyle-icon 样式,仅添加定位)
        > [data-node-id] .sb__resize-tip {
          position: absolute;
          top: 0;
          right: 0;
          z-index: 10;
          pointer-events: none;
          user-select: none;
        }

        .sb {
          margin-top: 0;
          margin-bottom: 0;
        }

        & > div .protyle-attr--refcount {
          position: initial;
          margin-left: 4px;
        }
      }
    }

    @include inline.interactive-marks;

    &.render-node {
      min-height: 32px;

      &:hover > .protyle-icons {
        opacity: .86;
      }

      &[data-type="NodeBlockQueryEmbed"] {
        background-color: var(--b3-embed-background);
        border: 1px dashed var(--b3-theme-on-surface-light);
        max-width: 100%;
        padding: 2px 4px;

        & > .protyle-icons[data-entry-hidden="true"],
        & > .protyle-wysiwyg__embed > .protyle-icons[data-entry-hidden="true"] {
          display: none;
        }

        /* 选中块的高亮覆盖 border */
        &.protyle-wysiwyg--select::after,
        &.protyle-wysiwyg--select-mode::after,
        &.protyle-wysiwyg--hl::after {
          width: calc(100% + 2px);
          height: calc(100% + 2px);
          left: -1px;
          top: -1px;
        }

        // https://github.com/siyuan-note/siyuan/issues/8715 & https://ld246.com/article/1689063197687 第一点无法进行以下设置
        //.protyle-attr--refcount {right: 0;}

        & > .protyle-wysiwyg__embed {
          border-top: 1px dashed var(--b3-theme-on-surface-light);
          position: relative;

          &:hover .protyle-icons {
            opacity: 1;
          }

          .code-block:hover .protyle-icon,
          .render-node:hover .protyle-icons {
            opacity: 0 !important;
          }
        }

        & > .protyle-icons {
          // https://github.com/siyuan-note/siyuan/issues/14678
          z-index: 2;

          &.protyle-icons--editing-obscured {
            opacity: 0;
            pointer-events: none;
          }

          & + .protyle-wysiwyg__embed {
            border-top: 0;
          }
        }
      }
    }

    &.custom-block {
      min-height: 32px;

      & > .custom-block__content > pre {
        color: var(--b3-theme-on-surface-light);
        font-family: var(--b3-font-family-code);
        margin: 0;
        overflow: auto;
        padding: 8px;
        white-space: pre-wrap;
        word-break: break-word;
      }
    }

    code:not(.hljs):empty {
      padding: 0;
    }

    &.table[custom-pinthead="true"] {
      & > div:first-child {
        max-height: 50vh;
        overflow: auto;

        &::-webkit-scrollbar-track:vertical,
        &::-webkit-scrollbar-corner {
          background-color: var(--b3-parent-background);
        }
      }

      table {
        border-radius: var(--b3-table-border-radius-top-left) var(--b3-table-border-radius-top-right) var(--b3-table-border-radius-bottom-right) var(--b3-table-border-radius-bottom-left);
        box-shadow: inset 0 -1px 0 var(--b3-theme-surface-lighter);
      }

      thead {
        position: sticky;
        top: 0;
        z-index: 2;
        box-shadow: 0 -1px 0 var(--b3-border-color) inset;
        background-color: var(--b3-parent-background);

        th {
          border-top: 0;
        }
      }
    }

    .img {

      user-select: none;
      // 不能放在 typography 下 https://github.com/siyuan-note/siyuan/issues/9844
      &:not([style]) {
        display: initial;
      }

      &--select {
        filter: brightness(.68);
      }

      &--drag > span::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }

      > .protyle-image-container {
        position: relative;

        > .img__name {
          font-size: min(100%, var(--protyle-image-font-size, 100%));
        }

        > .protyle-action__title,
        > .img__alt {
          font-size: min(85%, var(--protyle-image-font-size, 85%));
        }
      }

      > .protyle-image-container--compact {
        > .protyle-icons,
        > .img__net,
        .protyle-block-resize[data-resize-axis="width"],
        .protyle-block-resize[data-resize-axis="height"] {
          display: none;
        }

        .protyle-block-resize[data-resize-axis="both"]::after {
          width: 5px;
          height: 5px;
          // 鼠标与触屏手柄都向图片内部延伸 8px,将圆点中心固定在图片角上。
          left: 8px;
          top: 8px;
          right: auto;
          bottom: auto;
          transform: translate(-50%, -50%);
          border: 0;
          border-radius: 50%;
          background-color: currentColor;
        }
      }

      .protyle-image-resize {
        position: absolute;
        pointer-events: none;
        z-index: 6;

        > .protyle-block-resize {
          pointer-events: auto;
        }
      }

      &:hover .protyle-block-resize {
        opacity: 1;
      }

      &__net {
        position: absolute;
        top: 4px;
        left: 4px;
        color: var(--b3-theme-primary);
        background-color: var(--b3-theme-surface-lighter);
        padding: 4px;
        border-radius: var(--b3-border-radius);

        svg {
          height: 12px;
          width: 12px;
          float: left;
        }
      }
    }

    &.iframe {
      // https://ld246.com/article/1644827326901
      // https://github.com/siyuan-note/siyuan/issues/4172
      &[data-type="NodeWidget"],
      &[data-type="NodeIFrame"] {
        .iframe-content {
          -webkit-user-modify: read-only;
        }
      }

      user-select: none;

      &--drag {
        .iframe-content::after {
          content: "";
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
        }
      }

      &:not([data-type="NodeIFrame"]):not([data-type="NodeWidget"]) .protyle-action__drag {
        height: 32px;
        width: 4px;
        background-color: var(--b3-theme-surface);
        display: none;
        border-radius: var(--b3-border-radius);
        cursor: nwse-resize;
        transition: var(--b3-transition);
        position: absolute;
        right: -4px;
        bottom: 0;
        box-shadow: 0 0 1px 1px var(--b3-theme-on-surface);
        box-sizing: border-box;

        &::after {
          content: "";
          background-color: var(--b3-theme-surface);
          width: 32px;
          height: 4px;
          display: block;
          position: absolute;
          bottom: 0;
          right: 0;
          border-radius: var(--b3-border-radius);
          box-shadow: 0 0 1px 1px var(--b3-theme-on-surface);
          box-sizing: border-box;
          cursor: nwse-resize;
        }

        &:hover,
        &:hover::after {
          background-color: var(--b3-theme-background);
          box-shadow: 0 0 1px 1px var(--b3-theme-on-background);
        }
      }
    }
  }

  &--select::after,
  &--select-mode::after,
  &--hl::after {
    background-color: var(--b3-theme-primary-lightest);
    position: absolute;
    width: 100%;
    height: 100%;
    content: " ";
    left: 0;
    top: 0;
    z-index: 3;
    pointer-events: none;
    border-radius: var(--b3-border-radius);
  }

  &--select-mode::after {
    box-shadow: inset 0 0 0 1px var(--b3-theme-primary-lighter);
  }

  &--hl {
    transition: var(--b3-background-transition);
  }

  &--hiderange {
    ::selection {
      background-color: transparent;
    }

    .hljs ::selection {
      background-color: transparent;
      color: inherit;
    }
  }

  // https://github.com/siyuan-note/siyuan/issues/11589
  .hljs wbr {
    display: none;
  }

  &--attr .protyle-attr {
    opacity: 1;

    & > div {
      &.protyle-attr--memo {
        cursor: pointer;
      }

      &:not(.protyle-attr--memo):not(.protyle-attr--refcount) {
        cursor: pointer;
        @include mixin.text-clamp(1);
        max-width: 25vw;
      }
    }

    .b3-tooltips::after {
      max-width: var(--b3-width-protyle-wysiwyg);
    }
  }

  &--animate {
    animation: bottom2Top .3s ease-in-out;
  }

  div[data-type="NodeMathBlock"] {
    min-height: 62px !important;
  }

  div[data-type="NodeHTMLBlock"] {
    min-height: 26px !important;
  }

  div[fold="1"][data-type="NodeHeading"]::before {
    content: "";
    height: 16px;
    width: 16px;
    background-color: var(--b3-theme-surface-lighter);
    display: block;
    position: absolute;
    // 与块标到内容的 4 像素间距保持一致,使折叠三角形位于圆圈中央。
    left: -20px;
    top: 50%;
    border-radius: var(--b3-border-radius-b);
    margin-top: -8px;
    border-left: 0 !important;
  }

  .bq > div[fold="1"][data-type="NodeHeading"]::before,
  .callout-content > div[fold="1"][data-type="NodeHeading"]::before {
    left: -30px;
  }

  div[fold="1"][data-type="NodeHeading"][data-heading-empty="true"]::before {
    display: none;
  }

  [data-node-id][fold="1"]:not(.li):not([data-type="NodeHeading"]) {
    @include mixin.text-clamp(1);
    opacity: .38;

    // 隐藏容器块的后续子块,避免光标移入折叠内容带来的一系列问题
    &.bq > [data-node-id] ~ [data-node-id],
    &.callout > .callout-content > [data-node-id] ~ [data-node-id] {
      display: none;
    }

    .protyle-attr {
      opacity: 0;
    }

    &.av {
      height: 4.8em;
    }

    &.table {
      height: calc(1.625em + 6px);
    }

    &.sb {
      height: calc(1.625em + 12px);
      display: flex;
    }

    &.list {
      height: calc(1.625em + 12px);
    }

    &.callout {
      display: block;
      height: auto;

      > .callout-content {
        display: none;
      }
    }

    &.tabs {
      display: block;
      height: calc(1.625em + 12px);

      > .tab-item,
      > .tabs-divider {
        display: none;
      }
    }

    &[data-type="NodeMindmap"],
    &[data-type="NodeList"][custom-sy-list-mindmap="1"] {
      height: calc(1.625em + 12px);
      max-height: calc(1.625em + 12px);

      > .mindmap-view {
        display: none;
      }

      > [data-node-id]:first-child {
        display: block;
      }
    }

    &[data-type="NodeBlockQueryEmbed"],
    &.bq {
      height: calc(1.625em + 8px);
    }

    &.code-block {
      line-height: 1.625;
      height: 1.625em;

      .protyle-action__language {
        opacity: .86;
      }

      .protyle-action__copy,
      .protyle-action__menu {
        margin-top: -2px;
      }
    }

    .protyle-wysiwyg__embed {
      overflow: hidden;
    }
  }
}

.protyle .protyle-wysiwyg {
  // 只读情况下列表前的圆点需要可以点击进行缩放
  .li[data-subtype="o"] > .protyle-action,
  .li[data-subtype="u"] > .protyle-action,
  &[data-readonly="false"] .li[data-subtype="t"] > .protyle-action {
    cursor: pointer;

    &:hover {
      @include mixin.protyle-list-action-hover;
    }
  }

  // 复制粘贴序号会状态异常 https://ld246.com/article/1762691143057
  .li > .protyle-action {
    user-select: none;
  }
}

body[data-format-painter] .protyle-wysiwyg[data-readonly="false"] {
  cursor: text;
}

.protyle-wysiwyg[data-readonly="true"] .iframe .protyle-block-resize,
.protyle-wysiwyg[data-readonly="true"] [data-subtype="mermaid"] > .protyle-block-resize,
.protyle-wysiwyg .sb > [data-subtype="mermaid"] > .protyle-block-resize {
  display: none;
}

.protyle-wysiwyg [data-subtype="mermaid"]:hover > .protyle-block-resize {
  opacity: 1;
}

.protyle-wysiwyg[data-readonly="true"] .protyle-image-resize,
.protyle-wysiwyg__embed .protyle-image-resize,
.mindmap-view__preview-block .protyle-image-resize {
  display: none;
}

.protyle-wysiwyg[data-readonly="false"] .img .protyle-image-caption {
  margin-top: 12px;
}

@media (any-pointer: coarse) {
  .protyle-wysiwyg[data-readonly="false"] .img .protyle-image-caption {
    margin-top: 20px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .protyle-wysiwyg .img:not(.img--select):not(.img--drag) .protyle-block-resize {
    visibility: hidden;
    pointer-events: none;
  }
}

.protyle-format-painter__cursor {
  position: fixed;
  z-index: 9;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  color: var(--b3-theme-on-background);
  pointer-events: none;
  will-change: transform;

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

// 在思源中,不论只读模式还是预览点击图片都可以进行预览
.protyle .img > span:nth-child(2) {
  cursor: pointer;
}

// 导出 html 不需要编辑样式
.protyle-wysiwyg[data-readonly="false"] {
  &[contenteditable="true"] [data-node-id].table {
    padding-right: 30px;
    padding-bottom: 30px;
  }

  caption {
    cursor: pointer;
  }

  span[data-type~="inline-math"],
  .protyle-action__language,
  .render-node:not([data-type="NodeBlockQueryEmbed"]) {
    cursor: pointer;
  }

  span[data-type~="tag"]:hover {
    background-color: var(--b3-theme-surface-lighter);
  }


  .img:hover .protyle-action__drag,
  .iframe:hover .protyle-action__drag {
    display: inline-block;
  }

  .iframe:hover .protyle-block-resize {
    opacity: 1;
  }

  .code-block .protyle-action {
    -webkit-user-modify: read-only;

    .protyle-action__language {
      &:hover {
        color: var(--b3-theme-on-background);
      }

      &:empty::after {
        content: "language";
        opacity: .68;
      }
    }
  }

  .img:hover .protyle-icons {
    opacity: .86;
  }

  .callout-icon {
    cursor: pointer;
    transition: var(--b3-background-transition);

    &:hover {
      background-color: var(--b3-list-hover);
    }
  }

  .callout-title {
    cursor: text;

    &:hover {
      opacity: 1;
    }
  }
}

.protyle-wysiwyg:not([contenteditable]),
.protyle-wysiwyg[data-readonly="true"] {
  // 只读时仅隐藏手柄并禁用交互,保留其占位宽度,避免子块间距变化导致横向布局改变
  .sb__resize {
    visibility: hidden;
    pointer-events: none;
  }

  .img:hover .protyle-icons {
    display: none;
  }

  .av {
    .b3-chip[data-type="block-more"],
    .av__row--util:not(.av__readonly--show),
    .av__row--footer:not(.av__readonly--show),
    .av__row--util .b3-button[data-type="av-add-bottom"],
    .av__row--util svg[data-type="set-page-size"],
    .av__row--header > .block__icons,
    .av__views .fn__space,
    .av__views .block__icon:not([data-type="av-search-icon"]):not(.av__readonly-sort),
    .av__widthdrag,
    .av__gallery-actions,
    .av__gallery-add,
    .av__new {
      display: none;
    }

    .av__row--util:not(.av__readonly--show) + .av__row--footer.av__readonly--show {
      border-top-color: transparent;
    }

    .av__row > div:nth-last-child(-n + 2) {
      border-right-color: transparent;
    }

    .av__row--footer:hover .av__calc:not(.av__calc--ashow) {
      opacity: 0;
    }

    &:hover .av__group-icon--hover {
      display: none;
    }

    .av__row--footer .av__calc:hover,
    .av__cell--header:hover {
      background-color: transparent;
    }

    .av__cell {
      cursor: inherit;

      &text--url,
      &assetimg {
        cursor: pointer;
      }
    }

    .av__row .av__cell[data-dtype="block"] > .av__cell-action[data-type="copy"] {
      display: flex;
    }
  }
}

// export pdf 中需要使用 https://github.com/siyuan-note/siyuan/issues/14548
.protyle-cursor {
  position: absolute;
  right: 0;
  top: 0;
}