@gramlot/gramlot 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +3 -3
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +16 -16
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/collection.js +28 -19
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +21 -0
- package/dist/components/grouplets/__init__.py +1 -1
- package/dist/components/grouplets/assets/collection.js +2 -2
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/collection.js +21 -21
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +15 -15
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +11 -11
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +3 -3
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +8 -8
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/gramlot.js +624 -86
- package/dist/gramlot.min.js +47 -46
- package/package.json +1 -1
- package/src/binding/grid-struct.js +1 -1
- package/src/binding/validation-context.js +2 -1
- package/src/components/bases.js +5 -3
- package/src/components/choice-editor.js +28 -13
- package/src/components/database-choices.js +9 -6
- package/src/components/field-state.js +8 -1
- package/src/components/grid-cell-editor.js +83 -19
- package/src/components/grid-grammar.json +21 -0
- package/src/components/grid-structure.js +4 -1
- package/src/components/grid-styles.js +11 -2
- package/src/components/grid.js +16 -1
- package/src/components/inputs.js +2 -2
- package/src/components/parameters.js +6 -2
- package/src/components/tree.js +1 -0
- package/src/components/typed-editor.js +4 -4
- package/src/components/validation.js +1 -1
- package/src/editing-session.d.ts +1 -0
- package/src/editing-session.js +113 -15
- package/src/editor-values.js +57 -0
- package/src/gramlot.d.ts +1 -0
- package/src/gramlot.js +7 -4
- package/src/index.d.ts +1 -1
- package/src/renderer/gramlot-renderer.d.ts +1 -0
- package/src/renderer/gramlot-renderer.js +11 -0
- package/src/server/source-import.d.ts +1 -1
- package/src/server/source-import.js +5 -1
- package/src/server/visual-editor.d.ts +1 -1
- package/src/server/visual-editor.js +30 -20
- package/src/source-picker.d.ts +1 -1
- package/src/source-picker.js +1 -2
- package/src/visual-editor-canvas.js +29 -0
- package/src/visual-editor-catalogue.js +34 -0
- package/src/visual-editor.d.ts +5 -0
- package/src/visual-editor.js +244 -26
- package/themes/gramlot-base/theme.css +78 -36
- package/tools/gramlot-tools-inspector.js +1 -1
- package/tools/inspector-agent.js +1 -1
package/dist/gramlot.js
CHANGED
|
@@ -23194,9 +23194,12 @@ function defineCollection(options) {
|
|
|
23194
23194
|
|
|
23195
23195
|
// src/components/parameters.js
|
|
23196
23196
|
function projectParameters(element, attrs) {
|
|
23197
|
-
element.parameters =
|
|
23197
|
+
element.parameters = parameterValues(element.constructor.gramlotComponent, attrs);
|
|
23198
23198
|
return Object.fromEntries(Object.entries(attrs).filter(([name]) => !Object.hasOwn(element.parameters, name)));
|
|
23199
23199
|
}
|
|
23200
|
+
function parameterValues(component, attrs) {
|
|
23201
|
+
return Object.fromEntries(Object.entries(component.parameters).map(([name, spec]) => [name, Object.hasOwn(attrs, name) ? attrs[name] : spec.default]));
|
|
23202
|
+
}
|
|
23200
23203
|
|
|
23201
23204
|
// src/components/choices.js
|
|
23202
23205
|
function parseChoices(values, separator = ",") {
|
|
@@ -23261,13 +23264,19 @@ function controlElement(HTMLElement) {
|
|
|
23261
23264
|
finishValidation() {
|
|
23262
23265
|
}
|
|
23263
23266
|
validationValueCheck() {
|
|
23264
|
-
|
|
23267
|
+
return this.constructor.validationValueCheck(this.pageContext);
|
|
23268
|
+
}
|
|
23269
|
+
static validationValueCheck() {
|
|
23270
|
+
const nullable = this.gramlotComponent.parameters.value.nullable;
|
|
23265
23271
|
return (value, original) => {
|
|
23266
23272
|
if (value == null && !nullable) throw new TypeError("This component requires a non-null value.");
|
|
23267
23273
|
if (value != null && original != null && typeof value !== typeof original) throw new TypeError("Validation must preserve the component value type.");
|
|
23268
23274
|
};
|
|
23269
23275
|
}
|
|
23270
23276
|
validationSelection() {
|
|
23277
|
+
return this.constructor.validationSelection(this.parameters, this.pageContext);
|
|
23278
|
+
}
|
|
23279
|
+
static validationSelection() {
|
|
23271
23280
|
return () => {
|
|
23272
23281
|
throw new TypeError("validate_select requires a constrained choice editor.");
|
|
23273
23282
|
};
|
|
@@ -24860,6 +24869,7 @@ function validationContext(binding) {
|
|
|
24860
24869
|
return {
|
|
24861
24870
|
isDecimal: isDecimal2,
|
|
24862
24871
|
invoke,
|
|
24872
|
+
callLogic: (method, keywords) => callLogic(binding.runtime, node, method, keywords),
|
|
24863
24873
|
remote: (method, keywords, signal) => app.rpc.call("data", method, keywords, { signal }),
|
|
24864
24874
|
reportError: (error, title) => {
|
|
24865
24875
|
if (!binding.closed) binding.runtime.reportError(error, title);
|
|
@@ -24915,6 +24925,11 @@ var EditingSession = class {
|
|
|
24915
24925
|
this.retainedFields = /* @__PURE__ */ new Map();
|
|
24916
24926
|
this.listeners = /* @__PURE__ */ new Set();
|
|
24917
24927
|
this.navigators = /* @__PURE__ */ new Set();
|
|
24928
|
+
this.validationSources = /* @__PURE__ */ new Set();
|
|
24929
|
+
this.validationDependencies = /* @__PURE__ */ new Map();
|
|
24930
|
+
this.validationRevision = 0;
|
|
24931
|
+
this.validatedRevision = -1;
|
|
24932
|
+
this.fullValidation = null;
|
|
24918
24933
|
if (!(this.data instanceof Bag)) throw new TypeError("A form requires a Bag at its datapath.");
|
|
24919
24934
|
this.registers.setItem("baseline", copy(this.data));
|
|
24920
24935
|
for (const name of ["changes", "errors", "pending", "drafts"]) this.registers.setItem(name, new Bag());
|
|
@@ -25016,7 +25031,7 @@ var EditingSession = class {
|
|
|
25016
25031
|
}
|
|
25017
25032
|
get status() {
|
|
25018
25033
|
const dirty = this.registers.getItem("changes").length > 0;
|
|
25019
|
-
const pending = this.registers.getItem("pending").length > 0;
|
|
25034
|
+
const pending = this.fullValidation !== null || this.registers.getItem("pending").length > 0;
|
|
25020
25035
|
const invalid = this.registers.getItem("errors").length > 0;
|
|
25021
25036
|
const incomplete = this.registers.getItem("drafts").length > 0;
|
|
25022
25037
|
return {
|
|
@@ -25030,27 +25045,8 @@ var EditingSession = class {
|
|
|
25030
25045
|
register(adapter) {
|
|
25031
25046
|
const node = adapter.node;
|
|
25032
25047
|
this.fields.set(node, adapter);
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
field = {
|
|
25036
|
-
node,
|
|
25037
|
-
binding: adapter.binding,
|
|
25038
|
-
context: validationContext(adapter.binding),
|
|
25039
|
-
run: new ValidationRun(),
|
|
25040
|
-
execute: adapter.element.validationExecutor,
|
|
25041
|
-
checkValue: adapter.element.validationValueCheck(),
|
|
25042
|
-
path: fieldPath(node),
|
|
25043
|
-
rules: null,
|
|
25044
|
-
value: void 0,
|
|
25045
|
-
target: null,
|
|
25046
|
-
result: null,
|
|
25047
|
-
selection: adapter.element.validationSelection()
|
|
25048
|
-
};
|
|
25049
|
-
this.validations.set(node, field);
|
|
25050
|
-
adapter.binding.editingSession = this;
|
|
25051
|
-
field.release = adapter.binding.track(() => this.forgetField(node));
|
|
25052
|
-
this.refreshField(node);
|
|
25053
|
-
}
|
|
25048
|
+
const field = this.registerField(node, adapter.element.constructor);
|
|
25049
|
+
field.selection = adapter.element.validationSelection();
|
|
25054
25050
|
this.schedule(() => {
|
|
25055
25051
|
if (this.fields.get(node) !== adapter) return;
|
|
25056
25052
|
const draft = this.registers.getItem("drafts").getNode(key(node));
|
|
@@ -25067,6 +25063,118 @@ var EditingSession = class {
|
|
|
25067
25063
|
this.fields.delete(node);
|
|
25068
25064
|
};
|
|
25069
25065
|
}
|
|
25066
|
+
/** A real Source declaration can validate without an element or ControlAdapter. */
|
|
25067
|
+
registerField(node, component, schedule = true) {
|
|
25068
|
+
let field = this.validations.get(node);
|
|
25069
|
+
if (field) return field;
|
|
25070
|
+
if (!component.validationExecutor) throw new TypeError("Grid editors require shared input validation.");
|
|
25071
|
+
const binding = this.runtime.bindingFor(node), context = validationContext(binding);
|
|
25072
|
+
field = {
|
|
25073
|
+
node,
|
|
25074
|
+
binding,
|
|
25075
|
+
context,
|
|
25076
|
+
component,
|
|
25077
|
+
run: new ValidationRun(),
|
|
25078
|
+
execute: component.validationExecutor,
|
|
25079
|
+
checkValue: component.validationValueCheck(context),
|
|
25080
|
+
path: fieldPath(node),
|
|
25081
|
+
rules: null,
|
|
25082
|
+
value: void 0,
|
|
25083
|
+
target: null,
|
|
25084
|
+
result: null,
|
|
25085
|
+
selection: null
|
|
25086
|
+
};
|
|
25087
|
+
this.validations.set(node, field);
|
|
25088
|
+
binding.editingSession = this;
|
|
25089
|
+
field.release = binding.track(() => this.forgetField(node));
|
|
25090
|
+
this.refreshField(node, schedule);
|
|
25091
|
+
return field;
|
|
25092
|
+
}
|
|
25093
|
+
registerValidationSource(fields) {
|
|
25094
|
+
this.validationSources.add(fields);
|
|
25095
|
+
this.invalidateValidation();
|
|
25096
|
+
return () => {
|
|
25097
|
+
this.validationSources.delete(fields);
|
|
25098
|
+
this.invalidateValidation();
|
|
25099
|
+
};
|
|
25100
|
+
}
|
|
25101
|
+
invalidateValidation() {
|
|
25102
|
+
this.validationRevision++;
|
|
25103
|
+
if (this.fullValidation) for (const node of this.fullValidation.active) this.cancelValidation(node);
|
|
25104
|
+
}
|
|
25105
|
+
trackValidationDependency(absolute) {
|
|
25106
|
+
if (absolute === null || this.validationDependencies.has(absolute)) return;
|
|
25107
|
+
const [path, attr = null] = absolute.split("?", 2);
|
|
25108
|
+
this.validationDependencies.set(absolute, this.runtime.router.register({
|
|
25109
|
+
path,
|
|
25110
|
+
attr,
|
|
25111
|
+
subtree: true,
|
|
25112
|
+
recipient: { receive: () => this.invalidateValidation() }
|
|
25113
|
+
}));
|
|
25114
|
+
}
|
|
25115
|
+
clearValidationDependencies() {
|
|
25116
|
+
for (const registration of this.validationDependencies.values()) registration.close();
|
|
25117
|
+
this.validationDependencies.clear();
|
|
25118
|
+
}
|
|
25119
|
+
/** Validate the complete declared scope. Bounded work keeps remote checks and UI responsive. */
|
|
25120
|
+
validate() {
|
|
25121
|
+
if (this.disposed) return Promise.resolve(false);
|
|
25122
|
+
if (this.fullValidation) return this.fullValidation.promise;
|
|
25123
|
+
for (const adapter of this.fields.values()) if (Object.hasOwn(adapter.node, "formDraft")) adapter.commit();
|
|
25124
|
+
this.clearValidationDependencies();
|
|
25125
|
+
const pass = { revision: this.validationRevision, promise: null, active: /* @__PURE__ */ new Set(), failed: false, complete: true };
|
|
25126
|
+
this.fullValidation = pass;
|
|
25127
|
+
this.notify();
|
|
25128
|
+
const fields = this.validationFields();
|
|
25129
|
+
const current = () => !this.disposed && !pass.failed && pass.revision === this.validationRevision;
|
|
25130
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
25131
|
+
const worker = async () => {
|
|
25132
|
+
let count = 0;
|
|
25133
|
+
while (current()) {
|
|
25134
|
+
const next = fields.next();
|
|
25135
|
+
if (next.done) return;
|
|
25136
|
+
const { node, release } = next.value;
|
|
25137
|
+
try {
|
|
25138
|
+
if (seen.has(node)) continue;
|
|
25139
|
+
seen.add(node);
|
|
25140
|
+
for (const [name, pointer] of node.pointers()) if (name !== "value") {
|
|
25141
|
+
this.trackValidationDependency((name === "datapath" ? node.parentNode : node).absDatapath(pointer));
|
|
25142
|
+
}
|
|
25143
|
+
pass.active.add(node);
|
|
25144
|
+
const outcome = await this.validateField(node);
|
|
25145
|
+
if (!outcome?.ok) pass.complete = false;
|
|
25146
|
+
} finally {
|
|
25147
|
+
pass.active.delete(node);
|
|
25148
|
+
release();
|
|
25149
|
+
}
|
|
25150
|
+
if (++count % 20 === 0) await new Promise((resolve) => setTimeout(resolve, 0));
|
|
25151
|
+
}
|
|
25152
|
+
};
|
|
25153
|
+
pass.promise = Promise.resolve().then(async () => {
|
|
25154
|
+
const outcomes = await Promise.allSettled(Array.from({ length: 8 }, () => worker().catch((error) => {
|
|
25155
|
+
pass.failed = true;
|
|
25156
|
+
for (const node of pass.active) this.cancelValidation(node);
|
|
25157
|
+
throw error;
|
|
25158
|
+
})));
|
|
25159
|
+
const failure2 = outcomes.find((outcome) => outcome.status === "rejected");
|
|
25160
|
+
if (failure2) throw failure2.reason;
|
|
25161
|
+
if (!current()) return false;
|
|
25162
|
+
const valid = pass.complete && this.status.valid && this.registers.getItem("pending").length === 0;
|
|
25163
|
+
if (valid) this.validatedRevision = this.validationRevision;
|
|
25164
|
+
return valid;
|
|
25165
|
+
}).finally(() => {
|
|
25166
|
+
fields.return();
|
|
25167
|
+
this.fullValidation = null;
|
|
25168
|
+
this.notify();
|
|
25169
|
+
});
|
|
25170
|
+
return pass.promise;
|
|
25171
|
+
}
|
|
25172
|
+
*validationFields() {
|
|
25173
|
+
const existing = [...this.validations.keys()];
|
|
25174
|
+
for (const fields of this.validationSources) yield* fields();
|
|
25175
|
+
for (const node of existing) if (this.validations.has(node)) yield { node, release: () => {
|
|
25176
|
+
} };
|
|
25177
|
+
}
|
|
25070
25178
|
forgetField(node) {
|
|
25071
25179
|
const field = this.validations.get(node);
|
|
25072
25180
|
if (!field) return;
|
|
@@ -25089,16 +25197,18 @@ var EditingSession = class {
|
|
|
25089
25197
|
delete node.formDraft;
|
|
25090
25198
|
this.notify();
|
|
25091
25199
|
}
|
|
25092
|
-
refreshField(node) {
|
|
25200
|
+
refreshField(node, schedule = true) {
|
|
25093
25201
|
const field = this.validations.get(node);
|
|
25094
25202
|
if (!field || this.disposed || this.writing) return;
|
|
25095
25203
|
const [, attrs] = node.rootBuilder.runtimeValues(node);
|
|
25096
|
-
const resolved2 = this.runtime.renderer.evaluateExpressions(node, attrs);
|
|
25204
|
+
const resolved2 = field.component.validationParameters(this.runtime.renderer.evaluateExpressions(node, attrs));
|
|
25097
25205
|
const rules = Object.fromEntries(Object.entries(resolved2).filter(([name]) => name.startsWith("validate_")));
|
|
25206
|
+
const configuration = toTytx(Object.fromEntries(Object.entries(resolved2).filter(([name]) => name !== "value")));
|
|
25098
25207
|
const path = fieldPath(node), target = this.runtime.gramlot.data.getNode(path.split("?")[0]);
|
|
25099
25208
|
const value = node.getRelativeData(node.getAttr("value"));
|
|
25100
25209
|
const dataChanged = field.path !== path || field.target !== target || !same(field.value, value);
|
|
25101
|
-
if (!dataChanged &&
|
|
25210
|
+
if (!dataChanged && field.configuration === configuration) return;
|
|
25211
|
+
if (field.rules !== null) this.invalidateValidation();
|
|
25102
25212
|
this.cancelValidation(node);
|
|
25103
25213
|
if (field.path !== path) {
|
|
25104
25214
|
for (const name of ["errors", "pending", "drafts"]) {
|
|
@@ -25106,9 +25216,17 @@ var EditingSession = class {
|
|
|
25106
25216
|
if (bag.getNode(encoded(field.path))) bag.popNode(encoded(field.path));
|
|
25107
25217
|
}
|
|
25108
25218
|
}
|
|
25109
|
-
Object.assign(field, {
|
|
25219
|
+
Object.assign(field, {
|
|
25220
|
+
path,
|
|
25221
|
+
target,
|
|
25222
|
+
value,
|
|
25223
|
+
rules,
|
|
25224
|
+
configuration,
|
|
25225
|
+
result: null,
|
|
25226
|
+
selection: field.component.validationSelection(resolved2, field.context)
|
|
25227
|
+
});
|
|
25110
25228
|
if (dataChanged) this.clearDraft(node);
|
|
25111
|
-
this.scheduleField(node);
|
|
25229
|
+
if (schedule) this.scheduleField(node);
|
|
25112
25230
|
}
|
|
25113
25231
|
cancelValidation(node) {
|
|
25114
25232
|
this.validations.get(node)?.run.cancel();
|
|
@@ -25131,6 +25249,7 @@ var EditingSession = class {
|
|
|
25131
25249
|
for (const other of this.validations.keys()) if (other !== node) this.refreshField(other);
|
|
25132
25250
|
}
|
|
25133
25251
|
validateCandidate(node, value, selection) {
|
|
25252
|
+
this.invalidateValidation();
|
|
25134
25253
|
this.cancelValidation(node);
|
|
25135
25254
|
this.writeCandidate(node, value);
|
|
25136
25255
|
const field = this.validations.get(node);
|
|
@@ -25197,6 +25316,7 @@ var EditingSession = class {
|
|
|
25197
25316
|
this.notify();
|
|
25198
25317
|
}
|
|
25199
25318
|
draft(node, text3) {
|
|
25319
|
+
this.invalidateValidation();
|
|
25200
25320
|
this.cancelValidation(node);
|
|
25201
25321
|
node.formDraft = text3;
|
|
25202
25322
|
this.set("drafts", node, text3);
|
|
@@ -25244,6 +25364,7 @@ var EditingSession = class {
|
|
|
25244
25364
|
if (this.disposed) return;
|
|
25245
25365
|
this.updateChanges(change.path);
|
|
25246
25366
|
if (this.writing) return;
|
|
25367
|
+
this.invalidateValidation();
|
|
25247
25368
|
for (const node of this.validations.keys()) this.refreshField(node);
|
|
25248
25369
|
}
|
|
25249
25370
|
updateChanges(changedPath = null) {
|
|
@@ -25311,6 +25432,7 @@ var EditingSession = class {
|
|
|
25311
25432
|
if (Object.hasOwn(adapter.node, "formDraft")) adapter.commit();
|
|
25312
25433
|
}
|
|
25313
25434
|
if (!this.status.valid || this.status.pending) return false;
|
|
25435
|
+
if (this.validationSources.size && this.validatedRevision !== this.validationRevision) return false;
|
|
25314
25436
|
this.registers.setItem("baseline", copy(this.data));
|
|
25315
25437
|
this.updateChanges();
|
|
25316
25438
|
return true;
|
|
@@ -25323,6 +25445,7 @@ var EditingSession = class {
|
|
|
25323
25445
|
}
|
|
25324
25446
|
restore() {
|
|
25325
25447
|
if (this.disposed) return;
|
|
25448
|
+
this.invalidateValidation();
|
|
25326
25449
|
for (const node of this.validations.keys()) this.cancelValidation(node);
|
|
25327
25450
|
for (const adapter of this.fields.values()) {
|
|
25328
25451
|
adapter.element.cancelValidation();
|
|
@@ -25346,6 +25469,8 @@ var EditingSession = class {
|
|
|
25346
25469
|
this.retainedFields.clear();
|
|
25347
25470
|
this.listeners.clear();
|
|
25348
25471
|
this.navigators.clear();
|
|
25472
|
+
this.validationSources.clear();
|
|
25473
|
+
this.clearValidationDependencies();
|
|
25349
25474
|
}
|
|
25350
25475
|
};
|
|
25351
25476
|
|
|
@@ -29447,7 +29572,7 @@ var DataRouter = class {
|
|
|
29447
29572
|
|
|
29448
29573
|
// src/components/grid-structure.js
|
|
29449
29574
|
var TYPES = /* @__PURE__ */ new Set(["T", "B", "L", "R", "N", "D", "H", "DHZ"]);
|
|
29450
|
-
var COLUMN_KEYS = /* @__PURE__ */ new Set(["tag", "field", "name", "dtype", "width", "align", "format", "columnset", "white_space", "edit"]);
|
|
29575
|
+
var COLUMN_KEYS = /* @__PURE__ */ new Set(["tag", "field", "name", "dtype", "width", "align", "format", "columnset", "white_space", "max_height", "edit"]);
|
|
29451
29576
|
var GROUP_KEYS = /* @__PURE__ */ new Set(["tag", "code", "name", "background", "color"]);
|
|
29452
29577
|
var GridStructure = class {
|
|
29453
29578
|
#nodes = /* @__PURE__ */ new Map();
|
|
@@ -29484,6 +29609,9 @@ var GridStructure = class {
|
|
|
29484
29609
|
if (attrs.width != null && (typeof attrs.width !== "string" || !/^(?:\d+(?:\.\d+)?)(?:px|em|rem|ch|%)$/.test(attrs.width))) {
|
|
29485
29610
|
throw new TypeError("grid width requires a nonnegative CSS length (px, em, rem, ch or %)");
|
|
29486
29611
|
}
|
|
29612
|
+
if (attrs.max_height != null && (typeof attrs.max_height !== "string" || !/^(?:\d+(?:\.\d+)?)(?:px|em|rem)$/.test(attrs.max_height))) {
|
|
29613
|
+
throw new TypeError("grid max_height requires a nonnegative CSS length (px, em or rem)");
|
|
29614
|
+
}
|
|
29487
29615
|
if (attrs.white_space != null && !["normal", "nowrap", "pre-wrap"].includes(attrs.white_space)) throw new TypeError("grid white_space requires normal, nowrap or pre-wrap");
|
|
29488
29616
|
for (const key2 of ["name", "format"]) if (attrs[key2] != null && typeof attrs[key2] !== "string") throw new TypeError(`grid ${key2} must be text`);
|
|
29489
29617
|
if (attrs.edit != null && typeof attrs.edit !== "boolean" && (typeof attrs.edit !== "object" || Array.isArray(attrs.edit))) throw new TypeError("grid edit requires a boolean or editor options");
|
|
@@ -29549,7 +29677,7 @@ function structureData(source) {
|
|
|
29549
29677
|
node.builder.validateNode(node);
|
|
29550
29678
|
if (node.nodeTag !== "column" || node.staticValue != null) throw new TypeError("grid column must be a scalar declaration");
|
|
29551
29679
|
const attrs = { tag: "cell" };
|
|
29552
|
-
for (const key2 of ["field", "name", "dtype", "width", "align", "format", "white_space", "edit"]) {
|
|
29680
|
+
for (const key2 of ["field", "name", "dtype", "width", "align", "format", "white_space", "max_height", "edit"]) {
|
|
29553
29681
|
if (node.getAttr(key2) != null) attrs[key2] = node.getAttr(key2);
|
|
29554
29682
|
}
|
|
29555
29683
|
const label = `cell_${attrs.field}`;
|
|
@@ -32263,6 +32391,16 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
|
|
|
32263
32391
|
}
|
|
32264
32392
|
throw errors.length === 1 ? error : new AggregateError(errors, "Source build and cleanup failed");
|
|
32265
32393
|
}
|
|
32394
|
+
/** Mount the same Source and bindings in a new document's element realm. */
|
|
32395
|
+
mountDestination(node, destination) {
|
|
32396
|
+
const record2 = this.records.get(node);
|
|
32397
|
+
if (!record2?.presentation || destination?.nodeType !== 1)
|
|
32398
|
+
throw new TypeError("mountDestination requires a mounted element and an HTML destination");
|
|
32399
|
+
if (record2.presentation.contains(destination)) throw new Error("Destination cannot be inside the moved presentation");
|
|
32400
|
+
const parent = record2.parent;
|
|
32401
|
+
this.remove(node);
|
|
32402
|
+
return this.buildNode(node, destination, null, parent);
|
|
32403
|
+
}
|
|
32266
32404
|
assignContainer(record2, container) {
|
|
32267
32405
|
record2.container = container;
|
|
32268
32406
|
const childContainer = record2.element ?? container;
|
|
@@ -34297,6 +34435,7 @@ var UtilitiesHandler = class extends Handler {
|
|
|
34297
34435
|
// src/gramlot.js
|
|
34298
34436
|
var Gramlot = class {
|
|
34299
34437
|
#mobileEnvironment;
|
|
34438
|
+
#collections;
|
|
34300
34439
|
constructor({
|
|
34301
34440
|
pageId,
|
|
34302
34441
|
uploadUrl = null,
|
|
@@ -34315,10 +34454,8 @@ var Gramlot = class {
|
|
|
34315
34454
|
nameSyntax = null,
|
|
34316
34455
|
websocketUrl = null
|
|
34317
34456
|
} = {}) {
|
|
34318
|
-
buttons_default.
|
|
34319
|
-
|
|
34320
|
-
if (collection instanceof ComponentCollection) collection.register(document.defaultView);
|
|
34321
|
-
}
|
|
34457
|
+
this.#collections = [buttons_default, ...collections.filter((collection) => collection instanceof ComponentCollection)];
|
|
34458
|
+
this.registerDocument(document);
|
|
34322
34459
|
this.commands = new CommandRegistry();
|
|
34323
34460
|
this.pageId = pageId;
|
|
34324
34461
|
this.uploadUrl = uploadUrl;
|
|
@@ -34357,6 +34494,10 @@ var Gramlot = class {
|
|
|
34357
34494
|
publish(topic, payload = {}) {
|
|
34358
34495
|
return this._subscriptions.publish(topic, payload);
|
|
34359
34496
|
}
|
|
34497
|
+
/** Register this page's activated collections in an additional rendering realm. */
|
|
34498
|
+
registerDocument(document) {
|
|
34499
|
+
for (const collection of this.#collections) collection.register(document.defaultView);
|
|
34500
|
+
}
|
|
34360
34501
|
subscribe(topic, callback) {
|
|
34361
34502
|
return this._subscriptions.subscribe(topic, callback);
|
|
34362
34503
|
}
|
|
@@ -35861,6 +36002,34 @@ var UploadTarget = class {
|
|
|
35861
36002
|
}
|
|
35862
36003
|
};
|
|
35863
36004
|
|
|
36005
|
+
// src/visual-editor-catalogue.js
|
|
36006
|
+
var htmlTags = new Set(Object.entries(new HtmlBuilder().schema).filter(([, info]) => !info._meta?.data_element && !info._meta?.subbuilder && !info._meta?.container).map(([tag2]) => tag2));
|
|
36007
|
+
function validateCatalogue(catalogue) {
|
|
36008
|
+
if (catalogue == null || catalogue === "html") return;
|
|
36009
|
+
if (!Array.isArray(catalogue) || catalogue.some((tag2) => typeof tag2 !== "string" || !tag2 || tag2.trim() !== tag2))
|
|
36010
|
+
throw new TypeError('catalogue must be "html" or a list of tag names');
|
|
36011
|
+
if (!catalogue.includes("div")) throw new Error("catalogue must include div for pageRoot");
|
|
36012
|
+
}
|
|
36013
|
+
function catalogueAllows(catalogue, tag2, meta = {}) {
|
|
36014
|
+
if (catalogue == null) return true;
|
|
36015
|
+
if (Array.isArray(catalogue)) return catalogue.includes(tag2);
|
|
36016
|
+
return !meta.gramlot_component && !meta.data_element && !meta.subbuilder && !meta.container && htmlTags.has(meta.render_tag ?? tag2);
|
|
36017
|
+
}
|
|
36018
|
+
function validateCatalogueSource(catalogue, source) {
|
|
36019
|
+
if (catalogue == null) return;
|
|
36020
|
+
const visit = (bag, prefix) => {
|
|
36021
|
+
for (const node of bag.getNodes()) {
|
|
36022
|
+
const path = prefix ? `${prefix}.${node.label}` : node.label;
|
|
36023
|
+
if (!catalogueAllows(catalogue, node.nodeTag, node.getAttr("_meta") ?? {}))
|
|
36024
|
+
throw new Error(`Tag ${node.nodeTag} is outside the editor catalogue at ${path}`);
|
|
36025
|
+
if (node.resolver) throw new Error(`Catalogue scope requires materialized Source at ${path}`);
|
|
36026
|
+
const value = node.getValue(true);
|
|
36027
|
+
if (value instanceof SourceBag) visit(value, path);
|
|
36028
|
+
}
|
|
36029
|
+
};
|
|
36030
|
+
visit(source, "");
|
|
36031
|
+
}
|
|
36032
|
+
|
|
35864
36033
|
// src/visual-editor-icons.js
|
|
35865
36034
|
var toolIcons = { "navigation": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M9%204v16M5.5%208h1M5.5%2012h1%22%2F%3E%3C%2Fsvg%3E", "catalogue": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2214%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M14%2017.5h7M17.5%2014v7%22%2F%3E%3C%2Fsvg%3E", "properties": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h16M4%2012h16M4%2018h16%22%2F%3E%3Ccircle%20cx%3D%228%22%20cy%3D%226%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2212%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2218%22%20r%3D%222%22%2F%3E%3C%2Fsvg%3E", "new": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M14%202H6a2%202%200%200%200-2%202v16a2%202%200%200%200%202%202h12a2%202%200%200%200%202-2V8Z%20M14%202v6h6%20M8%2015h8%20M12%2011v8%22%2F%3E%3C%2Fsvg%3E", "download": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203v12m-5-5%205%205%205-5%20M4%2016v4a1%201%200%200%200%201%201h14a1%201%200%200%200%201-1v-4%22%2F%3E%3C%2Fsvg%3E", "copy": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%228%22%20y%3D%228%22%20width%3D%2212%22%20height%3D%2213%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M16%208V5a2%202%200%200%200-2-2H5a2%202%200%200%200-2%202v9a2%202%200%200%200%202%202h3%22%2F%3E%3C%2Fsvg%3E" };
|
|
35866
36035
|
toolIcons.open = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%207V5a2%202%200%200%201%202-2h5l2%202h7a2%202%200%200%201%202%202v2M3%209h18l-2%2011H4z%22%2F%3E%3C%2Fsvg%3E";
|
|
@@ -35870,15 +36039,21 @@ toolIcons.appearance = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.
|
|
|
35870
36039
|
|
|
35871
36040
|
// src/server/visual-editor.js
|
|
35872
36041
|
var VisualEditor = class {
|
|
35873
|
-
constructor(root, { datapath = "__editor", dataRoot = "", editorId = "visual", uploadOperation = "import_source", codeDocument = null, ...attributes } = {}) {
|
|
36042
|
+
constructor(root, { datapath = "__editor", dataRoot = "", editorId = "visual", uploadOperation = "import_source", codeDocument = null, catalogue = null, fileCommands = true, canvasCss = null, ...attributes } = {}) {
|
|
35874
36043
|
if (!/^[A-Za-z][A-Za-z0-9_]*$/.test(editorId)) throw new Error("editorId must be a literal identifier");
|
|
35875
36044
|
if (!dataRoot && datapath !== "__editor" && !datapath.startsWith("__editor.")) throw new Error("Root Data editing requires an __editor datapath");
|
|
36045
|
+
validateCatalogue(catalogue);
|
|
36046
|
+
if (canvasCss != null && (!Array.isArray(canvasCss) || canvasCss.some((text3) => typeof text3 !== "string")))
|
|
36047
|
+
throw new TypeError("canvasCss must be a list of CSS texts");
|
|
35876
36048
|
this.dataRoot = dataRoot;
|
|
35877
36049
|
const pane = this.pane = root.main({ node_label: editorId, datapath, visualEditorId: editorId, ...attributes, nodeId: `${editorId}Editor`, class: `visual-editor-shell ${attributes.class ?? ""}`, overflow: "hidden", tabindex: 0, connect_onkeydown: "clipboardShortcut" });
|
|
36050
|
+
pane.dataSetter({ destination_path: ".catalogueScope", value: catalogue });
|
|
36051
|
+
pane.dataSetter({ destination_path: ".canvasCss", value: canvasCss });
|
|
35878
36052
|
pane.dataSetter({ destination_path: ".uploadQueue", value: new Bag() });
|
|
35879
36053
|
pane.dataController({ func: "initializeEditor", dataRoot: this.dataRoot, _init: true });
|
|
35880
36054
|
pane.dataController({ func: "showProperties", path: "^.selection", _init: true });
|
|
35881
36055
|
pane.dataController({ func: "initializeCanvasSelection", _onBuilt: true });
|
|
36056
|
+
pane.dataController({ func: "initializeDocument", _onBuilt: true });
|
|
35882
36057
|
pane.dataController({ func: "highlightSelection", path: "^.selection", _init: true });
|
|
35883
36058
|
pane.style("^.appearanceCss");
|
|
35884
36059
|
pane.dataController({ func: "initializeEditorAppearance", _onBuilt: true });
|
|
@@ -35887,14 +36062,28 @@ var VisualEditor = class {
|
|
|
35887
36062
|
this.toolButton(rail.menuline({ group: true, overflowable: false }), "Source / Data", "toggleNavigation", toolIcons.navigation);
|
|
35888
36063
|
this.toolButton(rail.menuline({ group: true, overflowable: false }), "Catalogue", "openCatalogue", toolIcons.catalogue);
|
|
35889
36064
|
this.toolButton(rail.menuline({ group: true, overflowable: false }), "Properties", "openProperties", toolIcons.properties);
|
|
35890
|
-
this.toolButton(
|
|
36065
|
+
this.toolButton(
|
|
36066
|
+
rail.menuline({ group: true, overflowable: false }),
|
|
36067
|
+
"Clipboard",
|
|
36068
|
+
"this.SET('.clipboardVisible', !this.GET('.clipboardVisible'))",
|
|
36069
|
+
toolIcons.paste,
|
|
36070
|
+
{
|
|
36071
|
+
dropTarget: true,
|
|
36072
|
+
dropTypes: "app/source",
|
|
36073
|
+
dropTags: `${editorId}Source`,
|
|
36074
|
+
dropEffect: "^.clipboardDropEffect",
|
|
36075
|
+
connect_ondragover: "clipboardModifiers",
|
|
36076
|
+
connect_ondrop: "clipboardModifiers",
|
|
36077
|
+
onDrop: "dropClipboard"
|
|
36078
|
+
}
|
|
36079
|
+
);
|
|
35891
36080
|
rail.spacer({ flex: 1 });
|
|
35892
36081
|
this.toolButton(rail.menuline({ group: true, overflowable: false }), "Appearance", "this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))", toolIcons.appearance);
|
|
35893
36082
|
const layoutRoot = pane.framePane({ node_label: "layout", height: "100%", id: `${editorId}-editor-frame`, class: "visual-editor-layout" });
|
|
35894
|
-
layoutRoot.top.setAttr({ height: "
|
|
36083
|
+
layoutRoot.top.setAttr({ height: "30px" });
|
|
35895
36084
|
const toolbar = layoutRoot.top.menu({ presentation: "bar", aria_label: "Editor tools", class: "visual-editor-toolbar" });
|
|
35896
36085
|
toolbar.menuline({ group: true, overflowable: false }).span("Source editor", { class: "visual-editor-brand" });
|
|
35897
|
-
const files = toolbar.menuline({ group: true, overflowable: false, gap: "4px" });
|
|
36086
|
+
const files = toolbar.menuline({ group: true, overflowable: false, gap: "4px", hidden: !fileCommands });
|
|
35898
36087
|
for (const [caption, action, icon] of [["New", "newPage", "new"], ["Open", "openUpload", "open"], ["Download", "downloadPage", "download"], ["Copy Source", "copySource", "copy"]])
|
|
35899
36088
|
this.toolButton(files, caption, action, toolIcons[icon], { id: `${editorId}-${icon}` });
|
|
35900
36089
|
toolbar.menuline({ group: true, overflowable: false }).span({ class: "visual-toolbar-divider", aria_hidden: "true" });
|
|
@@ -35903,11 +36092,12 @@ var VisualEditor = class {
|
|
|
35903
36092
|
this.toolButton(edit, "Copy branch", "copyBranch", toolIcons.copy);
|
|
35904
36093
|
this.toolButton(edit, "Paste branch", "pasteBranch", toolIcons.paste, { title: "Paste branch (F9)" });
|
|
35905
36094
|
toolbar.spacer({ flex: 1 });
|
|
36095
|
+
toolbar.menuline({ group: true, overflowable: false, hidden: "^.modified:=!{}" }).span("Unsaved changes", { role: "status", class: "visual-editor-hint" });
|
|
35906
36096
|
toolbar.menuline({ group: true, overflowable: false }).span("^.fileStatus", { role: "status", class: "visual-editor-file-status" });
|
|
35907
36097
|
toolbar.menuline({ group: true, overflowable: false }).span("^.filename", { class: "visual-editor-filename" });
|
|
35908
36098
|
const left = layoutRoot.left;
|
|
35909
36099
|
left.setAttr({
|
|
35910
|
-
width: "min(
|
|
36100
|
+
width: "min(240px, 34vw)",
|
|
35911
36101
|
splitter: true,
|
|
35912
36102
|
drawer: "^.navigationOpen",
|
|
35913
36103
|
default_drawer: true,
|
|
@@ -35997,7 +36187,7 @@ var VisualEditor = class {
|
|
|
35997
36187
|
center.setAttr({ overflow: "auto", class: "visual-editor-workspace" });
|
|
35998
36188
|
const design = center.div({ node_label: "design", class: "visual-editor-canvas" });
|
|
35999
36189
|
design.div({ node_label: "pageRoot", ...this.dataRoot ? { datapath: this.dataRoot } : {} });
|
|
36000
|
-
const window2 = pane.floatingPane({ title: "Widget catalogue", open: "^.catalogueOpen", default_open: false, width: "
|
|
36190
|
+
const window2 = pane.floatingPane({ title: "Widget catalogue", open: "^.catalogueOpen", default_open: false, width: "280px", height: "400px", class: "visual-editor-popup", movable: true, resizable: true });
|
|
36001
36191
|
this.search(window2.frame.top, "catalogueSearch", "Search widgets");
|
|
36002
36192
|
window2.frame.center.tree({
|
|
36003
36193
|
storepath: ".catalogue",
|
|
@@ -36013,7 +36203,7 @@ var VisualEditor = class {
|
|
|
36013
36203
|
const properties = sidebar.contentPane({
|
|
36014
36204
|
region: "bottom",
|
|
36015
36205
|
height: "^.propertiesHeight",
|
|
36016
|
-
default_height: "
|
|
36206
|
+
default_height: "200px",
|
|
36017
36207
|
minSize: 140,
|
|
36018
36208
|
splitter: true,
|
|
36019
36209
|
title: "^.propertiesTitle",
|
|
@@ -36025,8 +36215,8 @@ var VisualEditor = class {
|
|
|
36025
36215
|
min_height: 0
|
|
36026
36216
|
});
|
|
36027
36217
|
properties.div({ nodeId: `${editorId}EditorFields`, class: "visual-editor-fields", display: "flex", flex_direction: "column", flex: 1, min_height: 0 }).span("");
|
|
36028
|
-
properties.p("^.propertyError", { role: "alert", class: "visual-editor-hint", margin: "
|
|
36029
|
-
const uploader = pane.dialog({ title: "Open Source", open: "^.uploadOpen", width: "480px", height: "300px", movable: true, resizable: true });
|
|
36218
|
+
properties.p("^.propertyError", { role: "alert", class: "visual-editor-hint", margin: "3px" });
|
|
36219
|
+
const uploader = pane.dialog({ class: "visual-editor-popup", title: "Open Source", open: "^.uploadOpen", width: "480px", height: "300px", movable: true, resizable: true });
|
|
36030
36220
|
uploader.frame.center.uploader({
|
|
36031
36221
|
operation: uploadOperation,
|
|
36032
36222
|
storepath: ".uploadQueue",
|
|
@@ -36036,24 +36226,24 @@ var VisualEditor = class {
|
|
|
36036
36226
|
onComplete: "sourceUploaded",
|
|
36037
36227
|
id: `${editorId}-uploader`
|
|
36038
36228
|
});
|
|
36039
|
-
const naming = pane.dialog({ title: "Save branch to clipboard", open: "^.clipboardOpen", width: "380px", height: "210px" });
|
|
36229
|
+
const naming = pane.dialog({ class: "visual-editor-popup", title: "Save branch to clipboard", open: "^.clipboardOpen", width: "380px", height: "210px" });
|
|
36040
36230
|
naming.frame.center.textbox({ value: "^.clipboardDraft.name", lbl: "Name", margin: "12px" });
|
|
36041
36231
|
naming.frame.center.p("^.error", { role: "alert", margin: "12px" });
|
|
36042
|
-
const namingBar = naming.frame.bottom.menu({ presentation: "bar", aria_label: "Clipboard commands", padding: "
|
|
36232
|
+
const namingBar = naming.frame.bottom.menu({ presentation: "bar", aria_label: "Clipboard commands", padding: "3px 6px" });
|
|
36043
36233
|
namingBar.spacer({ flex: 1 });
|
|
36044
36234
|
const namingButtons = namingBar.menuline({ group: true, overflowable: false, gap: "8px" });
|
|
36045
36235
|
namingButtons.button("Cancel", { action: "this.SET('.clipboardOpen', false)" });
|
|
36046
36236
|
namingButtons.button("Save branch", { action: "saveClipboard" });
|
|
36047
|
-
const dialog = pane.dialog({ title: "Required parameters", open: "^.insertionOpen", width: "400px", height: "280px", movable: true, resizable: true });
|
|
36048
|
-
dialog.frame.center.div({ nodeId: `${editorId}InsertFields`, class: "visual-editor-fields", padding: "
|
|
36237
|
+
const dialog = pane.dialog({ class: "visual-editor-popup", title: "Required parameters", open: "^.insertionOpen", width: "400px", height: "280px", movable: true, resizable: true });
|
|
36238
|
+
dialog.frame.center.div({ nodeId: `${editorId}InsertFields`, class: "visual-editor-fields", padding: "6px" }).span("");
|
|
36049
36239
|
dialog.frame.center.p("^.error", { role: "alert" });
|
|
36050
|
-
const bar = dialog.frame.bottom.menu({ presentation: "bar", aria_label: "Insertion commands", padding: "
|
|
36240
|
+
const bar = dialog.frame.bottom.menu({ presentation: "bar", aria_label: "Insertion commands", padding: "3px 6px", border_top: "1px solid var(--gramlot-border)" });
|
|
36051
36241
|
bar.spacer({ flex: 1 });
|
|
36052
36242
|
const buttons = bar.menuline({ group: true, overflowable: false, gap: "8px" });
|
|
36053
36243
|
buttons.button("Cancel", { action: "this.SET('.insertionOpen', false)" });
|
|
36054
36244
|
buttons.button("Insert", { action: "insertWidget" });
|
|
36055
|
-
const settings = pane.floatingPane({ title: "Appearance", open: "^.appearanceOpen", default_open: false, width: "280px", height: "260px", movable: true, resizable: true });
|
|
36056
|
-
const form = settings.frame.center.formlet({ columns: 1, lbl_position: "TL", gap: "
|
|
36245
|
+
const settings = pane.floatingPane({ class: "visual-editor-popup", title: "Appearance", open: "^.appearanceOpen", default_open: false, width: "280px", height: "260px", movable: true, resizable: true });
|
|
36246
|
+
const form = settings.frame.center.formlet({ columns: 1, lbl_position: "TL", gap: "4px", padding: "6px" });
|
|
36057
36247
|
form.filteringSelect({ validate_notnull: true, lbl: "Theme", value: "^.appearanceProfile", values: "base:Base,compact:Compact,mimi:Mimi,joanna:Joanna,mela:Mela" });
|
|
36058
36248
|
form.filteringSelect({ validate_notnull: true, lbl: "Colors", value: "^.appearancePalette", values: "default:Theme default,compact:Blue & slate,mimi:Sage & green,joanna:Warm gray & blue" });
|
|
36059
36249
|
form.filteringSelect({ validate_notnull: true, lbl: "Mode", value: "^.appearanceMode", values: "light:Light,dark:Dark" });
|
|
@@ -36078,6 +36268,7 @@ var VisualEditor = class {
|
|
|
36078
36268
|
opener.menuline({ group: true, overflowable: false }).button("Code", { action: "openCode", class: "button--quiet" });
|
|
36079
36269
|
const drawer = frame.right;
|
|
36080
36270
|
drawer.setAttr({
|
|
36271
|
+
class: "visual-editor-code",
|
|
36081
36272
|
datapath: anchor,
|
|
36082
36273
|
title: "Page code",
|
|
36083
36274
|
detachable: true,
|
|
@@ -36093,13 +36284,13 @@ var VisualEditor = class {
|
|
|
36093
36284
|
overflow: "hidden"
|
|
36094
36285
|
});
|
|
36095
36286
|
const code = drawer.framePane({ height: "100%", width: "100%", min_width: 0, flex: 1 });
|
|
36096
|
-
code.top.setAttr({ height: "
|
|
36097
|
-
code.bottom.setAttr({ height: "
|
|
36287
|
+
code.top.setAttr({ height: "26px" });
|
|
36288
|
+
code.bottom.setAttr({ height: "48px" });
|
|
36098
36289
|
code.center.setAttr({ display: "flex", flex_direction: "column", min_height: 0, overflow: "hidden" });
|
|
36099
|
-
code.top.div(document.path, { padding: "
|
|
36290
|
+
code.top.div(document.path, { padding: "3px 6px", font_size: "12px", overflow: "hidden", text_overflow: "ellipsis", white_space: "nowrap" });
|
|
36100
36291
|
code.center.codeMirror({ value: "^.codeDocument.content", language: document.language, live: true, readonly: "^.codeDocument.writable:=!{}", height: "100%", box_height: "100%", box_c_height: "100%", box_min_height: 0, box_c_min_height: 0, fontSize: 13, flex: 1, min_height: 0 });
|
|
36101
36292
|
code.bottom.div("^.codeDocument.status", { role: "status", font_size: "12px", padding: "4px 10px" });
|
|
36102
|
-
const bar = code.bottom.menu({ presentation: "bar", aria_label: "Page code commands", padding: "6px
|
|
36293
|
+
const bar = code.bottom.menu({ presentation: "bar", aria_label: "Page code commands", padding: "3px 6px" });
|
|
36103
36294
|
bar.spacer({ flex: 1 });
|
|
36104
36295
|
const commands = bar.menuline({ group: true, overflowable: false, gap: "6px" });
|
|
36105
36296
|
commands.button("Close", { action: "this.SET('.codeOpen', 'close')" });
|
|
@@ -36132,8 +36323,10 @@ var VisualEditor = class {
|
|
|
36132
36323
|
|
|
36133
36324
|
// src/server/source-import.js
|
|
36134
36325
|
var SourceImport = class extends UploadTarget {
|
|
36135
|
-
constructor() {
|
|
36326
|
+
constructor({ catalogue = null } = {}) {
|
|
36136
36327
|
super({ maxBytes: 5 * 1024 * 1024 });
|
|
36328
|
+
validateCatalogue(catalogue);
|
|
36329
|
+
this.catalogue = catalogue;
|
|
36137
36330
|
this.decoder = new TextDecoder("utf-8", { fatal: true });
|
|
36138
36331
|
this.parts = [];
|
|
36139
36332
|
this.outcome = { state: "pending" };
|
|
@@ -36149,6 +36342,7 @@ var SourceImport = class extends UploadTarget {
|
|
|
36149
36342
|
if (!(source instanceof SourceBag) || source.length !== 1 || source.getNodes()[0].label !== "pageRoot") {
|
|
36150
36343
|
throw new TypeError("Expected one pageRoot Source");
|
|
36151
36344
|
}
|
|
36345
|
+
validateCatalogueSource(this.catalogue, source);
|
|
36152
36346
|
this.outcome = { state: "completed", result: wire };
|
|
36153
36347
|
return this.outcome;
|
|
36154
36348
|
}
|
|
@@ -38401,7 +38595,7 @@ function fail3(errorcode, message, extra = {}) {
|
|
|
38401
38595
|
return { errorcode, message, ...extra };
|
|
38402
38596
|
}
|
|
38403
38597
|
function localRule(rule, param, value, context) {
|
|
38404
|
-
if (rule === "select") return context.selection(value);
|
|
38598
|
+
if (rule === "select") return context.selection(value, context.signal);
|
|
38405
38599
|
if (rule === "notnull") return empty(value) && param ? fail3("notnull", "A value is required.", { required: true }) : null;
|
|
38406
38600
|
if (rule === "empty") return empty(value) ? { value: param } : null;
|
|
38407
38601
|
if (rule === "len") {
|
|
@@ -38490,9 +38684,17 @@ function FieldState(Base) {
|
|
|
38490
38684
|
get supportsFormValidation() {
|
|
38491
38685
|
return true;
|
|
38492
38686
|
}
|
|
38493
|
-
|
|
38687
|
+
static validationParameters(attrs) {
|
|
38688
|
+
const parameters2 = { ...parameterValues(this.gramlotComponent, attrs), ...attrs };
|
|
38689
|
+
if (this.constrained && parameters2.validate_select == null) parameters2.validate_select = true;
|
|
38690
|
+
return parameters2;
|
|
38691
|
+
}
|
|
38692
|
+
static get validationExecutor() {
|
|
38494
38693
|
return validateInput;
|
|
38495
38694
|
}
|
|
38695
|
+
get validationExecutor() {
|
|
38696
|
+
return this.constructor.validationExecutor;
|
|
38697
|
+
}
|
|
38496
38698
|
connectedCallback() {
|
|
38497
38699
|
super.connectedCallback();
|
|
38498
38700
|
if (this.pageContext?.form) this.pageContext.formValidate();
|
|
@@ -39137,6 +39339,85 @@ function chatRenderAttachments(page, node, { attachments }) {
|
|
|
39137
39339
|
for (const child of prepared.getNodes()) page.src.builder.setChild(target.value, child.nodeTag, child.value, { ...child.attr, node_label: child.label });
|
|
39138
39340
|
}
|
|
39139
39341
|
|
|
39342
|
+
// src/visual-editor-canvas.js
|
|
39343
|
+
var VisualEditorCanvas = class {
|
|
39344
|
+
constructor({ app, editor, design }) {
|
|
39345
|
+
this.renderer = app.src.renderer;
|
|
39346
|
+
this.design = design;
|
|
39347
|
+
const presentation = this.renderer.records.get(design).presentation;
|
|
39348
|
+
this.frame = presentation.ownerDocument.createElement("iframe");
|
|
39349
|
+
this.frame.title = "Page canvas";
|
|
39350
|
+
this.frame.className = "visual-editor-canvas-frame";
|
|
39351
|
+
this.frame.style.cssText = "display:block;width:100%;height:100%;min-height:240px;border:0;background:white";
|
|
39352
|
+
presentation.before(this.frame);
|
|
39353
|
+
const document = this.frame.contentDocument;
|
|
39354
|
+
app.registerDocument(document);
|
|
39355
|
+
const base = document.createElement("style");
|
|
39356
|
+
base.textContent = "html,body{margin:0;min-height:100%;} .visual-editor-canvas{min-height:100vh;}";
|
|
39357
|
+
this.styles = document.createElement("style");
|
|
39358
|
+
const selection = document.createElement("style");
|
|
39359
|
+
selection.textContent = ".gramlot-source-selected{outline:2px solid #8ab4f8!important;outline-offset:-2px!important;}";
|
|
39360
|
+
document.head.append(base, this.styles, selection);
|
|
39361
|
+
this.body = document.body;
|
|
39362
|
+
this.renderer.mountDestination(design, this.body);
|
|
39363
|
+
this.release = this.renderer.onDispose(editor, () => this.dispose());
|
|
39364
|
+
}
|
|
39365
|
+
setCss(texts) {
|
|
39366
|
+
this.styles.textContent = texts.join("\n");
|
|
39367
|
+
}
|
|
39368
|
+
dispose() {
|
|
39369
|
+
this.release?.();
|
|
39370
|
+
this.release = null;
|
|
39371
|
+
this.frame.remove();
|
|
39372
|
+
}
|
|
39373
|
+
};
|
|
39374
|
+
|
|
39375
|
+
// src/editor-values.js
|
|
39376
|
+
var editorTypes = ["string", "number", "integer", "boolean", "date", "time", "datetime", "null"];
|
|
39377
|
+
function scalarType(value) {
|
|
39378
|
+
if (value === null) return "null";
|
|
39379
|
+
if (["string", "boolean"].includes(typeof value)) return typeof value;
|
|
39380
|
+
if (typeof value === "number" && Number.isFinite(value)) return Number.isSafeInteger(value) ? "integer" : "number";
|
|
39381
|
+
if (value instanceof Date && Number.isFinite(value.getTime())) {
|
|
39382
|
+
const iso = value.toISOString();
|
|
39383
|
+
return iso.slice(0, 10) === "1970-01-01" ? "time" : iso.endsWith("T00:00:00.000Z") ? "date" : "datetime";
|
|
39384
|
+
}
|
|
39385
|
+
return null;
|
|
39386
|
+
}
|
|
39387
|
+
function scalarText(value, type) {
|
|
39388
|
+
if (type === "null") return "";
|
|
39389
|
+
if (value instanceof Date) {
|
|
39390
|
+
const iso = value.toISOString();
|
|
39391
|
+
return type === "date" ? iso.slice(0, 10) : type === "time" ? iso.slice(11, 23) : iso;
|
|
39392
|
+
}
|
|
39393
|
+
return String(value);
|
|
39394
|
+
}
|
|
39395
|
+
function parseScalar(type, text3) {
|
|
39396
|
+
if (type === "string") return text3;
|
|
39397
|
+
if (type === "null") return null;
|
|
39398
|
+
if (type === "boolean" && ["true", "false"].includes(text3)) return text3 === "true";
|
|
39399
|
+
if (type === "number" || type === "integer") {
|
|
39400
|
+
if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(text3.trim())) {
|
|
39401
|
+
const value = Number(text3);
|
|
39402
|
+
if (Number.isFinite(value) && (type !== "integer" || Number.isSafeInteger(value))) return value;
|
|
39403
|
+
}
|
|
39404
|
+
}
|
|
39405
|
+
if (["date", "time", "datetime"].includes(type)) {
|
|
39406
|
+
const pattern = type === "date" ? /^\d{4}-\d{2}-\d{2}$/ : type === "time" ? /^\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?$/ : /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?Z$/;
|
|
39407
|
+
if (pattern.test(text3)) {
|
|
39408
|
+
const input = type === "date" ? `${text3}T00:00:00Z` : type === "time" ? `1970-01-01T${text3}Z` : text3;
|
|
39409
|
+
const date = new Date(input);
|
|
39410
|
+
if (Number.isFinite(date.getTime())) {
|
|
39411
|
+
const iso = date.toISOString();
|
|
39412
|
+
const supplied = input.replace(/Z$/, "").split(/[T:.]/);
|
|
39413
|
+
const actual = iso.replace(/Z$/, "").split(/[T:.]/);
|
|
39414
|
+
if (supplied.every((part, index) => index === 4 ? Number(part.padEnd(3, "0")) === Number(actual[index]) : part === actual[index])) return date;
|
|
39415
|
+
}
|
|
39416
|
+
}
|
|
39417
|
+
}
|
|
39418
|
+
throw new Error(`Invalid ${type} value: ${text3 || "(empty)"}`);
|
|
39419
|
+
}
|
|
39420
|
+
|
|
39140
39421
|
// src/source-picker.js
|
|
39141
39422
|
var SourcePicker = class {
|
|
39142
39423
|
#renderer;
|
|
@@ -39148,9 +39429,8 @@ var SourcePicker = class {
|
|
|
39148
39429
|
#highlighted = null;
|
|
39149
39430
|
#release = null;
|
|
39150
39431
|
#disposed = false;
|
|
39151
|
-
constructor({ renderer, root, onSelect }) {
|
|
39432
|
+
constructor({ renderer, root, onSelect, canvas = renderer.records.get(root.parentNode)?.presentation }) {
|
|
39152
39433
|
if (!root?.parentNode || typeof onSelect !== "function") throw new TypeError("SourcePicker requires a mounted Source root and onSelect");
|
|
39153
|
-
const canvas = renderer.records.get(root.parentNode)?.presentation;
|
|
39154
39434
|
if (!canvas || canvas.nodeType !== 1) throw new TypeError("SourcePicker requires a mounted preview");
|
|
39155
39435
|
this.#renderer = renderer;
|
|
39156
39436
|
this.#root = root;
|
|
@@ -39281,6 +39561,7 @@ var specifications = (node, tag2, current = null) => {
|
|
|
39281
39561
|
};
|
|
39282
39562
|
};
|
|
39283
39563
|
var canvasSelections = /* @__PURE__ */ new WeakMap();
|
|
39564
|
+
var canvasDocuments = /* @__PURE__ */ new WeakMap();
|
|
39284
39565
|
var VisualEditorLogic = class {
|
|
39285
39566
|
chatRender(node, params) {
|
|
39286
39567
|
return chatRender(this.page, node, params);
|
|
@@ -39315,8 +39596,10 @@ var VisualEditorLogic = class {
|
|
|
39315
39596
|
return;
|
|
39316
39597
|
}
|
|
39317
39598
|
const run = (editor.GET(".assistantRun.run") ?? 0) + 1;
|
|
39599
|
+
const scope = editor.GET(".catalogueScope");
|
|
39318
39600
|
const schema = { commonParameters: styleParameters, labelboxParameters, widgets: {} };
|
|
39319
39601
|
for (const [tag2, info] of Object.entries(node.builder.schema)) {
|
|
39602
|
+
if (!catalogueAllows(scope, tag2, info._meta ?? {})) continue;
|
|
39320
39603
|
if (info._meta?.data_element || info._meta?.subbuilder || info._meta?.container) continue;
|
|
39321
39604
|
const component = info._meta?.gramlot_component;
|
|
39322
39605
|
schema.widgets[tag2] = {
|
|
@@ -39440,6 +39723,7 @@ var VisualEditorLogic = class {
|
|
|
39440
39723
|
}
|
|
39441
39724
|
};
|
|
39442
39725
|
candidate.getNodes().forEach(validateChildren);
|
|
39726
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), candidate);
|
|
39443
39727
|
app.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
39444
39728
|
const current = node.builder.source.getNode(`${sourceRoot(node)}.${path}`);
|
|
39445
39729
|
let selected = path;
|
|
@@ -39466,14 +39750,43 @@ var VisualEditorLogic = class {
|
|
|
39466
39750
|
initializeCanvasSelection(node) {
|
|
39467
39751
|
const renderer = node.rootBuilder.binding.renderer;
|
|
39468
39752
|
const design = node.builder.source.getNode(sourceRoot(node));
|
|
39469
|
-
const
|
|
39470
|
-
|
|
39471
|
-
|
|
39472
|
-
|
|
39753
|
+
const editor = visualEditorScope(node), css = editor.GET(".canvasCss");
|
|
39754
|
+
if (css != null) this.applyCanvasCss(editor, css);
|
|
39755
|
+
const previous = canvasSelections.get(design);
|
|
39756
|
+
previous?.dispose();
|
|
39757
|
+
const picker = new SourcePicker({
|
|
39758
|
+
renderer,
|
|
39759
|
+
root: design,
|
|
39760
|
+
...canvasDocuments.has(design) ? { canvas: canvasDocuments.get(design).body } : {},
|
|
39761
|
+
onSelect: (selected) => {
|
|
39762
|
+
node.SET(".sourceSearch", "");
|
|
39763
|
+
node.SET(".selection", selected.fullpath.slice(design.fullpath.length + 1));
|
|
39764
|
+
}
|
|
39765
|
+
});
|
|
39473
39766
|
canvasSelections.set(design, picker);
|
|
39474
|
-
renderer.onDispose(design.parentNode, () =>
|
|
39767
|
+
if (!previous) renderer.onDispose(design.parentNode, () => {
|
|
39768
|
+
canvasSelections.delete(design);
|
|
39769
|
+
canvasDocuments.delete(design);
|
|
39770
|
+
});
|
|
39475
39771
|
this.highlightSelection(node);
|
|
39476
39772
|
}
|
|
39773
|
+
applyCanvasCss(node, texts) {
|
|
39774
|
+
if (!Array.isArray(texts) || texts.some((text3) => typeof text3 !== "string"))
|
|
39775
|
+
throw new TypeError("canvas CSS must be a list of CSS texts");
|
|
39776
|
+
const editor = visualEditorScope(node), design = editor.builder.source.getNode(sourceRoot(editor));
|
|
39777
|
+
let canvas = canvasDocuments.get(design);
|
|
39778
|
+
if (!canvas) {
|
|
39779
|
+
canvas = new VisualEditorCanvas({ app: editor.rootBuilder.binding.gramlot, editor, design });
|
|
39780
|
+
canvasDocuments.set(design, canvas);
|
|
39781
|
+
}
|
|
39782
|
+
canvas.setCss(texts);
|
|
39783
|
+
}
|
|
39784
|
+
setCanvasCss(node, texts) {
|
|
39785
|
+
const editor = visualEditorScope(node);
|
|
39786
|
+
this.applyCanvasCss(editor, texts);
|
|
39787
|
+
editor.SET(".canvasCss", texts);
|
|
39788
|
+
this.initializeCanvasSelection(editor);
|
|
39789
|
+
}
|
|
39477
39790
|
highlightSelection(node) {
|
|
39478
39791
|
const design = node.builder.source.getNode(sourceRoot(node));
|
|
39479
39792
|
const path = node.GET(".selection");
|
|
@@ -39592,6 +39905,7 @@ var VisualEditorLogic = class {
|
|
|
39592
39905
|
const parent = path ? node.builder.source.getNode(`${sourceRoot(node)}.${path}`) : null;
|
|
39593
39906
|
if (!parent) throw new Error("Choose a destination in the Source tree");
|
|
39594
39907
|
const source = node.rootBuilder.binding.gramlot.src.prepareSource(saved.getValue(true), parent.builder);
|
|
39908
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), source);
|
|
39595
39909
|
const branch2 = source.getNodes()[0];
|
|
39596
39910
|
parent.builder.validateParent(branch2.nodeTag, parent.nodeTag);
|
|
39597
39911
|
const body = parent.getValue(true);
|
|
@@ -39612,7 +39926,7 @@ var VisualEditorLogic = class {
|
|
|
39612
39926
|
fields.getValue(true).clear();
|
|
39613
39927
|
const root = node.builder.wrapSource(fields);
|
|
39614
39928
|
root.p(`Paste ${saved.getAttr("name")} into ${parent.label} [${parent.nodeTag}]`, { class: "visual-editor-hint" });
|
|
39615
|
-
const form = root.formlet({ columns: 2, gap: "
|
|
39929
|
+
const form = root.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
39616
39930
|
for (const [name, spec] of required) this.parameterField(node, form, branch2.nodeTag, name, spec, "insertion", spec.default);
|
|
39617
39931
|
node.SET(".insertionOpen", true);
|
|
39618
39932
|
}
|
|
@@ -39646,6 +39960,7 @@ var VisualEditorLogic = class {
|
|
|
39646
39960
|
if (!parent) throw new Error("The destination no longer exists");
|
|
39647
39961
|
const app = node.rootBuilder.binding.gramlot;
|
|
39648
39962
|
const source = app.src.prepareSource(node.GET(".insertion.clipboard"), parent.builder);
|
|
39963
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), source);
|
|
39649
39964
|
const branch2 = source.getNodes()[0];
|
|
39650
39965
|
const attrs = { ...branch2.getAttr() };
|
|
39651
39966
|
for (const [name, spec] of Object.entries(specifications(parent, branch2.nodeTag))) {
|
|
@@ -39666,6 +39981,7 @@ var VisualEditorLogic = class {
|
|
|
39666
39981
|
const children = candidateParent.getValue(true);
|
|
39667
39982
|
candidateParent.builder.validateChildren(candidateParent.nodeTag, [...children instanceof node.builder.source.constructor ? children.getNodes().map((child) => child.nodeTag) : [], branch2.nodeTag]);
|
|
39668
39983
|
const inserted = this.appendBranch(candidateParent, branch2, label);
|
|
39984
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), candidate);
|
|
39669
39985
|
app.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
39670
39986
|
this.appendBranch(parent, inserted, label);
|
|
39671
39987
|
node.SET(".insertionOpen", false);
|
|
@@ -39736,6 +40052,7 @@ var VisualEditorLogic = class {
|
|
|
39736
40052
|
if (request.signal.aborted) return;
|
|
39737
40053
|
if (design.value.toTytx() !== before) throw new Error("Source changed while preparing preview; it was retained");
|
|
39738
40054
|
const candidate = this.page.src.prepareSource(wire, design.builder);
|
|
40055
|
+
validateCatalogueSource(editor.GET(".catalogueScope"), candidate);
|
|
39739
40056
|
this.page.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
39740
40057
|
if (editor.GET(".assistantRun")) editor.SET(".assistantRun.blocked", true);
|
|
39741
40058
|
editor.SET(".selection", null);
|
|
@@ -39765,32 +40082,21 @@ var VisualEditorLogic = class {
|
|
|
39765
40082
|
async copySource(node) {
|
|
39766
40083
|
node.SET(".fileStatus", "");
|
|
39767
40084
|
try {
|
|
39768
|
-
|
|
39769
|
-
await node.rootBuilder.binding.gramlot.utl.inout.copyText(page.toTytx());
|
|
40085
|
+
await node.rootBuilder.binding.gramlot.utl.inout.copyText(this.currentSource(node));
|
|
39770
40086
|
node.SET(".fileStatus", "Source copied");
|
|
39771
40087
|
} catch (error) {
|
|
39772
40088
|
node.SET(".fileStatus", `Copy failed: ${error.message}`);
|
|
39773
40089
|
}
|
|
39774
40090
|
}
|
|
39775
40091
|
downloadPage(node) {
|
|
39776
|
-
|
|
39777
|
-
node.rootBuilder.binding.gramlot.utl.inout.saveText(page.toTytx(), node.GET(".filename"), "application/json");
|
|
40092
|
+
node.rootBuilder.binding.gramlot.utl.inout.saveText(this.currentSource(node), node.GET(".filename"), "application/json");
|
|
39778
40093
|
}
|
|
39779
40094
|
openUpload(node) {
|
|
39780
40095
|
node.SET(".uploadOpen", true);
|
|
39781
40096
|
}
|
|
39782
40097
|
sourceUploaded(node, { item, result }) {
|
|
39783
40098
|
try {
|
|
39784
|
-
|
|
39785
|
-
const target = node.builder.source.getNode(sourceRoot(node));
|
|
39786
|
-
const source = app.src.prepareSource(result, target.builder);
|
|
39787
|
-
const roots = source.getNodes();
|
|
39788
|
-
if (roots.length !== 1 || roots[0].label !== "pageRoot") throw new Error("Expected one pageRoot Source");
|
|
39789
|
-
app.src.renderer.validateCandidate(source, { replacingNode: target });
|
|
39790
|
-
if (node.GET(".assistantRun")) node.SET(".assistantRun.blocked", true);
|
|
39791
|
-
target.setValue(source, true, { _text: null }, true);
|
|
39792
|
-
node.SET(".filename", item.value.getItem("name"));
|
|
39793
|
-
node.SET(".selection", "pageRoot");
|
|
40099
|
+
this.loadSource(node, { source: result, filename: item.value.getItem("name") });
|
|
39794
40100
|
node.SET(".fileStatus", "Source opened");
|
|
39795
40101
|
node.SET(".uploadOpen", false);
|
|
39796
40102
|
} catch (error) {
|
|
@@ -39798,6 +40104,43 @@ var VisualEditorLogic = class {
|
|
|
39798
40104
|
throw error;
|
|
39799
40105
|
}
|
|
39800
40106
|
}
|
|
40107
|
+
initializeDocument(node) {
|
|
40108
|
+
const editor = visualEditorScope(node), source = editor.builder.source;
|
|
40109
|
+
const prefix = sourceRoot(editor).split(".");
|
|
40110
|
+
const subscription = `${editor.getAttr("visualEditorId")}-document`;
|
|
40111
|
+
editor.SET(".modified", false);
|
|
40112
|
+
source.subscribe(subscription, { any: (event) => {
|
|
40113
|
+
if (prefix.every((part, index) => event.pathlist[index] === part)) editor.SET(".modified", true);
|
|
40114
|
+
} });
|
|
40115
|
+
editor.rootBuilder.binding.renderer.onDispose(editor, () => source.unsubscribe(subscription, { any: true }));
|
|
40116
|
+
}
|
|
40117
|
+
currentSource(node) {
|
|
40118
|
+
const editor = visualEditorScope(node);
|
|
40119
|
+
return editor.builder.source.getNode(sourceRoot(editor)).getValue(true).toTytx();
|
|
40120
|
+
}
|
|
40121
|
+
markSaved(node) {
|
|
40122
|
+
visualEditorScope(node).SET(".modified", false);
|
|
40123
|
+
}
|
|
40124
|
+
loadSource(node, { source, filename }) {
|
|
40125
|
+
const editor = visualEditorScope(node);
|
|
40126
|
+
if (typeof source !== "string") throw new TypeError("source must be Source TYTX");
|
|
40127
|
+
if (typeof filename !== "string" || !filename.trim()) throw new TypeError("filename must be a non-empty string");
|
|
40128
|
+
const app = editor.rootBuilder.binding.gramlot;
|
|
40129
|
+
const target = editor.builder.source.getNode(sourceRoot(editor));
|
|
40130
|
+
const candidate = app.src.prepareSource(source, target.builder);
|
|
40131
|
+
const roots = candidate.getNodes();
|
|
40132
|
+
if (roots.length !== 1 || roots[0].label !== "pageRoot") throw new Error("Expected one pageRoot Source");
|
|
40133
|
+
validateCatalogueSource(editor.GET(".catalogueScope"), candidate);
|
|
40134
|
+
app.src.renderer.validateCandidate(candidate, { replacingNode: target });
|
|
40135
|
+
if (editor.GET(".assistantRun")) editor.SET(".assistantRun.blocked", true);
|
|
40136
|
+
editor.SET(".selection", null);
|
|
40137
|
+
target.setValue(candidate, true, { _text: null }, true);
|
|
40138
|
+
editor.SET(".filename", filename);
|
|
40139
|
+
editor.SET(".insertionOpen", false);
|
|
40140
|
+
editor.SET(".sourceSearch", "");
|
|
40141
|
+
editor.SET(".selection", "pageRoot");
|
|
40142
|
+
this.markSaved(editor);
|
|
40143
|
+
}
|
|
39801
40144
|
toggleNavigation(node) {
|
|
39802
40145
|
node.SET(".navigationOpen", node.GET(".navigationOpen") === "close" ? true : "close");
|
|
39803
40146
|
}
|
|
@@ -39842,6 +40185,11 @@ var VisualEditorLogic = class {
|
|
|
39842
40185
|
node.rootBuilder.binding.renderer.destination.ownerDocument.documentElement.setAttribute("data-theme", mode);
|
|
39843
40186
|
}
|
|
39844
40187
|
initializeEditor(node, { dataRoot }) {
|
|
40188
|
+
const scope = node.GET(".catalogueScope");
|
|
40189
|
+
validateCatalogue(scope);
|
|
40190
|
+
if (Array.isArray(scope)) for (const tag2 of scope) {
|
|
40191
|
+
if (!node.builder.schema[tag2]) throw new Error(`Unknown catalogue tag: ${tag2}`);
|
|
40192
|
+
}
|
|
39845
40193
|
node.SET(".editingMode", "source");
|
|
39846
40194
|
node.SET(".clipboard", new Bag());
|
|
39847
40195
|
node.SET(".clipboardVisible", false);
|
|
@@ -39870,9 +40218,10 @@ var VisualEditorLogic = class {
|
|
|
39870
40218
|
return bag;
|
|
39871
40219
|
};
|
|
39872
40220
|
for (const [path, caption, tags] of catalogueSections) {
|
|
39873
|
-
if (tags.split(" ").some((tag2) => node.builder.schema[tag2])) ensureGroup(path, caption);
|
|
40221
|
+
if (tags.split(" ").some((tag2) => node.builder.schema[tag2] && catalogueAllows(scope, tag2, node.builder.schema[tag2]._meta ?? {}))) ensureGroup(path, caption);
|
|
39874
40222
|
}
|
|
39875
40223
|
for (const [tag2, info] of Object.entries(node.builder.schema).sort(([a], [b]) => a.localeCompare(b))) {
|
|
40224
|
+
if (!catalogueAllows(scope, tag2, info._meta ?? {})) continue;
|
|
39876
40225
|
if (info._meta?.data_element || info._meta?.subbuilder || info._meta?.container) continue;
|
|
39877
40226
|
const root = info._meta?.gramlot_component ? "components" : "html";
|
|
39878
40227
|
const section = catalogueSections.find(([path2, , tags]) => path2.startsWith(root + ".") && tags.split(" ").includes(tag2));
|
|
@@ -39900,6 +40249,7 @@ var VisualEditorLogic = class {
|
|
|
39900
40249
|
const targetPath = `${sourceRoot(node)}.${path}`;
|
|
39901
40250
|
const moving = node.builder.source.getNode(sourcePath);
|
|
39902
40251
|
if (!moving || sourcePath === `${sourceRoot(node)}.pageRoot`) throw new Error("The page root cannot be moved");
|
|
40252
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), moving.parentBag);
|
|
39903
40253
|
if (moving.resolver) throw new Error("Resolver-backed Source nodes cannot be moved in this trial");
|
|
39904
40254
|
if (sourcePath === targetPath || targetPath.startsWith(sourcePath + ".")) throw new Error("A node cannot be moved into itself");
|
|
39905
40255
|
const parent = item, origin = moving.parentBag, Source = node.builder.source.constructor;
|
|
@@ -39940,6 +40290,7 @@ var VisualEditorLogic = class {
|
|
|
39940
40290
|
return;
|
|
39941
40291
|
}
|
|
39942
40292
|
const tag2 = dropValues["app/widget"].tag;
|
|
40293
|
+
this.validateCatalogueTag(node, tag2);
|
|
39943
40294
|
item.builder.validateParent(tag2, item.nodeTag);
|
|
39944
40295
|
const body = item.getValue(true);
|
|
39945
40296
|
item.builder.validateChildren(item.nodeTag, [...body instanceof node.builder.source.constructor ? body.getNodes().map((child) => child.nodeTag) : [], tag2]);
|
|
@@ -39956,7 +40307,7 @@ var VisualEditorLogic = class {
|
|
|
39956
40307
|
fields.getValue(true).clear();
|
|
39957
40308
|
const root = node.builder.wrapSource(fields);
|
|
39958
40309
|
root.p(`Insert ${tag2} into ${item.label} [${item.nodeTag}]`, { class: "visual-editor-hint" });
|
|
39959
|
-
const form = root.formlet({ columns: 2, gap: "
|
|
40310
|
+
const form = root.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
39960
40311
|
for (const [name, spec] of required) this.parameterField(node, form, tag2, name, spec, "insertion", spec.default);
|
|
39961
40312
|
node.SET(".insertionOpen", true);
|
|
39962
40313
|
}
|
|
@@ -39977,8 +40328,9 @@ var VisualEditorLogic = class {
|
|
|
39977
40328
|
const parent = current.parentNode;
|
|
39978
40329
|
const entries3 = specifications(parent, current.nodeTag, current);
|
|
39979
40330
|
node.SET(".properties.path", path);
|
|
40331
|
+
this.attributeRows(node, current);
|
|
39980
40332
|
node.SET(".propertiesTitle", `${current.label} [${current.nodeTag}]`);
|
|
39981
|
-
node.SET(".propertiesHeight", `${Math.min(
|
|
40333
|
+
node.SET(".propertiesHeight", `${Math.min(300, Math.max(180, 80 + Math.ceil(Object.keys(entries3).filter((name) => parameterTheme(name, /* @__PURE__ */ new Set()) === "general").length / 2) * 38))}px`);
|
|
39982
40334
|
const root = node.builder.wrapSource(fields);
|
|
39983
40335
|
if (path !== "pageRoot") root.p(path, { class: "visual-editor-destination" });
|
|
39984
40336
|
const parentFields = new Set(Object.keys(parent._getMeta("gramlot_component")?.childParameters ?? {}));
|
|
@@ -39995,11 +40347,22 @@ var VisualEditorLogic = class {
|
|
|
39995
40347
|
});
|
|
39996
40348
|
for (const [key2, title] of parameterThemes) {
|
|
39997
40349
|
if (!groups.get(key2).length) continue;
|
|
39998
|
-
const panel = tabs.contentPane({
|
|
40350
|
+
const panel = tabs.contentPane({
|
|
40351
|
+
pageName: key2,
|
|
40352
|
+
title,
|
|
40353
|
+
overflow: "auto",
|
|
40354
|
+
padding: "4px",
|
|
40355
|
+
min_height: 0,
|
|
40356
|
+
...key2 === "styles" ? { nodeId: visualEditorScope(node).getAttr("visualEditorId") + "StyleAttributes" } : {}
|
|
40357
|
+
});
|
|
40358
|
+
if (key2 === "styles") {
|
|
40359
|
+
this.attributeFields(node, panel, current, "styles");
|
|
40360
|
+
continue;
|
|
40361
|
+
}
|
|
39999
40362
|
if (key2 === "container") panel.p(`Child parameters of ${parent.nodeTag}`, { class: "visual-editor-hint" });
|
|
40000
40363
|
if (key2 === "behaviour" && Object.hasOwn(entries3, "action")) panel.p("action: use a named Logic method, for example openCatalogue.", { class: "visual-editor-hint" });
|
|
40001
40364
|
if (key2 === "behaviour" && current.nodeTag === "borderContainer") panel.p("persist remembers splitter sizes and requires a stable container id.", { class: "visual-editor-hint" });
|
|
40002
|
-
const form = panel.formlet({ columns: 2, gap: "
|
|
40365
|
+
const form = panel.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
40003
40366
|
if (key2 === "general" && current._getMeta("gramlot_component")?.labelbox) {
|
|
40004
40367
|
this.labelboxFields(node, form, current, entries3);
|
|
40005
40368
|
}
|
|
@@ -40016,7 +40379,7 @@ var VisualEditorLogic = class {
|
|
|
40016
40379
|
if (!advanced) {
|
|
40017
40380
|
const details = panel.details({ class: "visual-validation-advanced" });
|
|
40018
40381
|
details.summary("Conditions and messages");
|
|
40019
|
-
advanced = details.formlet({ columns: 2, gap: "
|
|
40382
|
+
advanced = details.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
40020
40383
|
}
|
|
40021
40384
|
target = advanced;
|
|
40022
40385
|
}
|
|
@@ -40024,8 +40387,170 @@ var VisualEditorLogic = class {
|
|
|
40024
40387
|
this.parameterField(node, target, current.nodeTag, name, spec, "properties", value ?? spec.default);
|
|
40025
40388
|
}
|
|
40026
40389
|
}
|
|
40390
|
+
const more = tabs.contentPane({ nodeId: visualEditorScope(node).getAttr("visualEditorId") + "MoreAttributes", pageName: "attributes", title: "More attributes", overflow: "auto", padding: "4px", min_height: 0 });
|
|
40391
|
+
this.attributeFields(node, more, current);
|
|
40027
40392
|
node.SET(".propertiesOpen", true);
|
|
40028
40393
|
}
|
|
40394
|
+
attributeRows(node, current) {
|
|
40395
|
+
const rows = new Bag();
|
|
40396
|
+
for (const [name, value] of Object.entries(current.getAttr())) {
|
|
40397
|
+
if (name === "_meta") continue;
|
|
40398
|
+
const type = scalarType(value);
|
|
40399
|
+
const text3 = type ? scalarText(value, type) : "[non-scalar value]";
|
|
40400
|
+
rows.setItem(`r${rows.length}`, new Bag({ name, type: type ?? "readonly", text: text3, original: text3 }));
|
|
40401
|
+
}
|
|
40402
|
+
node.SET(".properties.attributeRows", rows);
|
|
40403
|
+
node.SET(".properties.attributeDraft", new Bag({ name: "", type: "string", text: "" }));
|
|
40404
|
+
node.SET(".properties.attributeDraftHidden", true);
|
|
40405
|
+
}
|
|
40406
|
+
attributeFields(node, panel, current, scope = "attributes") {
|
|
40407
|
+
const path = node.GET(".properties.path");
|
|
40408
|
+
const base = `${editorData(node)}.properties`;
|
|
40409
|
+
const renderer = node.rootBuilder.binding.gramlot.src.renderer;
|
|
40410
|
+
const parentFields = new Set(Object.keys(current.parentNode._getMeta("gramlot_component")?.childParameters ?? {}));
|
|
40411
|
+
const list = panel.div({ class: "visual-editor-attribute-list", "aria-label": scope === "styles" ? "Style attributes" : "Node attributes" });
|
|
40412
|
+
const heading = list.div({ class: "visual-editor-attribute-row visual-editor-attribute-heading" });
|
|
40413
|
+
heading.span("Attribute", { class: "visual-editor-attribute-name" });
|
|
40414
|
+
const headingValue = heading.div({ class: "visual-editor-attribute-value" });
|
|
40415
|
+
headingValue.span("Value");
|
|
40416
|
+
headingValue.button("+", {
|
|
40417
|
+
action: "beginAttribute",
|
|
40418
|
+
editingPath: path,
|
|
40419
|
+
"aria-label": scope === "styles" ? "Add style attribute" : "Add attribute",
|
|
40420
|
+
title: "Add attribute",
|
|
40421
|
+
class: "visual-editor-attribute-command"
|
|
40422
|
+
});
|
|
40423
|
+
for (const row of node.GET(".properties.attributeRows").getNodes()) {
|
|
40424
|
+
const name = row.value.getItem("name"), type = row.value.getItem("type"), key2 = row.label;
|
|
40425
|
+
if (scope === "styles" && parameterTheme(name, parentFields) !== "styles" && !renderer._isStyleContribution(name)) continue;
|
|
40426
|
+
const editable = type !== "readonly";
|
|
40427
|
+
const line = list.div({ class: "visual-editor-attribute-row" });
|
|
40428
|
+
line.span(name, { class: "visual-editor-attribute-name", title: name });
|
|
40429
|
+
const cell = line.div({ class: "visual-editor-attribute-value" });
|
|
40430
|
+
cell.input({
|
|
40431
|
+
value: `^${base}.attributeRows.${key2}.text`,
|
|
40432
|
+
disabled: !editable,
|
|
40433
|
+
"aria-label": `${name} attribute value`,
|
|
40434
|
+
title: editable ? type : "Non-scalar values are read-only"
|
|
40435
|
+
});
|
|
40436
|
+
cell.button("\xD7", {
|
|
40437
|
+
action: "removeAttribute",
|
|
40438
|
+
attributeRow: key2,
|
|
40439
|
+
editingPath: path,
|
|
40440
|
+
disabled: !editable,
|
|
40441
|
+
"aria-label": `Remove ${name} attribute`,
|
|
40442
|
+
title: `Remove ${name}`,
|
|
40443
|
+
class: "visual-editor-attribute-command"
|
|
40444
|
+
});
|
|
40445
|
+
if (editable && scope === "attributes") line.dataController({
|
|
40446
|
+
func: "changeAttribute",
|
|
40447
|
+
value: `^${base}.attributeRows.${key2}.text`,
|
|
40448
|
+
attributeRow: key2,
|
|
40449
|
+
editingPath: path,
|
|
40450
|
+
_userChanges: true
|
|
40451
|
+
});
|
|
40452
|
+
}
|
|
40453
|
+
const add2 = list.div({
|
|
40454
|
+
class: "visual-editor-attribute-row",
|
|
40455
|
+
hidden: `^${base}.attributeDraftHidden`,
|
|
40456
|
+
connect_onkeydown: "attributeDraftKey"
|
|
40457
|
+
});
|
|
40458
|
+
const nameCell = add2.div({ class: "visual-editor-attribute-name" });
|
|
40459
|
+
nameCell.input({ value: `^${base}.attributeDraft.name`, live: true, "aria-label": "New attribute name", placeholder: "Attribute name" });
|
|
40460
|
+
const valueCell = add2.div({ class: "visual-editor-attribute-value" });
|
|
40461
|
+
valueCell.input({ value: `^${base}.attributeDraft.text`, live: true, "aria-label": "New attribute value", placeholder: "Value" });
|
|
40462
|
+
const types = valueCell.select({ value: `^${base}.attributeDraft.type`, "aria-label": "New attribute type" });
|
|
40463
|
+
for (const type of editorTypes) types.option(type, { value: type });
|
|
40464
|
+
valueCell.button("\u2713", { action: "addAttribute", editingPath: path, "aria-label": "Apply new attribute", title: "Apply (Enter)", class: "visual-editor-attribute-command" });
|
|
40465
|
+
valueCell.button("\xD7", { action: "cancelAttribute", "aria-label": "Cancel new attribute", title: "Cancel (Escape)", class: "visual-editor-attribute-command" });
|
|
40466
|
+
}
|
|
40467
|
+
beginAttribute(node, { editingPath }) {
|
|
40468
|
+
const editor = visualEditorScope(node);
|
|
40469
|
+
if (editingPath !== editor.GET(".selection")) return;
|
|
40470
|
+
editor.SET(".properties.attributeDraft", new Bag({ name: "", type: "string", text: "" }));
|
|
40471
|
+
editor.SET(".properties.attributeDraftHidden", false);
|
|
40472
|
+
editor.SET(".propertyError", "");
|
|
40473
|
+
}
|
|
40474
|
+
cancelAttribute(node) {
|
|
40475
|
+
visualEditorScope(node).SET(".properties.attributeDraftHidden", true);
|
|
40476
|
+
}
|
|
40477
|
+
attributeDraftKey(node, event) {
|
|
40478
|
+
if (event.isComposing || !["Enter", "Escape"].includes(event.key)) return;
|
|
40479
|
+
event.preventDefault();
|
|
40480
|
+
event.stopPropagation();
|
|
40481
|
+
const editor = visualEditorScope(node);
|
|
40482
|
+
if (event.key === "Escape") this.cancelAttribute(editor);
|
|
40483
|
+
else this.addAttribute(editor, { editingPath: editor.GET(".properties.path") });
|
|
40484
|
+
}
|
|
40485
|
+
addAttribute(node, { editingPath }) {
|
|
40486
|
+
const editor = visualEditorScope(node);
|
|
40487
|
+
if (editingPath !== editor.GET(".selection")) return;
|
|
40488
|
+
editor.SET(".propertyError", "");
|
|
40489
|
+
try {
|
|
40490
|
+
const draft = editor.GET(".properties.attributeDraft");
|
|
40491
|
+
const name = draft.getItem("name");
|
|
40492
|
+
if (!name || !/^[^\s"'<>/=]+$/.test(name)) throw new Error("Enter a valid attribute name.");
|
|
40493
|
+
if (["_meta", "__proto__", "constructor", "prototype"].includes(name)) throw new Error("Unsupported attribute name.");
|
|
40494
|
+
const current = editor.builder.source.getNode(`${sourceRoot(editor)}.${editingPath}`);
|
|
40495
|
+
if (!current) throw new Error("The selected Source node no longer exists");
|
|
40496
|
+
if (Object.hasOwn(current.getAttr(), name)) throw new Error(`Duplicate attribute: ${name}`);
|
|
40497
|
+
const value = parseScalar(draft.getItem("type"), String(draft.getItem("text") ?? ""));
|
|
40498
|
+
this.writeAttribute(editor, current, editingPath, name, value, false);
|
|
40499
|
+
} catch (error) {
|
|
40500
|
+
editor.SET(".propertyError", error.message);
|
|
40501
|
+
}
|
|
40502
|
+
}
|
|
40503
|
+
changeAttribute(node, { attributeRow, editingPath, value }) {
|
|
40504
|
+
this.editAttribute(node, { attributeRow, editingPath, value, remove: false });
|
|
40505
|
+
}
|
|
40506
|
+
removeAttribute(node, { attributeRow, editingPath }) {
|
|
40507
|
+
this.editAttribute(node, { attributeRow, editingPath, remove: true });
|
|
40508
|
+
}
|
|
40509
|
+
editAttribute(node, { attributeRow, editingPath, value, remove }) {
|
|
40510
|
+
const editor = visualEditorScope(node);
|
|
40511
|
+
if (editingPath !== editor.GET(".selection")) return;
|
|
40512
|
+
editor.SET(".propertyError", "");
|
|
40513
|
+
try {
|
|
40514
|
+
const row = editor.GET(".properties.attributeRows").getItem(attributeRow);
|
|
40515
|
+
if (!row || row.getItem("type") === "readonly") throw new Error("This attribute is not editable");
|
|
40516
|
+
const name = row.getItem("name");
|
|
40517
|
+
if (["_meta", "__proto__", "constructor", "prototype"].includes(name)) throw new Error("Unsupported attribute name.");
|
|
40518
|
+
const current = editor.builder.source.getNode(`${sourceRoot(editor)}.${editingPath}`);
|
|
40519
|
+
if (!current) throw new Error("The selected Source node no longer exists");
|
|
40520
|
+
const attrs = current.getAttr(), type = scalarType(attrs[name]);
|
|
40521
|
+
if (!Object.hasOwn(attrs, name) || type !== row.getItem("type") || scalarText(attrs[name], type) !== row.getItem("original"))
|
|
40522
|
+
throw new Error("Attribute changed; select the node again before editing.");
|
|
40523
|
+
const parsed = remove ? null : parseScalar(type, String(value ?? ""));
|
|
40524
|
+
this.writeAttribute(editor, current, editingPath, name, parsed, remove, row);
|
|
40525
|
+
} catch (error) {
|
|
40526
|
+
editor.SET(".propertyError", error.message);
|
|
40527
|
+
}
|
|
40528
|
+
}
|
|
40529
|
+
writeAttribute(editor, current, path, name, value, remove, row = null) {
|
|
40530
|
+
const attrs = { ...current.getAttr() };
|
|
40531
|
+
if (remove) delete attrs[name];
|
|
40532
|
+
else attrs[name] = value;
|
|
40533
|
+
const specs = specifications(current.parentNode, current.nodeTag, current);
|
|
40534
|
+
if (specs[name]) this.validateParameter(current.parentNode, current, name, specs[name], remove ? null : value);
|
|
40535
|
+
const design = editor.builder.source.getNode(sourceRoot(editor)), app = editor.rootBuilder.binding.gramlot;
|
|
40536
|
+
const candidate = app.src.prepareSource(design.getValue(true).toTytx(), design.builder);
|
|
40537
|
+
candidate.getNode(path).setAttr(attrs, true, false, false);
|
|
40538
|
+
validateCatalogueSource(editor.GET(".catalogueScope"), candidate);
|
|
40539
|
+
app.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
40540
|
+
current.setAttr(attrs, true, false, false);
|
|
40541
|
+
if (row && !remove) {
|
|
40542
|
+
const text3 = scalarText(value, row.getItem("type"));
|
|
40543
|
+
row.setItem("original", text3);
|
|
40544
|
+
row.setItem("text", text3);
|
|
40545
|
+
const type = editor.GET(`.properties.types.${name}`);
|
|
40546
|
+
if (specs[name]?.enum) editor.SET(`.properties.parameters.${name}`, value);
|
|
40547
|
+
else if (type) editor.SET(`.properties.parameters.${name}.${type}`, value);
|
|
40548
|
+
} else {
|
|
40549
|
+
const tab = editor.GET(".parameterTab") === "styles" ? "styles" : "attributes";
|
|
40550
|
+
this.showProperties(editor, { path });
|
|
40551
|
+
editor.SET(".parameterTab", tab);
|
|
40552
|
+
}
|
|
40553
|
+
}
|
|
40029
40554
|
toggleLabelboxAttributes(node, { prefix }) {
|
|
40030
40555
|
node.SET(`.properties.${prefix}Hidden`, !node.GET(`.properties.${prefix}Hidden`));
|
|
40031
40556
|
}
|
|
@@ -40184,6 +40709,7 @@ var VisualEditorLogic = class {
|
|
|
40184
40709
|
try {
|
|
40185
40710
|
const current = node.builder.source.getNode(`${sourceRoot(node)}.${editingPath}`);
|
|
40186
40711
|
if (!current) throw new Error("The selected Source node no longer exists");
|
|
40712
|
+
if (parameterName !== "_text" && Object.is(current.getAttr(parameterName), value)) return;
|
|
40187
40713
|
const specs = specifications(current.parentNode, current.nodeTag, current);
|
|
40188
40714
|
const spec = specs[parameterName];
|
|
40189
40715
|
if (!spec) throw new Error(`Unknown parameter: ${parameterName}`);
|
|
@@ -40195,6 +40721,12 @@ var VisualEditorLogic = class {
|
|
|
40195
40721
|
else attrs[parameterName] = value;
|
|
40196
40722
|
current.setAttr(attrs, true, false, false);
|
|
40197
40723
|
}
|
|
40724
|
+
this.attributeRows(node, current);
|
|
40725
|
+
for (const [field, scope] of [["MoreAttributes", "attributes"], ["StyleAttributes", "styles"]]) {
|
|
40726
|
+
const panel = editorField(node, field);
|
|
40727
|
+
panel.getValue(true).clear();
|
|
40728
|
+
this.attributeFields(node, node.builder.wrapSource(panel), current, scope);
|
|
40729
|
+
}
|
|
40198
40730
|
} catch (error) {
|
|
40199
40731
|
node.SET(".propertyError", error.message);
|
|
40200
40732
|
}
|
|
@@ -40206,6 +40738,11 @@ var VisualEditorLogic = class {
|
|
|
40206
40738
|
const children = parent.getValue(true);
|
|
40207
40739
|
if (!empty2 && spec.unique && children instanceof parent.builder.source.constructor && children.getNodes().some((child) => child !== current && child.getAttr(name) === value)) throw new Error(`${name} is already in use`);
|
|
40208
40740
|
}
|
|
40741
|
+
validateCatalogueTag(node, tag2) {
|
|
40742
|
+
const scope = visualEditorScope(node).GET(".catalogueScope");
|
|
40743
|
+
if (!catalogueAllows(scope, tag2, node.builder.schema[tag2]?._meta ?? {}))
|
|
40744
|
+
throw new Error(`Tag ${tag2} is outside the editor catalogue`);
|
|
40745
|
+
}
|
|
40209
40746
|
applyInsert(node) {
|
|
40210
40747
|
if (node.GET(".insertion.clipboard")) {
|
|
40211
40748
|
this.finishPaste(node);
|
|
@@ -40215,6 +40752,7 @@ var VisualEditorLogic = class {
|
|
|
40215
40752
|
const parent = node.builder.source.getNode(`${sourceRoot(node)}.${path}`);
|
|
40216
40753
|
if (!parent) throw new Error("The target Source node is no longer available");
|
|
40217
40754
|
const tag2 = node.GET(".insertion.tag");
|
|
40755
|
+
this.validateCatalogueTag(node, tag2);
|
|
40218
40756
|
const attrs = {};
|
|
40219
40757
|
for (const [name, spec] of Object.entries(specifications(parent, tag2)).filter(([, spec2]) => spec2.required)) {
|
|
40220
40758
|
const type = node.GET(`.insertion.types.${name}`);
|