Skip to content

Commit

Permalink
Fix interceptInputs for languages with diacritics (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Feb 27, 2023
1 parent cbb5b42 commit fdf3072
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CoreEditor/src/modules/input/wrapBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { EditorView } from '@codemirror/view';
* @param mark The mark, e.g., "*"
*/
export default function wrapBlock(mark: string, editor: EditorView) {
// Fallback to the default behavior if all selections are empty
if (!editor.state.selection.ranges.some(range => !range.empty)) {
return false;
}

const doc = editor.state.doc;
editor.dispatch(editor.state.changeByRange(({ from, to }) => {
const selection = doc.sliceString(from, to);
Expand Down
2 changes: 1 addition & 1 deletion CoreEditor/src/styling/nodes/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const selectedTextDecoration = ViewPlugin.fromClass(class {
return;
}

const ranges = update.state.selection.ranges.filter(range => range.to !== range.from);
const ranges = update.state.selection.ranges.filter(range => !range.empty);
const markDeco = Decoration.mark({ class: 'cm-selectedTextRange' });
this.decorations = Decoration.set(ranges.map(range => {
return markDeco.range(range.from, range.to);
Expand Down

0 comments on commit fdf3072

Please sign in to comment.