diff options
author | tschicke-brown <tyler_schicke@brown.edu> | 2019-03-16 21:54:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-16 21:54:27 -0400 |
commit | 972d7c28f2f99ee0fa8f0de521e7798edc4fd556 (patch) | |
tree | 9fcb3eb93fd4048c64c8ddcd9755e9f2d093cd53 /src/client/views/nodes/DocumentView.tsx | |
parent | 0a1b68e534aebf6f5fa6af31fd6a1e3d63f299d1 (diff) | |
parent | a5a5e17adb4f5881c905baa13669c0ca4e884467 (diff) |
Merge pull request #60 from browngraphicslab/template
Template
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 6b305fb96..3c1f98ef8 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -240,6 +240,20 @@ export class DocumentView extends React.Component<DocumentViewProps> { e.stopPropagation(); } + onDrop = (e: React.DragEvent) => { + if (e.isDefaultPrevented()) { + return; + } + let text = e.dataTransfer.getData("text/plain"); + if (text && text.startsWith("<div")) { + let oldLayout = this.props.Document.GetText(KeyStore.Layout, ""); + let layout = text.replace("{layout}", oldLayout); + this.props.Document.SetText(KeyStore.Layout, layout); + e.stopPropagation(); + e.preventDefault(); + } + } + @action onContextMenu = (e: React.MouseEvent): void => { e.stopPropagation(); @@ -322,6 +336,7 @@ export class DocumentView extends React.Component<DocumentViewProps> { transformOrigin: "left top", transform: `scale(${scaling} , ${scaling})` }} + onDrop={this.onDrop} onContextMenu={this.onContextMenu} onPointerDown={this.onPointerDown} > <DocumentContentsView {...this.getProps} /> |