Skip to content

Build your personal knowledge base with Trilium Notes

5.4 KB
Raw Blame
/**
 * Math Equation Editor Dialog Styles - Compact & Readable
 */

/* === Z-INDEX: MathLive UI above CKEditor === */
.ML__keyboard, .ML__popover, .ML__menu, .ML__suggestions, .ML__autocomplete,
.ML__tooltip, .ML__sr-only, [data-ml-root], #mathlive-suggestion-popover,
.mathlive-suggestions-popover, [data-ml-tooltip], .ML__base {
    z-index: calc(var(--ck-z-panel) + 1000) !important;
}
/* MathLive's own floating UI only — never a bare [role="tooltip"] or .popover, which would reach
   every tooltip and popover in the whole app the moment the editor's CSS loads. The forced
   `position: fixed` once collapsed the geo map's marker preview (a MapLibre popup wrapping the
   app's note tooltip, role and all) to a zero-size box that spilled its content across the map. */
.ML__tooltip, .ML__popover[role="tooltip"], [data-ml-tooltip] {
    z-index: calc(var(--ck-z-panel) + 2000) !important;
    position: fixed !important;
}

/* === MAIN DIALOG === */
.ck.ck-math-form {
    display: flex;
    flex-direction: column;
    padding: var(--ck-spacing-standard, var(--ck-spacing-base));
    box-sizing: border-box;
	min-width: 400px;
    max-width: 60vw;
    /* Fits both fields at their 120px max-height */
    max-height: 480px;
    overflow: visible;
    user-select: text;
}

/* Scrollable content - vertical scroll, horizontal visible for tooltips */
.ck.ck-math-form .ck-math-view {
    overflow-y: auto;
    overflow-x: visible;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: var(--ck-spacing-standard, var(--ck-spacing-base));
    min-height: 0;
    /* Room for the fields' 3px focus rings, which the scrolling view clips at its padding edge */
    margin: -3px;
    padding: 3px;
}

/* === MATH INPUT === */
.ck.ck-math-input {
    display: flex;
    flex-direction: column;
    gap: var(--ck-spacing-standard, var(--ck-spacing-base));
    width: fit-content;
    min-width: 100%;
    max-width: 100%;
    flex: 1 0 auto;
    overflow: visible !important;
}

/* === MATHLIVE EDITOR === */
.ck.ck-math-input .ck-mathlive-container {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: var(--ck-spacing-small, var(--ck-spacing-sm));
    border: 1px solid var(--ck-color-input-border);
    border-radius: var(--ck-border-radius);
    /* The LaTeX textarea's min-width: `--ck-input-width` (18em) at its 0.95em font size */
    min-width: calc(0.95 * var(--ck-input-width));
    background: var(--ck-color-input-background);
    color: var(--ck-color-input-text);
    transition: border-color 120ms ease;
    clip-path: none;
}
.ck.ck-math-input .ck-mathlive-container,
.ck.ck-math-input .ck-latex-textarea {
    max-width: 100%;
    min-height: 60px;
    max-height: 120px;
    resize: both;
    overflow: auto;
}
.ck.ck-math-input .ck-mathlive-container:focus-within {
    border-color: var(--ck-color-focus-border);
}

/* Position keyboard & menu buttons */
.ck-mathlive-container math-field::part(virtual-keyboard-toggle),
.ck-mathlive-container math-field::part(menu-toggle) {
    position: absolute;
    top: 8px;
}
.ck-mathlive-container math-field::part(virtual-keyboard-toggle) { right: 40px; }
.ck-mathlive-container math-field::part(menu-toggle) {
    right: 8px;
    display: flex !important;
    visibility: visible !important;
}

/* Math field element */
.ck.ck-math-form math-field {
    display: block !important;
    flex-grow: 1;
    width: 100%;
    font-size: 1.5em;
    background: transparent !important;
    color: inherit;
    border: none !important;
    padding: 0;
    outline: none !important;
    --selection-background-color: rgba(33, 150, 243, 0.2);
    --selection-color: inherit;
    --contains-highlight-background-color: rgba(0, 0, 0, 0.05);
}

/* === LATEX TEXTAREA === */
.ck.ck-math-input .ck-latex-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ck-color-text);
    opacity: 0.8;
    margin: 0 0 var(--ck-spacing-small, var(--ck-spacing-sm)) 0;
    flex-shrink: 0;
}
.ck.ck-math-input .ck-latex-textarea {
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    box-sizing: border-box;
}

/* === DISPLAY TOGGLE === */
.ck-button-display-toggle {
    align-self: flex-start;
    padding-block: var(--ck-spacing-small, var(--ck-spacing-sm));
    padding-inline: var(--ck-spacing-standard, var(--ck-spacing-base));
    background: var(--ck-color-input-background);
    color: var(--ck-color-text);
    border: 1px solid var(--ck-color-input-border);
    border-radius: var(--ck-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}
.ck-button-display-toggle:hover { background: var(--ck-color-focus-border); }

/* === PREVIEW === */
.ck-math-preview,
.ck.ck-math-preview {
    width: 100%;
    min-height: 40px;
    padding: var(--ck-spacing-small, var(--ck-spacing-sm));
    background: transparent !important;
    border: none !important;
    display: block;
    text-align: left;
    overflow: auto;
}

/* Center equation when in display mode */
.ck-math-preview[data-display="true"],
.ck.ck-math-preview[data-display="true"] {
    text-align: center;
}

.ck-math-preview.ck-error, .ck-math-render-error {
    border-color: var(--ck-color-feedback-error);
    background: var(--ck-color-base-background);
    color: var(--ck-color-feedback-error);
}

/* === BUTTONS === */
.ck-math-button-row {
    display: flex;
    gap: var(--ck-spacing-standard, var(--ck-spacing-base));
    justify-content: flex-end;
    margin-top: var(--ck-spacing-standard, var(--ck-spacing-base));
}