feat: Notion-like rich text editor with TipTap, 4 note types, slash commands & bubble menu
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m33s

This commit is contained in:
2026-05-01 01:11:03 +02:00
parent 7053e242d2
commit 1345403a31
31 changed files with 3222 additions and 150 deletions

View File

@@ -502,4 +502,473 @@
direction: ltr;
unicode-bidi: embed;
display: inline-block;
}
}
/* ============================================
Notion-like Rich Text Editor (TipTap)
============================================ */
/* --- Editor Wrapper --- */
.notion-editor-wrapper {
position: relative;
}
/* --- ProseMirror Base --- */
.notion-editor-wrapper .ProseMirror {
outline: none;
min-height: 120px;
padding: 4px 0;
font-size: 0.9375rem;
line-height: 1.7;
caret-color: var(--primary);
}
.notion-editor-wrapper .ProseMirror > *:first-child { margin-top: 0; }
/* Placeholder */
.notion-editor-wrapper .ProseMirror p.is-editor-empty:first-child::before,
.notion-editor-wrapper .ProseMirror p.is-empty::before {
content: attr(data-placeholder);
float: left;
color: var(--muted-foreground);
pointer-events: none;
height: 0;
opacity: 0.4;
font-style: italic;
}
/* --- Paragraphs --- */
.notion-editor-wrapper .ProseMirror p { margin: 0.2em 0; }
/* --- Headings (Notion style — clean, sans-serif) --- */
.notion-editor-wrapper .ProseMirror h1 {
font-size: 1.75rem;
font-weight: 700;
margin: 1.2em 0 0.2em;
line-height: 1.25;
letter-spacing: -0.02em;
}
.notion-editor-wrapper .ProseMirror h2 {
font-size: 1.375rem;
font-weight: 600;
margin: 1em 0 0.15em;
line-height: 1.3;
letter-spacing: -0.01em;
}
.notion-editor-wrapper .ProseMirror h3 {
font-size: 1.125rem;
font-weight: 600;
margin: 0.8em 0 0.1em;
line-height: 1.35;
}
/* --- Lists --- */
.notion-editor-wrapper .ProseMirror ul {
list-style-type: disc;
padding-left: 1.5rem;
margin: 0.25em 0;
}
.notion-editor-wrapper .ProseMirror ol {
list-style-type: decimal;
padding-left: 1.5rem;
margin: 0.25em 0;
}
.notion-editor-wrapper .ProseMirror li > p { margin: 0.1em 0; }
.notion-editor-wrapper .ProseMirror li > ul,
.notion-editor-wrapper .ProseMirror li > ol { margin: 0.1em 0; }
/* --- Task / Todo List --- */
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] {
list-style: none;
padding-left: 0;
}
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li {
display: flex;
align-items: flex-start;
gap: 0.4rem;
margin: 0.2em 0;
}
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li > label {
display: flex;
align-items: center;
cursor: pointer;
margin-top: 2px;
}
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"] {
-webkit-appearance: none; appearance: none;
width: 16px; height: 16px;
border: 2px solid var(--border);
border-radius: 4px;
cursor: pointer;
display: grid; place-content: center;
transition: all 0.15s ease;
background: transparent;
flex-shrink: 0;
}
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"]:checked {
background: var(--primary);
border-color: var(--primary);
}
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"]::before {
content: ""; width: 10px; height: 10px;
transform: scale(0);
transition: 120ms transform ease-in-out;
box-shadow: inset 1em 1em white;
clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"]:checked::before { transform: scale(1); }
.notion-editor-wrapper .ProseMirror ul[data-type="taskList"] li[data-checked="true"] > div > p {
color: var(--muted-foreground);
text-decoration: line-through;
}
/* --- Blockquote --- */
.notion-editor-wrapper .ProseMirror blockquote {
border-left: 3px solid var(--primary);
padding: 0.25em 0 0.25em 1em;
margin: 0.4em 0;
color: var(--muted-foreground);
font-style: italic;
background: oklch(0.5 0 0 / 0.03);
border-radius: 0 4px 4px 0;
}
/* --- Code --- */
.notion-editor-wrapper .ProseMirror code {
background: var(--muted);
padding: 0.15em 0.4em;
border-radius: 4px;
font-size: 0.85em;
font-family: var(--font-mono, ui-monospace, monospace);
color: var(--foreground);
}
.notion-editor-wrapper .ProseMirror pre {
background: var(--muted);
border-radius: 8px;
padding: 0.85rem 1rem;
margin: 0.5em 0;
overflow-x: auto;
border: 1px solid var(--border);
}
.notion-editor-wrapper .ProseMirror pre code {
background: none;
padding: 0;
border-radius: 0;
font-size: 0.8125rem;
line-height: 1.6;
}
/* --- Horizontal Rule --- */
.notion-editor-wrapper .ProseMirror hr {
border: none;
border-top: 1px solid var(--border);
margin: 0.75em 0;
}
/* --- Strong / Marks --- */
.notion-editor-wrapper .ProseMirror strong { font-weight: 600; }
/* --- Images --- */
.notion-editor-wrapper .ProseMirror img {
border-radius: 8px;
max-width: 100%;
height: auto;
display: block;
margin: 0.5em 0;
transition: filter 0.15s ease;
}
.notion-editor-wrapper .ProseMirror img:hover { filter: brightness(95%); }
.notion-editor-wrapper .ProseMirror img.ProseMirror-selectednode {
outline: 2px solid var(--primary);
outline-offset: 2px;
}
/* --- Links --- */
.notion-editor-wrapper .ProseMirror a {
color: var(--primary);
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
}
.notion-editor-wrapper .ProseMirror a:hover {
opacity: 0.8;
}
/* --- Highlight --- */
.notion-editor-wrapper .ProseMirror mark {
background: oklch(0.85 0.12 90);
border-radius: 2px;
padding: 0 1px;
}
.dark .notion-editor-wrapper .ProseMirror mark {
background: oklch(0.4 0.1 90);
}
/* ============================================
Bubble Menu (floating toolbar on selection)
============================================ */
.notion-bubble-menu {
background: var(--popover);
border: 1px solid var(--border);
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
padding: 2px;
display: flex;
align-items: center;
gap: 0;
z-index: 100;
}
.dark .notion-bubble-menu {
box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
}
.notion-bubble-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
border-radius: 6px;
border: none;
background: transparent;
color: var(--foreground);
cursor: pointer;
transition: all 0.12s ease;
}
.notion-bubble-btn:hover {
background: var(--accent);
}
.notion-bubble-btn-active {
background: var(--accent);
color: var(--primary);
}
/* AI submenu inside bubble */
.notion-ai-submenu {
position: absolute;
top: 100%;
right: 0;
margin-top: 4px;
background: var(--popover);
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0,0,0,0.12);
padding: 4px;
min-width: 150px;
z-index: 110;
}
.dark .notion-ai-submenu {
box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.notion-ai-subitem {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
padding: 7px 10px;
border: none;
background: transparent;
border-radius: 6px;
cursor: pointer;
font-size: 0.8125rem;
color: var(--foreground);
transition: background 0.1s ease;
}
.notion-ai-subitem:hover {
background: var(--accent);
}
/* Inline input inside bubble menu (link editor) */
.notion-inline-input {
background: transparent;
border: none;
outline: none;
font-size: 0.8125rem;
color: var(--foreground);
width: 200px;
min-width: 120px;
}
.notion-inline-input::placeholder {
color: var(--muted-foreground);
opacity: 0.6;
}
/* Image insert overlay */
.notion-overlay {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0,0,0,0.3);
}
.dark .notion-overlay {
background: rgba(0,0,0,0.6);
}
.notion-image-modal {
background: var(--popover);
border: 1px solid var(--border);
border-radius: 12px;
box-shadow: 0 16px 48px rgba(0,0,0,0.15);
padding: 20px;
width: 400px;
max-width: 90vw;
}
.dark .notion-image-modal {
box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.notion-modal-input {
width: 100%;
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--background);
color: var(--foreground);
font-size: 0.8125rem;
outline: none;
transition: border-color 0.15s ease;
}
.notion-modal-input:focus {
border-color: var(--primary);
}
.notion-modal-input::placeholder {
color: var(--muted-foreground);
opacity: 0.5;
}
.notion-modal-btn {
padding: 6px 14px;
border-radius: 6px;
font-size: 0.8125rem;
border: 1px solid var(--border);
background: transparent;
color: var(--foreground);
cursor: pointer;
transition: background 0.1s ease;
}
.notion-modal-btn:hover {
background: var(--accent);
}
.notion-modal-btn-primary {
background: var(--primary);
color: var(--primary-foreground);
border-color: var(--primary);
}
.notion-modal-btn-primary:hover {
opacity: 0.9;
background: var(--primary);
}
/* ============================================
Slash Command Menu
============================================ */
.notion-slash-menu {
position: fixed;
z-index: 9999;
background: var(--popover);
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 4px 24px rgba(0,0,0,0.1);
padding: 4px;
min-width: 300px;
max-height: 340px;
overflow-y: auto;
scrollbar-width: thin;
}
.dark .notion-slash-menu {
box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.notion-slash-section + .notion-slash-section {
border-top: 1px solid var(--border);
margin-top: 4px;
padding-top: 4px;
}
.notion-slash-label {
padding: 6px 8px 2px;
font-size: 11px;
font-weight: 600;
color: var(--muted-foreground);
user-select: none;
}
.notion-slash-item {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
padding: 4px 8px;
border: none;
background: transparent;
border-radius: 4px;
cursor: pointer;
text-align: left;
color: var(--foreground);
transition: background 0.1s ease;
}
.notion-slash-item:hover,
.notion-slash-item-selected {
background: var(--accent);
}
.notion-slash-icon {
display: flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border: 1px solid var(--border);
border-radius: 4px;
background: var(--background);
color: var(--muted-foreground);
flex-shrink: 0;
}
.notion-slash-icon-ai {
background: oklch(0.95 0.05 270);
border-color: oklch(0.8 0.08 270);
color: oklch(0.55 0.15 270);
}
.dark .notion-slash-icon-ai {
background: oklch(0.25 0.05 270);
border-color: oklch(0.4 0.08 270);
color: oklch(0.75 0.15 270);
}
.notion-slash-loading {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 10px;
font-size: 13px;
color: var(--muted-foreground);
}
.notion-slash-title {
font-size: 13px;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 0 1 auto;
}
.notion-slash-desc {
font-size: 11px;
color: var(--muted-foreground);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1 1 auto;
text-align: right;
}
/* ============================================
Note Card Rich Text Preview
============================================ */
.rt-preview { font-size: 0.875rem; line-height: 1.6; }
.rt-preview h1 { font-size: 1.3rem; font-weight: 700; margin: 0.3em 0; }
.rt-preview h2 { font-size: 1.1rem; font-weight: 600; margin: 0.3em 0; }
.rt-preview h3 { font-size: 1rem; font-weight: 600; margin: 0.3em 0; }
.rt-preview p { margin: 0.2em 0; }
.rt-preview ul, .rt-preview ol { padding-left: 1.25rem; margin: 0.2em 0; }
.rt-preview blockquote { border-left: 3px solid var(--border); padding-left: 0.75rem; color: var(--muted-foreground); margin: 0.3em 0; }