diff options
Diffstat (limited to 'src/client/views/PreviewCursor.tsx')
-rw-r--r-- | src/client/views/PreviewCursor.tsx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx index 4b7771f27..034ade50b 100644 --- a/src/client/views/PreviewCursor.tsx +++ b/src/client/views/PreviewCursor.tsx @@ -1,9 +1,10 @@ import { action, makeObservable, observable, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; -import { lightOrDark, returnFalse } from '../../Utils'; +import { lightOrDark, returnFalse } from '../../ClientUtils'; import { Doc, Opt } from '../../fields/Doc'; -import { DocUtils, Docs, DocumentOptions } from '../documents/Documents'; +import { Docs, DocumentOptions } from '../documents/Documents'; +import { DocUtils } from '../documents/DocUtils'; import { ImageUtils } from '../util/Import & Export/ImageUtils'; import { Transform } from '../util/Transform'; import { UndoManager, undoBatch } from '../util/UndoManager'; @@ -13,6 +14,7 @@ import { FormattedTextBox } from './nodes/formattedText/FormattedTextBox'; @observer export class PreviewCursor extends ObservableReactComponent<{}> { + // eslint-disable-next-line no-use-before-define static _instance: PreviewCursor; public static get Instance() { return PreviewCursor._instance; @@ -39,7 +41,9 @@ export class PreviewCursor extends ObservableReactComponent<{}> { paste = async (e: ClipboardEvent) => { if (this.Visible && e.clipboardData) { const newPoint = this._getTransform?.().transformPoint(this._clickPoint[0], this._clickPoint[1]); - runInAction(() => (this.Visible = false)); + runInAction(() => { + this.Visible = false; + }); // tests for URL and makes web document const re: any = /^https?:\/\//g; @@ -88,10 +92,10 @@ export class PreviewCursor extends ObservableReactComponent<{}> { UndoManager.RunInBatch(() => this._addLiveTextDoc?.(DocUtils.GetNewTextDoc('', newPoint[0], newPoint[1], 500, undefined, undefined)), 'paste'); } } - //pasting in images + // pasting in images else if (e.clipboardData.getData('text/html') !== '' && e.clipboardData.getData('text/html').includes('<img src=')) { - const re: any = /<img src="(.*?)"/g; - const arr: any[] = re.exec(e.clipboardData.getData('text/html')); + const regEx: any = /<img src="(.*?)"/g; + const arr: any[] = regEx.exec(e.clipboardData.getData('text/html')); if (newPoint) { undoBatch(() => { @@ -122,7 +126,7 @@ export class PreviewCursor extends ObservableReactComponent<{}> { @action onKeyDown = (e: KeyboardEvent) => { // Mixing events between React and Native is finicky. - //if not these keys, make a textbox if preview cursor is active! + // if not these keys, make a textbox if preview cursor is active! if ( e.key !== 'Escape' && e.key !== 'Backspace' && @@ -162,7 +166,7 @@ export class PreviewCursor extends ObservableReactComponent<{}> { } }; - //when focus is lost, this will remove the preview cursor + // when focus is lost, this will remove the preview cursor @action onBlur = (): void => { this.Visible = false; }; @@ -192,6 +196,7 @@ export class PreviewCursor extends ObservableReactComponent<{}> { } render() { return !this._clickPoint || !this.Visible ? null : ( + // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex <div className="previewCursor" onBlur={this.onBlur} tabIndex={0} ref={e => e?.focus()} style={{ color: lightOrDark(this.Doc?.backgroundColor ?? 'white'), transform: `translate(${this._clickPoint[0]}px, ${this._clickPoint[1]}px)` }}> I </div> |