UNPKG

@blocknote/core

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

596 lines (502 loc) 12.1 kB
/* BASIC STYLES */ .bn-block-outer { line-height: 1.5; transition: margin 0.2s; } /*Ensures blocks & block content spans editor width*/ .bn-block { display: flex; flex-direction: column; } .bn-block-content { padding: 3px 0; transition: font-size 0.2s; width: 100%; /* because the content elements are display: block we use flex to position them next to list markers */ } /* We can't set `display: flex` on `.bn-block-content` while it has inline content (see #1629). However, it's necessary to set alignment of blocks without content as these can't use `text-align`, so this additional rule is used. */ .bn-block-content:not(:has(.bn-inline-content)) { display: flex; } .bn-block-content::before { /* content: ""; */ transition: all 0.2s; /*margin: 0px;*/ } .bn-block-content.ProseMirror-selectednode > *, /* Case for node view renderers */ .ProseMirror-selectednode > .bn-block-content > * { border-radius: 4px; outline: 4px solid rgb(100, 160, 255); } .bn-inline-content { width: 100%; } /* NESTED BLOCKS */ .bn-block-group .bn-block-group { margin-left: 1.5em; } .bn-block-group .bn-block-group > .bn-block-outer { position: relative; } .bn-block-group .bn-block-group > .bn-block-outer:not([data-prev-depth-changed])::before { content: " "; display: inline; position: absolute; left: -20px; height: 100%; transition: all 0.2s 0.1s; } .bn-block-group .bn-block-group > .bn-block-outer[data-prev-depth-change="-2"]::before { height: 0; } .bn-inline-content code { font-family: monospace; } /* NESTED BLOCK ANIMATIONS (change in indent) */ [data-prev-depth-change="1"] { --x: 1; } [data-prev-depth-change="2"] { --x: 2; } [data-prev-depth-change="3"] { --x: 3; } [data-prev-depth-change="4"] { --x: 4; } [data-prev-depth-change="5"] { --x: 5; } [data-prev-depth-change="-1"] { --x: -1; } [data-prev-depth-change="-2"] { --x: -2; } [data-prev-depth-change="-3"] { --x: -3; } [data-prev-depth-change="-4"] { --x: -4; } [data-prev-depth-change="-5"] { --x: -5; } .bn-block-outer[data-prev-depth-change] { margin-left: calc(10px * var(--x)); } .bn-block-outer[data-prev-depth-change] .bn-block-outer[data-prev-depth-change] { margin-left: 0; } /* HEADINGS*/ [data-content-type="heading"] { --level: 3em; } [data-content-type="heading"][data-level="2"] { --level: 2em; } [data-content-type="heading"][data-level="3"] { --level: 1.3em; } [data-prev-level="1"] { --prev-level: 3em; } [data-prev-level="2"] { --prev-level: 2em; } [data-prev-level="3"] { --prev-level: 1.3em; } .bn-block-outer[data-prev-type="heading"] > .bn-block > .bn-block-content { font-size: var(--prev-level); font-weight: bold; } .bn-block-outer:not([data-prev-type]) > .bn-block > .bn-block-content[data-content-type="heading"], .bn-block-outer:not([data-prev-type]) > .bn-block > div[data-type="modification"] > div[data-type="modification"] > .bn-block-content[data-content-type="heading"] { font-size: var(--level); font-weight: bold; } /* QUOTES */ [data-content-type="quote"] blockquote { border-left: 2px solid rgb(125, 121, 122); color: rgb(125, 121, 122); margin: 0; padding-left: 1em; } /* LISTS */ .bn-block-content::before { margin-right: 0; content: ""; display: inline; } /* Ordered */ .bn-block-content[data-content-type="numberedListItem"] { display: flex; gap: 0.5em; } [data-content-type="numberedListItem"] { --index: attr(data-index); } [data-prev-type="numberedListItem"] { --prev-index: attr(data-prev-index); } .bn-block-outer[data-prev-type="numberedListItem"]:not([data-prev-index="none"]) > .bn-block > .bn-block-content::before { content: var(--prev-index) "."; } .bn-block-outer:not([data-prev-type]) > .bn-block > .bn-block-content[data-content-type="numberedListItem"]::before, .bn-block-outer:not([data-prev-type]) > .bn-block > div[data-type="modification"] > .bn-block-content[data-content-type="numberedListItem"]::before { content: var(--index) "."; } /* Unordered */ .bn-block-content[data-content-type="bulletListItem"] { display: flex; gap: 0.5em; } /* Checked */ .bn-block-content[data-content-type="checkListItem"] > div { display: flex; width: 100%; } .bn-block-content[data-content-type="checkListItem"] > div > div > input { margin: 0; margin-inline-end: 0.5em; cursor: pointer; } .bn-block-content[data-content-type="checkListItem"][data-checked="true"] .bn-inline-content { text-decoration: line-through; } .bn-block-content[data-text-alignment="center"] { justify-content: center; } .bn-block-content[data-text-alignment="right"] { justify-content: flex-end; } /* No list nesting */ .bn-block-outer[data-prev-type="bulletListItem"] > .bn-block > .bn-block-content::before { content: "•"; } .bn-block-outer:not([data-prev-type]) > .bn-block > .bn-block-content[data-content-type="bulletListItem"]::before, .bn-block-outer:not([data-prev-type]) > .bn-block > div[data-type="modification"] > .bn-block-content[data-content-type="bulletListItem"]::before { content: "•"; } /* 1 level of list nesting */ [data-content-type="bulletListItem"] ~ .bn-block-group > .bn-block-outer[data-prev-type="bulletListItem"] > .bn-block > .bn-block-content::before { content: "◦"; } [data-content-type="bulletListItem"] ~ .bn-block-group > .bn-block-outer:not([data-prev-type]) > .bn-block > .bn-block-content[data-content-type="bulletListItem"]::before, [data-content-type="bulletListItem"] ~ .bn-block-group > .bn-block-outer:not([data-prev-type]) > .bn-block > div[data-type="modification"] > .bn-block-content[data-content-type="bulletListItem"]::before { content: "◦"; } /* 2 levels of list nesting */ [data-content-type="bulletListItem"] ~ .bn-block-group [data-content-type="bulletListItem"] ~ .bn-block-group > .bn-block-outer[data-prev-type="bulletListItem"] > .bn-block > .bn-block-content::before { content: "▪"; } [data-content-type="bulletListItem"] ~ .bn-block-group [data-content-type="bulletListItem"] ~ .bn-block-group > .bn-block-outer:not([data-prev-type]) > .bn-block > .bn-block-content[data-content-type="bulletListItem"]::before, [data-content-type="bulletListItem"] ~ .bn-block-group [data-content-type="bulletListItem"] ~ .bn-block-group > .bn-block-outer:not([data-prev-type]) > .bn-block > div[data-type="modification"] > .bn-block-content[data-content-type="bulletListItem"]::before { content: "▪"; } /* CODE BLOCKS */ .bn-block-content[data-content-type="codeBlock"] { position: relative; background-color: rgb(22 22 22); color: white; border-radius: 8px; } .bn-block-content[data-content-type="codeBlock"] > pre { white-space: pre; overflow-x: auto; margin: 0; width: 100%; tab-size: 2; padding: 24px; } .bn-block-content[data-content-type="codeBlock"] > div { outline: none !important; } .bn-block-content[data-content-type="codeBlock"] > div > select { outline: none !important; appearance: none; user-select: none; border: none; cursor: pointer; background-color: transparent; position: absolute; top: 8px; left: 18px; font-size: 0.8em; color: white; opacity: 0; transition: opacity 0.3s; transition-delay: 1s; } .bn-block-content[data-content-type="codeBlock"] > div > select > option { color: black; } .bn-block-content[data-content-type="codeBlock"]:hover > div > select, .bn-block-content[data-content-type="codeBlock"] > div > select:focus { opacity: 0.5; transition-delay: 0.1s; } /* PAGE BREAK */ .bn-block-content[data-content-type="pageBreak"] > div { width: 100%; height: 0; border-top: dotted rgb(125, 121, 122) 2px; margin-block: 11px; } @media print { .bn-block-content[data-content-type="pageBreak"] > div { page-break-after: always; } } /* FILES */ /* Element that wraps content for all file blocks */ [data-file-block] .bn-file-block-content-wrapper { cursor: pointer; display: flex; flex-direction: column; user-select: none; } /* Add block button & default element (name with icon) */ [data-file-block] .bn-file-block-content-wrapper:has(.bn-add-file-button), [data-file-block] .bn-file-block-content-wrapper:has(.bn-file-name-with-icon) { width: 100%; } [data-file-block] .bn-add-file-button { align-items: center; background-color: rgb(242, 241, 238); border-radius: 4px; color: rgb(125, 121, 122); display: flex; gap: 10px; padding: 12px; } .bn-editor[contenteditable="true"] [data-file-block] .bn-add-file-button:hover, [data-file-block] .bn-file-name-with-icon:hover, .ProseMirror-selectednode .bn-file-name-with-icon { background-color: rgb(225, 225, 225); } [data-file-block] .bn-add-file-button-icon, [data-file-block] .bn-file-icon { width: 24px; height: 24px; } [data-file-block] .bn-add-file-button-text { font-size: 0.9rem; } [data-file-block] .bn-file-name-with-icon { border-radius: 4px; display: flex; gap: 4px; padding: 4px; } /* File captions */ [data-file-block] .bn-file-caption { font-size: 0.8em; padding-block: 4px; word-break: break-word; } [data-file-block] .bn-file-caption:empty { padding-block: 0; } /* Resize handles */ [data-file-block] .bn-resize-handle { position: absolute; width: 8px; height: 30px; background-color: black; border: 1px solid white; border-radius: 4px; cursor: ew-resize; } /* Visual media file blocks, e.g. images & videos */ [data-file-block] .bn-visual-media-wrapper { display: flex; align-items: center; position: relative; max-width: 100%; } [data-file-block] .bn-visual-media { border-radius: 4px; width: 100%; } /* Block-specific styles */ [data-content-type="audio"] > .bn-file-block-content-wrapper, .bn-audio { width: 100%; } /* PLACEHOLDERS*/ .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before { /*float: left; */ pointer-events: none; height: 0; /* width: 0; */ position: absolute; font-style: italic; } /* TODO: should this be here? */ /* TEXT COLORS */ [data-text-color="gray"] { color: #9b9a97; } [data-text-color="brown"] { color: #64473a; } [data-text-color="red"] { color: #e03e3e; } [data-text-color="orange"] { color: #d9730d; } [data-text-color="yellow"] { color: #dfab01; } [data-text-color="green"] { color: #4d6461; } [data-text-color="blue"] { color: #0b6e99; } [data-text-color="purple"] { color: #6940a5; } [data-text-color="pink"] { color: #ad1a72; } /* BACKGROUND COLORS */ [data-background-color="gray"] { background-color: #ebeced; } [data-background-color="brown"] { background-color: #e9e5e3; } [data-background-color="red"] { background-color: #fbe4e4; } [data-background-color="orange"] { background-color: #f6e9d9; } [data-background-color="yellow"] { background-color: #fbf3db; } [data-background-color="green"] { background-color: #ddedea; } [data-background-color="blue"] { background-color: #ddebf1; } [data-background-color="purple"] { background-color: #eae4f2; } [data-background-color="pink"] { background-color: #f4dfeb; } /* TEXT ALIGNMENT */ [data-text-alignment="left"] { justify-content: flex-start !important; text-align: left !important; } [data-text-alignment="center"] { justify-content: center !important; text-align: center !important; } [data-text-alignment="right"] { justify-content: flex-end !important; text-align: right !important; } [data-text-alignment="justify"] { justify-content: flex-start !important; text-align: justify !important; } .bn-block-column-list { display: flex; flex-direction: row; } .bn-block-column { flex: 1; padding: 12px 20px; /* scroll if we overflow, for example when tables or images are in the column */ overflow-x: auto; } .bn-block-column:first-child { padding-left: 0; } .bn-block-column:last-child { padding-right: 0; } .bn-thread-mark:not([data-orphan="true"]) { background: rgba(255, 200, 0, 0.15); } .bn-thread-mark .bn-thread-mark-selected { background: rgba(255, 200, 0, 0.25); }