diff options
Diffstat (limited to 'src/client/views/nodes/formattedText')
| -rw-r--r-- | src/client/views/nodes/formattedText/FormattedTextBox.tsx | 16 | ||||
| -rw-r--r-- | src/client/views/nodes/formattedText/RichTextMenu.tsx | 13 | 
2 files changed, 15 insertions, 14 deletions
| diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index dcdac6775..730c57794 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -265,6 +265,14 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB              docView && DragManager.StartAnchorAnnoDrag([ele], new DragManager.AnchorAnnoDragData(docView, () => this.getAnchor(true), targetCreator), e.pageX, e.pageY);          }); +        AnchorMenu.Instance.AddDrawingAnnotation = (drawing: Doc) => { +            const container = DocCast(this.Document.embedContainer); +            const docView = DocumentView.getDocumentView?.(container); +            docView?.ComponentView?._props.addDocument?.(drawing); +            drawing.x = NumCast(this.Document.x) + NumCast(this.Document.width); +            drawing.y = NumCast(this.Document.y); +        }; +          AnchorMenu.Instance.setSelectedText(window.getSelection()?.toString() ?? '');          const coordsB = this._editorView!.coordsAtPos(this._editorView!.state.selection.to);          this._props.rootSelected?.() && AnchorMenu.Instance.jumpTo(coordsB.left, coordsB.bottom); @@ -648,7 +656,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB                          textContent += node.child(i).textContent;                          i++;                      } -                    // eslint-disable-next-line no-cond-assign                      while (ep && (foundAt = textContent.slice(index).search(regexp)) > -1) {                          const sel = new TextSelection(pm.state.doc.resolve(ep.from + index + blockOffset + foundAt + 1), pm.state.doc.resolve(ep.from + index + blockOffset + foundAt + find.length + 1));                          ret.push(sel); @@ -707,7 +714,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB              const hr = Math.round(Date.now() / 1000 / 60 / 60);              numberRange(10).map(i => addStyleSheetRule(FormattedTextBox._userStyleSheet, 'UM-hr-' + (hr - i), { opacity: ((10 - i - 1) / 10).toString() }));          } -        // eslint-disable-next-line operator-assignment          this.layoutDoc[DocCss] = this.layoutDoc[DocCss] + 1; // css changes happen outside of react/mobx.  so we need to set a flag that will notify anyone interested in layout changes triggered by css changes (eg., CollectionLinkView)      }; @@ -1124,7 +1130,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB              const nodes: Node[] = [];              let hadStart = start !== 0;              frag.forEach((node, index) => { -                // eslint-disable-next-line no-use-before-define                  const examinedNode = findAnchorNode(node, editor);                  if (examinedNode?.node && (examinedNode.node.textContent || examinedNode.node.type === this._editorView?.state.schema.nodes.dashDoc || examinedNode.node.type === this._editorView?.state.schema.nodes.audiotag)) {                      nodes.push(examinedNode.node); @@ -1278,7 +1283,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB              action(selected => {                  this.prepareForTyping();                  if (FormattedTextBox._globalHighlights.has('Bold Text')) { -                    // eslint-disable-next-line operator-assignment                      this.layoutDoc[DocCss] = this.layoutDoc[DocCss] + 1; // css change happens outside of mobx/react, so this will notify anyone interested in the layout that it has changed                  }                  if (RichTextMenu.Instance?.view === this._editorView && !selected) { @@ -1705,7 +1709,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB          const match = RTFCast(this.Document[this.fieldKey])?.Text.match(/^(@[a-zA-Z][a-zA-Z_0-9 -]*[a-zA-Z_0-9-]+)/);          if (match) {              this.dataDoc.title_custom = true; -            // eslint-disable-next-line prefer-destructuring              this.dataDoc.title = match[1]; // this triggers the collectionDockingView to publish this Doc              this.EditorView?.dispatch(this.EditorView?.state.tr.deleteRange(0, match[1].length + 1));          } @@ -1787,7 +1790,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB          const margins = 2 * NumCast(this.layoutDoc._yMargin, this._props.yPadding || 0);          const children = this.ProseRef?.children.length ? Array.from(this.ProseRef.children[0].children) : undefined;          if (children && !SnappingManager.IsDragging) { -            // eslint-disable-next-line no-use-before-define              const getChildrenHeights = (kids: Element[] | undefined) => kids?.reduce((p, child) => p + toHgt(child), margins) ?? 0;              const toNum = (val: string) => Number(val.replace('px', ''));              const toHgt = (node: Element): number => { @@ -1874,7 +1876,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB              return ComponentTag === CollectionStackingView ? (                  <SidebarAnnos                      ref={this._sidebarRef} -                    // eslint-disable-next-line react/jsx-props-no-spreading                      {...this._props}                      Document={this.Document}                      layoutDoc={this.layoutDoc} @@ -1894,7 +1895,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB              ) : (                  <div onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, () => DocumentView.SelectView(this.DocumentView?.(), false), true)}>                      <ComponentTag -                        // eslint-disable-next-line react/jsx-props-no-spreading                          {...this._props}                          ref={this._sidebarTagRef}                          setContentView={emptyFunction} diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx index 738f6d699..88e2e4248 100644 --- a/src/client/views/nodes/formattedText/RichTextMenu.tsx +++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx @@ -1,6 +1,6 @@  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';  import { Tooltip } from '@mui/material'; -import { action, computed, IReactionDisposer, makeObservable, observable } from 'mobx'; +import { action, computed, IReactionDisposer, makeObservable, observable, runInAction } from 'mobx';  import { observer } from 'mobx-react';  import { lift, toggleMark, wrapIn } from 'prosemirror-commands';  import { Mark, MarkType } from 'prosemirror-model'; @@ -68,10 +68,12 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {      constructor(props: AntimodeMenuProps) {          super(props);          makeObservable(this); -        RichTextMenu._instance.menu = this; -        this.updateMenu(undefined, undefined, props, this.layoutDoc); -        this._canFade = false; -        this.Pinned = true; +        runInAction(() => { +            RichTextMenu._instance.menu = this; +            this.updateMenu(undefined, undefined, props, this.layoutDoc); +            this._canFade = false; +            this.Pinned = true; +        });      }      @computed get noAutoLink() { @@ -695,7 +697,6 @@ interface RichTextMenuPluginProps {      editorProps: FormattedTextBoxProps;  }  export class RichTextMenuPlugin extends React.Component<RichTextMenuPluginProps> { -    // eslint-disable-next-line react/no-unused-class-component-methods      update(view: EditorView & { TextView?: FormattedTextBox }, lastState: EditorState | undefined) {          RichTextMenu.Instance?.updateMenu(view, lastState, this.props.editorProps, view.TextView?.layoutDoc);      } | 
