aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-04 16:00:18 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-04 16:00:18 -0500
commitd245b5101253814219fd68368c62cf78b9d24ef7 (patch)
tree66d8db4608c3a81718849c9577ec8f493f552e0a /src
parent765b2162e38ce728265a410c4f270c91ab336e28 (diff)
fixed on enter, trying resize
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/ScriptingBox.tsx28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx
index a3b11c734..a621e2bc6 100644
--- a/src/client/views/nodes/ScriptingBox.tsx
+++ b/src/client/views/nodes/ScriptingBox.tsx
@@ -18,6 +18,7 @@ import { FieldView, FieldViewProps } from "../nodes/FieldView";
import { OverlayView } from "../OverlayView";
import { DocumentIconContainer } from "./DocumentIcon";
import "./ScriptingBox.scss";
+const _global = (window /* browser */ || global /* node */) as any;
import ReactTextareaAutocomplete from "@webscopeio/react-textarea-autocomplete";
import "@webscopeio/react-textarea-autocomplete/style.css";
@@ -53,6 +54,9 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@observable private _suggestionRef: any = React.createRef();
@observable private _scriptTextRef: any = React.createRef();
+ @observable private _panelWidth = 0;
+ @observable private _panelHeight = 0;
+
// vars included in fields that store parameters types and names and the script itself
@computed({ keepAlive: true }) get paramsNames() { return this.compileParams.map(p => p.split(":")[0].trim()); }
@computed({ keepAlive: true }) get paramsTypes() { return this.compileParams.map(p => p.split(":")[1].trim()); }
@@ -107,9 +111,25 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@action
componentDidMount() {
this.rawScript = ScriptCast(this.dataDoc[this.props.fieldKey])?.script?.originalScript ?? this.rawScript;
+
+ const observer = new _global.ResizeObserver(action((entries: any) => {
+ for (const entry of entries) {
+ this._panelWidth = entry.contentRect.width;
+ this._panelHeight = entry.contentRect.height;
+ this.onActiveContentItemChanged();
+ }
+ }));
+ observer.observe(document.getElementsByClassName("scriptingBox")[0]);
}
- componentWillUnmount() { this._overlayDisposer?.(); }
+ componentWillUnmount() {
+ this._overlayDisposer?.();
+ }
+
+ @action.bound
+ private onActiveContentItemChanged() {
+ this.suggestionPos();
+ }
protected createDashEventsTarget = (ele: HTMLDivElement, dropFunc: (e: Event, de: DragManager.DropEvent) => void) => { //used for stacking and masonry view
if (ele) {
@@ -475,6 +495,9 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@action
suggestionPos() {
+
+ console.log("suggestionPos");
+
const getCaretCoordinates = require('textarea-caret');
const This = this;
document.querySelector('textarea')?.addEventListener('input', function () {
@@ -500,6 +523,9 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@action
keyHandler(e: any, pos: number) {
+ if (this._lastChar === "Enter") {
+ this.rawScript = this.rawScript + " ";
+ }
console.log(e.key);
if (e.key === "(") {
console.log("hello");