/** * Copyright Aquera Inc 2023 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import { css } from 'lit'; /** * Markdown editor CSS */ export const styles = css` :host { position: relative; display: block; font-family: inherit; -webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing)); -moz-osx-font-smoothing: var( --nile-moz-osx-font-smoothing,var(--ng-moz-osx-font-smoothing)); text-rendering: var(--nile-text-rendering, var(--ng-text-rendering)); } .editor { width: 100%; border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral)); border-radius: var(--nile-radius-radius-xl, var(--ng-radius-md)); background: var(--nile-colors-white-base, var(--ng-colors-bg-primary)); box-sizing: border-box; display: flex; flex-direction: column; } .editor--disabled { border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled)); background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle)); cursor: not-allowed; pointer-events: none; } .header { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; padding: 8px; border-bottom: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral)); background: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary)); border-radius: 8px 8px 0 0; width: 100%; box-sizing: border-box; } .editor--disabled .header { border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled)); background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle)); } .tabs { display: flex; } /* Slimmer segmented control inside the editor header. */ .tabs nile-button-toggle::part(base) { height: 28px; padding: var(--nile-spacing-xxs, var(--ng-spacing-xs)) var(--nile-spacing-md, var(--ng-spacing-md)); font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm)); } .tab__content { display: inline-flex; align-items: center; gap: var(--nile-spacing-xs, var(--ng-spacing-xs)); } .toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; } .toolbar__button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0px 6px; box-sizing: border-box; border: none; background: transparent; border-radius: var(--nile-radius-radius-lg, var(--ng-radius-md)); cursor: pointer; color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900)); font-family: inherit; font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md)); transition: background 0.15s ease; } .toolbar__button:hover { background: var(--nile-colors-dark-100, var(--ng-colors-bg-primary-hover)); } .toolbar__menu { display: inline-flex; } .toolbar__menu .toolbar__button { width: auto; gap: 2px; } .toolbar__button nile-icon { pointer-events: none; } .toolbar__divider { margin: 0 4px; display: inline-block; height: 24px; width: 1px; background: var(--nile-colors-neutral-400, var(--ng-colors-border-neutral)); } .toolbar__glyph--heading { font-weight: bold; } .toolbar__glyph--strikethrough { text-decoration: line-through; } .toolbar__glyph--code { font-family: var(--nile-font-family-mono, monospace); font-size: var(--nile-type-scale-1, var(--ng-font-size-text-xs)); } .body { display: flex; align-items: stretch; overflow: hidden; min-height: 160px; border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)) var(--nile-radius-radius-xl, var(--ng-radius-md)); } .pane { flex: 1 1 0; min-width: 0; } /* Draggable divider between the write and preview panes in split mode. */ .gutter { flex: 0 0 auto; position: relative; width: 1px; align-self: stretch; background: var(--nile-colors-neutral-400, var(--ng-colors-border-neutral)); cursor: col-resize; touch-action: none; } /* Widen the hit area without shifting the 1px visual line. */ .gutter::before { content: ''; position: absolute; inset: 0 -4px; } .gutter:hover, .body--dragging .gutter { background: var(--nile-colors-primary-500, var(--ng-colors-border-brand)); } /* Keep the drag smooth: no text selection or pointer capture by the panes. */ .body--dragging { cursor: col-resize; user-select: none; -webkit-user-select: none; } .body--dragging .pane { pointer-events: none; } .pane--write { display: flex; } textarea { flex: 1; /* The body owns the resize/height now; the textarea fills it and scrolls its own overflow. min-height:0 lets it shrink when the body shrinks. */ min-height: 0; width: 100%; padding: 12px; border: none; outline: none; resize: none; box-sizing: border-box; tab-size: 4; -moz-tab-size: 4; word-break: break-word; font-family: inherit; font-size: inherit; line-height: inherit; color: inherit; background: var(--nile-colors-white-base, var(--ng-colors-bg-primary)); border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)) var(--nile-radius-radius-xl, var(--ng-radius-md)); } textarea::placeholder { color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary)); font-family: var(--nile-font-family-sans-serif, var(--ng-font-family-body)); opacity: 0.7; } .editor--disabled textarea { background: var( --nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle) ); color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled)); pointer-events: none; user-select: none; -webkit-user-select: none; } .pane--preview { min-height: 0; padding: 12px; overflow: auto; box-sizing: border-box; word-wrap: break-word; background: var(--nile-colors-white-base, var(--ng-colors-bg-primary)); border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)) var(--nile-radius-radius-xl, var(--ng-radius-md)); } .editor--disabled .pane--preview { background: var( --nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle) ); color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled)); } .editor--split .pane--preview { border-radius: 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)) 0; } .editor--split textarea { border-radius: 0 0 0 var(--nile-radius-radius-xl, var(--ng-radius-md)); } .preview-empty { color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary)); font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm)); opacity: 0.7; } `;