aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/ScriptBox.tsx
diff options
context:
space:
mode:
authorStanley Yip <stanley_yip@brown.edu>2020-01-17 15:45:05 -0500
committerStanley Yip <stanley_yip@brown.edu>2020-01-17 15:45:05 -0500
commit8667498929fce14295658f89c8787a1a9b1ce468 (patch)
treec3d03768bf2b8d23e438479c67141fae43c63e1e /src/client/views/ScriptBox.tsx
parent4b0a056f1afaf20dea4be64c7b238748d99ad12e (diff)
parent9620d149a2051bc9b42a037b1c65b61deebd11fa (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into pen
Diffstat (limited to 'src/client/views/ScriptBox.tsx')
-rw-r--r--src/client/views/ScriptBox.tsx13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index ded2329b4..d24256886 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -82,28 +82,19 @@ export class ScriptBox extends React.Component<ScriptBoxProps> {
);
}
//let l = docList(this.source[0].data).length; if (l) { let ind = this.target[0].index !== undefined ? (this.target[0].index+1) % l : 0; this.target[0].index = ind; this.target[0].proto = getProto(docList(this.source[0].data)[ind]);}
- public static EditButtonScript(title: string, doc: Doc, fieldKey: string, clientX: number, clientY: number, prewrapper?: string, postwrapper?: string) {
+ public static EditButtonScript(title: string, doc: Doc, fieldKey: string, clientX: number, clientY: number, contextParams?: { [name: string]: string }) {
let overlayDisposer: () => void = emptyFunction;
const script = ScriptCast(doc[fieldKey]);
let originalText: string | undefined = undefined;
if (script) {
originalText = script.script.originalScript;
- if (prewrapper && originalText.startsWith(prewrapper)) {
- originalText = originalText.substr(prewrapper.length);
- }
- if (postwrapper && originalText.endsWith(postwrapper)) {
- originalText = originalText.substr(0, originalText.length - postwrapper.length);
- }
}
// tslint:disable-next-line: no-unnecessary-callback-wrapper
const params: string[] = [];
const setParams = (p: string[]) => params.splice(0, params.length, ...p);
const scriptingBox = <ScriptBox initialText={originalText} setParams={setParams} onCancel={overlayDisposer} onSave={(text, onError) => {
- if (prewrapper) {
- text = prewrapper + text + (postwrapper ? postwrapper : "");
- }
const script = CompileScript(text, {
- params: { this: Doc.name },
+ params: { this: Doc.name, ...contextParams },
typecheck: false,
editable: true,
transformer: DocumentIconContainer.getTransformer()