diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/TooltipTextMenu.scss | 8 | ||||
-rw-r--r-- | src/client/util/TooltipTextMenu.tsx | 37 | ||||
-rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 17 | ||||
-rw-r--r-- | src/client/views/search/SearchItem.tsx | 14 |
4 files changed, 28 insertions, 48 deletions
diff --git a/src/client/util/TooltipTextMenu.scss b/src/client/util/TooltipTextMenu.scss index 6e6818636..38870a1ce 100644 --- a/src/client/util/TooltipTextMenu.scss +++ b/src/client/util/TooltipTextMenu.scss @@ -18,7 +18,8 @@ .ProseMirror-menuitem { margin-right: 3px; display: inline-block; - z-index: 100000; + z-index: 50000; + position: relative; } .ProseMirror-menuseparator { @@ -67,7 +68,7 @@ } .ProseMirror-menu-dropdown-menu { - z-index: 100000; + z-index: 50000; min-width: 6em; background: white; position: absolute; @@ -236,7 +237,7 @@ .tooltipMenu { position: absolute; - z-index: 2000; + z-index: 20000; background: #121721; border: 1px solid silver; border-radius: 15px; @@ -298,6 +299,7 @@ cursor: pointer; text-align: center; min-width: 10px; + } .strong, .heading { font-weight: bold; } .em { font-style: italic; } diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx index 36be0398c..42d72e441 100644 --- a/src/client/util/TooltipTextMenu.tsx +++ b/src/client/util/TooltipTextMenu.tsx @@ -18,7 +18,7 @@ import { DocServer } from "../DocServer"; import { CollectionDockingView } from "../views/collections/CollectionDockingView"; import { DocumentManager } from "./DocumentManager"; import { Id } from "../../new_fields/FieldSymbols"; -import { FormattedTextBoxProps } from "../views/nodes/FormattedTextBox"; +import { FormattedTextBoxProps, FormattedTextBox } from "../views/nodes/FormattedTextBox"; //appears above a selection of text in a RichTextBox to give user options such as Bold, Italics, etc. export class TooltipTextMenu { @@ -197,7 +197,6 @@ export class TooltipTextMenu { // set the element's new position: elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; - self.highlightSearchTerms(["hello", "there"]); } function closeDragElement() { @@ -205,7 +204,7 @@ export class TooltipTextMenu { document.onmouseup = null; document.onmousemove = null; //self.highlightSearchTerms(self.state, ["hello"]); - self.unhighlightSearchTerms(); + FormattedTextBox.Instance.unhighlightSearchTerms(); } } @@ -596,38 +595,6 @@ export class TooltipTextMenu { return found; } - public highlightSearchTerms = (terms: String[]) => { - const doc = this.view.state.doc; - const mark = this.view.state.schema.mark(this.view.state.schema.marks.search_highlight); - doc.nodesBetween(0, doc.content.size, (node: ProsNode, pos: number, parent: ProsNode, index: number) => { - if (node.isLeaf && node.isText && node.text) { - let nodeText: String = node.text; - let tokens = nodeText.split(" "); - let start = pos; - tokens.forEach((word) => { - if (terms.includes(word)) { - this.view.dispatch(this.view.state.tr.addMark(start, start + word.length, mark).removeStoredMark(mark)); - } - else { - start += word.length + 1; - } - }); - } - }); - } - - public unhighlightSearchTerms = () => { - const doc = this.view.state.doc; - const mark = this.view.state.schema.mark(this.view.state.schema.marks.search_highlight); - doc.nodesBetween(0, doc.content.size, (node: ProsNode, pos: number, parent: ProsNode, index: number) => { - if (node.isLeaf && node.isText && node.text) { - if (node.marks.includes(mark)) { - this.view.dispatch(this.view.state.tr.removeMark(pos, pos + node.nodeSize, mark)); - } - } - }); - } - //updates the tooltip menu when the selection changes update(view: EditorView, lastState: EditorState | undefined) { let state = view.state; diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 340455677..2fdb16cc3 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -152,9 +152,7 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe if (terms.includes(word) && this._editorView) { this._editorView.dispatch(this._editorView.state.tr.addMark(start, start + word.length, mark).removeStoredMark(mark)); } - else { - start += word.length + 1; - } + start += word.length + 1; }); } }); @@ -172,6 +170,12 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe } } }); + // const fieldkey = 'search_string'; + // if (Object.keys(this.props.Document).indexOf(fieldkey) !== -1) { + // this.props.Document[fieldkey] = undefined; + // } + // else this.props.Document.proto![fieldkey] = undefined; + // } } } @@ -255,7 +259,12 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe this._searchReactionDisposer = reaction(() => { return StrCast(this.props.Document.search_string); }, searchString => { - this.highlightSearchTerms([searchString]); + if (searchString) { + this.highlightSearchTerms([searchString]); + } + else { + this.unhighlightSearchTerms(); + } }); this._reactionDisposer = reaction( diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index d2e57c5ca..9c91c524b 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -149,12 +149,14 @@ export class SearchItem extends React.Component<SearchItemProps> { highlightTextBox = (doc: Doc) => { if (this.props.query) { - doc.search_string = this.props.query; - // FormattedTextBox.Instance.highlightSearchTerms([this.props.query]); - } - else { - // FormattedTextBox.Instance.highlightSearchTerms(["hello"]); - doc.search_string = "hello"; + const fieldkey = 'search_string'; + if (Object.keys(doc).indexOf(fieldkey) === -1) { + doc.search_string = this.props.query; + } + else { + doc.search_string = undefined; + } + } } |