.editor-image { display: block; max-width: 100%; height: auto; margin: 1rem auto; }
.editor-image img {
max-width: 100%;
display: block;
}
/* Line adder button styles */
.line-adder-button {
position: absolute;
left: -28px;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #e2e8f0;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transition: opacity 0.2s;
cursor: pointer;
border: none;
padding: 0;
z-index: 10;
}
.ProseMirror p:hover .line-adder-button,
.ProseMirror h1:hover .line-adder-button,
.ProseMirror h2:hover .line-adder-button,
.ProseMirror h3:hover .line-adder-button,
.ProseMirror ul:hover .line-adder-button,
.ProseMirror ol:hover .line-adder-button,
.ProseMirror blockquote:hover .line-adder-button,
.ProseMirror pre:hover .line-adder-button,
.ProseMirror .editor-image:hover .line-adder-button,
.line-adder-button:hover {
opacity: 1;
}
/* Add some padding to the left to make room for the buttons */
.ProseMirror {
padding-left: 30px;
stop adding these buill shit classes. create notion style editor where (+) button clicked new line appear.
I'll create a Notion-style editor with a clean "+" button implementation:
I've created a clean, Notion-style editor with a simple "+" button implementation:
Single "+" Button
Adding New Lines
Clean Implementation
This implementation is much cleaner and more focused on the specific Notion-style functionality you requested. I've removed all the previous complex code and created a straightforward solution.
To use it, simply:
why the new line appearing at the top instead of under the current node
You're right - the new line is appearing at the top instead of under the current node. Let me fix that:
I've fixed the issue with the new line appearing at the top instead of under the current node. Here's what was wrong and how I fixed it:
In the previous implementation, we were using the wrong position to insert the new content. We were getting the start position of the current block, which meant we were inserting content at the beginning of the block rather than after it.
Get the End Position of the Node:
$pos.after(depth)Handle Different Depths:
$pos.after()$pos.after(depth) to get the position after the current node at the current depthImproved Button Positioning:
Better State Management:
This implementation now correctly inserts new lines under the current node, just like in Notion.
The code returns the following error:
Uncaught error: Uncaught RangeError: There is no position after the top-level node
at l.after (prosemirror-model)
at HTMLDivElement.<anonymous> (/components/notion-style-editor)
Revise the code to address the error.
I was previewing: /