@floless/app 0.143.0 → 0.144.0
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/floless-server.cjs +177152 -160760
- package/dist/schemas/steel.model.v2.schema.json +50 -2
- package/dist/schemas/tekla.model.v1.schema.json +66 -0
- package/dist/schemas/tekla.model.v2.schema.json +69 -0
- package/dist/schemas/tekla.source-package.v1.schema.json +37 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +24 -1
- package/dist/skills/floless-app-workflows/SKILL.md +8 -2
- package/dist/skills/floless-app-workflows/references/workspace-data.md +25 -4
- package/dist/templates/floless-workspace-model-report.flo +27 -23
- package/dist/templates/revit-model.flo +6 -2
- package/dist/templates/tekla-model-report.flo +60 -0
- package/dist/templates/tekla-parser.flo +61 -0
- package/dist/web/app.css +89 -2
- package/dist/web/aware.js +423 -46
- package/dist/web/commands-revit.js +4 -0
- package/dist/web/commands-shell.js +136 -3
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/commands-tekla-parser.js +48 -0
- package/dist/web/commands.js +1 -1
- package/dist/web/grid-core.js +15 -0
- package/dist/web/index.html +40 -2
- package/dist/web/instructor.js +13 -3
- package/dist/web/left-pane.js +160 -10
- package/dist/web/model-artifact-loader.js +15 -0
- package/dist/web/model-display-units.js +89 -0
- package/dist/web/model-editor-revit-adapter.js +21 -4
- package/dist/web/model-editor.css +4 -2
- package/dist/web/model-measure.js +10 -6
- package/dist/web/model-panel-bridge.js +46 -3
- package/dist/web/model-pointer-dock.js +21 -1
- package/dist/web/model-property-display.js +91 -0
- package/dist/web/model-revit-module.js +9 -0
- package/dist/web/model-selection-tools.js +11 -0
- package/dist/web/model-spatial-panel.js +52 -21
- package/dist/web/model-structural-grid-view.js +334 -0
- package/dist/web/model-tekla-selection.js +32 -0
- package/dist/web/model-viewport-revit-adapter.js +119 -32
- package/dist/web/revit-editor.css +11 -1
- package/dist/web/revit-editor.html +4 -3
- package/dist/web/revit-editor.js +589 -111
- package/dist/web/steel-3d-view.js +58 -372
- package/dist/web/steel-editor.html +231 -8
- package/dist/web/tekla-editor.html +71 -0
- package/dist/web/tekla-structural-grid-adapter.js +56 -0
- package/dist/web/workspaces.js +872 -97
- package/distribution-profile-production.mjs +4 -0
- package/distribution-resource-inventory.mjs +4 -2
- package/package.json +5 -2
package/dist/web/left-pane.js
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
const split = document.getElementById('left-pane-split');
|
|
14
14
|
const status = document.getElementById('left-pane-status');
|
|
15
15
|
const modelTabs = document.getElementById('left-model-tabs');
|
|
16
|
+
const modelSearch = document.getElementById('left-model-search');
|
|
17
|
+
const modelSearchInput = document.getElementById('left-model-search-input');
|
|
18
|
+
const modelSearchClear = document.getElementById('left-model-search-clear');
|
|
16
19
|
const modelIndexLabel = document.getElementById('left-model-index-label');
|
|
17
20
|
const followSelection = document.getElementById('left-model-follow-selection');
|
|
18
21
|
const modelContent = document.getElementById('left-model-content');
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
// controls leave with it. No src: the frame's first about:blank document is this origin and stays put.
|
|
26
29
|
const panelSlot = document.getElementById('left-model-panel-slot');
|
|
27
30
|
let panelFrame = document.getElementById('left-model-panel');
|
|
28
|
-
if (!frame || !pane || !stack || !split || !status || !modelTabs || !modelIndexLabel || !followSelection || !modelContent || !collapsedHost || !empty || !modelContext
|
|
31
|
+
if (!frame || !pane || !stack || !split || !status || !modelTabs || !modelSearch || !modelSearchInput || !modelSearchClear || !modelIndexLabel || !followSelection || !modelContent || !collapsedHost || !empty || !modelContext
|
|
29
32
|
|| !modelIndexHeader || !panelSlot || !panelFrame) return;
|
|
30
33
|
|
|
31
34
|
const sections = {
|
|
@@ -73,6 +76,8 @@
|
|
|
73
76
|
let panelShown = null; // the panel tab the editor was last told it is showing (null: none)
|
|
74
77
|
let chosenByPerson = false; // true only while a click on a tab renders: the editor is told a person chose it
|
|
75
78
|
let displacedTab = null; // a chosen tab the snapshot stopped offering (a 3D-only tab while in 2D); it comes back with it
|
|
79
|
+
let searchTimer = null;
|
|
80
|
+
let lastSearchAnnouncement = '';
|
|
76
81
|
|
|
77
82
|
const panelTabsOf = (snapshot) => (Array.isArray(snapshot?.panelTabs) ? snapshot.panelTabs : [])
|
|
78
83
|
.filter((tab) => typeof tab?.key === 'string' && typeof tab?.label === 'string');
|
|
@@ -101,6 +106,25 @@
|
|
|
101
106
|
if (state.followSelection) revealSelectedEntity();
|
|
102
107
|
if (followsTab(state.tab)) { panelShown = null; renderModel(); } // the editor draws the following, so it is told again
|
|
103
108
|
});
|
|
109
|
+
const searchContext = (query) => ({ generation: state.generation, datasetKey: state.datasetKey, tab: state.tab, query: String(query).slice(0, 200) });
|
|
110
|
+
const requestSearch = (context) => {
|
|
111
|
+
if (context.generation !== state.generation || context.datasetKey !== state.datasetKey || context.tab !== state.tab
|
|
112
|
+
|| isPanelTab(context.tab) || !context.datasetKey) return false;
|
|
113
|
+
const requestId = sendAction({ action: 'search', tab: context.tab, query: context.query, datasetKey: context.datasetKey });
|
|
114
|
+
if (requestId) pendingActions.set(requestId, { kind: 'search', tab: context.tab });
|
|
115
|
+
return !!requestId;
|
|
116
|
+
};
|
|
117
|
+
const clearSearch = () => {
|
|
118
|
+
clearTimeout(searchTimer); modelSearchInput.value = ''; modelSearchClear.hidden = true;
|
|
119
|
+
requestSearch(searchContext('')); modelSearchInput.focus();
|
|
120
|
+
};
|
|
121
|
+
modelSearchInput.addEventListener('input', () => {
|
|
122
|
+
modelSearchClear.hidden = !modelSearchInput.value;
|
|
123
|
+
const context = searchContext(modelSearchInput.value);
|
|
124
|
+
clearTimeout(searchTimer); searchTimer = setTimeout(() => requestSearch(context), 120);
|
|
125
|
+
});
|
|
126
|
+
modelSearchInput.addEventListener('keydown', (event) => { if (event.key === 'Escape' && modelSearchInput.value) { event.preventDefault(); clearSearch(); } });
|
|
127
|
+
modelSearchClear.addEventListener('click', clearSearch);
|
|
104
128
|
|
|
105
129
|
function available(key) { return key === 'narrative' || state.modelAvailable; }
|
|
106
130
|
function shown(key) { return available(key) && (state.visible[key] || sessionVisible[key]); }
|
|
@@ -441,8 +465,66 @@
|
|
|
441
465
|
|
|
442
466
|
function renderNodes(nodes, host) {
|
|
443
467
|
const scrollTop = host.scrollTop;
|
|
468
|
+
let objectRowIndex = 0;
|
|
444
469
|
host.replaceChildren();
|
|
445
470
|
if (!Array.isArray(nodes) || !nodes.length) { const empty = document.createElement('div'); empty.className = 'left-model-empty'; empty.textContent = 'No objects in this index.'; host.append(empty); return; }
|
|
471
|
+
const renderGridVisibility = (control) => {
|
|
472
|
+
const levels = Array.isArray(control?.levels) ? control.levels.filter((level) => level && typeof level.key === 'string'
|
|
473
|
+
&& Number.isFinite(level.mm) && typeof level.visible === 'boolean').sort((left, right) => left.mm - right.mm) : [];
|
|
474
|
+
if (!levels.length) return null;
|
|
475
|
+
const fieldset = document.createElement('fieldset'); fieldset.className = 'left-grid-visibility';
|
|
476
|
+
fieldset.setAttribute('aria-label', 'Grid visibility');
|
|
477
|
+
const legend = document.createElement('legend'); legend.textContent = 'Grid visibility'; fieldset.append(legend);
|
|
478
|
+
const rows = [];
|
|
479
|
+
const option = ({ key, primary, secondary = '', checked, master = false }) => {
|
|
480
|
+
const row = document.createElement('label'); row.className = `left-grid-level${master ? ' left-grid-level-all' : ''}`;
|
|
481
|
+
const input = document.createElement('input'); input.type = 'checkbox'; input.checked = checked;
|
|
482
|
+
input.dataset.gridLevelKey = key; input.dataset.commandId = `shell.grid-elevation#${commandInstance(key)}`;
|
|
483
|
+
const name = document.createElement('span'); name.className = 'left-grid-level-name'; name.textContent = primary;
|
|
484
|
+
row.append(input, name);
|
|
485
|
+
if (secondary) { const value = document.createElement('span'); value.className = 'left-grid-level-value'; value.textContent = secondary; row.append(value); }
|
|
486
|
+
fieldset.append(row); rows.push({ input, level: key === '*' ? null : levels.find((level) => level.key === key) });
|
|
487
|
+
return input;
|
|
488
|
+
};
|
|
489
|
+
const visibleCount = levels.filter((level) => level.visible).length;
|
|
490
|
+
const master = option({ key: '*', primary: 'All elevations', secondary: `${visibleCount} of ${levels.length}`, checked: visibleCount === levels.length, master: true });
|
|
491
|
+
master.indeterminate = visibleCount > 0 && visibleCount < levels.length;
|
|
492
|
+
master.setAttribute('aria-checked', master.indeterminate ? 'mixed' : String(master.checked));
|
|
493
|
+
for (const level of levels) {
|
|
494
|
+
const primary = String(level.authored || level.label || 'Grid plane').trim() || 'Grid plane';
|
|
495
|
+
const display = String(level.display || `${Math.round(level.mm)} mm`).trim();
|
|
496
|
+
const comparable = (value) => value.toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu, '');
|
|
497
|
+
option({ key: level.key, primary, secondary: comparable(display) === comparable(primary) ? '' : display, checked: level.visible });
|
|
498
|
+
}
|
|
499
|
+
const note = document.createElement('p'); note.className = 'left-grid-visibility-status'; fieldset.append(note);
|
|
500
|
+
const repaint = (announce = false) => {
|
|
501
|
+
const individual = rows.filter((item) => item.level); const shown = individual.filter((item) => item.input.checked);
|
|
502
|
+
master.checked = shown.length === individual.length; master.indeterminate = shown.length > 0 && shown.length < individual.length;
|
|
503
|
+
master.setAttribute('aria-checked', master.indeterminate ? 'mixed' : String(master.checked));
|
|
504
|
+
master.dataset.commandInstanceLabel = `all elevations — ${master.indeterminate ? 'mixed' : master.checked ? 'shown' : 'hidden'}`;
|
|
505
|
+
for (const item of individual) {
|
|
506
|
+
const authored = String(item.level.authored || item.level.label || item.level.display || 'grid plane').trim();
|
|
507
|
+
item.input.dataset.commandInstanceLabel = `${authored} — ${item.input.checked ? 'shown' : 'hidden'}`;
|
|
508
|
+
}
|
|
509
|
+
const count = master.closest('label')?.querySelector('.left-grid-level-value'); if (count) count.textContent = `${shown.length} of ${individual.length}`;
|
|
510
|
+
note.textContent = shown.length ? `Bubbles at lowest shown elevation: ${String(shown[0].level.authored || shown[0].level.label || shown[0].level.display).trim()}.`
|
|
511
|
+
: 'Grid hidden at all elevations. Check an elevation to show it.';
|
|
512
|
+
if (announce) status.textContent = note.textContent;
|
|
513
|
+
const active = document.activeElement;
|
|
514
|
+
if (rows.some((item) => item.input === active)) window.Instructor?.refreshCarrier?.(active);
|
|
515
|
+
};
|
|
516
|
+
const sendVisibility = (levelKey, visible, input) => {
|
|
517
|
+
const requestId = sendAction({ action: 'grid-visibility', levelKey, visible, datasetKey: state.datasetKey });
|
|
518
|
+
if (requestId) pendingActions.set(requestId, { kind: 'grid-visibility', commandId: input.dataset.commandId });
|
|
519
|
+
};
|
|
520
|
+
master.addEventListener('change', () => {
|
|
521
|
+
for (const item of rows) if (item.level) item.input.checked = master.checked;
|
|
522
|
+
repaint(true); sendVisibility(null, master.checked, master);
|
|
523
|
+
});
|
|
524
|
+
for (const item of rows) if (item.level) item.input.addEventListener('change', () => { repaint(true); sendVisibility(item.level.key, item.input.checked, item.input); });
|
|
525
|
+
repaint();
|
|
526
|
+
return fieldset;
|
|
527
|
+
};
|
|
446
528
|
const append = (items, parent) => {
|
|
447
529
|
for (const node of items) {
|
|
448
530
|
if (!node || typeof node.label !== 'string') continue;
|
|
@@ -455,17 +537,48 @@
|
|
|
455
537
|
? `shell.model-item#${commandInstance(instance)}`
|
|
456
538
|
: `shell.model-group#${commandInstance(instance)}`;
|
|
457
539
|
row.dataset.commandInstanceLabel = node.label;
|
|
458
|
-
const accessibleLabel = node.count == null ? node.label : `${node.label}, ${node.count}`;
|
|
459
|
-
row.setAttribute('aria-label', accessibleLabel);
|
|
460
540
|
if (typeof node.tip === 'string' && node.tip) row.dataset.tip = node.tip;
|
|
461
|
-
const label = document.createElement('span'); label.className = 'row-label'; label.textContent = node.label;
|
|
541
|
+
const label = document.createElement('span'); label.className = 'row-label'; label.textContent = node.label;
|
|
542
|
+
if (node.entityId && node.objectFields && ['name', 'profile', 'id'].every((key) => node.objectFields[key] == null || typeof node.objectFields[key] === 'string')) {
|
|
543
|
+
row.classList.add('model-object-row');
|
|
544
|
+
const summary = document.createElement('span'); summary.className = 'model-object-summary';
|
|
545
|
+
const fieldId = `left-model-object-${++objectRowIndex}`;
|
|
546
|
+
label.classList.add('model-object-name'); label.id = `${fieldId}-name`;
|
|
547
|
+
if (node.objectFields.name != null) { label.dataset.objectField = 'name'; label.textContent = node.objectFields.name; }
|
|
548
|
+
summary.append(label); row.setAttribute('aria-labelledby', label.id);
|
|
549
|
+
const details = document.createElement('span'); details.className = 'model-object-details'; details.id = `${fieldId}-details`;
|
|
550
|
+
for (const [key, caption] of [['profile', 'Profile'], ['id', 'ID']]) {
|
|
551
|
+
if (node.objectFields[key] == null) continue;
|
|
552
|
+
const field = document.createElement('span'); field.className = 'model-object-field';
|
|
553
|
+
const fieldLabel = document.createElement('span'); fieldLabel.className = 'model-object-field-label'; fieldLabel.textContent = `${caption}: `;
|
|
554
|
+
const value = document.createElement('span'); value.dataset.objectField = key; value.textContent = node.objectFields[key];
|
|
555
|
+
field.append(fieldLabel, value); details.append(field);
|
|
556
|
+
}
|
|
557
|
+
if (details.children.length) { summary.append(details); row.setAttribute('aria-describedby', details.id); }
|
|
558
|
+
row.append(summary);
|
|
559
|
+
} else {
|
|
560
|
+
row.setAttribute('aria-label', node.count == null ? node.label : `${node.label}, ${node.count}`);
|
|
561
|
+
row.append(label);
|
|
562
|
+
}
|
|
462
563
|
if (node.count != null) { const count = document.createElement('span'); count.className = 'explorer-count'; count.textContent = String(node.count); row.append(count); }
|
|
463
564
|
if (node.entityId) {
|
|
464
565
|
row.dataset.entityId = node.entityId;
|
|
465
566
|
row.classList.toggle('selected', selectedIdsOf(state.snapshot).includes(node.entityId));
|
|
466
567
|
if (node.entityId === state.snapshot?.selectedId) row.setAttribute('aria-current', 'true');
|
|
467
|
-
|
|
468
|
-
const item = document.createElement('div'); item.setAttribute('role', 'listitem');
|
|
568
|
+
const gridControl = state.snapshot?.gridVisibility?.entityId === node.entityId ? renderGridVisibility(state.snapshot.gridVisibility) : null;
|
|
569
|
+
const item = document.createElement('div'); item.setAttribute('role', 'listitem');
|
|
570
|
+
if (gridControl) {
|
|
571
|
+
item.className = 'left-model-branch left-grid-object';
|
|
572
|
+
const disclosureKey = `${state.datasetKey}:${state.tab}:grid-visibility:${node.entityId}`;
|
|
573
|
+
const searching = !!state.snapshot?.searches?.[state.tab]?.query;
|
|
574
|
+
const expanded = searching || (groupDisclosure.has(disclosureKey) ? groupDisclosure.get(disclosureKey) : true);
|
|
575
|
+
row.setAttribute('aria-expanded', String(expanded)); gridControl.hidden = !expanded;
|
|
576
|
+
row.addEventListener('click', (event) => {
|
|
577
|
+
const open = row.getAttribute('aria-expanded') !== 'true'; row.setAttribute('aria-expanded', String(open)); gridControl.hidden = !open;
|
|
578
|
+
groupDisclosure.set(disclosureKey, open); selectRow(node.entityId, event);
|
|
579
|
+
});
|
|
580
|
+
item.append(row, gridControl);
|
|
581
|
+
} else { row.addEventListener('click', (event) => selectRow(node.entityId, event)); item.append(row); }
|
|
469
582
|
parent.append(item); continue;
|
|
470
583
|
}
|
|
471
584
|
if (Array.isArray(node.children)) {
|
|
@@ -487,6 +600,7 @@
|
|
|
487
600
|
if (node.lazy && !node.children.length) { requestLazyChildren(); return; }
|
|
488
601
|
const open = row.getAttribute('aria-expanded') !== 'true'; row.setAttribute('aria-expanded', String(open)); children.hidden = !open;
|
|
489
602
|
groupDisclosure.set(disclosureKey, open);
|
|
603
|
+
if (node.selectable === true) sendAction({ action: 'select-group', groupId: node.groupId, datasetKey: state.datasetKey });
|
|
490
604
|
});
|
|
491
605
|
branch.append(row, children); parent.append(branch);
|
|
492
606
|
if (expanded && node.lazy && !node.children.length) requestLazyChildren();
|
|
@@ -509,10 +623,14 @@
|
|
|
509
623
|
}
|
|
510
624
|
const selectedId = selectedIds[0];
|
|
511
625
|
pendingRevealId = selectedId;
|
|
512
|
-
|
|
626
|
+
const followTab = state.snapshot.tabs.find((tab) => tab.key === 'model')?.key || state.snapshot.tabs[0]?.key;
|
|
627
|
+
if (followTab && state.tab !== followTab) { state.tab = followTab; renderModel(); }
|
|
513
628
|
const row = [...modelContent.querySelectorAll('[data-entity-id]')]
|
|
514
629
|
.find((candidate) => candidate.dataset.entityId === selectedId);
|
|
515
|
-
if (!row)
|
|
630
|
+
if (!row) {
|
|
631
|
+
if (state.snapshot?.searches?.[state.tab]?.query) status.textContent = 'The selected object is hidden by search. Clear the search to reveal it.';
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
516
634
|
let children = row.closest('.left-model-children');
|
|
517
635
|
while (children) {
|
|
518
636
|
children.hidden = false;
|
|
@@ -525,6 +643,8 @@
|
|
|
525
643
|
}
|
|
526
644
|
children = branch?.parentElement?.closest('.left-model-children') || null;
|
|
527
645
|
}
|
|
646
|
+
const gridControl = row.parentElement?.querySelector(':scope > .left-grid-visibility');
|
|
647
|
+
if (gridControl) { row.setAttribute('aria-expanded', 'true'); gridControl.hidden = false; }
|
|
528
648
|
const sequence = ++revealSequence;
|
|
529
649
|
const generation = state.generation;
|
|
530
650
|
const revision = state.revision;
|
|
@@ -581,6 +701,7 @@
|
|
|
581
701
|
if (!button.dataset.leftPaneBound) {
|
|
582
702
|
button.dataset.leftPaneBound = 'true';
|
|
583
703
|
button.addEventListener('click', () => {
|
|
704
|
+
clearTimeout(searchTimer); searchTimer = null;
|
|
584
705
|
state.tab = button.dataset.modelTabKey; displacedTab = null; save();
|
|
585
706
|
chosenByPerson = true; try { renderModel(); } finally { chosenByPerson = false; }
|
|
586
707
|
button.focus();
|
|
@@ -601,7 +722,7 @@
|
|
|
601
722
|
if (focusedKey) buttons.find((button) => button.dataset.modelTabKey === focusedKey)?.focus({ preventScroll: true });
|
|
602
723
|
// A PANEL tab: the editor draws it in the frame; this side only shows the slot and says which tab.
|
|
603
724
|
const panel = isPanelTab(state.tab) ? state.tab : null;
|
|
604
|
-
modelIndexHeader.hidden = !!panel && !followsTab(panel); modelContent.hidden = !!panel; panelSlot.hidden = !panel;
|
|
725
|
+
modelSearch.hidden = !!panel; modelIndexHeader.hidden = !!panel && !followsTab(panel); modelContent.hidden = !!panel; panelSlot.hidden = !panel;
|
|
605
726
|
if (panel) {
|
|
606
727
|
if (followsTab(panel)) modelIndexLabel.textContent = tabs.find((tab) => tab.key === panel).label;
|
|
607
728
|
panelSlot.setAttribute('aria-labelledby', `left-model-tab-${panel}`);
|
|
@@ -613,12 +734,27 @@
|
|
|
613
734
|
if (requestId) { panelShown = panel; pendingActions.set(requestId, { kind: 'panel', key: panel }); }
|
|
614
735
|
}
|
|
615
736
|
if (panel) return;
|
|
737
|
+
const activeSearch = snapshot.searches?.[state.tab] || {};
|
|
738
|
+
const nextQuery = typeof activeSearch.query === 'string' ? activeSearch.query : '';
|
|
739
|
+
if (document.activeElement !== modelSearchInput) modelSearchInput.value = nextQuery;
|
|
740
|
+
modelSearchInput.setAttribute('aria-label', `Search objects in ${tabs.find((tab) => tab.key === state.tab)?.label || 'model'}`);
|
|
741
|
+
modelSearchClear.hidden = !modelSearchInput.value;
|
|
616
742
|
modelContent.setAttribute('aria-labelledby', `left-model-tab-${state.tab}`);
|
|
617
743
|
const focusedCommand = modelContent.contains(document.activeElement)
|
|
618
744
|
? document.activeElement?.closest?.('[data-command-id]')?.getAttribute('data-command-id') : null;
|
|
619
745
|
const body = Array.isArray(snapshot.bodies?.[state.tab]) ? snapshot.bodies[state.tab] : [];
|
|
620
746
|
const headingIndex = body.findIndex((node) => node?.kind === 'label');
|
|
621
|
-
|
|
747
|
+
const indexLabel = headingIndex >= 0 ? body[headingIndex].label : `Browse by ${tabs.find((tab) => tab.key === state.tab)?.label?.toLowerCase() || 'model'}`;
|
|
748
|
+
modelIndexLabel.textContent = Number.isFinite(activeSearch.shown) && Number.isFinite(activeSearch.total) && nextQuery
|
|
749
|
+
? `${indexLabel} · ${activeSearch.shown} of ${activeSearch.total}` : indexLabel;
|
|
750
|
+
const announcementKey = nextQuery && Number.isFinite(activeSearch.shown) && Number.isFinite(activeSearch.total)
|
|
751
|
+
? `${state.datasetKey}:${state.tab}:${nextQuery}:${activeSearch.shown}:${activeSearch.total}` : '';
|
|
752
|
+
if (announcementKey && announcementKey !== lastSearchAnnouncement) {
|
|
753
|
+
status.textContent = activeSearch.shown > 0
|
|
754
|
+
? `${activeSearch.shown} of ${activeSearch.total} objects.`
|
|
755
|
+
: `No objects match “${nextQuery}”.`;
|
|
756
|
+
lastSearchAnnouncement = announcementKey;
|
|
757
|
+
} else if (!announcementKey) lastSearchAnnouncement = '';
|
|
622
758
|
renderNodes(headingIndex >= 0 ? body.filter((_node, index) => index !== headingIndex) : body, modelContent);
|
|
623
759
|
if (focusedCommand) [...modelContent.querySelectorAll('[data-command-id]')]
|
|
624
760
|
.find((item) => item.getAttribute('data-command-id') === focusedCommand)?.focus({ preventScroll: true });
|
|
@@ -686,6 +822,16 @@
|
|
|
686
822
|
if (currentChildren) currentChildren.hidden = false;
|
|
687
823
|
}
|
|
688
824
|
}
|
|
825
|
+
if (pending?.kind === 'grid-visibility' && !data.ok) {
|
|
826
|
+
const refreshRollback = document.activeElement?.dataset?.commandId === pending.commandId;
|
|
827
|
+
renderModel();
|
|
828
|
+
if (refreshRollback) {
|
|
829
|
+
const restored = [...modelContent.querySelectorAll('[data-command-id]')]
|
|
830
|
+
.find((row) => row.dataset.commandId === pending.commandId);
|
|
831
|
+
if (restored) { restored.focus(); window.Instructor?.refreshCarrier?.(restored); }
|
|
832
|
+
else window.Instructor?.clear?.();
|
|
833
|
+
}
|
|
834
|
+
}
|
|
689
835
|
if (!data.ok) status.textContent = data.message || 'That model action is no longer available.';
|
|
690
836
|
// The frame stays empty, so say so where the tab would be — for the tab still shown, not an earlier one.
|
|
691
837
|
if (pending?.kind === 'panel' && !data.ok && pending.key === panelShown) {
|
|
@@ -715,6 +861,10 @@
|
|
|
715
861
|
state.snapshot.selectedId = typeof data.selectedId === 'string' ? data.selectedId : null;
|
|
716
862
|
state.snapshot.selectedIds = Array.isArray(data.selectedIds) ? data.selectedIds.filter((id) => typeof id === 'string') : (state.snapshot.selectedId ? [state.snapshot.selectedId] : []);
|
|
717
863
|
state.snapshot.selectionOrigin = data.selectionOrigin || 'tree';
|
|
864
|
+
if (Array.isArray(data.geometrySelectionIds)) {
|
|
865
|
+
state.snapshot.focusEntityId = typeof data.focusEntityId === 'string' ? data.focusEntityId : null;
|
|
866
|
+
state.snapshot.geometrySelectionIds = data.geometrySelectionIds.filter((id) => typeof id === 'string');
|
|
867
|
+
}
|
|
718
868
|
state.snapshot.subjects = data.subjects && typeof data.subjects === 'object' ? data.subjects : null;
|
|
719
869
|
}
|
|
720
870
|
announceSelection();
|
|
@@ -56,6 +56,21 @@ export async function readModelJsonArtifact({ url, receipt, rowKey, expectedItem
|
|
|
56
56
|
return { document, rows, bytes: bytes.byteLength };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** Fetch and authenticate a signed JSON document whose receipt counts something other than a top-level row array. */
|
|
60
|
+
export async function readModelJsonDocument({ url, receipt, fetchImpl = fetch, cryptoImpl = crypto, signal = undefined }) {
|
|
61
|
+
preflightModelJsonReceipt(receipt);
|
|
62
|
+
const response = await fetchImpl(url, { credentials: 'same-origin', signal });
|
|
63
|
+
if (!response.ok) throw new Error(`Model artifact request failed (${response.status}).`);
|
|
64
|
+
const bytes = await readBoundedBytes(response, receipt, MODEL_VIEWER_MAX_JSON_BYTES);
|
|
65
|
+
if (bytes.byteLength !== receipt.bytes) throw new Error('The model artifact byte length does not match its signed receipt.');
|
|
66
|
+
const digest = hex(new Uint8Array(await cryptoImpl.subtle.digest('SHA-256', bytes)));
|
|
67
|
+
if (digest !== receipt.digest) throw new Error('The model artifact digest does not match its signed receipt.');
|
|
68
|
+
let document;
|
|
69
|
+
try { document = JSON.parse(new TextDecoder().decode(bytes)); } catch { throw new Error('The authenticated model artifact is not valid JSON.'); }
|
|
70
|
+
if (!document || typeof document !== 'object' || Array.isArray(document)) throw new Error('The authenticated model artifact is not a JSON object.');
|
|
71
|
+
return { document, bytes: bytes.byteLength };
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
/** Fetch and authenticate one signed binary model artifact without exceeding its bounded receipt. */
|
|
60
75
|
export async function readModelBinaryArtifact({ url, receipt, maxBytes, fetchImpl = fetch, cryptoImpl = crypto, signal = undefined }) {
|
|
61
76
|
if (!receipt || !Number.isSafeInteger(receipt.bytes) || receipt.bytes < 0 || receipt.bytes > maxBytes || !SHA256.test(receipt.digest)) throw new Error('The model artifact has no safe signed byte receipt.');
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { DEFAULT_DISPLAY_UNITS, formatLength, FT_IN, MM } from './display-units.js';
|
|
2
|
+
|
|
3
|
+
const valid = (value) => value === FT_IN || value === MM;
|
|
4
|
+
|
|
5
|
+
/** The parser viewers share Steel's project preference and its single length formatter. */
|
|
6
|
+
export function mountModelDisplayUnits({ host, doc, projectId, commandPrefix, request, onChange, onError,
|
|
7
|
+
wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) }) {
|
|
8
|
+
let units = null, saving = false, destroyed = false, generation = 0, readGeneration = 0, connectionGeneration = 0, connected = true, stale = false;
|
|
9
|
+
const controls = [];
|
|
10
|
+
host.setAttribute('role', 'group'); host.setAttribute('aria-label', 'Display units');
|
|
11
|
+
const label = doc.createElement('span'); label.textContent = 'Units'; host.append(label);
|
|
12
|
+
const status = doc.createElement('span'); status.className = 'model-units-status'; status.setAttribute('role', 'status');
|
|
13
|
+
const retry = doc.createElement('button'); retry.type = 'button'; retry.className = 'model-units-retry'; retry.textContent = 'Retry'; retry.dataset.commandId = `${commandPrefix}.display-units-retry`; retry.setAttribute('aria-label', 'Retry loading project display units');
|
|
14
|
+
retry.addEventListener('click', () => load());
|
|
15
|
+
const paint = () => {
|
|
16
|
+
for (const [value, button] of controls) {
|
|
17
|
+
button.disabled = units === null || saving;
|
|
18
|
+
button.setAttribute('aria-pressed', String(value === units));
|
|
19
|
+
button.dataset.tip = units === null ? 'Loading this project’s display units…'
|
|
20
|
+
: saving ? 'Saving this project’s display units…' : `Display lengths in ${value === MM ? 'millimetres' : 'feet and inches'}`;
|
|
21
|
+
}
|
|
22
|
+
status.hidden = connected && !stale;
|
|
23
|
+
status.textContent = stale ? (units === null ? 'Units unavailable (ft-in)' : 'Units may be stale') : connected ? '' : 'Offline';
|
|
24
|
+
status.dataset.tip = units === null ? 'Project units could not be confirmed. Feet and inches are shown until Retry succeeds.' : 'The last confirmed units are shown. Retry to read the current project setting.';
|
|
25
|
+
status.setAttribute('aria-label', status.hidden ? '' : units === null ? 'Project display units unavailable; showing feet and inches' : 'Display units may be out of date');
|
|
26
|
+
retry.hidden = !stale; retry.disabled = saving;
|
|
27
|
+
const instructorState = doc.defaultView?.__revitInstructorState;
|
|
28
|
+
if (instructorState && typeof instructorState === 'object') {
|
|
29
|
+
doc.defaultView.__revitInstructorState = {
|
|
30
|
+
...instructorState,
|
|
31
|
+
hiddenCommands: retry.hidden ? [retry.dataset.commandId] : [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
doc.defaultView?.__instructor?.notifyChanged?.();
|
|
35
|
+
};
|
|
36
|
+
const confirm = (value) => { if (!valid(value) || destroyed) return; const changed = units !== value; units = value; paint(); if (changed) onChange(units); };
|
|
37
|
+
const adopt = (value) => { if (!valid(value) || destroyed) return; generation += 1; confirm(value); };
|
|
38
|
+
const url = `/api/projects/${encodeURIComponent(projectId)}/display-units`;
|
|
39
|
+
const choose = async (value) => {
|
|
40
|
+
if (saving || units === null || units === value || destroyed) return;
|
|
41
|
+
const started = generation;
|
|
42
|
+
saving = true; paint();
|
|
43
|
+
try {
|
|
44
|
+
const body = await request(url, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ displayUnits: value }) });
|
|
45
|
+
if (!valid(body.displayUnits)) throw new Error('Unknown confirmed display units');
|
|
46
|
+
if (generation === started) { stale = false; confirm(body.displayUnits); }
|
|
47
|
+
else await load(); // A live event arrived during the write; ask the server which value won.
|
|
48
|
+
} catch { if (!destroyed) { await load(); onError('Could not confirm the unit change. Showing the last confirmed units.'); } }
|
|
49
|
+
finally { saving = false; if (!destroyed) paint(); }
|
|
50
|
+
};
|
|
51
|
+
for (const value of [FT_IN, MM]) {
|
|
52
|
+
const button = doc.createElement('button'); button.type = 'button'; button.textContent = value;
|
|
53
|
+
button.dataset.unitChoice = value;
|
|
54
|
+
button.dataset.commandId = `${commandPrefix}.display-units#${value}`;
|
|
55
|
+
button.setAttribute('aria-label', `Display units: ${value}`);
|
|
56
|
+
button.addEventListener('click', () => choose(value)); controls.push([value, button]); host.append(button);
|
|
57
|
+
}
|
|
58
|
+
host.append(status, retry);
|
|
59
|
+
paint();
|
|
60
|
+
async function load() {
|
|
61
|
+
const requestGeneration = ++readGeneration;
|
|
62
|
+
for (const backoff of [100, 250, 500]) {
|
|
63
|
+
await wait(backoff);
|
|
64
|
+
if (destroyed || requestGeneration !== readGeneration) return false;
|
|
65
|
+
const started = generation;
|
|
66
|
+
try {
|
|
67
|
+
const body = await request(url); if (!valid(body.displayUnits)) throw new Error('Unknown display units');
|
|
68
|
+
if (destroyed || requestGeneration !== readGeneration) return false;
|
|
69
|
+
// Every event is an observation epoch, even when the displayed units did not change.
|
|
70
|
+
// Retry until the GET completed without an intervening cross-tab observation.
|
|
71
|
+
if (generation !== started) continue;
|
|
72
|
+
stale = false; confirm(body.displayUnits); return true;
|
|
73
|
+
} catch { /* Retry the same bounded reconciliation pass. */ }
|
|
74
|
+
}
|
|
75
|
+
if (!destroyed && requestGeneration === readGeneration) {
|
|
76
|
+
stale = true; paint(); onError(units === null ? 'Could not read this project’s display units. Showing feet and inches.' : 'Project units could not be refreshed. Showing the last confirmed units.');
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
load,
|
|
82
|
+
connectionLost() { connectionGeneration++; connected = false; paint(); },
|
|
83
|
+
async reconnect() { const attempt = ++connectionGeneration; const confirmed = await load(); if (!destroyed && attempt === connectionGeneration) { connected = confirmed; paint(); } },
|
|
84
|
+
adopt,
|
|
85
|
+
units: () => units ?? DEFAULT_DISPLAY_UNITS,
|
|
86
|
+
length(mm) { const value = units ?? DEFAULT_DISPLAY_UNITS; return formatLength(mm, value) + (value === MM ? ' mm' : ''); },
|
|
87
|
+
destroy() { destroyed = true; host.replaceChildren(); },
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -89,16 +89,31 @@ const CONTROLS = Object.freeze({
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
export function revitRenderPlan(entries = revitCapabilityEntries()) {
|
|
92
|
+
return readOnlyModelRenderPlan({ entries, commandPrefix: 'revit', sourceLabel: 'Revit' });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const mappedText = (value, commandPrefix, sourceLabel) => typeof value === 'string'
|
|
96
|
+
? value.replaceAll('revit.', `${commandPrefix}.`).replaceAll('Revit', sourceLabel)
|
|
97
|
+
: value;
|
|
98
|
+
|
|
99
|
+
/** Reuse the authenticated read-only model chrome without leaking Revit product language. */
|
|
100
|
+
export function readOnlyModelRenderPlan({
|
|
101
|
+
entries = revitCapabilityEntries(), commandPrefix = 'revit', sourceLabel = 'Revit',
|
|
102
|
+
} = {}) {
|
|
92
103
|
const resolved = resolveToolbar(capabilityMap(entries));
|
|
93
104
|
const clusters = toolbarClusters(resolved).map((cluster) => ({
|
|
94
105
|
...cluster,
|
|
95
106
|
controls: cluster.controls.map((control) => {
|
|
96
107
|
const descriptor = CONTROLS[control.id];
|
|
97
108
|
if (!descriptor) throw new Error(`revitRenderPlan: no descriptor for "${control.id}"`);
|
|
98
|
-
const withCommand =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
const withCommand = Object.fromEntries(Object.entries({
|
|
110
|
+
...descriptor, semantic: control.id, cmd: descriptor.cmd ?? REVIT_COMMAND_BINDING_V1[control.id],
|
|
111
|
+
}).map(([key, value]) => [key, mappedText(value, commandPrefix, sourceLabel)]));
|
|
112
|
+
if (!descriptor.items) return withCommand;
|
|
113
|
+
const live = control.items ? new Set(control.items) : null;
|
|
114
|
+
return { ...withCommand, items: descriptor.items.filter((item) => !item.cap || !live || live.has(item.cap)).map((item) => (
|
|
115
|
+
Object.fromEntries(Object.entries(item).map(([key, value]) => [key, mappedText(value, commandPrefix, sourceLabel)]))
|
|
116
|
+
)) };
|
|
102
117
|
}),
|
|
103
118
|
}));
|
|
104
119
|
const plan = { schema: 'floless.model-toolbar-plan/v1', clusters };
|
|
@@ -139,3 +154,5 @@ export function createRevitEditorAdapter({ viewport, host = {} }) {
|
|
|
139
154
|
const capabilities = capabilityMap(revitCapabilityEntries());
|
|
140
155
|
return createModelEditorFacade({ provider: provider(viewport), capabilities, host });
|
|
141
156
|
}
|
|
157
|
+
|
|
158
|
+
export const createReadOnlyModelEditorAdapter = createRevitEditorAdapter;
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
.model-view-cube-host canvas:focus-visible,#m3dCube canvas:focus-visible{outline:2px solid var(--brand,var(--accent,#60a5fa));outline-offset:3px;border-radius:8px}
|
|
118
118
|
.model-view-cube-status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
119
119
|
|
|
120
|
-
.model-clip-list{border-top:1px solid var(--line);margin-top:8px;padding-top:4px}.model-clip-list-header{height:30px;display:flex;align-items:center;gap:7px;padding:0 5px;color:var(--text)}.model-clip-list-header strong{font-size:11px;text-transform:uppercase;letter-spacing:.08em}.model-clip-count{min-width:18px;height:18px;display:grid;place-items:center;border-radius:9px;background:var(--btn);color:var(--muted);font-size:10px}.model-clip-enable-all{width:24px;min-width:24px;min-height:24px;padding:0;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-enable-all[data-state="on"]{color:var(--brand,#60a5fa)}.model-clip-enable-all[data-state="mixed"]{color:#64748b}.model-clip-clear{margin-left:auto}.model-clip-list-rows{display:grid;gap:2px}.model-clip-row{min-height:30px;display:grid;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:4px;border-radius:5px;padding:2px 3px}.model-clip-row:hover,.model-clip-row.is-selected{background:var(--accent-soft)}.model-clip-row.is-selected{outline:1px solid color-mix(in srgb,var(--brand,#3b82f6) 58%,transparent)}.model-clip-row button{min-width:0;min-height:24px;padding:2px 5px;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-row button:hover{background:var(--btn-hover);color:var(--text)}.model-clip-enable{width:22px;border:1px solid var(--line)!important;color:var(--brand,#60a5fa)!important}.model-clip-enable[aria-pressed="false"]{color:transparent!important}.model-clip-label{text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)!important}.model-clip-remove{font-size:16px;line-height:1}.model-clip-rename{width:100%;min-width:0;height:25px;border:1px solid var(--brand,#3b82f6);border-radius:4px;background:var(--bg,#020817);color:var(--text);padding:2px 6px;font:inherit;outline:none}.model-clip-list-empty{padding:10px 7px 12px;color:var(--muted);font-size:11px;line-height:1.45}.model-clip-drag-readout{position:fixed;z-index:60;pointer-events:none;padding:5px 9px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);box-shadow:0 3px 10px rgba(0,0,0,.45);font:11px var(--mono,monospace)}
|
|
120
|
+
.model-clip-list{border-top:1px solid var(--line);margin-top:8px;padding-top:4px}.model-clip-list-header{height:30px;display:flex;align-items:center;gap:7px;padding:0 5px;color:var(--text)}.model-clip-list-header strong{font-size:11px;text-transform:uppercase;letter-spacing:.08em}.model-clip-count{min-width:18px;height:18px;display:grid;place-items:center;border-radius:9px;background:var(--btn);color:var(--muted);font-size:10px}.model-clip-enable-all{width:24px;min-width:24px;min-height:24px;padding:0;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-enable-all[data-state="on"]{color:var(--brand,#60a5fa)}.model-clip-enable-all[data-state="mixed"]{color:#64748b}.model-clip-clear{margin-left:auto}.model-clip-list-rows{display:grid;align-content:start;gap:2px}.model-clip-row{min-height:30px;display:grid;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:4px;border-radius:5px;padding:2px 3px}.model-clip-row:hover,.model-clip-row.is-selected{background:var(--accent-soft)}.model-clip-row.is-selected{outline:1px solid color-mix(in srgb,var(--brand,#3b82f6) 58%,transparent)}.model-clip-row button{min-width:0;min-height:24px;padding:2px 5px;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-row button:hover{background:var(--btn-hover);color:var(--text)}.model-clip-enable{width:22px;border:1px solid var(--line)!important;color:var(--brand,#60a5fa)!important}.model-clip-enable[aria-pressed="false"]{color:transparent!important}.model-clip-label{text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)!important}.model-clip-remove{font-size:16px;line-height:1}.model-clip-rename{width:100%;min-width:0;height:25px;border:1px solid var(--brand,#3b82f6);border-radius:4px;background:var(--bg,#020817);color:var(--text);padding:2px 6px;font:inherit;outline:none}.model-clip-list-empty{padding:10px 7px 12px;color:var(--muted);font-size:11px;line-height:1.45}.model-clip-drag-readout{position:fixed;z-index:60;pointer-events:none;padding:5px 9px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);box-shadow:0 3px 10px rgba(0,0,0,.45);font:11px var(--mono,monospace)}
|
|
121
121
|
|
|
122
122
|
/* Inspector seam, stub and grip are shared with master Steel. */
|
|
123
123
|
.model-inspector-resizer{flex:none;width:11px;cursor:col-resize;background:transparent;position:relative;z-index:6;touch-action:none;align-self:stretch}
|
|
@@ -162,7 +162,9 @@ body:has(.model-inspector-resizer.drag) .model-inspector-panel,body:has(.model-i
|
|
|
162
162
|
.model-module-actions{gap:5px}
|
|
163
163
|
.model-module-actions button{min-height:28px;padding:3px 9px;font-size:11px}
|
|
164
164
|
.model-module-actions button.on{background:var(--brand,var(--accent,#60a5fa));border-color:var(--brand,var(--accent,#60a5fa));color:#0f172a}
|
|
165
|
-
|
|
165
|
+
/* One line, width-capped: a sentence-long status (a snap refusal) must never widen the actions bar enough to
|
|
166
|
+
wrap the dock (#1738). The full text is in the pill's data-tip and its role=status announcement. */
|
|
167
|
+
.model-dock-status{min-width:52px;max-width:320px;padding:0 5px;color:var(--mut,var(--muted));font-size:10px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
166
168
|
|
|
167
169
|
/* Shared model-space dimension and acquisition overlay. Providers supply points; this presentation,
|
|
168
170
|
including witness lines, ticks, reticle and acquired-target readout, is identical in every module. */
|
|
@@ -156,11 +156,11 @@ function constrainedPoint(anchor, target, lockSet, frame, verticalOnly) {
|
|
|
156
156
|
* Session-only, provider-neutral point → point → placement dimension tool.
|
|
157
157
|
* @param {{surface:any,host:any,viewport:any,snapIndex?:()=>any,onState?:(state:any)=>void,
|
|
158
158
|
* onChange?:(value:any,reason:string)=>void,onEditRequest?:((dimension:any,index:number)=>void)|null,
|
|
159
|
-
* initialDimensions?:any[],initialPresentation?:any}} options
|
|
159
|
+
* initialDimensions?:any[],initialPresentation?:any,formatDistance?:((mm:number)=>string)|null}} options
|
|
160
160
|
*/
|
|
161
161
|
export function mountModelMeasureTool({
|
|
162
162
|
surface, host, viewport, snapIndex = () => null, onState = () => {}, onChange = () => {},
|
|
163
|
-
onEditRequest = null, initialDimensions = [], initialPresentation = null,
|
|
163
|
+
onEditRequest = null, initialDimensions = [], initialPresentation = null, formatDistance = null,
|
|
164
164
|
}) {
|
|
165
165
|
if (!surface || !host || !viewport) throw new Error('Model measurement needs a surface, overlay host, and viewport.');
|
|
166
166
|
const svg = document.createElementNS(SVG_NS, 'svg'); svg.classList.add('model-dim-overlay'); svg.setAttribute('aria-hidden', 'true'); host.append(svg);
|
|
@@ -208,7 +208,7 @@ export function mountModelMeasureTool({
|
|
|
208
208
|
const distance = viewport.distanceMm?.(dimension.a, dimension.b) ?? Math.hypot(...dimension.b.map((value, axis) => value - dimension.a[axis]));
|
|
209
209
|
const style = { ...presentation, ...(dimension.presentation ?? {}) };
|
|
210
210
|
const converted = distanceInUnits(distance, style.units);
|
|
211
|
-
label.textContent = `${converted.toLocaleString(undefined, { minimumFractionDigits: style.precision, maximumFractionDigits: style.precision })} ${style.units}`;
|
|
211
|
+
label.textContent = formatDistance ? formatDistance(distance) : `${converted.toLocaleString(undefined, { minimumFractionDigits: style.precision, maximumFractionDigits: style.precision })} ${style.units}`;
|
|
212
212
|
group.append(label); svg.append(group);
|
|
213
213
|
};
|
|
214
214
|
const drawGuide = (guide) => {
|
|
@@ -255,7 +255,10 @@ export function mountModelMeasureTool({
|
|
|
255
255
|
};
|
|
256
256
|
const notify = () => {
|
|
257
257
|
const index = snapIndex(); const step = !armed ? 0 : first === null ? 1 : second === null ? 2 : 3;
|
|
258
|
-
|
|
258
|
+
// The snap refusal is about picking points, so it is shown only while the tool is armed. Disarmed, the
|
|
259
|
+
// status returns to the session (Ready / N placed / selected) — a sentence-long refusal left behind there
|
|
260
|
+
// kept the dock's actions bar wide enough to strand it on its own upper row (#1738).
|
|
261
|
+
const status = armed && index?.available === false ? index.refusal?.message : (step === 1 ? 'Pick point 1' : step === 2 ? 'Pick point 2' : step === 3 ? 'Place dimension'
|
|
259
262
|
: selectedIndex !== null ? 'Dimension selected · Enter to edit · Delete to remove' : (dimensions.length ? `${dimensions.length} placed` : 'Ready'));
|
|
260
263
|
onState({ armed, hasDraft: !!first, step, count: dimensions.length, selectedIndex, status, visible,
|
|
261
264
|
presentation: { ...presentation }, snapModes: { ...snapModes }, locks: [...lockSet],
|
|
@@ -314,8 +317,8 @@ export function mountModelMeasureTool({
|
|
|
314
317
|
}
|
|
315
318
|
dialog.append(group);
|
|
316
319
|
};
|
|
317
|
-
choice('Units', ['mm', 'cm', 'm', 'in', 'ft'], dimension.presentation.units, (units) => api.update(index, { presentation: { units } }));
|
|
318
|
-
choice('Precision', [0, 1, 2, 3, 4], dimension.presentation.precision, (precision) => api.update(index, { presentation: { precision } }));
|
|
320
|
+
if (!formatDistance) choice('Units', ['mm', 'cm', 'm', 'in', 'ft'], dimension.presentation.units, (units) => api.update(index, { presentation: { units } }));
|
|
321
|
+
if (!formatDistance) choice('Precision', [0, 1, 2, 3, 4], dimension.presentation.precision, (precision) => api.update(index, { presentation: { precision } }));
|
|
319
322
|
choice('Label', ['above', 'center', 'below'], dimension.presentation.labelPlacement, (labelPlacement) => api.update(index, { presentation: { labelPlacement } }));
|
|
320
323
|
const actions = document.createElement('div'); actions.className = 'model-dimension-editor-actions';
|
|
321
324
|
const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Delete'; remove.dataset.tip = 'Delete selected dimension';
|
|
@@ -384,6 +387,7 @@ export function mountModelMeasureTool({
|
|
|
384
387
|
selectedIndex, visible, presentation: { ...presentation }, snapModes: { ...snapModes }, locks: [...lockSet], activeFrame: resolveFrame(viewport).label, onePickKind }; },
|
|
385
388
|
dimensions() { return session.dimensions(); },
|
|
386
389
|
serialize() { return session.serialize(); },
|
|
390
|
+
refresh() { render(); },
|
|
387
391
|
destroy() { closeOnePickMenu(); closeEditor(); unsubscribe(); releaseInput(); session.dispose(); svg.remove(); },
|
|
388
392
|
};
|
|
389
393
|
notify(); return api;
|
|
@@ -49,13 +49,15 @@ export function serializeModelPanelNodes(host, path = 'root') {
|
|
|
49
49
|
nodes.push({ label: trigger.querySelector('.row-label')?.textContent || trigger.textContent || '',
|
|
50
50
|
count: trigger.querySelector('.explorer-count')?.textContent || null, children,
|
|
51
51
|
tip: trigger.dataset.tip || null,
|
|
52
|
+
...(trigger.dataset.selectable === 'true' ? { selectable: true } : {}),
|
|
52
53
|
lazy: !children.length && Number(trigger.querySelector('.explorer-count')?.textContent || 0) > 0,
|
|
53
54
|
expanded: trigger.getAttribute('aria-expanded') === 'true', groupId: `${path}.${index}` });
|
|
54
55
|
}
|
|
55
56
|
continue;
|
|
56
57
|
}
|
|
57
|
-
if (child.classList.contains('explorer-row')) nodes.push({ label: child.querySelector('.row-label')?.textContent
|
|
58
|
+
if (child.classList.contains('explorer-row')) nodes.push({ label: child.querySelector('.row-label')?.textContent ?? child.textContent ?? '',
|
|
58
59
|
count: child.querySelector('.explorer-count')?.textContent || null, entityId: child.dataset.entityId || null,
|
|
60
|
+
...(child.classList.contains('model-object-row') ? { objectFields: Object.fromEntries(['name', 'profile', 'id'].map((key) => [key, child.querySelector(`[data-object-field="${key}"]`)?.textContent ?? null])) } : {}),
|
|
59
61
|
tip: child.dataset.tip || null });
|
|
60
62
|
}
|
|
61
63
|
return nodes;
|
|
@@ -80,6 +82,24 @@ export function expandModelPanelGroup(tabs, byId, groupId) {
|
|
|
80
82
|
return true;
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
/** Select an already-populated selectable group without changing its disclosure state. */
|
|
86
|
+
export function selectModelPanelGroup(tabs, byId, groupId) {
|
|
87
|
+
const parts = String(groupId || '').split('.'), key = parts.shift();
|
|
88
|
+
const tab = tabs.find((item) => item.key === key); if (!tab || !parts.length) return false;
|
|
89
|
+
let host = byId(tab.bodyId), trigger = null;
|
|
90
|
+
for (const raw of parts) {
|
|
91
|
+
if (!/^\d+$/.test(raw)) return false;
|
|
92
|
+
const branch = [...(host?.children || [])][Number(raw)];
|
|
93
|
+
if (!branch?.classList.contains('revit-tree-branch')) return false;
|
|
94
|
+
trigger = branch.querySelector(':scope > .explorer-row');
|
|
95
|
+
host = branch.querySelector(':scope > .revit-tree-children');
|
|
96
|
+
if (!trigger || !host) return false;
|
|
97
|
+
}
|
|
98
|
+
if (trigger?.dataset.selectable !== 'true') return false;
|
|
99
|
+
trigger.dispatchEvent(new trigger.ownerDocument.defaultView.Event('model-group-select'));
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
83
103
|
// The main window's panel frame is an about:blank iframe, so it shares this origin and an editor may move its
|
|
84
104
|
// own elements into it. It gets the editor's stylesheets and follows the editor's <html> attributes (the
|
|
85
105
|
// theme), so what moves renders as it did at home. Returns the function that stops following.
|
|
@@ -151,7 +171,9 @@ export function createPanelHost({ win = window, root, bodies, install = (_doc) =
|
|
|
151
171
|
|
|
152
172
|
export function createModelPanelBridge({ win = window, origin = location.origin, snapshot, selectedId, selectedIds = () => {
|
|
153
173
|
const id = selectedId(); return typeof id === 'string' ? [id] : [];
|
|
154
|
-
},
|
|
174
|
+
}, select, expand, selectGroup = (_groupId) => false, search = (_tab, _query) => false,
|
|
175
|
+
selectionState = () => ({}), panel = (_tab, _person, _follow) => false,
|
|
176
|
+
gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksChanged = null }) {
|
|
155
177
|
let requested = false;
|
|
156
178
|
let generation = null;
|
|
157
179
|
let revision = 0;
|
|
@@ -172,7 +194,7 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
|
|
|
172
194
|
// `subjects` is the selection as model objects a chat message may be about (#1653): {source, revision, total,
|
|
173
195
|
// items: [{kind, id, label}]}, or null. Raw selected ids stay beside it for the tree's own rows.
|
|
174
196
|
const publishSelection = (selectionOrigin = 'tree') => lifecycle === 'ready' && send({ type: 'selection', selectedId: selectedId(), selectedIds: selectedIds(),
|
|
175
|
-
subjects: selectedSubjects(), selectionOrigin });
|
|
197
|
+
subjects: selectedSubjects(), selectionOrigin, ...selectionState() });
|
|
176
198
|
const actionResult = (requestId, ok, message = '') => send({ type: 'action-result', requestId, ok, message });
|
|
177
199
|
|
|
178
200
|
const receive = (event) => {
|
|
@@ -209,6 +231,27 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
|
|
|
209
231
|
actionResult(data.requestId, ok, ok ? '' : 'That model group has changed. Try opening it again.');
|
|
210
232
|
return;
|
|
211
233
|
}
|
|
234
|
+
if (data.action === 'select-group' && typeof data.groupId === 'string') {
|
|
235
|
+
let ok = false;
|
|
236
|
+
try { ok = data.datasetKey === datasetKey && !!selectGroup(data.groupId); if (ok) { publishSnapshot(); publishSelection('tree'); } }
|
|
237
|
+
catch (error) { try { win.console?.error?.('[model-panel] group selection failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
238
|
+
actionResult(data.requestId, ok, ok ? '' : 'That model group has changed. Try selecting it again.');
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (data.action === 'search' && typeof data.tab === 'string' && typeof data.query === 'string' && data.query.length <= 200) {
|
|
242
|
+
let ok = false;
|
|
243
|
+
try { ok = data.datasetKey === datasetKey && !!search(data.tab, data.query); if (ok) publishSnapshot(); }
|
|
244
|
+
catch (error) { try { win.console?.error?.('[model-panel] search action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
245
|
+
actionResult(data.requestId, ok, ok ? '' : 'Object search could not be updated. Reopen the model and try again.');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (data.action === 'grid-visibility' && (data.levelKey === null || typeof data.levelKey === 'string') && typeof data.visible === 'boolean') {
|
|
249
|
+
let ok = false;
|
|
250
|
+
try { ok = data.datasetKey === datasetKey && !!gridVisibility({ levelKey: data.levelKey, visible: data.visible }); if (ok) publishSnapshot(); }
|
|
251
|
+
catch (error) { try { win.console?.error?.('[model-panel] grid visibility action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
252
|
+
actionResult(data.requestId, ok, ok ? '' : 'Grid visibility could not be updated. Try again.');
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
212
255
|
// The main window shows one of the snapshot's panelTabs (tab: its key) or has left them (tab: null). `person` is
|
|
213
256
|
// true when a person chose it (a click on the tab), not the main window restoring or following the editor's reveal.
|
|
214
257
|
// `follow` is the Follow selection switch, for a panel tab that declared `follows` (it re-arrives when the switch flips).
|