Skip to content

Commit 44b73f6

Browse files
committed
InputSaveDelay
1 parent 082cfde commit 44b73f6

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Views/Notebook/Notebook.wlx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,14 @@ evaluateCell[cell_, notebook_, secret_String, log_String, kernels_, cli_, modals
413413
promise
414414
] ];
415415

416-
Script[OptionsPattern[]] := With[{ExtensionTemplateInjection = OptionValue["ExtensionTemplateInjection"]},
416+
Script[OptionsPattern[]] := With[{
417+
ExtensionTemplateInjection = OptionValue["ExtensionTemplateInjection"],
418+
InputSaveDelay = Lookup[OptionValue["Parameters"], "InputSaveDelay", 200]
419+
},
417420
<div>
418421
<script type="module">
422+
CellWrapper.inputSaveDelay = <InputSaveDelay/>;
423+
419424
core.UINotebook = async (args, env) => {
420425
const type = await interpretate(args[0], env);
421426
core.UINotebook[type](args.slice(1), env);
@@ -972,7 +977,7 @@ Component[OptionsPattern[]] := With[{
972977
<ExtensionTemplateInjection Template={"Footer"} Modals={modals} Messager={log} Notebook={notebook} Event={secret} Controls={controller}/>
973978
<ExtensionTemplateInjection Template={"Scripts"} />
974979

975-
<Script ExtensionTemplateInjection={ExtensionTemplateInjection}/>
980+
<Script Parameters={parameters} ExtensionTemplateInjection={ExtensionTemplateInjection}/>
976981

977982
<WebUIOnLoad Event={secret} Pattern={"Load"}/>
978983
</main>
@@ -981,7 +986,7 @@ Component[OptionsPattern[]] := With[{
981986
]
982987

983988
Options[Component] = {"Parameters"->Null, "IframeQ"->False, "AppEvents"->"blacksheep", "Kernels"->{}, "Modals"->"", "Controls" ->"", "ControlsPort"->"", "Notebook"->Null, "Event"->"blackhole", "Messager"->"blackout", "Secret" :> CreateUUID[], "ExtensionTemplateWrapper"-> sequenceIdentity, "ExtensionTemplateInjection" -> emptyStringFunction, "ExternalEventHandlers" -> Null}
984-
Options[Script] = {"ExtensionTemplateInjection" -> emptyStringFunction}
989+
Options[Script] = {"Parameters"->Null, "ExtensionTemplateInjection" -> emptyStringFunction}
985990

986991
emptyStringFunction[x__] := ""
987992
sequenceIdentity[first__, rulels___Rule] := first

Views/Settings/Components/General.wlx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ parseInt[any_String] := ToExpression[any]
2222
parseInt[any_] := any
2323

2424
defaultBackupTime = If[KeyExistsQ[settings, "BackupTimeout"], Round[settings["BackupTimeout"]/60/1000], 3]
25+
defaultInputSaveDelay = If[KeyExistsQ[settings, "InputSaveDelay"], settings["InputSaveDelay"], 180]
2526
defaultTheme = If[KeyExistsQ[settings, "Theme"], settings["Theme"], "System"]
2627

2728
defaultTray = If[KeyExistsQ[settings, "RunInTray"], settings["RunInTray"], False]
@@ -107,6 +108,12 @@ EventHandler[Secret, {"Load" -> Function[Null,
107108
]
108109
],
109110

111+
"InputSaveDelay" -> Function[value,
112+
settings = Join[settings, <|"InputSaveDelay"-> parseInt[value]|>];
113+
onSave[settings];
114+
EventFire[Messager, Notifications`NotificationMessage["Info"](*`*), "Changes will be applied after restart"];
115+
],
116+
110117
"BackupTimeout" -> Function[value,
111118
settings = Join[settings, <|"BackupTimeout"-> (60 1000 parseInt[value])|>];
112119
onSave[settings];
@@ -197,12 +204,20 @@ EventHandler[Secret, {"Load" -> Function[Null,
197204

198205
<div class="pb-2 mt-2 mt-5 gap-y-2 flex flex-col">
199206
<div class="rounded-md px-3 pb-3 pt-2.5 shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-indigo-600">
200-
<label for="BackupTimeout" class="block text-xs font-medium text-gray-900 dark:text-gray-400">Backup time interval</label>
207+
<label for="BackupTimeout" class="block text-xs font-medium text-gray-900 dark:text-gray-400">Backup time interval (mins)</label>
201208
<input type="number" value="{defaultBackupTime}" min="3" max="3000" step="1" id="BackupTimeout" class="block w-full border-0 p-0 dark:bg-gray-700 text-gray-900 dark:text-gray-300 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"/>
202209
<WebUIEventListener Id={"BackupTimeout"} Type={"blur"} Event={controller} Pattern={"BackupTimeout"}/>
203210
</div>
204211
</div>
205212

213+
<div class="pb-2 mt-2 mt-5 gap-y-2 flex flex-col">
214+
<div class="rounded-md px-3 pb-3 pt-2.5 shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-indigo-600">
215+
<label for="inputSaveDelay" class="block text-xs font-medium text-gray-900 dark:text-gray-400">On change saving interval (ms)</label>
216+
<input type="number" value="{defaultInputSaveDelay}" min="50" max="500" step="20" id="inputSaveDelay" class="block w-full border-0 p-0 dark:bg-gray-700 text-gray-900 dark:text-gray-300 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"/>
217+
<WebUIEventListener Id={"inputSaveDelay"} Type={"blur"} Event={controller} Pattern={"InputSaveDelay"}/>
218+
</div>
219+
</div>
220+
206221
<StringRiffle>
207222
<Checkbox Label={"Expert mode"} Event={controller} Topic={"ExpertMode"} Description={"Shows invisible cells"} Checked={settings["ExpertMode"]}/>
208223
</StringRiffle>

0 commit comments

Comments
 (0)