aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/PreviewCursor.tsx31
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx3
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx46
3 files changed, 46 insertions, 34 deletions
diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx
index 04ec51218..dbda46dbc 100644
--- a/src/client/views/PreviewCursor.tsx
+++ b/src/client/views/PreviewCursor.tsx
@@ -4,13 +4,15 @@ import "normalize.css";
import * as React from 'react';
import "./PreviewCursor.scss";
import { Docs } from '../documents/Documents';
-import { Transform } from 'prosemirror-transform';
+// import { Transform } from 'prosemirror-transform';
import { Doc } from '../../new_fields/Doc';
+import { Transform } from "../util/Transform";
@observer
export class PreviewCursor extends React.Component<{}> {
private _prompt = React.createRef<HTMLDivElement>();
static _onKeyPress?: (e: KeyboardEvent) => void;
+ static _getTransform: () => Transform;
static _addLiveTextDoc: (doc: Doc) => void;
@observable static _clickPoint = [0, 0];
@observable public static Visible = false;
@@ -26,22 +28,28 @@ export class PreviewCursor extends React.Component<{}> {
}
paste = (e: ClipboardEvent) => {
- console.log("pasting")
if (PreviewCursor.Visible) {
- console.log("preview is visible")
if (e.clipboardData) {
- //what needs to be done with this?
- console.log(e.clipboardData.getData("text/html"));
+ //keeping these just to hold onto types of pastes
+ //what needs to be done with html?
+ // console.log(e.clipboardData.getData("text/html"));
// console.log(e.clipboardData.getData("text/csv"));
- console.log(e.clipboardData.getData("text/plain"));
- console.log(e.clipboardData.getData("image/png"));
- console.log(e.clipboardData.getData("image/jpg"));
- console.log(e.clipboardData.getData("image/jpeg"));
+ // console.log(e.clipboardData.getData("text/plain"));
+ // console.log(e.clipboardData.getData("image/png"));
+ // console.log(e.clipboardData.getData("image/jpg"));
+ // console.log(e.clipboardData.getData("image/jpeg"));
// pasting in text
if (e.clipboardData.getData("text/plain") !== "") {
let text = e.clipboardData.getData("text/plain");
- let newBox = Docs.Create.TextDocument({ width: 200, height: 100, x: PreviewCursor._clickPoint[0], y: PreviewCursor._clickPoint[1], title: "-typed text-" });
+ let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]);
+ let newBox = Docs.Create.TextDocument({
+ width: 200, height: 100,
+ x: newPoint[0],
+ y: newPoint[1],
+ title: "-typed text-"
+ });
+
newBox.proto!.autoHeight = true;
PreviewCursor._addLiveTextDoc(newBox);
}
@@ -69,10 +77,11 @@ export class PreviewCursor extends React.Component<{}> {
}
}
@action
- public static Show(x: number, y: number, onKeyPress: (e: KeyboardEvent) => void, addLiveText: (doc: Doc) => void) {
+ public static Show(x: number, y: number, onKeyPress: (e: KeyboardEvent) => void, addLiveText: (doc: Doc) => void, getTransform: () => Transform) {
this._clickPoint = [x, y];
this._onKeyPress = onKeyPress;
this._addLiveTextDoc = addLiveText;
+ this._getTransform = getTransform;
setTimeout(action(() => this.Visible = true), (1));
}
render() {
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 08d2a8adf..72444983c 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -203,7 +203,8 @@ export class MarqueeView extends React.Component<MarqueeViewProps>
onClick = (e: React.MouseEvent): void => {
if (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD &&
Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD) {
- PreviewCursor.Show(e.clientX, e.clientY, this.onKeyPress, this.props.addLiveTextDocument);
+ //this is probably the wrong transform
+ PreviewCursor.Show(e.clientX, e.clientY, this.onKeyPress, this.props.addLiveTextDocument, this.props.getTransform);
// let the DocumentView stopPropagation of this event when it selects this document
} else { // why do we get a click event when the cursor have moved a big distance?
// let's cut it off here so no one else has to deal with it.
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index a304cb297..25f611f19 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -134,28 +134,31 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
paste = (e: ClipboardEvent) => {
+ //this is throwing a ton of erros so i had to comment it out
if (e.clipboardData && this._editorView) {
- let pdfPasteText = `${Utils.GenerateDeterministicGuid("pdf paste")}`;
- for (let i = 0; i < e.clipboardData.items.length; i++) {
- let item = e.clipboardData.items.item(i);
- if (item.type === "text/plain") {
- item.getAsString((text) => {
- let pdfPasteIndex = text.indexOf(pdfPasteText);
- if (pdfPasteIndex > -1) {
- let insertText = text.substr(0, pdfPasteIndex);
- const tx = this._editorView!.state.tr.insertText(insertText);
- // tx.setSelection(new Selection(tx.))
- const state = this._editorView!.state;
- this._editorView!.dispatch(tx);
- if (FormattedTextBox._toolTipTextMenu) {
- // this._toolTipTextMenu.makeLinkWithState(state)
- }
- e.stopPropagation();
- e.preventDefault();
- }
- });
- }
- }
+ // let pdfPasteText = `${Utils.GenerateDeterministicGuid("pdf paste")}`;
+ // for (let i = 0; i < e.clipboardData.items.length; i++) {
+ // let item = e.clipboardData.items.item(i);
+ // console.log(item)
+ // if (item.type === "text/plain") {
+ // console.log("plain")
+ // item.getAsString((text) => {
+ // let pdfPasteIndex = text.indexOf(pdfPasteText);
+ // if (pdfPasteIndex > -1) {
+ // let insertText = text.substr(0, pdfPasteIndex);
+ // const tx = this._editorView!.state.tr.insertText(insertText);
+ // // tx.setSelection(new Selection(tx.))
+ // const state = this._editorView!.state;
+ // this._editorView!.dispatch(tx);
+ // if (FormattedTextBox._toolTipTextMenu) {
+ // // this._toolTipTextMenu.makeLinkWithState(state)
+ // }
+ // e.stopPropagation();
+ // e.preventDefault();
+ // }
+ // });
+ // }
+ // }
}
}
@@ -167,7 +170,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
FormattedTextBox._toolTipTextMenu && (FormattedTextBox._toolTipTextMenu.HackToFixTextSelectionGlitch = false);
if (state.selection.empty && FormattedTextBox._toolTipTextMenu) {
const marks = tx.storedMarks;
- console.log(marks)
if (marks) { FormattedTextBox._toolTipTextMenu.mark_key_pressed(marks); }
}
this._applyingChange = true;