aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/ScriptBox.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-09-10 15:55:51 -0400
committerbob <bcz@cs.brown.edu>2019-09-10 15:55:51 -0400
commit9608245db4ba8cca6054a0641f2eb2bd2032eba6 (patch)
tree5e0ac16b5c849db828bb211eb9d09cc6eee90f26 /src/client/views/ScriptBox.tsx
parent5ea7e3318620865146318e0f3826b6f13aec0675 (diff)
fixed up some stuff with portals and added a ButtonBox menu item for running scripts over a collection
Diffstat (limited to 'src/client/views/ScriptBox.tsx')
-rw-r--r--src/client/views/ScriptBox.tsx15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index 2b862a81e..7afba5e01 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -66,13 +66,24 @@ export class ScriptBox extends React.Component<ScriptBoxProps> {
</div>
);
}
- public static EditClickScript(doc: Doc, fieldKey: string) {
+ public static EditClickScript(doc: Doc, fieldKey: string, prewrapper?: string, postwrapper?: string) {
let overlayDisposer: () => void = emptyFunction;
const script = ScriptCast(doc[fieldKey]);
let originalText: string | undefined = undefined;
- if (script) originalText = script.script.originalScript;
+ 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
let scriptingBox = <ScriptBox initialText={originalText} onCancel={() => overlayDisposer()} onSave={(text, onError) => {
+ if (prewrapper) {
+ text = prewrapper + text + (postwrapper ? postwrapper : "");
+ }
const script = CompileScript(text, {
params: { this: Doc.name },
typecheck: false,