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 highlight shortcut
awarm.space
5 months ago
bc831b56
9878449e
+19
-5
1 changed file
expand all
collapse all
unified
split
components
SelectionManager.tsx
+19
-5
components/SelectionManager.tsx
···
186
186
handler: async () => {
187
187
let [sortedBlocks] = await getSortedSelectionBound();
188
188
toggleMarkInBlocks(
189
189
-
schema.marks.underline,
190
189
sortedBlocks.filter((b) => b.type === "text").map((b) => b.value),
190
190
+
schema.marks.underline,
191
191
);
192
192
},
193
193
},
···
197
197
handler: async () => {
198
198
let [sortedBlocks] = await getSortedSelectionBound();
199
199
toggleMarkInBlocks(
200
200
+
sortedBlocks.filter((b) => b.type === "text").map((b) => b.value),
200
201
schema.marks.em,
201
201
-
sortedBlocks.filter((b) => b.type === "text").map((b) => b.value),
202
202
);
203
203
},
204
204
},
···
208
208
handler: async () => {
209
209
let [sortedBlocks] = await getSortedSelectionBound();
210
210
toggleMarkInBlocks(
211
211
+
sortedBlocks.filter((b) => b.type === "text").map((b) => b.value),
211
212
schema.marks.strong,
213
213
+
);
214
214
+
},
215
215
+
},
216
216
+
{
217
217
+
metaAndCtrl: true,
218
218
+
key: "h",
219
219
+
handler: async () => {
220
220
+
let [sortedBlocks] = await getSortedSelectionBound();
221
221
+
toggleMarkInBlocks(
212
222
sortedBlocks.filter((b) => b.type === "text").map((b) => b.value),
223
223
+
schema.marks.highlight,
224
224
+
{
225
225
+
color: useUIState.getState().lastUsedHighlight,
226
226
+
},
213
227
);
214
228
},
215
229
},
···
219
233
handler: async () => {
220
234
let [sortedBlocks] = await getSortedSelectionBound();
221
235
toggleMarkInBlocks(
222
222
-
schema.marks.strikethrough,
223
236
sortedBlocks.filter((b) => b.type === "text").map((b) => b.value),
237
237
+
schema.marks.strikethrough,
224
238
);
225
239
},
226
240
},
···
716
730
];
717
731
};
718
732
719
719
-
function toggleMarkInBlocks(mark: MarkType, blocks: string[]) {
733
733
+
function toggleMarkInBlocks(blocks: string[], mark: MarkType, attrs?: any) {
720
734
let everyBlockHasMark = blocks.reduce((acc, block) => {
721
735
let editor = useEditorStates.getState().editorStates[block];
722
736
if (!editor) return acc;
···
739
753
if (everyBlockHasMark) {
740
754
tr.removeMark(from, to, mark);
741
755
} else {
742
742
-
tr.addMark(from, to, mark.create());
756
756
+
tr.addMark(from, to, mark.create(attrs));
743
757
}
744
758
745
759
view.dispatch(tr);