Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

7.5 KB
Raw Blame
.RichMarkdownEditor {
    .RichMarkdownEditor__rawPreview {
        padding: 0.75rem;
        overflow: auto;
        font-family: 'SF Mono', 'Fira Code', Monaco, monospace;
        font-size: 0.75rem;
        line-height: 1.5;
        word-break: break-word;
        white-space: pre-wrap;
        background: var(--color-bg-surface-primary);
        border: 1px solid var(--color-border-primary);
        border-radius: 8px;
    }

    .RichMarkdownEditor__content {
        position: relative;
        display: flex;
    }

    .ProseMirror {
        flex: 1;
        min-height: 100%;
        cursor: text;
        outline: none;

        p {
            margin-bottom: 0.5rem;
        }

        // Used to prevent extra spaces at the end from appearing when its just one element
        // Readonly (e.g. TextCard body): no caret — hide the placeholder paragraph entirely.
        &[contenteditable='false'] > p:last-child:has(> br.ProseMirror-trailingBreak:only-child) {
            display: none;
        }

        // Drop bottom margin when a heading is the last block, or only followed by the trailing caret paragraph.
        > :is(h1, h2, h3, h4, h5, h6):last-child,
        > :is(h1, h2, h3, h4, h5, h6):has(+ p:last-child > br.ProseMirror-trailingBreak:only-child) {
            margin-bottom: 0;
        }

        ul,
        ol {
            padding-left: 1.5rem;

            li {
                display: list-item;
                margin-top: 0.25em;

                p {
                    margin: 0;
                }
            }
        }

        ul {
            list-style-type: disc;
        }

        ol {
            list-style-type: decimal;
        }

        ul[data-type='taskList'] {
            padding-left: 0;
            list-style-type: none;

            > li {
                display: flex;
                gap: 0.5rem;
                align-items: flex-start;

                > label {
                    flex: 0 0 auto;
                    margin-top: 0.15rem;
                    user-select: none;
                }

                > div {
                    flex: 1 1 auto;
                }

                input[type='checkbox'] {
                    width: 1rem;
                    height: 1rem;
                    accent-color: var(--color-accent);
                    border-radius: 4px;
                    transform: translateY(1px);
                }
            }
        }

        s,
        del {
            text-decoration: line-through;
        }

        code {
            padding: 0.15em 0.4em;
            font-family: 'SF Mono', 'Fira Code', Monaco, monospace;
            font-size: 0.875em;
            color: var(--danger);
            background: var(--bg-fill-primary);
            border-radius: 4px;
        }

        pre {
            padding: 0.75rem 1rem;
            margin: 0.75rem 0;
            overflow-x: auto;
            background: var(--color-bg-fill-tertiary);
            border: 1px solid var(--color-border-primary);
            border-radius: 8px;

            code {
                padding: 0;
                font-size: 0.875rem;
                line-height: 1.5;
                color: inherit;
                white-space: pre;
                background: transparent;
                border-radius: 0;
            }
        }

        blockquote {
            padding-left: 1rem;
            margin: 0.75rem 0;
            font-style: italic;
            color: var(--color-text-secondary);
            border-left: 3px solid var(--color-border-primary);
        }

        hr {
            margin: 1rem 0;
            border: none;
            border-top: 1px solid var(--color-border-primary);
        }

        img {
            display: block;
            max-width: 100%;
            height: auto;
            margin: 0.75rem 0;
        }

        &[contenteditable='true'] hr.ProseMirror-selectednode {
            outline: 2px solid var(--color-accent);
            outline-offset: 2px;
        }

        &[contenteditable='true'] img.ProseMirror-selectednode {
            outline: 2px solid var(--color-accent);
        }

        [data-resize-container][data-node='image'] {
            max-width: 100%;
            margin: 0.75rem 0;
        }

        [data-resize-container][data-node='image'] img {
            margin: 0;
        }

        [data-resize-handle] {
            position: absolute;
            z-index: 10;
            background: rgb(0 0 0 / 50%);
            border: 1px solid rgb(255 255 255 / 80%);
            border-radius: 2px;

            &:hover {
                background: rgb(0 0 0 / 80%);
            }

            &[data-resize-handle='top-left'],
            &[data-resize-handle='top-right'],
            &[data-resize-handle='bottom-left'],
            &[data-resize-handle='bottom-right'] {
                width: 8px;
                height: 8px;
            }

            &[data-resize-handle='top-left'] {
                top: -4px;
                left: -4px;
                cursor: nwse-resize;
            }

            &[data-resize-handle='top-right'] {
                top: -4px;
                right: -4px;
                cursor: nesw-resize;
            }

            &[data-resize-handle='bottom-left'] {
                bottom: -4px;
                left: -4px;
                cursor: nesw-resize;
            }

            &[data-resize-handle='bottom-right'] {
                right: -4px;
                bottom: -4px;
                cursor: nwse-resize;
            }

            &[data-resize-handle='top'],
            &[data-resize-handle='bottom'] {
                right: 8px;
                left: 8px;
                height: 6px;
            }

            &[data-resize-handle='top'] {
                top: -3px;
                cursor: ns-resize;
            }

            &[data-resize-handle='bottom'] {
                bottom: -3px;
                cursor: ns-resize;
            }

            &[data-resize-handle='left'],
            &[data-resize-handle='right'] {
                top: 8px;
                bottom: 8px;
                width: 6px;
            }

            &[data-resize-handle='left'] {
                left: -3px;
                cursor: ew-resize;
            }

            &[data-resize-handle='right'] {
                right: -3px;
                cursor: ew-resize;
            }
        }

        [data-resize-state='true'] [data-resize-wrapper] {
            border-radius: 0.125rem;
            outline: 1px solid rgb(0 0 0 / 25%);
        }

        table {
            width: 100%;
            margin: 0.75rem 0;
            overflow: auto;
            border-spacing: 0;
            border-collapse: separate;
            border: 1px solid var(--border);
            border-radius: var(--radius);
        }

        th,
        td {
            padding: 0.375rem 0.75rem;
            color: var(--default);
            text-align: left;
            vertical-align: top;
            border-right: 1px solid var(--border);
            border-bottom: 1px solid var(--border);

            &:last-child {
                border-right: none;
            }
        }

        th {
            font-weight: 600;
        }

        tbody tr:last-child td {
            border-bottom: none;
        }

        > .is-empty:first-child::before {
            float: left;
            height: 0;
            color: rgb(0 0 0 / 60%);
            pointer-events: none;
            content: attr(data-placeholder);

            [theme='dark'] & {
                color: rgb(255 255 255 / 60%);
            }
        }
    }
}