Skip to content

Commit 8132ee6

Browse files
authored
fix(block-editor): remove extra placeholder of specific block types
Merge commits below into one: * fix(block-editor): show slash commands * chore: lint * fix(block-editor): drag-menu with columns
1 parent 4bb0410 commit 8132ee6

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

Diff for: src/shared/components/control/block-editor/BlockEditor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import '@/styles/prosemirror.css';
17+
import '@/styles/prosemirror.scss';
1818

1919
import clsx from 'clsx';
2020
import {

Diff for: src/shared/components/control/block-editor/slash.js renamed to src/shared/components/control/block-editor/slash.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ import {
3333
} from 'lucide-react';
3434
import { createSuggestionItems, Command, renderItems } from 'novel';
3535

36+
import type { SuggestionItem } from 'novel';
37+
3638
import uploadFn from './upload';
3739

3840
function createColumnItems() {
3941
return [
4042
{ count: 2, ItemIcon: Columns2 },
4143
{ count: 3, ItemIcon: Columns3 },
4244
{ count: 4, ItemIcon: Columns4 },
43-
].map(({ count, ItemIcon }) => ({
45+
].map<SuggestionItem>(({ count, ItemIcon }) => ({
4446
title: `${count} Columns`,
4547
description: `Create ${count} columns block.`,
4648
searchTerms: ['columnBlock', 'column'],
@@ -155,7 +157,8 @@ const suggestionItems = createSuggestionItems([
155157
searchTerms: ['video', 'youtube', 'embed'],
156158
icon: <Youtube size={18} />,
157159
command: ({ editor, range }) => {
158-
const videoLink = prompt('Please enter Youtube Video Link');
160+
const videoLink = prompt('Please enter Youtube Video Link') ?? '';
161+
159162
//From https://regexr.com/3dj5t
160163
const ytregex = new RegExp(
161164
// eslint-disable-next-line no-useless-escape
@@ -184,7 +187,8 @@ const suggestionItems = createSuggestionItems([
184187
searchTerms: ['twitter', 'embed'],
185188
icon: <Twitter size={18} />,
186189
command: ({ editor, range }) => {
187-
const tweetLink = prompt('Please enter Twitter Link');
190+
const tweetLink = prompt('Please enter Twitter Link') ?? '';
191+
188192
const tweetRegex = new RegExp(/^https?:\/\/(www\.)?x\.com\/([a-zA-Z0-9_]{1,15})(\/status\/(\d+))?(\/\S*)?$/);
189193

190194
if (tweetRegex.test(tweetLink)) {

Diff for: src/shared/styles/prosemirror.css renamed to src/shared/styles/prosemirror.scss

+34-20
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,33 @@
1818
@apply p-12 px-8 sm:px-12;
1919
}
2020

21-
.ProseMirror .is-editor-empty:first-child::before {
22-
content: attr(data-placeholder);
23-
float: left;
24-
color: hsl(var(--muted-foreground));
25-
pointer-events: none;
26-
height: 0;
21+
.ProseMirror {
22+
p,
23+
h1,
24+
h2,
25+
h3 {
26+
&.is-editor-empty:first-child::before {
27+
content: attr(data-placeholder);
28+
float: left;
29+
color: hsl(var(--muted-foreground));
30+
pointer-events: none;
31+
height: 0;
32+
}
33+
}
2734
}
28-
.ProseMirror .is-empty::before {
29-
content: attr(data-placeholder);
30-
float: left;
31-
color: hsl(var(--muted-foreground));
32-
pointer-events: none;
33-
height: 0;
35+
.ProseMirror {
36+
p,
37+
h1,
38+
h2,
39+
h3 {
40+
&.is-empty::before {
41+
content: attr(data-placeholder);
42+
float: left;
43+
color: hsl(var(--muted-foreground));
44+
pointer-events: none;
45+
height: 0;
46+
}
47+
}
3448
}
3549

3650
/* Custom image styles */
@@ -53,7 +67,7 @@
5367
position: relative;
5468

5569
&:before {
56-
content: "";
70+
content: '';
5771
box-sizing: border-box;
5872
position: absolute;
5973
top: 50%;
@@ -75,18 +89,18 @@
7589

7690
/* Custom TODO list checkboxes – shoutout to this awesome tutorial: https://moderncss.dev/pure-css-custom-checkbox-style/ */
7791

78-
ul[data-type="taskList"] li > label {
92+
ul[data-type='taskList'] li > label {
7993
margin-right: 0.2rem;
8094
user-select: none;
8195
}
8296

8397
@media screen and (max-width: 768px) {
84-
ul[data-type="taskList"] li > label {
98+
ul[data-type='taskList'] li > label {
8599
margin-right: 0.5rem;
86100
}
87101
}
88102

89-
ul[data-type="taskList"] li > label input[type="checkbox"] {
103+
ul[data-type='taskList'] li > label input[type='checkbox'] {
90104
-webkit-appearance: none;
91105
appearance: none;
92106
background-color: hsl(var(--novel-custom-background));
@@ -110,7 +124,7 @@ ul[data-type="taskList"] li > label input[type="checkbox"] {
110124
}
111125

112126
&::before {
113-
content: "";
127+
content: '';
114128
width: 0.65em;
115129
height: 0.65em;
116130
transform: scale(0);
@@ -125,7 +139,7 @@ ul[data-type="taskList"] li > label input[type="checkbox"] {
125139
}
126140
}
127141

128-
ul[data-type="taskList"] li[data-checked="true"] > div > p {
142+
ul[data-type='taskList'] li[data-checked='true'] > div > p {
129143
color: var(--muted-foreground);
130144
text-decoration: line-through;
131145
text-decoration-thickness: 2px;
@@ -241,8 +255,8 @@ mark[style] > strong {
241255
.ProseMirror .column {
242256
border: 1px dashed transparent;
243257
overflow: hidden;
244-
padding: 8px;
245-
margin: -8px;
258+
// padding: 8px;
259+
// margin: -8px;
246260
}
247261

248262
.ProseMirror-focused .column {

0 commit comments

Comments
 (0)