diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-10-09 22:35:47 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-10-09 22:35:47 -0400 |
commit | 3b1345616bf2f7101a21c182e0c9719b1e31f899 (patch) | |
tree | 7a3cf616919f601c5e660cba5cf1c7a47549e434 /src | |
parent | bfdbc495c0327b87ee0f896778968e65e2f18af6 (diff) |
semicolons and fix to unhighlighting searched text in text boxes.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 77543d2e8..9ca77cc8b 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -232,7 +232,7 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe if (this._editorView && (this._editorView as any).docView) { const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight); const activeMark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight, { selected: true }); - let end = this._editorView!.state.doc.textContent.length - 1; + let end = this._editorView!.state.doc.nodeSize - 2; this._editorView!.dispatch(this._editorView!.state.tr.removeMark(0, end, mark).removeMark(0, end, activeMark)); } } @@ -291,20 +291,20 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe } getNodeEndpoints(context: Node, node: Node): { from: number, to: number } | null { - let offset = 0 + let offset = 0; - if (context === node) return { from: offset, to: offset + node.nodeSize } + if (context === node) return { from: offset, to: offset + node.nodeSize }; if (node.isBlock) { for (let i = 0; i < (context.content as any).content.length; i++) { - let result = this.getNodeEndpoints((context.content as any).content[i], node) + let result = this.getNodeEndpoints((context.content as any).content[i], node); if (result) { return { from: result.from + offset + (context.type.name === "doc" ? 0 : 1), to: result.to + offset + (context.type.name === "doc" ? 0 : 1) - } + }; } - offset += (context.content as any).content[i].nodeSize + offset += (context.content as any).content[i].nodeSize; } return null; } else { @@ -320,14 +320,14 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe if (node.isTextblock) { let index = 0, foundAt, ep = this.getNodeEndpoints(pm.state.doc, node); while (ep && (foundAt = node.textContent.slice(index).search(RegExp(find, "i"))) > -1) { - let sel = new TextSelection(pm.state.doc.resolve(ep.from + index + foundAt + 1), pm.state.doc.resolve(ep.from + index + foundAt + find.length + 1)) - ret.push(sel) + let sel = new TextSelection(pm.state.doc.resolve(ep.from + index + foundAt + 1), pm.state.doc.resolve(ep.from + index + foundAt + find.length + 1)); + ret.push(sel); index = index + foundAt + find.length; } } else { - node.content.forEach((child, i) => ret = ret.concat(this.findInNode(pm, child, find))) + node.content.forEach((child, i) => ret = ret.concat(this.findInNode(pm, child, find))); } - return ret + return ret; } static _highlights: string[] = []; |