mirror of
https://github.com/Automattic/harper.git
synced 2025-12-23 08:48:15 +00:00
fix(wp): construct linters properly
This commit is contained in:
parent
f545f626ad
commit
c794d3939a
2 changed files with 6 additions and 5 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { Linter, WorkerLinter } from 'harper.js';
|
||||
import { Linter, WorkerLinter, binaryInlined } from 'harper.js';
|
||||
import React, { createContext, ReactNode, useContext, useEffect, useRef, useState } from 'react';
|
||||
|
||||
const linterContext = createContext<Linter>(new WorkerLinter());
|
||||
const linterContext = createContext<Linter>(new WorkerLinter({ binary: binaryInlined }));
|
||||
|
||||
export default function LinterProvider({ children }: { children: ReactNode | ReactNode[] }) {
|
||||
const linter = useRef(new WorkerLinter());
|
||||
const linter = useRef(new WorkerLinter({ binary: binaryInlined }));
|
||||
|
||||
return <linterContext.Provider value={linter.current}>{children}</linterContext.Provider>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Lint, LocalLinter, Suggestion } from 'harper.js';
|
||||
import { Lint, LocalLinter, Suggestion, binaryInlined } from 'harper.js';
|
||||
import { LintBox } from './Box';
|
||||
import DataBlock from './DataBlock';
|
||||
import { getRangeForTextSpan } from './domUtils';
|
||||
|
|
@ -32,7 +32,8 @@ export default class RichText {
|
|||
const text = this.targetElement.textContent;
|
||||
const span = lint.span();
|
||||
const range = getRangeForTextSpan(this.targetElement, span);
|
||||
const linter = new LocalLinter();
|
||||
// Use a local linter because we won't be doing any expensive operations with it.
|
||||
const linter = new LocalLinter({ binary: binaryInlined });
|
||||
|
||||
if (range === null || text === null) {
|
||||
console.log('Could not locate range.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue