tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
add alternate names to block commands
awarm.space
4 months ago
a613e397
045e283b
+11
-2
2 changed files
expand all
collapse all
unified
split
components
Blocks
BlockCommandBar.tsx
BlockCommands.tsx
+7
-2
components/Blocks/BlockCommandBar.tsx
···
47
47
};
48
48
49
49
let commandResults = blockCommands.filter((command) => {
50
50
-
const matchesSearch = command.name
50
50
+
const lowerSearchValue = searchValue.toLocaleLowerCase();
51
51
+
const matchesName = command.name
51
52
.toLocaleLowerCase()
52
52
-
.includes(searchValue.toLocaleLowerCase());
53
53
+
.includes(lowerSearchValue);
54
54
+
const matchesAlternate = command.alternateNames?.some((altName) =>
55
55
+
altName.toLocaleLowerCase().includes(lowerSearchValue)
56
56
+
) ?? false;
57
57
+
const matchesSearch = matchesName || matchesAlternate;
53
58
const isVisible = !pub || !command.hiddenInPublication;
54
59
return matchesSearch && isVisible;
55
60
});
+4
components/Blocks/BlockCommands.tsx
···
102
102
name: string;
103
103
icon: React.ReactNode;
104
104
type: string;
105
105
+
alternateNames?: string[];
105
106
hiddenInPublication?: boolean;
106
107
onSelect: (
107
108
rep: Replicache<ReplicacheMutators>,
···
125
126
name: "Title",
126
127
icon: <Header1Small />,
127
128
type: "text",
129
129
+
alternateNames: ["h1"],
128
130
onSelect: async (rep, props, um) => {
129
131
await setHeaderCommand(1, rep, props);
130
132
},
···
133
135
name: "Header",
134
136
icon: <Header2Small />,
135
137
type: "text",
138
138
+
alternateNames: ["h2"],
136
139
onSelect: async (rep, props, um) => {
137
140
await setHeaderCommand(2, rep, props);
138
141
},
···
141
144
name: "Subheader",
142
145
icon: <Header3Small />,
143
146
type: "text",
147
147
+
alternateNames: ["h3"],
144
148
onSelect: async (rep, props, um) => {
145
149
await setHeaderCommand(3, rep, props);
146
150
},