Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonherbert committed Sep 2, 2020
1 parent 99d8202 commit 990ecc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/ts/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from "./interfaces/IMatch";
import { EditorView } from "prosemirror-view";
import { compact } from "./utils/array";
import { Mark } from "prosemirror-model";

type Command = (
state: EditorState,
Expand Down Expand Up @@ -324,13 +325,20 @@ const maybeApplySuggestions = (
if (dispatch) {
const tr = state.tr;
suggestionsToApply.forEach(
({ from, to, text }) =>
text &&
({ from, to, text }) => {
if (!text) {
return;
}
const $from = tr.doc.resolve(from);
const $to = tr.doc.resolve(to);
const marks = $from.marksAcross($to) || Mark.none
const newNode = state.schema.text(text).mark(marks)
tr.replaceWith(
tr.mapping.map(from),
tr.mapping.map(to),
state.schema.text(text)
newNode
)
}
);
dispatch(tr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ts/createView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface IViewOptions {
// to place the match in the middle of the screen, as the size of the
// document might change during the lifecycle of the page.
getScrollOffset?: () => number;
telemetryService: TelemetryService;
telemetryService?: TelemetryService;
}

/**
Expand Down Expand Up @@ -71,7 +71,7 @@ const createView = ({
(match => {
commands.ignoreMatch(match.matchId);
onMarkCorrect(match);
telemetryService.matchIsMarkedAsCorrect({
telemetryService?.matchIsMarkedAsCorrect({
documentUrl: document.URL,
ruleId: match.ruleId,
matchId: match.matchId,
Expand Down

0 comments on commit 990ecc5

Please sign in to comment.