@import (reference) "../../../assets/css/index";
@import "./quill.snow.less";
@import "./emoji.less";

@tabs-prefix: ~"@{fishd-prefix}-tabs";
@popover-prefix: ~"@{fishd-prefix}-popover";
@rich-editor-prefix: ~"@{fishd-prefix}-richeditor";
@icon-normal-color: @text-6;

/* stylelint-disable declaration-no-important */
.@{rich-editor-prefix}-link-modal,
.@{rich-editor-prefix}-video-modal {
  .text {
    font-size: 14px;
    margin-right: 8px;
    color: #333;
  }

  .tip {
    font-size: 12px;
    margin-top: 8px;
    color: #999;
  }
}

.@{rich-editor-prefix}-image-modal {
  .tip {
    font-size: 12px;
    margin-top: 8px;
    color: #999;
  }
}

.@{rich-editor-prefix}.resizable {
  .iconfont-mixin();
  resize: both;
  display: flex;
  flex-direction: column;

  &:before {
    position: absolute;
    cursor: nw-resize;
    content: '\e6db';
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    color: @border-color-base;
    background-color: #fff;
    z-index: 10;
  }
}

.@{rich-editor-prefix} {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 320px;
  border: @border-width-base @border-style-base @border-color-base;

  .hide {
    display: none !important;
  }

  .editor-head {
    display: block;
    padding: 0 14px 5px;
    border: none;
    border-radius: @border-radius-base @border-radius-base 0 0;
    border-bottom: none;
    background: #fafbfc;
    white-space: normal;
  }

  .editor-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    border-top: @border-width-base @border-style-base @border-color-base;
    overflow: hidden; // 修复升级浏览器到Chrome 76后导致的flex布局异常

    .ql-editor {
      overflow-y: scroll;
      .scrollbar();
      -moz-user-select: all;
      -ms-user-select: auto;
      -webkit-user-select: auto;  // fix bug: safari can't edit
      user-select: all;
      // 默认文本的大小和颜色
      font-size: 14px;
      color: #333;
    }

    .ql-editor.ql-blank::before {
      color: @input-placeholder-color;
      font-style: normal;
    }

    .custom-hide {
      display: none !important;
    }

    .custom-show {
      display: flex !important;
    }
  }

  .item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    width: 28px;
    height: 24px;
    float: left;
    margin-top: 6px;

    &:focus,
    .ql-picker:focus,
    .ql-picker-label:focus {
      outline: none;
    }
  }

  // .item.@{popover-prefix}-open,
  .ql-active {
    background: @primary-color !important;
    border-color: @primary-color !important;
    color: #fff !important;

    .ql-stroke {
      stroke: #fff !important;
    }

    .ql-fill {
      fill: #fff !important;
    }
  }

  // 区分默认的超链接和自定义超链接的高亮
  // .item.@{popover-prefix}-open,
  // .ql-active:not(.ql-myLink):not(.custom-entry),
  // .link-active {
  //   background: @primary-color !important;
  //   border-color: @primary-color !important;
  //   color: #fff !important;

  //   .ql-stroke {
  //     stroke: #fff !important;
  //   }

  //   .ql-fill {
  //     fill: #fff !important;
  //   }
  // }

  .toolbar-grp {
    // display: inline-block;
    float: left;
    margin: 0 12px 0 0;

    > .item {
      position: relative;
      display: inline-block;
      background: @component-background;
      border-left: @border-width-base @border-style-base @border-color-base;
      border-top: @border-width-base @border-style-base @border-color-base;
      border-bottom: @border-width-base @border-style-base @border-color-base;
      color: @icon-normal-color;

      &:after {
        position: absolute;
        content: '';
        top: 0;
        right: -1px;
        border-right: @border-width-base @border-style-base @border-color-base;
        width: 0;
        height: 100%;
      }

      .action {
        width: 100%;
        height: 100%;
        outline: none;
      }

      .ql-picker-options .ql-stroke {
        stroke: @icon-normal-color;
      }

      .ql-picker-item:hover {
        color: @primary-color;
        background-color: @background-color-base;
      }

      .ql-picker-item:hover .ql-stroke {
        stroke: @primary-color;
      }

      .ql-fill {
        fill: @icon-normal-color;
      }

      .ql-formatPainter {
        color: @icon-normal-color;
      }
    }

    > .item:hover {
      color: @icon-normal-color;
      background: @richeditor-icon-hover-bg;

      .ql-picker-options,
      .ql-picker-label {
        color: @icon-normal-color;
      }

      .ql-stroke {
        stroke: @icon-normal-color;
      }

      .ql-fill {
        fill: @icon-normal-color;
      }
    }

    > .item:first-child {
      border-top-left-radius: @border-radius-base;
      border-bottom-left-radius: @border-radius-base;
    }

    > .item:last-child {
      border-right: @border-width-base @border-style-base @border-color-base;
      border-top-right-radius: @border-radius-base;
      border-bottom-right-radius: @border-radius-base;
    }

    &:last-child {
      margin-right: 0;
    }
  }

  .custom-icon {
    position: relative;
    width: 28px;
    height: 24px;
    float: left;
    cursor: pointer;
    color: @icon-normal-color;
    padding: 5px 6px 6px 5px;
  }

  .custom-color,
  .custom-size,
  .custom-emoji,
  .custom-entry {
    .custom-icon;
  }

  .ql-myLink,
  .ql-link,
  .ql-bold,
  .ql-italic,
  .ql-underline,
  .ql-list,
  .ql-image,
  .ql-clean {
    svg {
      display: none;
    }
  }

  .ql-align > svg {
    display: none;
  }

  .ql-align .ql-picker-label,
  .ql-align .ql-picker-item {
    .iconfont-mixin();
    display: flex;
    align-items: center;
    justify-content: center;

    &:before {
      content: "\e6c2";
    }

    &[data-value='center']:before {
      content: "\e6c7";
    }

    &[data-value='right']:before {
      content: "\e6c9";
    }

    &[data-value='justify']:before {
      content: "\e6cf";
    }

    svg {
      display: none;
    }
  }
}

.@{rich-editor-prefix}-size-popover {
  .@{popover-prefix}-inner-content {
    padding: 0;
  }

  .size-con {
    position: relative;
    display: inline-block;
    padding: 5px 0;
  }

  .size-item {
    display: block;
    width: 100%;
    padding: 3px 5px;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    text-align: left;

    &:hover {
      background: @richeditor-icon-hover-bg;
    }
  }

  .size-item.active {
    color: @primary-color;
  }
}

.@{rich-editor-prefix}-background-popover,
.@{rich-editor-prefix}-color-popover {
  .@{popover-prefix}-inner-content {
    padding: 0;
  }

  .background-con,
  .color-con {
    position: relative;
    display: inline-block;
    padding: 10px 10px 5px 10px;
    max-width: 202px;
  }

  .background-item,
  .color-item {
    // display: inline-block;
    width: 26px;
    height: 26px;
    margin: 2px;
    padding: 0;
    outline: none;
    cursor: pointer;
    border: 1px solid transparent;
    float: left;
  }
}

.@{rich-editor-prefix}-insert-value-popover {
  .@{popover-prefix}-inner-content {
    padding: 0;
  }

  .insert-value-con {
    position: relative;
    max-width: 348px;
    max-height: 272px;
    overflow-y: scroll;
    padding: 8px 0;

    .scrollbar();
  }

  .insert-value-search {
    position: relative;
    display: inline-block;
    width: 100%;
    padding: 2px 12px;
  }

  .insert-value-icon-clear {
    font-size: 12px;
    color: @text-9;

    &:hover {
      color: @text-6;
    }
  }

  .insert-value-empty {
    position: relative;
    color: @text-9;
    line-height: 32px;
    text-align: center;
    padding: 6px 12px 2px;
  }

  .insert-value-item {
    position: relative;
    display: block;
    width: 100%;
    height: 32px;
    line-height: 20px;
    padding: 6px 12px;
    font-size: 14px;
    background: #fff;
    outline: none;
    cursor: pointer;
    border: 1px solid transparent;
    text-align: left;
    text-overflow: ellipsis;
    overflow: hidden;

    &:hover {
      background: @item-hover-bg;
    }
  }
}
/* stylelint-enable */
