aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonikahedman <monika_hedman@brown.edu>2019-08-21 14:22:30 -0400
committermonikahedman <monika_hedman@brown.edu>2019-08-21 14:22:30 -0400
commit76a693012866178a3fbe037ab06cfd4482f37917 (patch)
tree898a3fa31d1b34a77fd01edd0dd5965724fac3ac
parent9a39ac87972243787474d489856818f44b90d524 (diff)
djlzdkfj
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx7
-rw-r--r--src/client/views/nodes/WebBox.tsx26
2 files changed, 23 insertions, 10 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 25f611f19..d299bbf72 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -162,6 +162,13 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
}
}
+ public setText = (text: string) => {
+ const tx = this._editorView!.state.tr.insertText(text);
+ const state = this._editorView!.state;
+ this._editorView!.dispatch(tx);
+ return new RichTextField(JSON.stringify(state.toJSON()));
+ }
+
dispatchTransaction = (tx: Transaction) => {
if (this._editorView) {
const state = this._editorView.state.apply(tx);
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index c43b90f91..e7bed3bed 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -26,6 +26,8 @@ import { SelectionManager } from "../../util/SelectionManager";
import { CollectionView } from "../collections/CollectionView";
import { CollectionPDFView } from "../collections/CollectionPDFView";
import { CollectionVideoView } from "../collections/CollectionVideoView";
+import { DocumentView } from "./DocumentView";
+import { FormattedTextBox } from "./FormattedTextBox";
library.add(faStickyNote)
@@ -85,14 +87,15 @@ export class WebBox extends React.Component<FieldViewProps> {
let field = Cast(this.props.Document[this.props.fieldKey], WebField);
if (field) url = field.url.href;
- let parent: Opt<CollectionView | CollectionPDFView | CollectionVideoView>;
+ let docView: DocumentView;
// let parentDoc: any;
SelectionManager.SelectedDocuments().map(dv => {
- parent = dv.props.ContainingCollectionView;
- // if(parent) parentDoc = parent.props.Document;
+ // docView = dv;
dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);
});
+ console.log("happening")
+
// // let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]);
let newBox = Docs.Create.TextDocument({
width: 200, height: 100,
@@ -103,13 +106,16 @@ export class WebBox extends React.Component<FieldViewProps> {
title: url
});
- console.log(newBox)
- if (parent) {
- let parentDoc: Doc = parent.props.Document;
- if (parentDoc && parentDoc.props) {
- parentDoc.props.addDocument();
- }
- }
+ console.log(typeof newBox)
+
+ // const script = KeyValueBox.CompileKVPScript(`new RichTextField("{"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"${url}"}]}]},"selection":{"type":"text","anchor":1,"head":1}}")`);
+ // const script = KeyValueBox.CompileKVPScript(newBox.setText(url))
+ // console.log(script)
+ // if (!script) return;
+ // KeyValueBox.ApplyKVPScript(this.props.Document, "data", script);
+
+ console.log(newBox);
+
newBox.proto!.autoHeight = true;
// PreviewCursor._addLiveTextDoc(newBox);