@mlightcad/cad-diff-viewer 1.6.3
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/LICENSE +21 -0
- package/README.md +203 -0
- package/dist/cad-diff-viewer.js +3543 -0
- package/dist/cad-diff-viewer.umd.cjs +969 -0
- package/lib/AcApDiffSettingsDialog.d.ts +99 -0
- package/lib/AcApDiffSettingsDialog.d.ts.map +1 -0
- package/lib/AcApDiffSettingsDialog.js +534 -0
- package/lib/AcApDiffSettingsDialog.js.map +1 -0
- package/lib/AcApDiffViewer.d.ts +532 -0
- package/lib/AcApDiffViewer.d.ts.map +1 -0
- package/lib/AcApDiffViewer.js +2757 -0
- package/lib/AcApDiffViewer.js.map +1 -0
- package/lib/compare/acapCompareChangeSets.d.ts +54 -0
- package/lib/compare/acapCompareChangeSets.d.ts.map +1 -0
- package/lib/compare/acapCompareChangeSets.js +191 -0
- package/lib/compare/acapCompareChangeSets.js.map +1 -0
- package/lib/compare/acapCompareDrawings.d.ts +116 -0
- package/lib/compare/acapCompareDrawings.d.ts.map +1 -0
- package/lib/compare/acapCompareDrawings.js +645 -0
- package/lib/compare/acapCompareDrawings.js.map +1 -0
- package/lib/compare/acapCompareSysVars.d.ts +97 -0
- package/lib/compare/acapCompareSysVars.d.ts.map +1 -0
- package/lib/compare/acapCompareSysVars.js +156 -0
- package/lib/compare/acapCompareSysVars.js.map +1 -0
- package/lib/compare/index.d.ts +4 -0
- package/lib/compare/index.d.ts.map +1 -0
- package/lib/compare/index.js +4 -0
- package/lib/compare/index.js.map +1 -0
- package/lib/i18n/index.d.ts +15 -0
- package/lib/i18n/index.d.ts.map +1 -0
- package/lib/i18n/index.js +30 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/i18n/messages.d.ts +527 -0
- package/lib/i18n/messages.d.ts.map +1 -0
- package/lib/i18n/messages.js +527 -0
- package/lib/i18n/messages.js.map +1 -0
- package/lib/icons.d.ts +29 -0
- package/lib/icons.d.ts.map +1 -0
- package/lib/icons.js +43 -0
- package/lib/icons.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/injectDiffViewerStyles.d.ts +3 -0
- package/lib/injectDiffViewerStyles.d.ts.map +1 -0
- package/lib/injectDiffViewerStyles.js +15 -0
- package/lib/injectDiffViewerStyles.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,2757 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
73
|
+
var __values = (this && this.__values) || function(o) {
|
|
74
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
75
|
+
if (m) return m.call(o);
|
|
76
|
+
if (o && typeof o.length === "number") return {
|
|
77
|
+
next: function () {
|
|
78
|
+
if (o && i >= o.length) o = void 0;
|
|
79
|
+
return { value: o && o[i++], done: !o };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
83
|
+
};
|
|
84
|
+
import { ACAP_DEFAULT_COMPARE_COLORS, AcApDocManager, AcApI18n, acedApplyUiTheme, AcEdOpenMode, createMarkupMeta, getMarkupPresenter, getMarkupStore, isMarkupVisible, listMarkupsForSession, runMarkupEdit, setMarkupVisible } from '@mlightcad/cad-simple-viewer';
|
|
85
|
+
import { ICON_ANNOTATION_HIDE, ICON_ANNOTATION_SHOW, ICON_CLEAR_MARKUPS, ICON_MARKUP_ARROW, ICON_MARKUP_CALLOUT, ICON_MARKUP_CIRCLE, ICON_MARKUP_CLOUD, ICON_MARKUP_LINE, ICON_MARKUP_RECT, ICON_MARKUP_STAMP, ICON_MARKUP_TEXT } from '@mlightcad/cad-simple-viewer/icons';
|
|
86
|
+
import { AcGeBox2d } from '@mlightcad/data-model';
|
|
87
|
+
import { acapDiffColorToCssHex, AcApDiffSettingsDialog } from './AcApDiffSettingsDialog';
|
|
88
|
+
import { acapChangeSetCloudRole, acapCompareDrawings, acapDefaultCompareSysVars, acapReadCompareSysVars, acapWriteCompareSysVars } from './compare';
|
|
89
|
+
import { acapDiffViewerT, acapRegisterDiffViewerI18n } from './i18n';
|
|
90
|
+
import { acapCreateEmptyFileIcon, acapCreateOpenFileIcon, ICON_COMPARE_CLOUDS, ICON_INFO, ICON_OVERLAY, ICON_RESULTS_PANEL, ICON_SETTINGS, ICON_SIDE_BY_SIDE, ICON_SYNC_VIEWS, ICON_THEME_MOON, ICON_THEME_SUNNY } from './icons';
|
|
91
|
+
import { acapInjectDiffViewerStyles } from './injectDiffViewerStyles';
|
|
92
|
+
/** Default open options used when the host does not supply {@link AcApDiffViewerOptions.openDocumentDefaults}. */
|
|
93
|
+
var DEFAULT_OPEN = {
|
|
94
|
+
minimumChunkSize: 1000,
|
|
95
|
+
mode: AcEdOpenMode.Write,
|
|
96
|
+
progressiveRendering: false,
|
|
97
|
+
sysVars: {
|
|
98
|
+
lwdisplay: false
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/** File-name pattern accepted by pane drop / file-picker open. */
|
|
102
|
+
var DRAWING_EXT = /\.(dwg|dxf)$/i;
|
|
103
|
+
/** Markup comment used to find clouds created from compare change sets. */
|
|
104
|
+
var COMPARE_CLOUD_COMMENT = 'cad-diff-viewer:changeset';
|
|
105
|
+
/** Delay before live-preview sysvar edits re-run compare (slider drags). */
|
|
106
|
+
var COMPARE_SYSVAR_PREVIEW_MS = 200;
|
|
107
|
+
/** Toolbar markup commands shown in the widget chrome. */
|
|
108
|
+
var MARKUP_TOOLS = [
|
|
109
|
+
{ command: 'markupcloud', labelKey: 'markupCloud', icon: ICON_MARKUP_CLOUD },
|
|
110
|
+
{ command: 'markuprect', labelKey: 'markupRect', icon: ICON_MARKUP_RECT },
|
|
111
|
+
{ command: 'markupcircle', labelKey: 'markupCircle', icon: ICON_MARKUP_CIRCLE },
|
|
112
|
+
{ command: 'markupcallout', labelKey: 'markupCallout', icon: ICON_MARKUP_CALLOUT },
|
|
113
|
+
{ command: 'markuparrow', labelKey: 'markupArrow', icon: ICON_MARKUP_ARROW },
|
|
114
|
+
{ command: 'markupline', labelKey: 'markupLine', icon: ICON_MARKUP_LINE },
|
|
115
|
+
{ command: 'markuptext', labelKey: 'markupText', icon: ICON_MARKUP_TEXT },
|
|
116
|
+
{ command: 'markupstamp', labelKey: 'markupStamp', icon: ICON_MARKUP_STAMP }
|
|
117
|
+
];
|
|
118
|
+
/** Language options shown in the toolbar select (same labels as cad-viewer ribbon). */
|
|
119
|
+
var LOCALE_OPTIONS = [
|
|
120
|
+
{ locale: 'en', label: 'English' },
|
|
121
|
+
{ locale: 'zh', label: '简体中文' },
|
|
122
|
+
{ locale: 'tr', label: 'Türkçe' },
|
|
123
|
+
{ locale: 'cs', label: 'Čeština' },
|
|
124
|
+
{ locale: 'ar', label: 'العربية' }
|
|
125
|
+
];
|
|
126
|
+
/** Caret used by the language select trigger (Element Plus-style). */
|
|
127
|
+
var LOCALE_CHEVRON = '<svg class="ml-diff-lang-select__caret" viewBox="0 0 12 12" aria-hidden="true"><path fill="currentColor" d="M2.4 4.2 6 8.1l3.6-3.9"/></svg>';
|
|
128
|
+
/** Visible label for a locale code. */
|
|
129
|
+
function localeOptionLabel(locale) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
return ((_b = (_a = LOCALE_OPTIONS.find(function (option) { return option.locale === locale; })) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : 'English');
|
|
132
|
+
}
|
|
133
|
+
/** i18n keys for field ids stored on {@link AcApDiffEntityHit.changes}. */
|
|
134
|
+
var DIFF_FIELD_I18N = {
|
|
135
|
+
objectId: 'fieldObjectId',
|
|
136
|
+
layer: 'fieldLayer',
|
|
137
|
+
color: 'fieldColor',
|
|
138
|
+
lineType: 'fieldLineType',
|
|
139
|
+
lineWeight: 'fieldLineWeight',
|
|
140
|
+
lineTypeScale: 'fieldLineTypeScale',
|
|
141
|
+
transparency: 'fieldTransparency',
|
|
142
|
+
thickness: 'fieldThickness',
|
|
143
|
+
visibility: 'fieldVisibility',
|
|
144
|
+
startPoint: 'fieldStartPoint',
|
|
145
|
+
endPoint: 'fieldEndPoint',
|
|
146
|
+
center: 'fieldCenter',
|
|
147
|
+
radius: 'fieldRadius',
|
|
148
|
+
startAngle: 'fieldStartAngle',
|
|
149
|
+
endAngle: 'fieldEndAngle',
|
|
150
|
+
position: 'fieldPosition',
|
|
151
|
+
location: 'fieldLocation',
|
|
152
|
+
rotation: 'fieldRotation',
|
|
153
|
+
height: 'fieldHeight',
|
|
154
|
+
blockName: 'fieldBlockName',
|
|
155
|
+
scale: 'fieldScale',
|
|
156
|
+
text: 'fieldText',
|
|
157
|
+
mtext: 'fieldMtext',
|
|
158
|
+
extents: 'fieldExtents',
|
|
159
|
+
geometry: 'fieldGeometry'
|
|
160
|
+
};
|
|
161
|
+
/** Localized label for a compare field id. */
|
|
162
|
+
function diffFieldLabel(field) {
|
|
163
|
+
var key = DIFF_FIELD_I18N[field];
|
|
164
|
+
return key ? acapDiffViewerT(key) : field;
|
|
165
|
+
}
|
|
166
|
+
/** Localized display value for a compare field. */
|
|
167
|
+
function formatDiffValue(field, value) {
|
|
168
|
+
if (value === '')
|
|
169
|
+
return '—';
|
|
170
|
+
if (field === 'visibility') {
|
|
171
|
+
return value === 'true'
|
|
172
|
+
? acapDiffViewerT('diffVisible')
|
|
173
|
+
: acapDiffViewerT('diffHidden');
|
|
174
|
+
}
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns the process-wide {@link AcApDocManager} created by this widget.
|
|
179
|
+
*
|
|
180
|
+
* @throws If the widget has not been constructed, or the manager was destroyed.
|
|
181
|
+
*/
|
|
182
|
+
function requireInstance() {
|
|
183
|
+
try {
|
|
184
|
+
return AcApDocManager.instance;
|
|
185
|
+
}
|
|
186
|
+
catch (_a) {
|
|
187
|
+
throw new Error('AcApDiffViewer is not initialized');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Returns true when `fileName` has a `.dwg` or `.dxf` extension. */
|
|
191
|
+
function isDrawingFile(fileName) {
|
|
192
|
+
return DRAWING_EXT.test(fileName);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Merges host compare colors onto {@link ACAP_DEFAULT_COMPARE_COLORS}.
|
|
196
|
+
*
|
|
197
|
+
* @param colors - Optional color overrides from {@link AcApDiffViewerOptions}.
|
|
198
|
+
*/
|
|
199
|
+
function mergeColors(colors) {
|
|
200
|
+
return __assign(__assign({}, ACAP_DEFAULT_COMPARE_COLORS), colors);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Side-by-side / overlay CAD comparison widget built on {@link AcApDocManager}.
|
|
204
|
+
*/
|
|
205
|
+
var AcApDiffViewer = /** @class */ (function () {
|
|
206
|
+
/**
|
|
207
|
+
* Creates the widget, injects styles, and constructs a dedicated
|
|
208
|
+
* {@link AcApDocManager} bound to the left canvas (and a split view for the right).
|
|
209
|
+
*
|
|
210
|
+
* @param options - Host container, workers, colors, and optional callbacks.
|
|
211
|
+
* @throws If an {@link AcApDocManager} already exists in this page.
|
|
212
|
+
*/
|
|
213
|
+
function AcApDiffViewer(options) {
|
|
214
|
+
var _a;
|
|
215
|
+
var _this = this;
|
|
216
|
+
var _b, _c, _d;
|
|
217
|
+
/** Markup tool buttons, kept so locale changes can refresh labels. */
|
|
218
|
+
this.markupButtons = [];
|
|
219
|
+
/** Nested `dragenter`/`dragleave` depth for the left pane. */
|
|
220
|
+
this.leftDragDepth = 0;
|
|
221
|
+
/** Nested `dragenter`/`dragleave` depth for the right pane. */
|
|
222
|
+
this.rightDragDepth = 0;
|
|
223
|
+
/** Auto-hide timers for per-pane error banners. */
|
|
224
|
+
this.bannerTimers = new Map();
|
|
225
|
+
/** How the results list is grouped. */
|
|
226
|
+
this.resultGroupMode = 'kind';
|
|
227
|
+
/**
|
|
228
|
+
* Collapsed result-list sections, keyed by
|
|
229
|
+
* `${resultGroupMode}:${groupKey}`. Missing keys are expanded.
|
|
230
|
+
*/
|
|
231
|
+
this.collapsedResultGroups = new Set();
|
|
232
|
+
/** Active side-panel tab. */
|
|
233
|
+
this.activeTab = 'results';
|
|
234
|
+
/** Index into {@link AcApDiffCompareResult.navigation}, or `-1` when unset. */
|
|
235
|
+
this.navIndex = -1;
|
|
236
|
+
/** True after {@link destroy} has run. */
|
|
237
|
+
this.disposed = false;
|
|
238
|
+
/** Whether the language dropdown is open. */
|
|
239
|
+
this.localeMenuOpen = false;
|
|
240
|
+
/** When true, the popover stays open until dismissed. */
|
|
241
|
+
this.diffPopoverPinned = false;
|
|
242
|
+
/** Timer used to delay hiding the popover after mouse leave. */
|
|
243
|
+
this.diffPopoverHideTimer = 0;
|
|
244
|
+
/** Monotonic id so overlapping {@link activateSide} calls keep the latest pane. */
|
|
245
|
+
this.activateSeq = 0;
|
|
246
|
+
/** Serializes {@link activateSide} so hover switches do not overlap. */
|
|
247
|
+
this.activateTail = Promise.resolve();
|
|
248
|
+
/** Monotonic id so overlapping {@link runCompareAndApply} calls keep the latest result. */
|
|
249
|
+
this.compareSeq = 0;
|
|
250
|
+
/**
|
|
251
|
+
* Monotonic id so overlapping {@link enterOverlayMode} calls drop stale
|
|
252
|
+
* overlay registrations instead of leaking them.
|
|
253
|
+
*/
|
|
254
|
+
this.overlayRegisterSeq = 0;
|
|
255
|
+
/** Timer used to debounce Settings sysvar live preview. */
|
|
256
|
+
this.sysVarPreviewTimer = 0;
|
|
257
|
+
/**
|
|
258
|
+
* Last pane the pointer entered. Toolbar markup commands target this side
|
|
259
|
+
* even after the pointer leaves for the toolbar.
|
|
260
|
+
*/
|
|
261
|
+
this.lastPointerSide = 'left';
|
|
262
|
+
/** When true, pan/zoom on one side-by-side canvas is copied to the other. */
|
|
263
|
+
this.viewsSynced = false;
|
|
264
|
+
/** Re-entrancy guard so a copied camera does not echo back. */
|
|
265
|
+
this.viewSyncLock = false;
|
|
266
|
+
/** Side whose camera is copied onto the other pane while sync is on. */
|
|
267
|
+
this.viewSyncLeader = 'left';
|
|
268
|
+
/**
|
|
269
|
+
* After opening into the follower pane, ignore its auto-fit until the
|
|
270
|
+
* user pans or zooms so the already-open drawing keeps its camera.
|
|
271
|
+
*/
|
|
272
|
+
this.viewSyncFollowOpen = false;
|
|
273
|
+
/** True when the latest pan/zoom came from pointer or wheel on a pane. */
|
|
274
|
+
this.viewSyncFromUser = false;
|
|
275
|
+
/** Relocalizes chrome and lists when {@link AcApI18n} locale changes. */
|
|
276
|
+
this.handleLocaleChanged = function () {
|
|
277
|
+
if (_this.disposed)
|
|
278
|
+
return;
|
|
279
|
+
_this.setLocaleMenuOpen(false);
|
|
280
|
+
_this.syncChrome();
|
|
281
|
+
_this.syncViewModeUi();
|
|
282
|
+
_this.syncPanelUi();
|
|
283
|
+
_this.renderResultsList();
|
|
284
|
+
_this.refreshMarkupsList();
|
|
285
|
+
};
|
|
286
|
+
/** Closes the language menu and unpinned diff popover when clicking outside. */
|
|
287
|
+
this.handleDocumentPointerDown = function (event) {
|
|
288
|
+
var _a;
|
|
289
|
+
if (!(event.target instanceof Node))
|
|
290
|
+
return;
|
|
291
|
+
if (_this.localeMenuOpen && !_this.localeSelectHost.contains(event.target)) {
|
|
292
|
+
_this.setLocaleMenuOpen(false);
|
|
293
|
+
}
|
|
294
|
+
if (!_this.diffPopoverPinned)
|
|
295
|
+
return;
|
|
296
|
+
if (_this.diffPopover.contains(event.target))
|
|
297
|
+
return;
|
|
298
|
+
if ((_a = _this.diffPopoverAnchor) === null || _a === void 0 ? void 0 : _a.contains(event.target))
|
|
299
|
+
return;
|
|
300
|
+
_this.hideDiffPopover(true);
|
|
301
|
+
};
|
|
302
|
+
this.handleDiffPopoverDismiss = function () {
|
|
303
|
+
_this.hideDiffPopover(true);
|
|
304
|
+
};
|
|
305
|
+
this.cancelDiffPopoverHide = function () {
|
|
306
|
+
if (_this.diffPopoverHideTimer) {
|
|
307
|
+
window.clearTimeout(_this.diffPopoverHideTimer);
|
|
308
|
+
_this.diffPopoverHideTimer = 0;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
this.scheduleDiffPopoverHide = function () {
|
|
312
|
+
if (_this.diffPopoverPinned)
|
|
313
|
+
return;
|
|
314
|
+
_this.cancelDiffPopoverHide();
|
|
315
|
+
_this.diffPopoverHideTimer = window.setTimeout(function () {
|
|
316
|
+
_this.diffPopoverHideTimer = 0;
|
|
317
|
+
_this.hideDiffPopover(false);
|
|
318
|
+
}, 180);
|
|
319
|
+
};
|
|
320
|
+
/** Marks the next camera change as coming from the user, not auto-fit. */
|
|
321
|
+
this.markViewSyncUserInput = function () {
|
|
322
|
+
_this.viewSyncFromUser = true;
|
|
323
|
+
};
|
|
324
|
+
this.handleLeftViewChanged = function () {
|
|
325
|
+
_this.onPaneViewChanged('left');
|
|
326
|
+
};
|
|
327
|
+
this.handleRightViewChanged = function () {
|
|
328
|
+
_this.onPaneViewChanged('right');
|
|
329
|
+
};
|
|
330
|
+
this.options = options;
|
|
331
|
+
this.colors = mergeColors(options.compareColors);
|
|
332
|
+
this.sessionSysVars = acapDefaultCompareSysVars();
|
|
333
|
+
this.uiTheme = (_b = options.theme) !== null && _b !== void 0 ? _b : 'dark';
|
|
334
|
+
this.viewMode = (_c = options.viewMode) !== null && _c !== void 0 ? _c : 'side-by-side';
|
|
335
|
+
this.sidePanelOpen = options.sidePanelOpen !== false;
|
|
336
|
+
acapRegisterDiffViewerI18n();
|
|
337
|
+
acapInjectDiffViewerStyles();
|
|
338
|
+
var alreadyCreated = false;
|
|
339
|
+
try {
|
|
340
|
+
AcApDocManager.instance;
|
|
341
|
+
alreadyCreated = true;
|
|
342
|
+
}
|
|
343
|
+
catch (_e) {
|
|
344
|
+
alreadyCreated = false;
|
|
345
|
+
}
|
|
346
|
+
if (alreadyCreated) {
|
|
347
|
+
throw new Error('AcApDiffViewer needs its own AcApDocManager. Create it on a page that does not already host a CAD viewer.');
|
|
348
|
+
}
|
|
349
|
+
this.root = document.createElement('div');
|
|
350
|
+
this.root.className = 'ml-diff-root';
|
|
351
|
+
acedApplyUiTheme(this.uiTheme, this.root);
|
|
352
|
+
this.toolbar = document.createElement('div');
|
|
353
|
+
this.toolbar.className = 'ml-diff-toolbar';
|
|
354
|
+
this.body = document.createElement('div');
|
|
355
|
+
this.body.className = 'ml-diff-body';
|
|
356
|
+
this.panesHost = document.createElement('div');
|
|
357
|
+
this.panesHost.className = 'ml-diff-panes';
|
|
358
|
+
this.leftUi = this.createPane('left');
|
|
359
|
+
this.rightUi = this.createPane('right');
|
|
360
|
+
this.panesHost.append(this.leftUi.pane, this.rightUi.pane);
|
|
361
|
+
var chrome = this.createChrome();
|
|
362
|
+
this.btnSideBySide = chrome.btnSideBySide;
|
|
363
|
+
this.btnOverlay = chrome.btnOverlay;
|
|
364
|
+
this.btnSyncViews = chrome.btnSyncViews;
|
|
365
|
+
this.btnTogglePanel = chrome.btnTogglePanel;
|
|
366
|
+
this.btnPrev = chrome.btnPrev;
|
|
367
|
+
this.btnNext = chrome.btnNext;
|
|
368
|
+
this.btnSettings = chrome.btnSettings;
|
|
369
|
+
this.btnMarkupVis = chrome.btnMarkupVis;
|
|
370
|
+
this.btnClearMarkups = chrome.btnClearMarkups;
|
|
371
|
+
this.btnTheme = chrome.btnTheme;
|
|
372
|
+
this.sidePanel = chrome.sidePanel;
|
|
373
|
+
this.resultsBody = chrome.resultsBody;
|
|
374
|
+
this.markupsBody = chrome.markupsBody;
|
|
375
|
+
this.tabResults = chrome.tabResults;
|
|
376
|
+
this.tabMarkups = chrome.tabMarkups;
|
|
377
|
+
this.groupByKindBtn = chrome.groupByKindBtn;
|
|
378
|
+
this.groupByTypeBtn = chrome.groupByTypeBtn;
|
|
379
|
+
this.panelTitle = chrome.panelTitle;
|
|
380
|
+
this.localeTrigger = chrome.localeTrigger;
|
|
381
|
+
this.localeMenu = chrome.localeMenu;
|
|
382
|
+
this.localeSelectHost = chrome.localeSelectHost;
|
|
383
|
+
this.diffPopover = document.createElement('div');
|
|
384
|
+
this.diffPopover.className = 'ml-diff-change-popover';
|
|
385
|
+
this.diffPopover.hidden = true;
|
|
386
|
+
this.diffPopover.setAttribute('role', 'tooltip');
|
|
387
|
+
this.diffPopover.addEventListener('mouseenter', this.cancelDiffPopoverHide);
|
|
388
|
+
this.diffPopover.addEventListener('mouseleave', this.scheduleDiffPopoverHide);
|
|
389
|
+
(_a = this.toolbar).append.apply(_a, __spreadArray([], __read(chrome.toolbarChildren), false));
|
|
390
|
+
this.body.append(this.panesHost, this.sidePanel);
|
|
391
|
+
this.root.append(this.toolbar, this.body, this.diffPopover);
|
|
392
|
+
options.container.appendChild(this.root);
|
|
393
|
+
var openDefaults = (_d = options.openDocumentDefaults) !== null && _d !== void 0 ? _d : DEFAULT_OPEN;
|
|
394
|
+
AcApDocManager.createInstance({
|
|
395
|
+
container: this.leftUi.canvas,
|
|
396
|
+
busyIndicatorHost: this.leftUi.canvas,
|
|
397
|
+
autoResize: true,
|
|
398
|
+
baseUrl: options.baseUrl,
|
|
399
|
+
builtinOpenFileDialog: false,
|
|
400
|
+
openDocumentDefaults: openDefaults,
|
|
401
|
+
webworkerFileUrls: options.webworkerFileUrls
|
|
402
|
+
});
|
|
403
|
+
var mgr = AcApDocManager.instance;
|
|
404
|
+
this.disableEntitySelection(mgr.mainView);
|
|
405
|
+
this.disableEntitySelection(mgr.ensureSplitView(this.rightUi.canvas));
|
|
406
|
+
this.bindViewSyncListeners();
|
|
407
|
+
AcApI18n.events.localeChanged.addEventListener(this.handleLocaleChanged);
|
|
408
|
+
document.addEventListener('pointerdown', this.handleDocumentPointerDown);
|
|
409
|
+
this.resultsBody.addEventListener('scroll', this.handleDiffPopoverDismiss);
|
|
410
|
+
window.addEventListener('resize', this.handleDiffPopoverDismiss);
|
|
411
|
+
this.syncChrome();
|
|
412
|
+
this.syncViewModeUi();
|
|
413
|
+
this.syncPanelUi();
|
|
414
|
+
this.syncCompareColorVars();
|
|
415
|
+
}
|
|
416
|
+
Object.defineProperty(AcApDiffViewer.prototype, "leftDocument", {
|
|
417
|
+
/** Drawing currently shown in the left pane, if still live. */
|
|
418
|
+
get: function () {
|
|
419
|
+
return this.liveDoc(this.leftDoc);
|
|
420
|
+
},
|
|
421
|
+
enumerable: false,
|
|
422
|
+
configurable: true
|
|
423
|
+
});
|
|
424
|
+
Object.defineProperty(AcApDiffViewer.prototype, "rightDocument", {
|
|
425
|
+
/** Drawing currently shown in the right pane, if still live. */
|
|
426
|
+
get: function () {
|
|
427
|
+
return this.liveDoc(this.rightDoc);
|
|
428
|
+
},
|
|
429
|
+
enumerable: false,
|
|
430
|
+
configurable: true
|
|
431
|
+
});
|
|
432
|
+
Object.defineProperty(AcApDiffViewer.prototype, "activeSide", {
|
|
433
|
+
/** Pane that currently owns commands (the active {@link AcApDocManager} document). */
|
|
434
|
+
get: function () {
|
|
435
|
+
var mgr = requireInstance();
|
|
436
|
+
return mgr.curDocument === this.rightDocument ? 'right' : 'left';
|
|
437
|
+
},
|
|
438
|
+
enumerable: false,
|
|
439
|
+
configurable: true
|
|
440
|
+
});
|
|
441
|
+
Object.defineProperty(AcApDiffViewer.prototype, "compareResultSnapshot", {
|
|
442
|
+
/** Last compare result, or `undefined` until both panes have drawings. */
|
|
443
|
+
get: function () {
|
|
444
|
+
return this.compareResult;
|
|
445
|
+
},
|
|
446
|
+
enumerable: false,
|
|
447
|
+
configurable: true
|
|
448
|
+
});
|
|
449
|
+
/**
|
|
450
|
+
* Opens a drawing into one pane from in-memory file content.
|
|
451
|
+
*
|
|
452
|
+
* @param side - Target pane.
|
|
453
|
+
* @param fileName - File name used for format detection and the pane title.
|
|
454
|
+
* @param content - DWG/DXF bytes.
|
|
455
|
+
* @param options - Optional open options; falls back to construction defaults.
|
|
456
|
+
* @returns `true` when the document opened successfully.
|
|
457
|
+
*/
|
|
458
|
+
AcApDiffViewer.prototype.openDocument = function (side, fileName, content, options) {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var mgr, wasOverlay, existing, otherDoc, success, doc;
|
|
461
|
+
var _a, _b, _c, _d, _e;
|
|
462
|
+
return __generator(this, function (_f) {
|
|
463
|
+
switch (_f.label) {
|
|
464
|
+
case 0:
|
|
465
|
+
this.assertAlive();
|
|
466
|
+
mgr = requireInstance();
|
|
467
|
+
wasOverlay = this.viewMode === 'overlay';
|
|
468
|
+
if (!wasOverlay) return [3 /*break*/, 2];
|
|
469
|
+
return [4 /*yield*/, this.exitOverlayMode()];
|
|
470
|
+
case 1:
|
|
471
|
+
_f.sent();
|
|
472
|
+
_f.label = 2;
|
|
473
|
+
case 2:
|
|
474
|
+
existing = side === 'left' ? this.leftDoc : this.rightDoc;
|
|
475
|
+
otherDoc = side === 'left' ? this.rightDoc : this.leftDoc;
|
|
476
|
+
if (!(existing &&
|
|
477
|
+
mgr.sessionFor(existing) &&
|
|
478
|
+
!existing.isReusableUntitled &&
|
|
479
|
+
existing !== otherDoc)) return [3 /*break*/, 4];
|
|
480
|
+
return [4 /*yield*/, mgr.closeDocument(existing)];
|
|
481
|
+
case 3:
|
|
482
|
+
_f.sent();
|
|
483
|
+
_f.label = 4;
|
|
484
|
+
case 4:
|
|
485
|
+
this.uiFor(side).empty.classList.add('is-hidden');
|
|
486
|
+
this.clearPaneError(side);
|
|
487
|
+
return [4 /*yield*/, mgr.openDocument(fileName, content, (_a = options !== null && options !== void 0 ? options : this.options.openDocumentDefaults) !== null && _a !== void 0 ? _a : DEFAULT_OPEN, this.viewFor(side))];
|
|
488
|
+
case 5:
|
|
489
|
+
success = _f.sent();
|
|
490
|
+
if (!!success) return [3 /*break*/, 8];
|
|
491
|
+
(_c = (_b = this.options.events) === null || _b === void 0 ? void 0 : _b.failed) === null || _c === void 0 ? void 0 : _c.call(_b, side, fileName);
|
|
492
|
+
this.syncChrome();
|
|
493
|
+
if (!wasOverlay) return [3 /*break*/, 7];
|
|
494
|
+
return [4 /*yield*/, this.enterOverlayMode()];
|
|
495
|
+
case 6:
|
|
496
|
+
_f.sent();
|
|
497
|
+
this.syncViewModeUi();
|
|
498
|
+
_f.label = 7;
|
|
499
|
+
case 7: return [2 /*return*/, false];
|
|
500
|
+
case 8:
|
|
501
|
+
doc = mgr.curDocument;
|
|
502
|
+
if (side === 'left')
|
|
503
|
+
this.leftDoc = doc;
|
|
504
|
+
else
|
|
505
|
+
this.rightDoc = doc;
|
|
506
|
+
this.adoptCompareSysVarsAfterOpen(doc, Boolean(this.liveDoc(otherDoc)));
|
|
507
|
+
this.syncChrome();
|
|
508
|
+
(_e = (_d = this.options.events) === null || _d === void 0 ? void 0 : _d.opened) === null || _e === void 0 ? void 0 : _e.call(_d, side, doc);
|
|
509
|
+
this.syncFollowerAfterOpen(side);
|
|
510
|
+
this.applyMarkupVisibility(isMarkupVisible());
|
|
511
|
+
return [4 /*yield*/, this.runCompareAndApply()];
|
|
512
|
+
case 9:
|
|
513
|
+
_f.sent();
|
|
514
|
+
return [2 /*return*/, true];
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* Makes `side` the command target without changing which canvas shows which drawing.
|
|
521
|
+
*
|
|
522
|
+
* @param side - Pane to activate.
|
|
523
|
+
* @returns `false` when that pane has no live document.
|
|
524
|
+
*/
|
|
525
|
+
AcApDiffViewer.prototype.activateSide = function (side) {
|
|
526
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
527
|
+
var doc, mgr, seq, run, result;
|
|
528
|
+
var _this = this;
|
|
529
|
+
return __generator(this, function (_a) {
|
|
530
|
+
this.assertAlive();
|
|
531
|
+
doc = side === 'left' ? this.leftDocument : this.rightDocument;
|
|
532
|
+
if (!doc)
|
|
533
|
+
return [2 /*return*/, false];
|
|
534
|
+
mgr = requireInstance();
|
|
535
|
+
// Same-document checks must be synchronous. Queuing would bump
|
|
536
|
+
// {@link activateSeq} and can cancel an in-flight markup via
|
|
537
|
+
// {@link AcApDocManager.activateDocument}.
|
|
538
|
+
if (mgr.curDocument === doc) {
|
|
539
|
+
this.applyFocusClass(side);
|
|
540
|
+
return [2 /*return*/, true];
|
|
541
|
+
}
|
|
542
|
+
seq = ++this.activateSeq;
|
|
543
|
+
run = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
544
|
+
var live, instance, ok;
|
|
545
|
+
var _a, _b;
|
|
546
|
+
return __generator(this, function (_c) {
|
|
547
|
+
switch (_c.label) {
|
|
548
|
+
case 0:
|
|
549
|
+
if (this.disposed || seq !== this.activateSeq)
|
|
550
|
+
return [2 /*return*/, false];
|
|
551
|
+
live = side === 'left' ? this.leftDocument : this.rightDocument;
|
|
552
|
+
if (!live)
|
|
553
|
+
return [2 /*return*/, false];
|
|
554
|
+
instance = requireInstance();
|
|
555
|
+
if (instance.curDocument === live) {
|
|
556
|
+
this.applyFocusClass(side);
|
|
557
|
+
return [2 /*return*/, true];
|
|
558
|
+
}
|
|
559
|
+
return [4 /*yield*/, instance.activateDocument(live)];
|
|
560
|
+
case 1:
|
|
561
|
+
ok = _c.sent();
|
|
562
|
+
if (this.disposed || seq !== this.activateSeq) {
|
|
563
|
+
if (!this.disposed)
|
|
564
|
+
this.syncFocusRings();
|
|
565
|
+
return [2 /*return*/, false];
|
|
566
|
+
}
|
|
567
|
+
this.applyFocusClass(side);
|
|
568
|
+
this.refreshMarkupsList();
|
|
569
|
+
if (ok)
|
|
570
|
+
(_b = (_a = this.options.events) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a, side);
|
|
571
|
+
return [2 /*return*/, ok];
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}); };
|
|
575
|
+
result = this.activateTail.then(run, run);
|
|
576
|
+
this.activateTail = result.then(function () { return undefined; }, function () { return undefined; });
|
|
577
|
+
return [2 /*return*/, result];
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* Switches between side-by-side canvases and a single overlay canvas.
|
|
583
|
+
*
|
|
584
|
+
* @param mode - Target view mode.
|
|
585
|
+
*/
|
|
586
|
+
AcApDiffViewer.prototype.setViewMode = function (mode) {
|
|
587
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
588
|
+
return __generator(this, function (_a) {
|
|
589
|
+
switch (_a.label) {
|
|
590
|
+
case 0:
|
|
591
|
+
this.assertAlive();
|
|
592
|
+
if (mode === this.viewMode)
|
|
593
|
+
return [2 /*return*/];
|
|
594
|
+
if (!(mode === 'overlay')) return [3 /*break*/, 2];
|
|
595
|
+
return [4 /*yield*/, this.enterOverlayMode()];
|
|
596
|
+
case 1:
|
|
597
|
+
_a.sent();
|
|
598
|
+
return [3 /*break*/, 4];
|
|
599
|
+
case 2: return [4 /*yield*/, this.exitOverlayMode()];
|
|
600
|
+
case 3:
|
|
601
|
+
_a.sent();
|
|
602
|
+
_a.label = 4;
|
|
603
|
+
case 4:
|
|
604
|
+
this.viewMode = mode;
|
|
605
|
+
this.syncViewModeUi();
|
|
606
|
+
if (mode === 'side-by-side')
|
|
607
|
+
this.applyViewSyncFromLeader();
|
|
608
|
+
return [4 /*yield*/, this.applyCompareDisplay()];
|
|
609
|
+
case 5:
|
|
610
|
+
_a.sent();
|
|
611
|
+
window.dispatchEvent(new Event('resize'));
|
|
612
|
+
return [2 /*return*/];
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* Expands or collapses the compare-results side panel.
|
|
619
|
+
*
|
|
620
|
+
* @param open - `true` to show the panel.
|
|
621
|
+
*/
|
|
622
|
+
AcApDiffViewer.prototype.setSidePanelOpen = function (open) {
|
|
623
|
+
this.sidePanelOpen = open;
|
|
624
|
+
this.syncPanelUi();
|
|
625
|
+
window.dispatchEvent(new Event('resize'));
|
|
626
|
+
};
|
|
627
|
+
/**
|
|
628
|
+
* Moves the current difference by `delta` entries in the navigation list.
|
|
629
|
+
*
|
|
630
|
+
* @param delta - Typically `-1` (previous) or `1` (next).
|
|
631
|
+
*/
|
|
632
|
+
AcApDiffViewer.prototype.goToDifference = function (delta) {
|
|
633
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
634
|
+
var nav, nextIndex, hit;
|
|
635
|
+
var _a, _b;
|
|
636
|
+
return __generator(this, function (_c) {
|
|
637
|
+
switch (_c.label) {
|
|
638
|
+
case 0:
|
|
639
|
+
nav = (_b = (_a = this.compareResult) === null || _a === void 0 ? void 0 : _a.navigation) !== null && _b !== void 0 ? _b : [];
|
|
640
|
+
if (nav.length === 0)
|
|
641
|
+
return [2 /*return*/];
|
|
642
|
+
if (this.navIndex < 0) {
|
|
643
|
+
if (delta > 0)
|
|
644
|
+
nextIndex = 0;
|
|
645
|
+
else if (delta < 0)
|
|
646
|
+
nextIndex = nav.length - 1;
|
|
647
|
+
else
|
|
648
|
+
return [2 /*return*/];
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
nextIndex = this.navIndex + delta;
|
|
652
|
+
if (nextIndex < 0 || nextIndex >= nav.length)
|
|
653
|
+
return [2 /*return*/];
|
|
654
|
+
}
|
|
655
|
+
this.navIndex = nextIndex;
|
|
656
|
+
hit = nav[this.navIndex];
|
|
657
|
+
this.collapsedResultGroups.delete(this.resultGroupStorageKeyForHit(hit));
|
|
658
|
+
return [4 /*yield*/, this.focusHit(hit)];
|
|
659
|
+
case 1:
|
|
660
|
+
_c.sent();
|
|
661
|
+
this.renderResultsList();
|
|
662
|
+
return [2 /*return*/];
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
};
|
|
667
|
+
/**
|
|
668
|
+
* Tears down the widget, document manager, and injected DOM.
|
|
669
|
+
* Safe to call more than once.
|
|
670
|
+
*/
|
|
671
|
+
AcApDiffViewer.prototype.destroy = function () {
|
|
672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
673
|
+
var _a, _b, timer, _c;
|
|
674
|
+
var e_1, _d;
|
|
675
|
+
return __generator(this, function (_e) {
|
|
676
|
+
switch (_e.label) {
|
|
677
|
+
case 0:
|
|
678
|
+
if (this.disposed)
|
|
679
|
+
return [2 /*return*/];
|
|
680
|
+
this.disposed = true;
|
|
681
|
+
this.compareSeq++;
|
|
682
|
+
this.overlayRegisterSeq++;
|
|
683
|
+
this.clearSysVarPreviewTimer();
|
|
684
|
+
AcApDiffSettingsDialog.dismiss();
|
|
685
|
+
AcApI18n.events.localeChanged.removeEventListener(this.handleLocaleChanged);
|
|
686
|
+
document.removeEventListener('pointerdown', this.handleDocumentPointerDown);
|
|
687
|
+
this.resultsBody.removeEventListener('scroll', this.handleDiffPopoverDismiss);
|
|
688
|
+
window.removeEventListener('resize', this.handleDiffPopoverDismiss);
|
|
689
|
+
this.hideDiffPopover(true);
|
|
690
|
+
this.unbindViewSyncListeners();
|
|
691
|
+
try {
|
|
692
|
+
for (_a = __values(this.bannerTimers.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
693
|
+
timer = _b.value;
|
|
694
|
+
window.clearTimeout(timer);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
698
|
+
finally {
|
|
699
|
+
try {
|
|
700
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
701
|
+
}
|
|
702
|
+
finally { if (e_1) throw e_1.error; }
|
|
703
|
+
}
|
|
704
|
+
this.bannerTimers.clear();
|
|
705
|
+
_e.label = 1;
|
|
706
|
+
case 1:
|
|
707
|
+
_e.trys.push([1, 3, , 4]);
|
|
708
|
+
if (this.overlayId) {
|
|
709
|
+
requireInstance().removeOverlay(this.overlayId);
|
|
710
|
+
}
|
|
711
|
+
return [4 /*yield*/, AcApDocManager.instance.destroy()];
|
|
712
|
+
case 2:
|
|
713
|
+
_e.sent();
|
|
714
|
+
return [3 /*break*/, 4];
|
|
715
|
+
case 3:
|
|
716
|
+
_c = _e.sent();
|
|
717
|
+
return [3 /*break*/, 4];
|
|
718
|
+
case 4:
|
|
719
|
+
this.root.remove();
|
|
720
|
+
return [2 /*return*/];
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
/**
|
|
726
|
+
* Builds the toolbar, side panel, and their event bindings.
|
|
727
|
+
*
|
|
728
|
+
* @returns Chrome nodes assigned onto class fields by the constructor.
|
|
729
|
+
*/
|
|
730
|
+
AcApDiffViewer.prototype.createChrome = function () {
|
|
731
|
+
var e_2, _a;
|
|
732
|
+
var _this = this;
|
|
733
|
+
var modeGroup = document.createElement('div');
|
|
734
|
+
modeGroup.className = 'ml-diff-toolbar-group';
|
|
735
|
+
var btnSideBySide = document.createElement('button');
|
|
736
|
+
btnSideBySide.type = 'button';
|
|
737
|
+
btnSideBySide.className = 'ml-diff-tool-btn is-icon';
|
|
738
|
+
btnSideBySide.innerHTML = ICON_SIDE_BY_SIDE;
|
|
739
|
+
var btnOverlay = document.createElement('button');
|
|
740
|
+
btnOverlay.type = 'button';
|
|
741
|
+
btnOverlay.className = 'ml-diff-tool-btn is-icon';
|
|
742
|
+
btnOverlay.innerHTML = ICON_OVERLAY;
|
|
743
|
+
var btnSyncViews = document.createElement('button');
|
|
744
|
+
btnSyncViews.type = 'button';
|
|
745
|
+
btnSyncViews.className = 'ml-diff-tool-btn is-icon ml-diff-sync-btn';
|
|
746
|
+
btnSyncViews.innerHTML = ICON_SYNC_VIEWS;
|
|
747
|
+
modeGroup.append(btnSideBySide, btnOverlay, btnSyncViews);
|
|
748
|
+
var navGroup = document.createElement('div');
|
|
749
|
+
navGroup.className = 'ml-diff-toolbar-group';
|
|
750
|
+
var btnTogglePanel = document.createElement('button');
|
|
751
|
+
btnTogglePanel.type = 'button';
|
|
752
|
+
btnTogglePanel.className = 'ml-diff-tool-btn is-icon';
|
|
753
|
+
btnTogglePanel.innerHTML = ICON_RESULTS_PANEL;
|
|
754
|
+
var btnPrev = document.createElement('button');
|
|
755
|
+
btnPrev.type = 'button';
|
|
756
|
+
btnPrev.className = 'ml-diff-tool-btn';
|
|
757
|
+
btnPrev.textContent = '◀';
|
|
758
|
+
btnPrev.disabled = true;
|
|
759
|
+
var btnNext = document.createElement('button');
|
|
760
|
+
btnNext.type = 'button';
|
|
761
|
+
btnNext.className = 'ml-diff-tool-btn';
|
|
762
|
+
btnNext.textContent = '▶';
|
|
763
|
+
btnNext.disabled = true;
|
|
764
|
+
navGroup.append(btnTogglePanel, btnPrev, btnNext);
|
|
765
|
+
var markupGroup = document.createElement('div');
|
|
766
|
+
markupGroup.className = 'ml-diff-toolbar-group';
|
|
767
|
+
var btnGenerateClouds = document.createElement('button');
|
|
768
|
+
btnGenerateClouds.type = 'button';
|
|
769
|
+
btnGenerateClouds.className = 'ml-diff-tool-btn is-icon';
|
|
770
|
+
btnGenerateClouds.dataset.labelKey = 'markupGenerateClouds';
|
|
771
|
+
btnGenerateClouds.disabled = true;
|
|
772
|
+
btnGenerateClouds.innerHTML = ICON_COMPARE_CLOUDS;
|
|
773
|
+
btnGenerateClouds.addEventListener('click', function () {
|
|
774
|
+
void _this.generateCompareCloudMarkups();
|
|
775
|
+
});
|
|
776
|
+
this.markupButtons.push(btnGenerateClouds);
|
|
777
|
+
markupGroup.appendChild(btnGenerateClouds);
|
|
778
|
+
var _loop_1 = function (tool) {
|
|
779
|
+
var btn = document.createElement('button');
|
|
780
|
+
btn.type = 'button';
|
|
781
|
+
btn.className = 'ml-diff-tool-btn is-icon';
|
|
782
|
+
btn.dataset.command = tool.command;
|
|
783
|
+
btn.dataset.labelKey = tool.labelKey;
|
|
784
|
+
btn.innerHTML = tool.icon;
|
|
785
|
+
btn.addEventListener('click', function () {
|
|
786
|
+
void _this.runMarkupCommand(tool.command);
|
|
787
|
+
});
|
|
788
|
+
this_1.markupButtons.push(btn);
|
|
789
|
+
markupGroup.appendChild(btn);
|
|
790
|
+
};
|
|
791
|
+
var this_1 = this;
|
|
792
|
+
try {
|
|
793
|
+
for (var MARKUP_TOOLS_1 = __values(MARKUP_TOOLS), MARKUP_TOOLS_1_1 = MARKUP_TOOLS_1.next(); !MARKUP_TOOLS_1_1.done; MARKUP_TOOLS_1_1 = MARKUP_TOOLS_1.next()) {
|
|
794
|
+
var tool = MARKUP_TOOLS_1_1.value;
|
|
795
|
+
_loop_1(tool);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
799
|
+
finally {
|
|
800
|
+
try {
|
|
801
|
+
if (MARKUP_TOOLS_1_1 && !MARKUP_TOOLS_1_1.done && (_a = MARKUP_TOOLS_1.return)) _a.call(MARKUP_TOOLS_1);
|
|
802
|
+
}
|
|
803
|
+
finally { if (e_2) throw e_2.error; }
|
|
804
|
+
}
|
|
805
|
+
var btnMarkupVis = document.createElement('button');
|
|
806
|
+
btnMarkupVis.type = 'button';
|
|
807
|
+
btnMarkupVis.className = 'ml-diff-tool-btn is-icon';
|
|
808
|
+
btnMarkupVis.addEventListener('click', function () {
|
|
809
|
+
_this.toggleMarkupVisibility();
|
|
810
|
+
});
|
|
811
|
+
markupGroup.appendChild(btnMarkupVis);
|
|
812
|
+
var btnClearMarkups = document.createElement('button');
|
|
813
|
+
btnClearMarkups.type = 'button';
|
|
814
|
+
btnClearMarkups.className = 'ml-diff-tool-btn is-icon';
|
|
815
|
+
btnClearMarkups.dataset.labelKey = 'markupClear';
|
|
816
|
+
btnClearMarkups.innerHTML = ICON_CLEAR_MARKUPS;
|
|
817
|
+
btnClearMarkups.addEventListener('click', function () {
|
|
818
|
+
void _this.clearAllMarkups();
|
|
819
|
+
});
|
|
820
|
+
this.markupButtons.push(btnClearMarkups);
|
|
821
|
+
markupGroup.appendChild(btnClearMarkups);
|
|
822
|
+
var localeChrome = this.createLanguageSelect();
|
|
823
|
+
var btnSettings = document.createElement('button');
|
|
824
|
+
btnSettings.type = 'button';
|
|
825
|
+
btnSettings.className = 'ml-diff-tool-btn is-icon';
|
|
826
|
+
btnSettings.innerHTML = ICON_SETTINGS;
|
|
827
|
+
var btnTheme = document.createElement('button');
|
|
828
|
+
btnTheme.type = 'button';
|
|
829
|
+
btnTheme.className = 'ml-diff-tool-btn is-icon';
|
|
830
|
+
localeChrome.group.prepend(btnSettings, btnTheme);
|
|
831
|
+
btnSideBySide.addEventListener('click', function () {
|
|
832
|
+
void _this.setViewMode('side-by-side');
|
|
833
|
+
});
|
|
834
|
+
btnOverlay.addEventListener('click', function () {
|
|
835
|
+
void _this.setViewMode('overlay');
|
|
836
|
+
});
|
|
837
|
+
btnSyncViews.addEventListener('click', function () {
|
|
838
|
+
_this.setViewsSynced(!_this.viewsSynced);
|
|
839
|
+
});
|
|
840
|
+
btnTogglePanel.addEventListener('click', function () {
|
|
841
|
+
_this.setSidePanelOpen(!_this.sidePanelOpen);
|
|
842
|
+
});
|
|
843
|
+
btnPrev.addEventListener('click', function () {
|
|
844
|
+
void _this.goToDifference(-1);
|
|
845
|
+
});
|
|
846
|
+
btnNext.addEventListener('click', function () {
|
|
847
|
+
void _this.goToDifference(1);
|
|
848
|
+
});
|
|
849
|
+
btnSettings.addEventListener('click', function () {
|
|
850
|
+
void _this.openSettings();
|
|
851
|
+
});
|
|
852
|
+
btnTheme.addEventListener('click', function () {
|
|
853
|
+
_this.setUiTheme(_this.uiTheme === 'dark' ? 'light' : 'dark');
|
|
854
|
+
});
|
|
855
|
+
var sidePanel = document.createElement('aside');
|
|
856
|
+
sidePanel.className = 'ml-diff-sidepanel';
|
|
857
|
+
var header = document.createElement('div');
|
|
858
|
+
header.className = 'ml-diff-sidepanel-header';
|
|
859
|
+
var panelTitle = document.createElement('div');
|
|
860
|
+
panelTitle.className = 'ml-diff-sidepanel-title';
|
|
861
|
+
var closeBtn = document.createElement('button');
|
|
862
|
+
closeBtn.type = 'button';
|
|
863
|
+
closeBtn.className = 'ml-diff-tool-btn';
|
|
864
|
+
closeBtn.textContent = '×';
|
|
865
|
+
closeBtn.addEventListener('click', function () { return _this.setSidePanelOpen(false); });
|
|
866
|
+
header.append(panelTitle, closeBtn);
|
|
867
|
+
var tabs = document.createElement('div');
|
|
868
|
+
tabs.className = 'ml-diff-sidepanel-tabs';
|
|
869
|
+
var tabResults = document.createElement('button');
|
|
870
|
+
tabResults.type = 'button';
|
|
871
|
+
tabResults.className = 'ml-diff-sidepanel-tab is-active';
|
|
872
|
+
var tabMarkups = document.createElement('button');
|
|
873
|
+
tabMarkups.type = 'button';
|
|
874
|
+
tabMarkups.className = 'ml-diff-sidepanel-tab';
|
|
875
|
+
tabs.append(tabResults, tabMarkups);
|
|
876
|
+
tabResults.addEventListener('click', function () {
|
|
877
|
+
_this.activeTab = 'results';
|
|
878
|
+
_this.syncPanelUi();
|
|
879
|
+
});
|
|
880
|
+
tabMarkups.addEventListener('click', function () {
|
|
881
|
+
_this.activeTab = 'markups';
|
|
882
|
+
_this.syncPanelUi();
|
|
883
|
+
_this.refreshMarkupsList();
|
|
884
|
+
});
|
|
885
|
+
var groupBar = document.createElement('div');
|
|
886
|
+
groupBar.className = 'ml-diff-sidepanel-toolbar';
|
|
887
|
+
var groupByKindBtn = document.createElement('button');
|
|
888
|
+
groupByKindBtn.type = 'button';
|
|
889
|
+
groupByKindBtn.className = 'ml-diff-tool-btn is-active';
|
|
890
|
+
var groupByTypeBtn = document.createElement('button');
|
|
891
|
+
groupByTypeBtn.type = 'button';
|
|
892
|
+
groupByTypeBtn.className = 'ml-diff-tool-btn';
|
|
893
|
+
groupBar.append(groupByKindBtn, groupByTypeBtn);
|
|
894
|
+
groupByKindBtn.addEventListener('click', function () {
|
|
895
|
+
_this.resultGroupMode = 'kind';
|
|
896
|
+
_this.renderResultsList();
|
|
897
|
+
_this.syncPanelUi();
|
|
898
|
+
});
|
|
899
|
+
groupByTypeBtn.addEventListener('click', function () {
|
|
900
|
+
_this.resultGroupMode = 'type';
|
|
901
|
+
_this.renderResultsList();
|
|
902
|
+
_this.syncPanelUi();
|
|
903
|
+
});
|
|
904
|
+
var resultsBody = document.createElement('div');
|
|
905
|
+
resultsBody.className = 'ml-diff-sidepanel-body';
|
|
906
|
+
var markupsBody = document.createElement('div');
|
|
907
|
+
markupsBody.className = 'ml-diff-sidepanel-body';
|
|
908
|
+
markupsBody.hidden = true;
|
|
909
|
+
sidePanel.append(header, tabs, groupBar, resultsBody, markupsBody);
|
|
910
|
+
return {
|
|
911
|
+
toolbarChildren: [modeGroup, navGroup, markupGroup, localeChrome.group],
|
|
912
|
+
btnSideBySide: btnSideBySide,
|
|
913
|
+
btnOverlay: btnOverlay,
|
|
914
|
+
btnSyncViews: btnSyncViews,
|
|
915
|
+
btnTogglePanel: btnTogglePanel,
|
|
916
|
+
btnPrev: btnPrev,
|
|
917
|
+
btnNext: btnNext,
|
|
918
|
+
btnSettings: btnSettings,
|
|
919
|
+
btnGenerateClouds: btnGenerateClouds,
|
|
920
|
+
btnMarkupVis: btnMarkupVis,
|
|
921
|
+
btnClearMarkups: btnClearMarkups,
|
|
922
|
+
btnTheme: btnTheme,
|
|
923
|
+
sidePanel: sidePanel,
|
|
924
|
+
resultsBody: resultsBody,
|
|
925
|
+
markupsBody: markupsBody,
|
|
926
|
+
tabResults: tabResults,
|
|
927
|
+
tabMarkups: tabMarkups,
|
|
928
|
+
groupByKindBtn: groupByKindBtn,
|
|
929
|
+
groupByTypeBtn: groupByTypeBtn,
|
|
930
|
+
panelTitle: panelTitle,
|
|
931
|
+
closeBtn: closeBtn,
|
|
932
|
+
localeTrigger: localeChrome.trigger,
|
|
933
|
+
localeMenu: localeChrome.menu,
|
|
934
|
+
localeSelectHost: localeChrome.host
|
|
935
|
+
};
|
|
936
|
+
};
|
|
937
|
+
/**
|
|
938
|
+
* Builds the far-right language select (compact dropdown like cad-viewer ribbon).
|
|
939
|
+
*/
|
|
940
|
+
AcApDiffViewer.prototype.createLanguageSelect = function () {
|
|
941
|
+
var e_3, _a;
|
|
942
|
+
var _this = this;
|
|
943
|
+
var group = document.createElement('div');
|
|
944
|
+
group.className = 'ml-diff-toolbar-group ml-diff-toolbar-locale';
|
|
945
|
+
var host = document.createElement('div');
|
|
946
|
+
host.className = 'ml-diff-lang-select';
|
|
947
|
+
var trigger = document.createElement('button');
|
|
948
|
+
trigger.type = 'button';
|
|
949
|
+
trigger.className = 'ml-diff-lang-select__trigger';
|
|
950
|
+
trigger.setAttribute('aria-haspopup', 'listbox');
|
|
951
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
952
|
+
var label = document.createElement('span');
|
|
953
|
+
label.className = 'ml-diff-lang-select__label';
|
|
954
|
+
trigger.append(label);
|
|
955
|
+
trigger.insertAdjacentHTML('beforeend', LOCALE_CHEVRON);
|
|
956
|
+
trigger.addEventListener('click', function (event) {
|
|
957
|
+
event.stopPropagation();
|
|
958
|
+
_this.setLocaleMenuOpen(!_this.localeMenuOpen);
|
|
959
|
+
});
|
|
960
|
+
var menu = document.createElement('div');
|
|
961
|
+
menu.className = 'ml-diff-lang-select__menu';
|
|
962
|
+
menu.setAttribute('role', 'listbox');
|
|
963
|
+
menu.hidden = true;
|
|
964
|
+
var _loop_2 = function (option) {
|
|
965
|
+
var btn = document.createElement('button');
|
|
966
|
+
btn.type = 'button';
|
|
967
|
+
btn.className = 'ml-diff-lang-select__option';
|
|
968
|
+
btn.setAttribute('role', 'option');
|
|
969
|
+
btn.dataset.locale = option.locale;
|
|
970
|
+
btn.textContent = option.label;
|
|
971
|
+
btn.addEventListener('click', function (event) {
|
|
972
|
+
event.stopPropagation();
|
|
973
|
+
_this.setLocaleMenuOpen(false);
|
|
974
|
+
if (option.locale === AcApI18n.currentLocale)
|
|
975
|
+
return;
|
|
976
|
+
AcApI18n.setCurrentLocale(option.locale);
|
|
977
|
+
document.documentElement.lang = option.locale;
|
|
978
|
+
});
|
|
979
|
+
menu.appendChild(btn);
|
|
980
|
+
};
|
|
981
|
+
try {
|
|
982
|
+
for (var LOCALE_OPTIONS_1 = __values(LOCALE_OPTIONS), LOCALE_OPTIONS_1_1 = LOCALE_OPTIONS_1.next(); !LOCALE_OPTIONS_1_1.done; LOCALE_OPTIONS_1_1 = LOCALE_OPTIONS_1.next()) {
|
|
983
|
+
var option = LOCALE_OPTIONS_1_1.value;
|
|
984
|
+
_loop_2(option);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
988
|
+
finally {
|
|
989
|
+
try {
|
|
990
|
+
if (LOCALE_OPTIONS_1_1 && !LOCALE_OPTIONS_1_1.done && (_a = LOCALE_OPTIONS_1.return)) _a.call(LOCALE_OPTIONS_1);
|
|
991
|
+
}
|
|
992
|
+
finally { if (e_3) throw e_3.error; }
|
|
993
|
+
}
|
|
994
|
+
host.append(trigger, menu);
|
|
995
|
+
group.appendChild(host);
|
|
996
|
+
return { group: group, host: host, trigger: trigger, menu: menu };
|
|
997
|
+
};
|
|
998
|
+
/** Opens or closes the language dropdown. */
|
|
999
|
+
AcApDiffViewer.prototype.setLocaleMenuOpen = function (open) {
|
|
1000
|
+
this.localeMenuOpen = open;
|
|
1001
|
+
this.localeMenu.hidden = !open;
|
|
1002
|
+
this.localeTrigger.setAttribute('aria-expanded', String(open));
|
|
1003
|
+
this.localeSelectHost.classList.toggle('is-open', open);
|
|
1004
|
+
};
|
|
1005
|
+
/** Highlights the active locale and refreshes the trigger label. */
|
|
1006
|
+
AcApDiffViewer.prototype.syncLocaleSelect = function () {
|
|
1007
|
+
var current = AcApI18n.currentLocale;
|
|
1008
|
+
var label = this.localeTrigger.querySelector('.ml-diff-lang-select__label');
|
|
1009
|
+
if (label)
|
|
1010
|
+
label.textContent = localeOptionLabel(current);
|
|
1011
|
+
this.localeTrigger.title = acapDiffViewerT('toolbarLanguage');
|
|
1012
|
+
this.localeTrigger.setAttribute('aria-label', acapDiffViewerT('toolbarLanguage'));
|
|
1013
|
+
this.localeMenu
|
|
1014
|
+
.querySelectorAll('.ml-diff-lang-select__option')
|
|
1015
|
+
.forEach(function (btn) {
|
|
1016
|
+
var selected = btn.dataset.locale === current;
|
|
1017
|
+
btn.classList.toggle('is-selected', selected);
|
|
1018
|
+
btn.setAttribute('aria-selected', String(selected));
|
|
1019
|
+
});
|
|
1020
|
+
};
|
|
1021
|
+
/**
|
|
1022
|
+
* Builds one pane (header, canvas slot, empty state, drop target).
|
|
1023
|
+
*
|
|
1024
|
+
* @param side - Which pane to create.
|
|
1025
|
+
*/
|
|
1026
|
+
AcApDiffViewer.prototype.createPane = function (side) {
|
|
1027
|
+
var _this = this;
|
|
1028
|
+
var pane = document.createElement('section');
|
|
1029
|
+
pane.className = 'ml-diff-pane';
|
|
1030
|
+
pane.dataset.side = side;
|
|
1031
|
+
if (side === 'left')
|
|
1032
|
+
pane.classList.add('is-focused');
|
|
1033
|
+
var header = document.createElement('header');
|
|
1034
|
+
header.className = 'ml-diff-header';
|
|
1035
|
+
var title = document.createElement('span');
|
|
1036
|
+
title.className = 'ml-diff-title is-empty';
|
|
1037
|
+
var openButton = document.createElement('button');
|
|
1038
|
+
openButton.type = 'button';
|
|
1039
|
+
openButton.className = 'ml-diff-open';
|
|
1040
|
+
openButton.appendChild(acapCreateOpenFileIcon());
|
|
1041
|
+
var fileInput = document.createElement('input');
|
|
1042
|
+
fileInput.type = 'file';
|
|
1043
|
+
fileInput.className = 'ml-diff-file-input';
|
|
1044
|
+
fileInput.accept = '.dwg,.dxf,application/acad,application/dxf';
|
|
1045
|
+
fileInput.tabIndex = -1;
|
|
1046
|
+
header.append(title, openButton, fileInput);
|
|
1047
|
+
var slot = document.createElement('div');
|
|
1048
|
+
slot.className = 'ml-diff-canvas-slot';
|
|
1049
|
+
var canvas = document.createElement('div');
|
|
1050
|
+
canvas.className = 'ml-diff-canvas';
|
|
1051
|
+
var empty = document.createElement('div');
|
|
1052
|
+
empty.className = 'ml-diff-empty';
|
|
1053
|
+
var card = document.createElement('div');
|
|
1054
|
+
card.className = 'ml-diff-empty-card';
|
|
1055
|
+
var emptyTitle = document.createElement('div');
|
|
1056
|
+
emptyTitle.className = 'ml-diff-empty-title';
|
|
1057
|
+
var emptyHint = document.createElement('div');
|
|
1058
|
+
emptyHint.className = 'ml-diff-empty-hint';
|
|
1059
|
+
var emptyError = document.createElement('div');
|
|
1060
|
+
emptyError.className = 'ml-diff-empty-error is-hidden';
|
|
1061
|
+
card.append(acapCreateEmptyFileIcon(), emptyTitle, emptyHint, emptyError);
|
|
1062
|
+
empty.appendChild(card);
|
|
1063
|
+
var banner = document.createElement('div');
|
|
1064
|
+
banner.className = 'ml-diff-banner is-hidden';
|
|
1065
|
+
slot.append(canvas, empty, banner);
|
|
1066
|
+
pane.append(header, slot);
|
|
1067
|
+
pane.addEventListener('pointerenter', function () {
|
|
1068
|
+
_this.activateSideOnHover(side);
|
|
1069
|
+
});
|
|
1070
|
+
pane.addEventListener('pointerdown', function () {
|
|
1071
|
+
_this.lastPointerSide = side;
|
|
1072
|
+
_this.applyFocusClass(side);
|
|
1073
|
+
void _this.activateSideAndResumeMarkup(side);
|
|
1074
|
+
});
|
|
1075
|
+
pane.addEventListener('click', function (event) {
|
|
1076
|
+
if (_this.documentFor(side))
|
|
1077
|
+
return;
|
|
1078
|
+
var target = event.target;
|
|
1079
|
+
if (target === null || target === void 0 ? void 0 : target.closest('.ml-diff-open'))
|
|
1080
|
+
return;
|
|
1081
|
+
_this.pickFile(side);
|
|
1082
|
+
});
|
|
1083
|
+
openButton.addEventListener('click', function (event) {
|
|
1084
|
+
event.preventDefault();
|
|
1085
|
+
event.stopPropagation();
|
|
1086
|
+
_this.pickFile(side);
|
|
1087
|
+
});
|
|
1088
|
+
fileInput.addEventListener('change', function () {
|
|
1089
|
+
var _a;
|
|
1090
|
+
var file = (_a = fileInput.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
1091
|
+
fileInput.value = '';
|
|
1092
|
+
if (file)
|
|
1093
|
+
void _this.openLocalFile(side, file);
|
|
1094
|
+
});
|
|
1095
|
+
pane.addEventListener('dragenter', function (event) {
|
|
1096
|
+
event.preventDefault();
|
|
1097
|
+
_this.changeDragDepth(side, 1);
|
|
1098
|
+
});
|
|
1099
|
+
pane.addEventListener('dragover', function (event) {
|
|
1100
|
+
event.preventDefault();
|
|
1101
|
+
if (event.dataTransfer)
|
|
1102
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
1103
|
+
});
|
|
1104
|
+
pane.addEventListener('dragleave', function (event) {
|
|
1105
|
+
event.preventDefault();
|
|
1106
|
+
_this.changeDragDepth(side, -1);
|
|
1107
|
+
});
|
|
1108
|
+
pane.addEventListener('drop', function (event) {
|
|
1109
|
+
var _a, _b;
|
|
1110
|
+
event.preventDefault();
|
|
1111
|
+
_this.resetDragDepth(side);
|
|
1112
|
+
var file = (_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
|
|
1113
|
+
if (file)
|
|
1114
|
+
void _this.openLocalFile(side, file);
|
|
1115
|
+
});
|
|
1116
|
+
return {
|
|
1117
|
+
pane: pane,
|
|
1118
|
+
canvas: canvas,
|
|
1119
|
+
title: title,
|
|
1120
|
+
empty: empty,
|
|
1121
|
+
emptyTitle: emptyTitle,
|
|
1122
|
+
emptyHint: emptyHint,
|
|
1123
|
+
emptyError: emptyError,
|
|
1124
|
+
banner: banner,
|
|
1125
|
+
openButton: openButton,
|
|
1126
|
+
fileInput: fileInput
|
|
1127
|
+
};
|
|
1128
|
+
};
|
|
1129
|
+
/**
|
|
1130
|
+
* Activates `side` when the pointer enters the pane in side-by-side mode.
|
|
1131
|
+
*
|
|
1132
|
+
* If a markup command is already running on the other pane, it is cancelled
|
|
1133
|
+
* by document activation and restarted on this pane so the tool follows
|
|
1134
|
+
* the pointer.
|
|
1135
|
+
*/
|
|
1136
|
+
AcApDiffViewer.prototype.activateSideOnHover = function (side) {
|
|
1137
|
+
if (this.disposed)
|
|
1138
|
+
return;
|
|
1139
|
+
if (this.viewMode !== 'side-by-side')
|
|
1140
|
+
return;
|
|
1141
|
+
this.lastPointerSide = side;
|
|
1142
|
+
this.applyFocusClass(side);
|
|
1143
|
+
void this.activateSideAndResumeMarkup(side);
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* Makes `side` the command target. When a markup tool is in progress on the
|
|
1147
|
+
* other document, re-issues it after the switch so drawing can continue here.
|
|
1148
|
+
*/
|
|
1149
|
+
AcApDiffViewer.prototype.activateSideAndResumeMarkup = function (side) {
|
|
1150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1151
|
+
var resume, mgr, ok;
|
|
1152
|
+
return __generator(this, function (_a) {
|
|
1153
|
+
switch (_a.label) {
|
|
1154
|
+
case 0:
|
|
1155
|
+
if (this.disposed)
|
|
1156
|
+
return [2 /*return*/];
|
|
1157
|
+
if (!this.documentFor(side))
|
|
1158
|
+
return [2 /*return*/];
|
|
1159
|
+
try {
|
|
1160
|
+
mgr = requireInstance();
|
|
1161
|
+
if (mgr.commandManager.activeCommand &&
|
|
1162
|
+
this.lastMarkupCommand &&
|
|
1163
|
+
mgr.curDocument !== this.documentFor(side)) {
|
|
1164
|
+
resume = this.lastMarkupCommand;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
catch (_b) {
|
|
1168
|
+
return [2 /*return*/];
|
|
1169
|
+
}
|
|
1170
|
+
return [4 /*yield*/, this.activateSide(side)];
|
|
1171
|
+
case 1:
|
|
1172
|
+
ok = _a.sent();
|
|
1173
|
+
if (!ok || this.disposed)
|
|
1174
|
+
return [2 /*return*/];
|
|
1175
|
+
if (this.lastPointerSide !== side)
|
|
1176
|
+
return [2 /*return*/];
|
|
1177
|
+
this.applyFocusClass(side);
|
|
1178
|
+
if (resume) {
|
|
1179
|
+
requireInstance().sendStringToExecute(resume);
|
|
1180
|
+
}
|
|
1181
|
+
return [2 /*return*/];
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
});
|
|
1185
|
+
};
|
|
1186
|
+
/** Opens the hidden file picker for `side`. */
|
|
1187
|
+
AcApDiffViewer.prototype.pickFile = function (side) {
|
|
1188
|
+
this.uiFor(side).fileInput.click();
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* Opens a local `File` into `side`, showing an error for non-drawing files.
|
|
1192
|
+
*
|
|
1193
|
+
* @param side - Target pane.
|
|
1194
|
+
* @param file - User-selected file.
|
|
1195
|
+
*/
|
|
1196
|
+
AcApDiffViewer.prototype.openLocalFile = function (side, file) {
|
|
1197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1198
|
+
var _a, _b;
|
|
1199
|
+
return __generator(this, function (_c) {
|
|
1200
|
+
switch (_c.label) {
|
|
1201
|
+
case 0:
|
|
1202
|
+
if (!isDrawingFile(file.name)) {
|
|
1203
|
+
this.showPaneError(side, acapDiffViewerT('invalidFile'));
|
|
1204
|
+
return [2 /*return*/];
|
|
1205
|
+
}
|
|
1206
|
+
_a = this.openDocument;
|
|
1207
|
+
_b = [side, file.name];
|
|
1208
|
+
return [4 /*yield*/, file.arrayBuffer()];
|
|
1209
|
+
case 1: return [4 /*yield*/, _a.apply(this, _b.concat([_c.sent()]))];
|
|
1210
|
+
case 2:
|
|
1211
|
+
_c.sent();
|
|
1212
|
+
return [2 /*return*/];
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
/**
|
|
1218
|
+
* Runs a markup command against the active pane's document.
|
|
1219
|
+
*
|
|
1220
|
+
* @param command - Registered command name (e.g. `markupcloud`).
|
|
1221
|
+
*/
|
|
1222
|
+
AcApDiffViewer.prototype.runMarkupCommand = function (command) {
|
|
1223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1224
|
+
var mgr, side, ok;
|
|
1225
|
+
return __generator(this, function (_a) {
|
|
1226
|
+
switch (_a.label) {
|
|
1227
|
+
case 0:
|
|
1228
|
+
mgr = requireInstance();
|
|
1229
|
+
side = this.viewMode === 'side-by-side' ? this.lastPointerSide : 'left';
|
|
1230
|
+
if (!this.documentFor(side))
|
|
1231
|
+
return [2 /*return*/];
|
|
1232
|
+
this.lastMarkupCommand = command;
|
|
1233
|
+
return [4 /*yield*/, this.activateSide(side)];
|
|
1234
|
+
case 1:
|
|
1235
|
+
ok = _a.sent();
|
|
1236
|
+
if (!ok)
|
|
1237
|
+
return [2 /*return*/];
|
|
1238
|
+
this.applyFocusClass(side);
|
|
1239
|
+
mgr.sendStringToExecute(command);
|
|
1240
|
+
return [2 /*return*/];
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
});
|
|
1244
|
+
};
|
|
1245
|
+
/**
|
|
1246
|
+
* Creates built-in markup clouds around the current compare change sets.
|
|
1247
|
+
*
|
|
1248
|
+
* Overlay mode commits every set onto the left drawing. Side-by-side commits
|
|
1249
|
+
* left-hit sets on the left pane and right-hit sets on the right pane.
|
|
1250
|
+
* Clouds previously generated this way are replaced.
|
|
1251
|
+
*/
|
|
1252
|
+
AcApDiffViewer.prototype.generateCompareCloudMarkups = function () {
|
|
1253
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1254
|
+
var sets, overlay;
|
|
1255
|
+
var _a;
|
|
1256
|
+
return __generator(this, function (_b) {
|
|
1257
|
+
switch (_b.label) {
|
|
1258
|
+
case 0:
|
|
1259
|
+
if (this.disposed)
|
|
1260
|
+
return [2 /*return*/];
|
|
1261
|
+
sets = (_a = this.compareResult) === null || _a === void 0 ? void 0 : _a.changeSets;
|
|
1262
|
+
if (!(sets === null || sets === void 0 ? void 0 : sets.length))
|
|
1263
|
+
return [2 /*return*/];
|
|
1264
|
+
overlay = this.viewMode === 'overlay';
|
|
1265
|
+
if (!overlay) return [3 /*break*/, 2];
|
|
1266
|
+
return [4 /*yield*/, this.commitChangeSetClouds('left', sets)];
|
|
1267
|
+
case 1:
|
|
1268
|
+
_b.sent();
|
|
1269
|
+
return [3 /*break*/, 5];
|
|
1270
|
+
case 2: return [4 /*yield*/, this.commitChangeSetClouds('left', sets.filter(function (set) { return set.hasLeft; }))];
|
|
1271
|
+
case 3:
|
|
1272
|
+
_b.sent();
|
|
1273
|
+
return [4 /*yield*/, this.commitChangeSetClouds('right', sets.filter(function (set) { return set.hasRight; }))];
|
|
1274
|
+
case 4:
|
|
1275
|
+
_b.sent();
|
|
1276
|
+
_b.label = 5;
|
|
1277
|
+
case 5:
|
|
1278
|
+
if (!this.disposed)
|
|
1279
|
+
this.refreshMarkupsList();
|
|
1280
|
+
return [2 /*return*/];
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
});
|
|
1284
|
+
};
|
|
1285
|
+
/**
|
|
1286
|
+
* Shows or hides markup overlays on every open pane.
|
|
1287
|
+
*
|
|
1288
|
+
* The session flag in cad-simple-viewer is global; both canvases are
|
|
1289
|
+
* updated so side-by-side views stay in sync.
|
|
1290
|
+
*/
|
|
1291
|
+
AcApDiffViewer.prototype.toggleMarkupVisibility = function () {
|
|
1292
|
+
if (this.disposed)
|
|
1293
|
+
return;
|
|
1294
|
+
if (!this.leftDocument && !this.rightDocument)
|
|
1295
|
+
return;
|
|
1296
|
+
this.applyMarkupVisibility(!isMarkupVisible());
|
|
1297
|
+
this.syncMarkupVisibilityButton();
|
|
1298
|
+
};
|
|
1299
|
+
/**
|
|
1300
|
+
* Applies markup-layer visibility to each pane that currently has a drawing.
|
|
1301
|
+
*
|
|
1302
|
+
* @param visible - Whether committed and live markup overlays should show.
|
|
1303
|
+
*/
|
|
1304
|
+
AcApDiffViewer.prototype.applyMarkupVisibility = function (visible) {
|
|
1305
|
+
if (this.leftDocument) {
|
|
1306
|
+
setMarkupVisible(this.viewFor('left'), visible);
|
|
1307
|
+
}
|
|
1308
|
+
if (this.rightDocument) {
|
|
1309
|
+
setMarkupVisible(this.viewFor('right'), visible);
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
/**
|
|
1313
|
+
* Clears Design Review markups on both open drawings (current layout).
|
|
1314
|
+
*/
|
|
1315
|
+
AcApDiffViewer.prototype.clearAllMarkups = function () {
|
|
1316
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1317
|
+
var _a, _b, side, ok, view, e_4_1;
|
|
1318
|
+
var e_4, _c;
|
|
1319
|
+
return __generator(this, function (_d) {
|
|
1320
|
+
switch (_d.label) {
|
|
1321
|
+
case 0:
|
|
1322
|
+
if (this.disposed)
|
|
1323
|
+
return [2 /*return*/];
|
|
1324
|
+
_d.label = 1;
|
|
1325
|
+
case 1:
|
|
1326
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
1327
|
+
_a = __values(['left', 'right']), _b = _a.next();
|
|
1328
|
+
_d.label = 2;
|
|
1329
|
+
case 2:
|
|
1330
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
1331
|
+
side = _b.value;
|
|
1332
|
+
if (!this.documentFor(side))
|
|
1333
|
+
return [3 /*break*/, 4];
|
|
1334
|
+
return [4 /*yield*/, this.activateSide(side)];
|
|
1335
|
+
case 3:
|
|
1336
|
+
ok = _d.sent();
|
|
1337
|
+
if (!ok || this.disposed)
|
|
1338
|
+
return [3 /*break*/, 4];
|
|
1339
|
+
view = this.viewFor(side);
|
|
1340
|
+
getMarkupPresenter().clearLayout(view, view.activeLayoutBtrId, {
|
|
1341
|
+
clearStore: true
|
|
1342
|
+
});
|
|
1343
|
+
_d.label = 4;
|
|
1344
|
+
case 4:
|
|
1345
|
+
_b = _a.next();
|
|
1346
|
+
return [3 /*break*/, 2];
|
|
1347
|
+
case 5: return [3 /*break*/, 8];
|
|
1348
|
+
case 6:
|
|
1349
|
+
e_4_1 = _d.sent();
|
|
1350
|
+
e_4 = { error: e_4_1 };
|
|
1351
|
+
return [3 /*break*/, 8];
|
|
1352
|
+
case 7:
|
|
1353
|
+
try {
|
|
1354
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1355
|
+
}
|
|
1356
|
+
finally { if (e_4) throw e_4.error; }
|
|
1357
|
+
return [7 /*endfinally*/];
|
|
1358
|
+
case 8:
|
|
1359
|
+
if (!this.disposed)
|
|
1360
|
+
this.refreshMarkupsList();
|
|
1361
|
+
return [2 /*return*/];
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
});
|
|
1365
|
+
};
|
|
1366
|
+
/**
|
|
1367
|
+
* Replaces previous compare-generated clouds on `side` with one markup
|
|
1368
|
+
* cloud per change set.
|
|
1369
|
+
*
|
|
1370
|
+
* @param side - Document session that receives the clouds.
|
|
1371
|
+
* @param sets - Change sets whose extents become cloud AABBs.
|
|
1372
|
+
*/
|
|
1373
|
+
AcApDiffViewer.prototype.commitChangeSetClouds = function (side, sets) {
|
|
1374
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1375
|
+
var ok, mgr, view, context;
|
|
1376
|
+
var _this = this;
|
|
1377
|
+
return __generator(this, function (_a) {
|
|
1378
|
+
switch (_a.label) {
|
|
1379
|
+
case 0: return [4 /*yield*/, this.activateSide(side)];
|
|
1380
|
+
case 1:
|
|
1381
|
+
ok = _a.sent();
|
|
1382
|
+
if (!ok || this.disposed)
|
|
1383
|
+
return [2 /*return*/];
|
|
1384
|
+
mgr = requireInstance();
|
|
1385
|
+
view = this.viewFor(side);
|
|
1386
|
+
context = mgr.context;
|
|
1387
|
+
runMarkupEdit(view, 'Create Markup', function () {
|
|
1388
|
+
var e_5, _a, e_6, _b;
|
|
1389
|
+
var store = getMarkupStore();
|
|
1390
|
+
var presenter = getMarkupPresenter();
|
|
1391
|
+
try {
|
|
1392
|
+
for (var _c = __values(store.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1393
|
+
var record = _d.value;
|
|
1394
|
+
if (record.type !== 'cloud' || record.comment !== COMPARE_CLOUD_COMMENT) {
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
presenter.unpublish(view, record.id, { keepInStore: true });
|
|
1398
|
+
store.removeRecord(record.id);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1402
|
+
finally {
|
|
1403
|
+
try {
|
|
1404
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1405
|
+
}
|
|
1406
|
+
finally { if (e_5) throw e_5.error; }
|
|
1407
|
+
}
|
|
1408
|
+
try {
|
|
1409
|
+
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
1410
|
+
var set = sets_1_1.value;
|
|
1411
|
+
var box = set.extents;
|
|
1412
|
+
if (box.maxX <= box.minX && box.maxY <= box.minY)
|
|
1413
|
+
continue;
|
|
1414
|
+
var meta = createMarkupMeta('cloud', view, context, {
|
|
1415
|
+
comment: COMPARE_CLOUD_COMMENT
|
|
1416
|
+
});
|
|
1417
|
+
var color = acapDiffColorToCssHex(_this.colors[acapChangeSetCloudRole(set)]);
|
|
1418
|
+
var record = __assign(__assign({}, meta), { type: 'cloud', style: __assign(__assign({}, meta.style), { color: color }), geometry: {
|
|
1419
|
+
type: 'cloud',
|
|
1420
|
+
corner1: { x: box.minX, y: box.minY },
|
|
1421
|
+
corner2: { x: box.maxX, y: box.maxY }
|
|
1422
|
+
} });
|
|
1423
|
+
store.upsert(record);
|
|
1424
|
+
presenter.publish(view, record);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1428
|
+
finally {
|
|
1429
|
+
try {
|
|
1430
|
+
if (sets_1_1 && !sets_1_1.done && (_b = sets_1.return)) _b.call(sets_1);
|
|
1431
|
+
}
|
|
1432
|
+
finally { if (e_6) throw e_6.error; }
|
|
1433
|
+
}
|
|
1434
|
+
});
|
|
1435
|
+
return [2 /*return*/];
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
});
|
|
1439
|
+
};
|
|
1440
|
+
/**
|
|
1441
|
+
* Opens the compare settings dialog. Edits preview live; Cancel restores
|
|
1442
|
+
* the colors and COMPARE sysvars that were in effect when the dialog opened.
|
|
1443
|
+
*/
|
|
1444
|
+
AcApDiffViewer.prototype.openSettings = function () {
|
|
1445
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1446
|
+
var snapshotColors, snapshotVars, result;
|
|
1447
|
+
var _this = this;
|
|
1448
|
+
return __generator(this, function (_a) {
|
|
1449
|
+
switch (_a.label) {
|
|
1450
|
+
case 0:
|
|
1451
|
+
if (this.disposed)
|
|
1452
|
+
return [2 /*return*/];
|
|
1453
|
+
snapshotColors = __assign({}, this.colors);
|
|
1454
|
+
snapshotVars = __assign({}, this.sessionSysVars);
|
|
1455
|
+
return [4 /*yield*/, AcApDiffSettingsDialog.open({
|
|
1456
|
+
host: document.body,
|
|
1457
|
+
theme: this.uiTheme,
|
|
1458
|
+
colors: this.colors,
|
|
1459
|
+
sysVars: this.sessionSysVars,
|
|
1460
|
+
onChange: function (draft) {
|
|
1461
|
+
if (_this.disposed)
|
|
1462
|
+
return;
|
|
1463
|
+
_this.applyCompareColors(draft.colors);
|
|
1464
|
+
var varsChanged = JSON.stringify(draft.sysVars) !== JSON.stringify(_this.sessionSysVars);
|
|
1465
|
+
if (varsChanged)
|
|
1466
|
+
_this.scheduleCompareSysVars(draft.sysVars);
|
|
1467
|
+
}
|
|
1468
|
+
})];
|
|
1469
|
+
case 1:
|
|
1470
|
+
result = _a.sent();
|
|
1471
|
+
if (this.disposed)
|
|
1472
|
+
return [2 /*return*/];
|
|
1473
|
+
if (!result.confirmed) {
|
|
1474
|
+
this.applyCompareColors(snapshotColors);
|
|
1475
|
+
this.flushCompareSysVars(snapshotVars);
|
|
1476
|
+
return [2 /*return*/];
|
|
1477
|
+
}
|
|
1478
|
+
this.flushCompareSysVars(result.sysVars);
|
|
1479
|
+
return [2 /*return*/];
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
});
|
|
1483
|
+
};
|
|
1484
|
+
/**
|
|
1485
|
+
* Adopts COMPARE sysvars after a pane opens a drawing.
|
|
1486
|
+
*
|
|
1487
|
+
* Drawing-saved variables are read from the new file when the other pane is
|
|
1488
|
+
* empty. When a comparison is already in progress, the current session is
|
|
1489
|
+
* written onto the new drawing so both panes stay in sync.
|
|
1490
|
+
*
|
|
1491
|
+
* @param doc - Newly opened document.
|
|
1492
|
+
* @param otherIsOpen - True when the opposite pane already has a drawing.
|
|
1493
|
+
*/
|
|
1494
|
+
AcApDiffViewer.prototype.adoptCompareSysVarsAfterOpen = function (doc, otherIsOpen) {
|
|
1495
|
+
if (!otherIsOpen) {
|
|
1496
|
+
this.sessionSysVars = acapReadCompareSysVars(doc.database);
|
|
1497
|
+
}
|
|
1498
|
+
acapWriteCompareSysVars(this.sessionSysVars, [doc.database]);
|
|
1499
|
+
};
|
|
1500
|
+
/** Cancels a pending Settings sysvar preview timer. */
|
|
1501
|
+
AcApDiffViewer.prototype.clearSysVarPreviewTimer = function () {
|
|
1502
|
+
if (!this.sysVarPreviewTimer)
|
|
1503
|
+
return;
|
|
1504
|
+
window.clearTimeout(this.sysVarPreviewTimer);
|
|
1505
|
+
this.sysVarPreviewTimer = 0;
|
|
1506
|
+
};
|
|
1507
|
+
/**
|
|
1508
|
+
* Debounces COMPARE sysvar live preview so slider drags do not re-compare
|
|
1509
|
+
* (and re-register the overlay) on every tick.
|
|
1510
|
+
*
|
|
1511
|
+
* @param sysVars - Draft values from the settings dialog.
|
|
1512
|
+
*/
|
|
1513
|
+
AcApDiffViewer.prototype.scheduleCompareSysVars = function (sysVars) {
|
|
1514
|
+
var _this = this;
|
|
1515
|
+
this.clearSysVarPreviewTimer();
|
|
1516
|
+
var next = __assign({}, sysVars);
|
|
1517
|
+
this.sysVarPreviewTimer = window.setTimeout(function () {
|
|
1518
|
+
_this.sysVarPreviewTimer = 0;
|
|
1519
|
+
if (_this.disposed)
|
|
1520
|
+
return;
|
|
1521
|
+
_this.applyCompareSysVars(next);
|
|
1522
|
+
}, COMPARE_SYSVAR_PREVIEW_MS);
|
|
1523
|
+
};
|
|
1524
|
+
/**
|
|
1525
|
+
* Applies COMPARE sysvars immediately, dropping any pending preview timer.
|
|
1526
|
+
*
|
|
1527
|
+
* @param sysVars - Values to persist (OK flush or Cancel restore).
|
|
1528
|
+
*/
|
|
1529
|
+
AcApDiffViewer.prototype.flushCompareSysVars = function (sysVars) {
|
|
1530
|
+
this.clearSysVarPreviewTimer();
|
|
1531
|
+
this.applyCompareSysVars(sysVars);
|
|
1532
|
+
};
|
|
1533
|
+
/**
|
|
1534
|
+
* Persists COMPARE sysvars onto open drawings and re-runs the comparison.
|
|
1535
|
+
*
|
|
1536
|
+
* @param sysVars - Session values to apply.
|
|
1537
|
+
*/
|
|
1538
|
+
AcApDiffViewer.prototype.applyCompareSysVars = function (sysVars) {
|
|
1539
|
+
var _a, _b;
|
|
1540
|
+
var unchanged = JSON.stringify(sysVars) === JSON.stringify(this.sessionSysVars);
|
|
1541
|
+
this.sessionSysVars = __assign({}, sysVars);
|
|
1542
|
+
var dbs = [(_a = this.leftDocument) === null || _a === void 0 ? void 0 : _a.database, (_b = this.rightDocument) === null || _b === void 0 ? void 0 : _b.database].filter(function (db) { return db != null; });
|
|
1543
|
+
acapWriteCompareSysVars(this.sessionSysVars, dbs);
|
|
1544
|
+
if (!unchanged)
|
|
1545
|
+
void this.runCompareAndApply();
|
|
1546
|
+
};
|
|
1547
|
+
/**
|
|
1548
|
+
* Writes compare colors onto the widget and re-tints open drawings.
|
|
1549
|
+
*
|
|
1550
|
+
* @param colors - Full role-color set to apply.
|
|
1551
|
+
*/
|
|
1552
|
+
AcApDiffViewer.prototype.applyCompareColors = function (colors) {
|
|
1553
|
+
this.colors = __assign({}, colors);
|
|
1554
|
+
this.syncCompareColorVars();
|
|
1555
|
+
void this.applyCompareDisplay();
|
|
1556
|
+
};
|
|
1557
|
+
/** Pushes role colors onto CSS custom properties used by the results list. */
|
|
1558
|
+
AcApDiffViewer.prototype.syncCompareColorVars = function () {
|
|
1559
|
+
this.root.style.setProperty('--ml-diff-added', acapDiffColorToCssHex(this.colors.added));
|
|
1560
|
+
this.root.style.setProperty('--ml-diff-deleted', acapDiffColorToCssHex(this.colors.deleted));
|
|
1561
|
+
this.root.style.setProperty('--ml-diff-modified', acapDiffColorToCssHex(this.colors.modified));
|
|
1562
|
+
};
|
|
1563
|
+
/** Compares both panes when they have drawings, then applies display coloring. */
|
|
1564
|
+
AcApDiffViewer.prototype.runCompareAndApply = function () {
|
|
1565
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1566
|
+
var seq, left, right, result;
|
|
1567
|
+
var _a, _b;
|
|
1568
|
+
return __generator(this, function (_c) {
|
|
1569
|
+
switch (_c.label) {
|
|
1570
|
+
case 0:
|
|
1571
|
+
seq = ++this.compareSeq;
|
|
1572
|
+
left = this.leftDocument;
|
|
1573
|
+
right = this.rightDocument;
|
|
1574
|
+
if (!(!left || !right)) return [3 /*break*/, 2];
|
|
1575
|
+
this.compareResult = undefined;
|
|
1576
|
+
this.navIndex = -1;
|
|
1577
|
+
return [4 /*yield*/, this.clearCompareDisplay()];
|
|
1578
|
+
case 1:
|
|
1579
|
+
_c.sent();
|
|
1580
|
+
if (this.disposed || seq !== this.compareSeq)
|
|
1581
|
+
return [2 /*return*/];
|
|
1582
|
+
this.renderResultsList();
|
|
1583
|
+
this.syncToolbarButtons();
|
|
1584
|
+
return [2 /*return*/];
|
|
1585
|
+
case 2:
|
|
1586
|
+
result = acapCompareDrawings(left.database, right.database, {
|
|
1587
|
+
compareProps: this.sessionSysVars.compareprops,
|
|
1588
|
+
compareHatch: this.sessionSysVars.comparehatch,
|
|
1589
|
+
compareText: this.sessionSysVars.comparetext,
|
|
1590
|
+
compareTolerance: this.sessionSysVars.comparetolerance,
|
|
1591
|
+
compareRcMargin: this.sessionSysVars.comparercmargin
|
|
1592
|
+
});
|
|
1593
|
+
if (this.disposed || seq !== this.compareSeq)
|
|
1594
|
+
return [2 /*return*/];
|
|
1595
|
+
this.compareResult = result;
|
|
1596
|
+
this.navIndex = -1;
|
|
1597
|
+
(_b = (_a = this.options.events) === null || _a === void 0 ? void 0 : _a.compared) === null || _b === void 0 ? void 0 : _b.call(_a, this.compareResult);
|
|
1598
|
+
if (!(this.viewMode === 'overlay')) return [3 /*break*/, 4];
|
|
1599
|
+
return [4 /*yield*/, this.enterOverlayMode()];
|
|
1600
|
+
case 3:
|
|
1601
|
+
_c.sent();
|
|
1602
|
+
_c.label = 4;
|
|
1603
|
+
case 4:
|
|
1604
|
+
if (this.disposed || seq !== this.compareSeq)
|
|
1605
|
+
return [2 /*return*/];
|
|
1606
|
+
return [4 /*yield*/, this.applyCompareDisplay()];
|
|
1607
|
+
case 5:
|
|
1608
|
+
_c.sent();
|
|
1609
|
+
if (this.disposed || seq !== this.compareSeq)
|
|
1610
|
+
return [2 /*return*/];
|
|
1611
|
+
this.renderResultsList();
|
|
1612
|
+
this.refreshMarkupsList();
|
|
1613
|
+
this.syncToolbarButtons();
|
|
1614
|
+
return [2 /*return*/];
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
});
|
|
1618
|
+
};
|
|
1619
|
+
/** Registers the right drawing as an overlay on the left canvas, hides the right pane, and focuses the left view. */
|
|
1620
|
+
AcApDiffViewer.prototype.enterOverlayMode = function () {
|
|
1621
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1622
|
+
var mgr, right, seq, overlayId;
|
|
1623
|
+
return __generator(this, function (_a) {
|
|
1624
|
+
switch (_a.label) {
|
|
1625
|
+
case 0:
|
|
1626
|
+
this.lastPointerSide = 'left';
|
|
1627
|
+
mgr = requireInstance();
|
|
1628
|
+
right = this.rightDocument;
|
|
1629
|
+
seq = ++this.overlayRegisterSeq;
|
|
1630
|
+
if (!!right) return [3 /*break*/, 2];
|
|
1631
|
+
this.viewMode = 'overlay';
|
|
1632
|
+
this.syncViewModeUi();
|
|
1633
|
+
return [4 /*yield*/, this.activateSide('left')];
|
|
1634
|
+
case 1:
|
|
1635
|
+
_a.sent();
|
|
1636
|
+
return [2 /*return*/];
|
|
1637
|
+
case 2:
|
|
1638
|
+
if (this.overlayId) {
|
|
1639
|
+
mgr.removeOverlay(this.overlayId);
|
|
1640
|
+
this.overlayId = undefined;
|
|
1641
|
+
}
|
|
1642
|
+
return [4 /*yield*/, mgr.registerOverlayDatabase(right.database, {
|
|
1643
|
+
targetView: mgr.mainView
|
|
1644
|
+
})];
|
|
1645
|
+
case 3:
|
|
1646
|
+
overlayId = _a.sent();
|
|
1647
|
+
if (this.disposed || seq !== this.overlayRegisterSeq) {
|
|
1648
|
+
try {
|
|
1649
|
+
mgr.removeOverlay(overlayId);
|
|
1650
|
+
}
|
|
1651
|
+
catch (_b) {
|
|
1652
|
+
// A newer call may already have replaced this registration.
|
|
1653
|
+
}
|
|
1654
|
+
return [2 /*return*/];
|
|
1655
|
+
}
|
|
1656
|
+
this.overlayId = overlayId;
|
|
1657
|
+
this.rightUi.pane.style.display = 'none';
|
|
1658
|
+
this.root.classList.add('is-overlay');
|
|
1659
|
+
return [4 /*yield*/, this.activateSide('left')];
|
|
1660
|
+
case 4:
|
|
1661
|
+
_a.sent();
|
|
1662
|
+
return [2 /*return*/];
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
});
|
|
1666
|
+
};
|
|
1667
|
+
/**
|
|
1668
|
+
* Removes the overlay and restores the right pane.
|
|
1669
|
+
* Does not change {@link viewMode}; callers that switch mode assign it themselves.
|
|
1670
|
+
*/
|
|
1671
|
+
AcApDiffViewer.prototype.exitOverlayMode = function () {
|
|
1672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1673
|
+
var mgr;
|
|
1674
|
+
return __generator(this, function (_a) {
|
|
1675
|
+
this.overlayRegisterSeq++;
|
|
1676
|
+
mgr = requireInstance();
|
|
1677
|
+
if (this.overlayId) {
|
|
1678
|
+
mgr.removeOverlay(this.overlayId);
|
|
1679
|
+
this.overlayId = undefined;
|
|
1680
|
+
}
|
|
1681
|
+
this.rightUi.pane.style.display = '';
|
|
1682
|
+
this.root.classList.remove('is-overlay');
|
|
1683
|
+
return [2 /*return*/];
|
|
1684
|
+
});
|
|
1685
|
+
});
|
|
1686
|
+
};
|
|
1687
|
+
/**
|
|
1688
|
+
* Waits until left/right canvases finish entity conversion so compare
|
|
1689
|
+
* role overrides can bind to packed geometry slots.
|
|
1690
|
+
*/
|
|
1691
|
+
AcApDiffViewer.prototype.waitForCompareViewsIdle = function () {
|
|
1692
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1693
|
+
var mgr, views;
|
|
1694
|
+
return __generator(this, function (_a) {
|
|
1695
|
+
switch (_a.label) {
|
|
1696
|
+
case 0:
|
|
1697
|
+
mgr = requireInstance();
|
|
1698
|
+
views = [mgr.mainView];
|
|
1699
|
+
if (mgr.splitView) {
|
|
1700
|
+
views.push(mgr.splitView);
|
|
1701
|
+
}
|
|
1702
|
+
return [4 /*yield*/, Promise.all(views.map(function (view) { return view.waitUntilIdle(); }))];
|
|
1703
|
+
case 1:
|
|
1704
|
+
_a.sent();
|
|
1705
|
+
return [2 /*return*/];
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
});
|
|
1709
|
+
};
|
|
1710
|
+
/** Turns off compare coloring on both canvases and any overlay. */
|
|
1711
|
+
AcApDiffViewer.prototype.clearCompareDisplay = function () {
|
|
1712
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1713
|
+
var mgr;
|
|
1714
|
+
return __generator(this, function (_a) {
|
|
1715
|
+
mgr = requireInstance();
|
|
1716
|
+
mgr.setCompareDisplay({ enabled: false }, mgr.mainView);
|
|
1717
|
+
if (mgr.splitView) {
|
|
1718
|
+
mgr.setCompareDisplay({ enabled: false }, mgr.splitView);
|
|
1719
|
+
}
|
|
1720
|
+
if (this.overlayId) {
|
|
1721
|
+
mgr.setOverlayCompareDisplay(this.overlayId, { enabled: false }, mgr.mainView);
|
|
1722
|
+
}
|
|
1723
|
+
return [2 /*return*/];
|
|
1724
|
+
});
|
|
1725
|
+
});
|
|
1726
|
+
};
|
|
1727
|
+
/** Applies role-based compare colors for the current view mode. */
|
|
1728
|
+
AcApDiffViewer.prototype.applyCompareDisplay = function () {
|
|
1729
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1730
|
+
var result, mgr, base, deletedIds, addedIds, leftOverrides_1, rightOverrides_1, leftOverrides, rightOverrides;
|
|
1731
|
+
return __generator(this, function (_a) {
|
|
1732
|
+
switch (_a.label) {
|
|
1733
|
+
case 0:
|
|
1734
|
+
result = this.compareResult;
|
|
1735
|
+
mgr = requireInstance();
|
|
1736
|
+
if (!(!result || !this.leftDocument || !this.rightDocument)) return [3 /*break*/, 2];
|
|
1737
|
+
return [4 /*yield*/, this.clearCompareDisplay()];
|
|
1738
|
+
case 1:
|
|
1739
|
+
_a.sent();
|
|
1740
|
+
return [2 /*return*/];
|
|
1741
|
+
case 2:
|
|
1742
|
+
// Open returns after the database is parsed, but Three.js conversion
|
|
1743
|
+
// is still draining. Role tints look up packed slots; applying before
|
|
1744
|
+
// those slots exist leaves added/deleted hits (often the last handles)
|
|
1745
|
+
// on the unchanged base color.
|
|
1746
|
+
return [4 /*yield*/, this.waitForCompareViewsIdle()];
|
|
1747
|
+
case 3:
|
|
1748
|
+
// Open returns after the database is parsed, but Three.js conversion
|
|
1749
|
+
// is still draining. Role tints look up packed slots; applying before
|
|
1750
|
+
// those slots exist leaves added/deleted hits (often the last handles)
|
|
1751
|
+
// on the unchanged base color.
|
|
1752
|
+
_a.sent();
|
|
1753
|
+
if (this.disposed ||
|
|
1754
|
+
this.compareResult !== result ||
|
|
1755
|
+
!this.leftDocument ||
|
|
1756
|
+
!this.rightDocument) {
|
|
1757
|
+
return [2 /*return*/];
|
|
1758
|
+
}
|
|
1759
|
+
base = {
|
|
1760
|
+
enabled: true,
|
|
1761
|
+
baseColor: this.colors.unchanged,
|
|
1762
|
+
colors: {
|
|
1763
|
+
deleted: this.colors.deleted,
|
|
1764
|
+
added: this.colors.added,
|
|
1765
|
+
modified: this.colors.modified
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
deletedIds = result.deleted
|
|
1769
|
+
.filter(function (h) { return h.side === 'left'; })
|
|
1770
|
+
.map(function (h) { return h.objectId; });
|
|
1771
|
+
addedIds = result.added
|
|
1772
|
+
.filter(function (h) { return h.side === 'right'; })
|
|
1773
|
+
.map(function (h) { return h.objectId; });
|
|
1774
|
+
if (this.viewMode === 'overlay') {
|
|
1775
|
+
leftOverrides_1 = __spreadArray(__spreadArray([], __read(deletedIds.map(function (objectId) { return ({
|
|
1776
|
+
objectId: objectId,
|
|
1777
|
+
role: 'deleted'
|
|
1778
|
+
}); })), false), __read(result.modified
|
|
1779
|
+
.filter(function (h) { return h.side === 'left'; })
|
|
1780
|
+
.map(function (h) { return ({ objectId: h.objectId, role: 'deleted' }); })), false);
|
|
1781
|
+
rightOverrides_1 = __spreadArray(__spreadArray([], __read(addedIds.map(function (objectId) { return ({
|
|
1782
|
+
objectId: objectId,
|
|
1783
|
+
role: 'added'
|
|
1784
|
+
}); })), false), __read(result.modified
|
|
1785
|
+
.filter(function (h) { return h.side === 'right'; })
|
|
1786
|
+
.map(function (h) { return ({ objectId: h.objectId, role: 'added' }); })), false);
|
|
1787
|
+
mgr.setCompareDisplay({ enabled: false }, mgr.mainView);
|
|
1788
|
+
mgr.setCompareDisplay(__assign(__assign({}, base), { overrides: leftOverrides_1 }), mgr.mainView);
|
|
1789
|
+
if (this.overlayId) {
|
|
1790
|
+
mgr.setOverlayCompareDisplay(this.overlayId, { enabled: false }, mgr.mainView);
|
|
1791
|
+
mgr.setOverlayCompareDisplay(this.overlayId, __assign(__assign({}, base), { overrides: rightOverrides_1 }), mgr.mainView);
|
|
1792
|
+
}
|
|
1793
|
+
return [2 /*return*/];
|
|
1794
|
+
}
|
|
1795
|
+
leftOverrides = __spreadArray(__spreadArray([], __read(deletedIds.map(function (objectId) { return ({
|
|
1796
|
+
objectId: objectId,
|
|
1797
|
+
role: 'deleted'
|
|
1798
|
+
}); })), false), __read(result.modified
|
|
1799
|
+
.filter(function (h) { return h.side === 'left'; })
|
|
1800
|
+
.map(function (h) { return ({
|
|
1801
|
+
objectId: h.objectId,
|
|
1802
|
+
role: 'modified'
|
|
1803
|
+
}); })), false);
|
|
1804
|
+
rightOverrides = __spreadArray(__spreadArray([], __read(addedIds.map(function (objectId) { return ({
|
|
1805
|
+
objectId: objectId,
|
|
1806
|
+
role: 'added'
|
|
1807
|
+
}); })), false), __read(result.modified
|
|
1808
|
+
.filter(function (h) { return h.side === 'right'; })
|
|
1809
|
+
.map(function (h) { return ({
|
|
1810
|
+
objectId: h.objectId,
|
|
1811
|
+
role: 'modified'
|
|
1812
|
+
}); })), false);
|
|
1813
|
+
mgr.setCompareDisplay({ enabled: false }, mgr.mainView);
|
|
1814
|
+
mgr.setCompareDisplay(__assign(__assign({}, base), { overrides: leftOverrides }), mgr.mainView);
|
|
1815
|
+
if (mgr.splitView) {
|
|
1816
|
+
mgr.setCompareDisplay({ enabled: false }, mgr.splitView);
|
|
1817
|
+
mgr.setCompareDisplay(__assign(__assign({}, base), { overrides: rightOverrides }), mgr.splitView);
|
|
1818
|
+
}
|
|
1819
|
+
return [2 /*return*/];
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
});
|
|
1823
|
+
};
|
|
1824
|
+
/**
|
|
1825
|
+
* Zooms to a hit (and its pair, when modified).
|
|
1826
|
+
*
|
|
1827
|
+
* Drawing entities are not selected or highlighted; compare display
|
|
1828
|
+
* already tints deleted / added / modified geometry.
|
|
1829
|
+
*
|
|
1830
|
+
* @param hit - Navigation entry from {@link AcApDiffCompareResult}.
|
|
1831
|
+
*/
|
|
1832
|
+
AcApDiffViewer.prototype.focusHit = function (hit) {
|
|
1833
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1834
|
+
var side, view, box, pair;
|
|
1835
|
+
return __generator(this, function (_a) {
|
|
1836
|
+
switch (_a.label) {
|
|
1837
|
+
case 0:
|
|
1838
|
+
side = this.viewMode === 'overlay' ? 'left' : hit.side;
|
|
1839
|
+
if (!(this.viewMode !== 'overlay')) return [3 /*break*/, 2];
|
|
1840
|
+
return [4 /*yield*/, this.activateSide(hit.side)];
|
|
1841
|
+
case 1:
|
|
1842
|
+
_a.sent();
|
|
1843
|
+
_a.label = 2;
|
|
1844
|
+
case 2:
|
|
1845
|
+
view = this.viewFor(side);
|
|
1846
|
+
if (hit.extents) {
|
|
1847
|
+
box = new AcGeBox2d();
|
|
1848
|
+
box.expandByPoint({ x: hit.extents.minX, y: hit.extents.minY });
|
|
1849
|
+
box.expandByPoint({ x: hit.extents.maxX, y: hit.extents.maxY });
|
|
1850
|
+
if (hit.pairedId && hit.kind === 'modified' && this.compareResult) {
|
|
1851
|
+
pair = this.compareResult.modified.find(function (h) { return h.objectId === hit.pairedId; });
|
|
1852
|
+
if (pair === null || pair === void 0 ? void 0 : pair.extents) {
|
|
1853
|
+
box.expandByPoint({ x: pair.extents.minX, y: pair.extents.minY });
|
|
1854
|
+
box.expandByPoint({ x: pair.extents.maxX, y: pair.extents.maxY });
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
view.zoomTo(box, 1.5);
|
|
1858
|
+
}
|
|
1859
|
+
if (this.isViewSyncActive()) {
|
|
1860
|
+
this.viewSyncLeader = side;
|
|
1861
|
+
this.viewSyncFollowOpen = false;
|
|
1862
|
+
this.copyVisibleView(side, side === 'left' ? 'right' : 'left');
|
|
1863
|
+
}
|
|
1864
|
+
return [2 /*return*/];
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
});
|
|
1868
|
+
};
|
|
1869
|
+
/** Rebuilds the results list from {@link compareResult}. */
|
|
1870
|
+
AcApDiffViewer.prototype.renderResultsList = function () {
|
|
1871
|
+
var e_7, _a, e_8, _b, e_9, _c, e_10, _d, e_11, _e;
|
|
1872
|
+
var _this = this;
|
|
1873
|
+
this.hideDiffPopover(true);
|
|
1874
|
+
var body = this.resultsBody;
|
|
1875
|
+
body.replaceChildren();
|
|
1876
|
+
var result = this.compareResult;
|
|
1877
|
+
if (!result || result.navigation.length === 0) {
|
|
1878
|
+
var empty = document.createElement('div');
|
|
1879
|
+
empty.className = 'ml-diff-empty-list';
|
|
1880
|
+
empty.textContent = acapDiffViewerT('noResults');
|
|
1881
|
+
body.appendChild(empty);
|
|
1882
|
+
this.syncToolbarButtons();
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
var groups = new Map();
|
|
1886
|
+
var push = function (key, hit) {
|
|
1887
|
+
var list = groups.get(key);
|
|
1888
|
+
if (list)
|
|
1889
|
+
list.push(hit);
|
|
1890
|
+
else
|
|
1891
|
+
groups.set(key, [hit]);
|
|
1892
|
+
};
|
|
1893
|
+
if (this.resultGroupMode === 'kind') {
|
|
1894
|
+
try {
|
|
1895
|
+
for (var _f = __values(result.deleted), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1896
|
+
var hit = _g.value;
|
|
1897
|
+
push('deleted', hit);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1901
|
+
finally {
|
|
1902
|
+
try {
|
|
1903
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
1904
|
+
}
|
|
1905
|
+
finally { if (e_7) throw e_7.error; }
|
|
1906
|
+
}
|
|
1907
|
+
try {
|
|
1908
|
+
for (var _h = __values(result.modified.filter(function (h) { return h.side === 'left'; })), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
1909
|
+
var hit = _j.value;
|
|
1910
|
+
push('modified', hit);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1914
|
+
finally {
|
|
1915
|
+
try {
|
|
1916
|
+
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
|
|
1917
|
+
}
|
|
1918
|
+
finally { if (e_8) throw e_8.error; }
|
|
1919
|
+
}
|
|
1920
|
+
try {
|
|
1921
|
+
for (var _k = __values(result.added), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1922
|
+
var hit = _l.value;
|
|
1923
|
+
push('added', hit);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1927
|
+
finally {
|
|
1928
|
+
try {
|
|
1929
|
+
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
|
|
1930
|
+
}
|
|
1931
|
+
finally { if (e_9) throw e_9.error; }
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
else {
|
|
1935
|
+
try {
|
|
1936
|
+
for (var _m = __values(result.navigation), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
1937
|
+
var hit = _o.value;
|
|
1938
|
+
push(hit.dxfType || 'UNKNOWN', hit);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1942
|
+
finally {
|
|
1943
|
+
try {
|
|
1944
|
+
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
|
|
1945
|
+
}
|
|
1946
|
+
finally { if (e_10) throw e_10.error; }
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
var kindLabel = function (kind) {
|
|
1950
|
+
if (kind === 'added')
|
|
1951
|
+
return acapDiffViewerT('kindAdded');
|
|
1952
|
+
if (kind === 'deleted')
|
|
1953
|
+
return acapDiffViewerT('kindDeleted');
|
|
1954
|
+
if (kind === 'modified')
|
|
1955
|
+
return acapDiffViewerT('kindModified');
|
|
1956
|
+
return kind;
|
|
1957
|
+
};
|
|
1958
|
+
var _loop_3 = function (key, hits) {
|
|
1959
|
+
var storageKey = this_2.resultGroupStorageKey(key);
|
|
1960
|
+
var group = document.createElement('details');
|
|
1961
|
+
group.className = 'ml-diff-group';
|
|
1962
|
+
group.open = !this_2.collapsedResultGroups.has(storageKey);
|
|
1963
|
+
var title = document.createElement('summary');
|
|
1964
|
+
title.className = 'ml-diff-group-title';
|
|
1965
|
+
title.textContent =
|
|
1966
|
+
this_2.resultGroupMode === 'kind'
|
|
1967
|
+
? "".concat(kindLabel(key), " (").concat(hits.length, ")")
|
|
1968
|
+
: "".concat(key, " (").concat(hits.length, ")");
|
|
1969
|
+
group.appendChild(title);
|
|
1970
|
+
group.addEventListener('toggle', function () {
|
|
1971
|
+
if (group.open)
|
|
1972
|
+
_this.collapsedResultGroups.delete(storageKey);
|
|
1973
|
+
else
|
|
1974
|
+
_this.collapsedResultGroups.add(storageKey);
|
|
1975
|
+
_this.hideDiffPopover(true);
|
|
1976
|
+
});
|
|
1977
|
+
hits.forEach(function (hit) {
|
|
1978
|
+
var row = document.createElement('div');
|
|
1979
|
+
row.className = 'ml-diff-result-row';
|
|
1980
|
+
row.dataset.kind = hit.kind;
|
|
1981
|
+
var navIdx = result.navigation.indexOf(hit);
|
|
1982
|
+
if (navIdx === _this.navIndex)
|
|
1983
|
+
row.classList.add('is-active');
|
|
1984
|
+
var btn = document.createElement('button');
|
|
1985
|
+
btn.type = 'button';
|
|
1986
|
+
btn.className = 'ml-diff-result-item';
|
|
1987
|
+
btn.dataset.kind = hit.kind;
|
|
1988
|
+
var label = document.createElement('span');
|
|
1989
|
+
label.className = 'ml-diff-result-label';
|
|
1990
|
+
label.textContent = "".concat(hit.dxfType, " \u00B7 ").concat(hit.objectId);
|
|
1991
|
+
var meta = document.createElement('span');
|
|
1992
|
+
meta.className = 'ml-diff-result-meta';
|
|
1993
|
+
meta.textContent = "".concat(hit.layer, " \u00B7 ").concat(kindLabel(hit.kind));
|
|
1994
|
+
btn.append(label, meta);
|
|
1995
|
+
btn.addEventListener('click', function () {
|
|
1996
|
+
_this.navIndex = navIdx >= 0 ? navIdx : _this.navIndex;
|
|
1997
|
+
void _this.focusHit(hit);
|
|
1998
|
+
_this.renderResultsList();
|
|
1999
|
+
});
|
|
2000
|
+
row.appendChild(btn);
|
|
2001
|
+
if (hit.kind === 'modified') {
|
|
2002
|
+
var info_1 = document.createElement('button');
|
|
2003
|
+
info_1.type = 'button';
|
|
2004
|
+
info_1.className = 'ml-diff-result-info';
|
|
2005
|
+
info_1.innerHTML = ICON_INFO;
|
|
2006
|
+
var detailsLabel = acapDiffViewerT('diffDetails');
|
|
2007
|
+
info_1.setAttribute('aria-label', detailsLabel);
|
|
2008
|
+
info_1.setAttribute('aria-expanded', 'false');
|
|
2009
|
+
info_1.addEventListener('click', function (event) {
|
|
2010
|
+
event.preventDefault();
|
|
2011
|
+
event.stopPropagation();
|
|
2012
|
+
_this.toggleDiffPopover(info_1, hit);
|
|
2013
|
+
});
|
|
2014
|
+
info_1.addEventListener('mouseenter', function () {
|
|
2015
|
+
_this.showDiffPopover(info_1, hit, false);
|
|
2016
|
+
});
|
|
2017
|
+
info_1.addEventListener('mouseleave', _this.scheduleDiffPopoverHide);
|
|
2018
|
+
row.appendChild(info_1);
|
|
2019
|
+
}
|
|
2020
|
+
group.appendChild(row);
|
|
2021
|
+
});
|
|
2022
|
+
body.appendChild(group);
|
|
2023
|
+
};
|
|
2024
|
+
var this_2 = this;
|
|
2025
|
+
try {
|
|
2026
|
+
for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
|
|
2027
|
+
var _p = __read(groups_1_1.value, 2), key = _p[0], hits = _p[1];
|
|
2028
|
+
_loop_3(key, hits);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
2032
|
+
finally {
|
|
2033
|
+
try {
|
|
2034
|
+
if (groups_1_1 && !groups_1_1.done && (_e = groups_1.return)) _e.call(groups_1);
|
|
2035
|
+
}
|
|
2036
|
+
finally { if (e_11) throw e_11.error; }
|
|
2037
|
+
}
|
|
2038
|
+
this.syncToolbarButtons();
|
|
2039
|
+
};
|
|
2040
|
+
/** Pins or unpins the field-diff popover for a modified result row. */
|
|
2041
|
+
AcApDiffViewer.prototype.toggleDiffPopover = function (anchor, hit) {
|
|
2042
|
+
if (this.diffPopoverAnchor === anchor && this.diffPopoverPinned) {
|
|
2043
|
+
this.hideDiffPopover(true);
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
this.showDiffPopover(anchor, hit, true);
|
|
2047
|
+
};
|
|
2048
|
+
/**
|
|
2049
|
+
* Shows field-level old/new values next to `anchor`.
|
|
2050
|
+
*
|
|
2051
|
+
* @param pinned - When true, the popover stays until dismissed.
|
|
2052
|
+
*/
|
|
2053
|
+
AcApDiffViewer.prototype.showDiffPopover = function (anchor, hit, pinned) {
|
|
2054
|
+
var _a;
|
|
2055
|
+
if (!pinned &&
|
|
2056
|
+
this.diffPopoverPinned &&
|
|
2057
|
+
this.diffPopoverAnchor !== anchor) {
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
this.cancelDiffPopoverHide();
|
|
2061
|
+
if (!pinned &&
|
|
2062
|
+
this.diffPopoverPinned &&
|
|
2063
|
+
this.diffPopoverAnchor === anchor &&
|
|
2064
|
+
!this.diffPopover.hidden) {
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
(_a = this.diffPopoverAnchor) === null || _a === void 0 ? void 0 : _a.classList.remove('is-open');
|
|
2068
|
+
this.diffPopoverAnchor = anchor;
|
|
2069
|
+
this.diffPopoverPinned = pinned;
|
|
2070
|
+
anchor.classList.toggle('is-open', pinned);
|
|
2071
|
+
anchor.setAttribute('aria-expanded', String(pinned));
|
|
2072
|
+
this.renderDiffPopoverContent(hit);
|
|
2073
|
+
this.positionDiffPopover(anchor);
|
|
2074
|
+
this.diffPopover.hidden = false;
|
|
2075
|
+
};
|
|
2076
|
+
/** Hides the field-diff popover. Pass `true` to also clear a pinned state. */
|
|
2077
|
+
AcApDiffViewer.prototype.hideDiffPopover = function (force) {
|
|
2078
|
+
var _a, _b;
|
|
2079
|
+
if (force === void 0) { force = false; }
|
|
2080
|
+
if (this.diffPopoverPinned && !force)
|
|
2081
|
+
return;
|
|
2082
|
+
this.cancelDiffPopoverHide();
|
|
2083
|
+
this.diffPopover.hidden = true;
|
|
2084
|
+
this.diffPopoverPinned = false;
|
|
2085
|
+
(_a = this.diffPopoverAnchor) === null || _a === void 0 ? void 0 : _a.classList.remove('is-open');
|
|
2086
|
+
(_b = this.diffPopoverAnchor) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
|
|
2087
|
+
this.diffPopoverAnchor = undefined;
|
|
2088
|
+
};
|
|
2089
|
+
/** Fills {@link diffPopover} with a property / old / new table. */
|
|
2090
|
+
AcApDiffViewer.prototype.renderDiffPopoverContent = function (hit) {
|
|
2091
|
+
var e_12, _a, e_13, _b;
|
|
2092
|
+
var _c;
|
|
2093
|
+
var pop = this.diffPopover;
|
|
2094
|
+
pop.replaceChildren();
|
|
2095
|
+
var changes = (_c = hit.changes) !== null && _c !== void 0 ? _c : [];
|
|
2096
|
+
var tableChanges = changes.filter(function (change) { return change.field !== 'geometry' || change.oldValue || change.newValue; });
|
|
2097
|
+
var geometryOnly = tableChanges.length === 0 &&
|
|
2098
|
+
changes.some(function (change) { return change.field === 'geometry'; });
|
|
2099
|
+
if (geometryOnly || tableChanges.length === 0) {
|
|
2100
|
+
var note = document.createElement('div');
|
|
2101
|
+
note.className = 'ml-diff-change-note';
|
|
2102
|
+
note.textContent = acapDiffViewerT('diffGeometryChanged');
|
|
2103
|
+
pop.appendChild(note);
|
|
2104
|
+
return;
|
|
2105
|
+
}
|
|
2106
|
+
var table = document.createElement('table');
|
|
2107
|
+
table.className = 'ml-diff-change-table';
|
|
2108
|
+
var thead = document.createElement('thead');
|
|
2109
|
+
var headRow = document.createElement('tr');
|
|
2110
|
+
try {
|
|
2111
|
+
for (var _d = __values(['diffColProperty', 'diffColOld', 'diffColNew']), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2112
|
+
var key = _e.value;
|
|
2113
|
+
var th = document.createElement('th');
|
|
2114
|
+
th.textContent = acapDiffViewerT(key);
|
|
2115
|
+
headRow.appendChild(th);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
2119
|
+
finally {
|
|
2120
|
+
try {
|
|
2121
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2122
|
+
}
|
|
2123
|
+
finally { if (e_12) throw e_12.error; }
|
|
2124
|
+
}
|
|
2125
|
+
thead.appendChild(headRow);
|
|
2126
|
+
var tbody = document.createElement('tbody');
|
|
2127
|
+
try {
|
|
2128
|
+
for (var tableChanges_1 = __values(tableChanges), tableChanges_1_1 = tableChanges_1.next(); !tableChanges_1_1.done; tableChanges_1_1 = tableChanges_1.next()) {
|
|
2129
|
+
var change = tableChanges_1_1.value;
|
|
2130
|
+
var tr = document.createElement('tr');
|
|
2131
|
+
var th = document.createElement('th');
|
|
2132
|
+
th.scope = 'row';
|
|
2133
|
+
th.textContent = diffFieldLabel(change.field);
|
|
2134
|
+
var tdOld = document.createElement('td');
|
|
2135
|
+
tdOld.className = 'ml-diff-change-old';
|
|
2136
|
+
tdOld.textContent = formatDiffValue(change.field, change.oldValue);
|
|
2137
|
+
var tdNew = document.createElement('td');
|
|
2138
|
+
tdNew.className = 'ml-diff-change-new';
|
|
2139
|
+
tdNew.textContent = formatDiffValue(change.field, change.newValue);
|
|
2140
|
+
tr.append(th, tdOld, tdNew);
|
|
2141
|
+
tbody.appendChild(tr);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
2145
|
+
finally {
|
|
2146
|
+
try {
|
|
2147
|
+
if (tableChanges_1_1 && !tableChanges_1_1.done && (_b = tableChanges_1.return)) _b.call(tableChanges_1);
|
|
2148
|
+
}
|
|
2149
|
+
finally { if (e_13) throw e_13.error; }
|
|
2150
|
+
}
|
|
2151
|
+
table.append(thead, tbody);
|
|
2152
|
+
pop.appendChild(table);
|
|
2153
|
+
};
|
|
2154
|
+
/** Places the popover beside `anchor`, flipping when it would overflow. */
|
|
2155
|
+
AcApDiffViewer.prototype.positionDiffPopover = function (anchor) {
|
|
2156
|
+
var pop = this.diffPopover;
|
|
2157
|
+
pop.style.left = '0px';
|
|
2158
|
+
pop.style.top = '0px';
|
|
2159
|
+
pop.hidden = false;
|
|
2160
|
+
var a = anchor.getBoundingClientRect();
|
|
2161
|
+
var p = pop.getBoundingClientRect();
|
|
2162
|
+
var gap = 8;
|
|
2163
|
+
var left = a.left - p.width - gap;
|
|
2164
|
+
var top = a.top;
|
|
2165
|
+
if (left < gap) {
|
|
2166
|
+
left = Math.max(gap, a.right - p.width);
|
|
2167
|
+
top = a.bottom + gap;
|
|
2168
|
+
}
|
|
2169
|
+
if (left + p.width > window.innerWidth - gap) {
|
|
2170
|
+
left = Math.max(gap, window.innerWidth - p.width - gap);
|
|
2171
|
+
}
|
|
2172
|
+
if (top + p.height > window.innerHeight - gap) {
|
|
2173
|
+
top = Math.max(gap, window.innerHeight - p.height - gap);
|
|
2174
|
+
}
|
|
2175
|
+
pop.style.left = "".concat(left, "px");
|
|
2176
|
+
pop.style.top = "".concat(top, "px");
|
|
2177
|
+
};
|
|
2178
|
+
/** Storage key for a results-list section in the current grouping mode. */
|
|
2179
|
+
AcApDiffViewer.prototype.resultGroupStorageKey = function (groupKey) {
|
|
2180
|
+
return "".concat(this.resultGroupMode, ":").concat(groupKey);
|
|
2181
|
+
};
|
|
2182
|
+
/** Storage key of the section that contains `hit`. */
|
|
2183
|
+
AcApDiffViewer.prototype.resultGroupStorageKeyForHit = function (hit) {
|
|
2184
|
+
var groupKey = this.resultGroupMode === 'kind' ? hit.kind : hit.dxfType || 'UNKNOWN';
|
|
2185
|
+
return this.resultGroupStorageKey(groupKey);
|
|
2186
|
+
};
|
|
2187
|
+
/** Rebuilds the markups list from both document sessions. */
|
|
2188
|
+
AcApDiffViewer.prototype.refreshMarkupsList = function () {
|
|
2189
|
+
var e_14, _a, e_15, _b, e_16, _c;
|
|
2190
|
+
var _this = this;
|
|
2191
|
+
var body = this.markupsBody;
|
|
2192
|
+
body.replaceChildren();
|
|
2193
|
+
var left = this.leftDocument;
|
|
2194
|
+
var right = this.rightDocument;
|
|
2195
|
+
var mgr = requireInstance();
|
|
2196
|
+
var entries = [];
|
|
2197
|
+
if (left) {
|
|
2198
|
+
var session = mgr.sessionFor(left);
|
|
2199
|
+
if (session) {
|
|
2200
|
+
try {
|
|
2201
|
+
for (var _d = __values(listMarkupsForSession(session.id)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2202
|
+
var record = _e.value;
|
|
2203
|
+
entries.push({ side: 'left', record: record });
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
2207
|
+
finally {
|
|
2208
|
+
try {
|
|
2209
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2210
|
+
}
|
|
2211
|
+
finally { if (e_14) throw e_14.error; }
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
if (right) {
|
|
2216
|
+
var session = mgr.sessionFor(right);
|
|
2217
|
+
if (session) {
|
|
2218
|
+
try {
|
|
2219
|
+
for (var _f = __values(listMarkupsForSession(session.id)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2220
|
+
var record = _g.value;
|
|
2221
|
+
entries.push({ side: 'right', record: record });
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
2225
|
+
finally {
|
|
2226
|
+
try {
|
|
2227
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
2228
|
+
}
|
|
2229
|
+
finally { if (e_15) throw e_15.error; }
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
if (entries.length === 0) {
|
|
2234
|
+
var empty = document.createElement('div');
|
|
2235
|
+
empty.className = 'ml-diff-empty-list';
|
|
2236
|
+
empty.textContent = acapDiffViewerT('noMarkups');
|
|
2237
|
+
body.appendChild(empty);
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
var _loop_4 = function (entry) {
|
|
2241
|
+
var btn = document.createElement('button');
|
|
2242
|
+
btn.type = 'button';
|
|
2243
|
+
btn.className = 'ml-diff-markup-item';
|
|
2244
|
+
btn.textContent = entry.record.type;
|
|
2245
|
+
var meta = document.createElement('span');
|
|
2246
|
+
meta.className = 'ml-diff-markup-meta';
|
|
2247
|
+
meta.textContent =
|
|
2248
|
+
entry.side === 'left'
|
|
2249
|
+
? acapDiffViewerT('markupFromLeft')
|
|
2250
|
+
: acapDiffViewerT('markupFromRight');
|
|
2251
|
+
btn.appendChild(meta);
|
|
2252
|
+
btn.addEventListener('click', function () {
|
|
2253
|
+
void _this.activateSide(entry.side);
|
|
2254
|
+
});
|
|
2255
|
+
body.appendChild(btn);
|
|
2256
|
+
};
|
|
2257
|
+
try {
|
|
2258
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
2259
|
+
var entry = entries_1_1.value;
|
|
2260
|
+
_loop_4(entry);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2264
|
+
finally {
|
|
2265
|
+
try {
|
|
2266
|
+
if (entries_1_1 && !entries_1_1.done && (_c = entries_1.return)) _c.call(entries_1);
|
|
2267
|
+
}
|
|
2268
|
+
finally { if (e_16) throw e_16.error; }
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
/**
|
|
2272
|
+
* Shows a pane error in the empty card or a transient banner.
|
|
2273
|
+
*
|
|
2274
|
+
* @param side - Pane that owns the message.
|
|
2275
|
+
* @param message - Localized error text.
|
|
2276
|
+
*/
|
|
2277
|
+
AcApDiffViewer.prototype.showPaneError = function (side, message) {
|
|
2278
|
+
var _this = this;
|
|
2279
|
+
var ui = this.uiFor(side);
|
|
2280
|
+
if (this.documentFor(side)) {
|
|
2281
|
+
ui.banner.textContent = message;
|
|
2282
|
+
ui.banner.classList.remove('is-hidden');
|
|
2283
|
+
var previous = this.bannerTimers.get(side);
|
|
2284
|
+
if (previous)
|
|
2285
|
+
window.clearTimeout(previous);
|
|
2286
|
+
var timer = window.setTimeout(function () {
|
|
2287
|
+
ui.banner.classList.add('is-hidden');
|
|
2288
|
+
_this.bannerTimers.delete(side);
|
|
2289
|
+
}, 3000);
|
|
2290
|
+
this.bannerTimers.set(side, timer);
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
ui.emptyError.textContent = message;
|
|
2294
|
+
ui.emptyError.classList.remove('is-hidden');
|
|
2295
|
+
};
|
|
2296
|
+
/** Hides empty-state and banner errors for `side`. */
|
|
2297
|
+
AcApDiffViewer.prototype.clearPaneError = function (side) {
|
|
2298
|
+
var ui = this.uiFor(side);
|
|
2299
|
+
ui.emptyError.textContent = '';
|
|
2300
|
+
ui.emptyError.classList.add('is-hidden');
|
|
2301
|
+
ui.banner.textContent = '';
|
|
2302
|
+
ui.banner.classList.add('is-hidden');
|
|
2303
|
+
var timer = this.bannerTimers.get(side);
|
|
2304
|
+
if (timer) {
|
|
2305
|
+
window.clearTimeout(timer);
|
|
2306
|
+
this.bannerTimers.delete(side);
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
/**
|
|
2310
|
+
* Updates nested drag-over depth so the pane highlight survives child enter/leave.
|
|
2311
|
+
*
|
|
2312
|
+
* @param side - Pane receiving the drag event.
|
|
2313
|
+
* @param delta - `+1` on enter, `-1` on leave.
|
|
2314
|
+
*/
|
|
2315
|
+
AcApDiffViewer.prototype.changeDragDepth = function (side, delta) {
|
|
2316
|
+
if (side === 'left') {
|
|
2317
|
+
this.leftDragDepth = Math.max(0, this.leftDragDepth + delta);
|
|
2318
|
+
}
|
|
2319
|
+
else {
|
|
2320
|
+
this.rightDragDepth = Math.max(0, this.rightDragDepth + delta);
|
|
2321
|
+
}
|
|
2322
|
+
this.uiFor(side).pane.classList.toggle('is-dragover', (side === 'left' ? this.leftDragDepth : this.rightDragDepth) > 0);
|
|
2323
|
+
};
|
|
2324
|
+
/** Clears drag-over state after a drop or cancelled drag. */
|
|
2325
|
+
AcApDiffViewer.prototype.resetDragDepth = function (side) {
|
|
2326
|
+
if (side === 'left')
|
|
2327
|
+
this.leftDragDepth = 0;
|
|
2328
|
+
else
|
|
2329
|
+
this.rightDragDepth = 0;
|
|
2330
|
+
this.uiFor(side).pane.classList.remove('is-dragover');
|
|
2331
|
+
};
|
|
2332
|
+
/** Returns the pane UI for `side`. */
|
|
2333
|
+
AcApDiffViewer.prototype.uiFor = function (side) {
|
|
2334
|
+
return side === 'left' ? this.leftUi : this.rightUi;
|
|
2335
|
+
};
|
|
2336
|
+
/** Live document for `side`, or `undefined` when that pane is empty. */
|
|
2337
|
+
AcApDiffViewer.prototype.documentFor = function (side) {
|
|
2338
|
+
return side === 'left' ? this.leftDocument : this.rightDocument;
|
|
2339
|
+
};
|
|
2340
|
+
/**
|
|
2341
|
+
* Returns the canvas that should receive convert for `side`.
|
|
2342
|
+
*
|
|
2343
|
+
* Creates the split view on first use of the right pane.
|
|
2344
|
+
*/
|
|
2345
|
+
AcApDiffViewer.prototype.viewFor = function (side) {
|
|
2346
|
+
var mgr = requireInstance();
|
|
2347
|
+
var view = side === 'left'
|
|
2348
|
+
? mgr.mainView
|
|
2349
|
+
: mgr.ensureSplitView(this.rightUi.canvas);
|
|
2350
|
+
this.disableEntitySelection(view);
|
|
2351
|
+
return view;
|
|
2352
|
+
};
|
|
2353
|
+
/** Turns off CAD entity pick, selection, and hover highlight on `view`. */
|
|
2354
|
+
AcApDiffViewer.prototype.disableEntitySelection = function (view) {
|
|
2355
|
+
view.entitySelectionEnabled = false;
|
|
2356
|
+
};
|
|
2357
|
+
/** True when both panes should share the same camera. */
|
|
2358
|
+
AcApDiffViewer.prototype.isViewSyncActive = function () {
|
|
2359
|
+
return (this.viewsSynced &&
|
|
2360
|
+
this.viewMode === 'side-by-side' &&
|
|
2361
|
+
Boolean(this.leftDocument) &&
|
|
2362
|
+
Boolean(this.rightDocument));
|
|
2363
|
+
};
|
|
2364
|
+
/** Turns pan/zoom locking on or off. */
|
|
2365
|
+
AcApDiffViewer.prototype.setViewsSynced = function (on) {
|
|
2366
|
+
this.viewsSynced = on;
|
|
2367
|
+
this.viewSyncFollowOpen = false;
|
|
2368
|
+
if (on) {
|
|
2369
|
+
var source = this.documentFor(this.lastPointerSide)
|
|
2370
|
+
? this.lastPointerSide
|
|
2371
|
+
: 'left';
|
|
2372
|
+
this.viewSyncLeader = source;
|
|
2373
|
+
this.applyViewSyncFromLeader();
|
|
2374
|
+
}
|
|
2375
|
+
this.syncViewModeUi();
|
|
2376
|
+
};
|
|
2377
|
+
/** Copies the leader pane's visible world box onto the follower. */
|
|
2378
|
+
AcApDiffViewer.prototype.applyViewSyncFromLeader = function () {
|
|
2379
|
+
if (!this.isViewSyncActive())
|
|
2380
|
+
return;
|
|
2381
|
+
var leader = this.documentFor(this.viewSyncLeader)
|
|
2382
|
+
? this.viewSyncLeader
|
|
2383
|
+
: this.leftDocument
|
|
2384
|
+
? 'left'
|
|
2385
|
+
: 'right';
|
|
2386
|
+
this.viewSyncLeader = leader;
|
|
2387
|
+
this.copyVisibleView(leader, leader === 'left' ? 'right' : 'left');
|
|
2388
|
+
};
|
|
2389
|
+
/**
|
|
2390
|
+
* After a pane opens, keep the already-open drawing's camera if sync is on.
|
|
2391
|
+
* Auto-fit on the new pane is ignored until the user pans or zooms.
|
|
2392
|
+
*/
|
|
2393
|
+
AcApDiffViewer.prototype.syncFollowerAfterOpen = function (opened) {
|
|
2394
|
+
var other = opened === 'left' ? 'right' : 'left';
|
|
2395
|
+
if (!this.isViewSyncActive() || !this.documentFor(other))
|
|
2396
|
+
return;
|
|
2397
|
+
this.viewSyncLeader = other;
|
|
2398
|
+
this.viewSyncFollowOpen = true;
|
|
2399
|
+
this.copyVisibleView(other, opened);
|
|
2400
|
+
};
|
|
2401
|
+
/** Subscribes to camera changes on both canvases. */
|
|
2402
|
+
AcApDiffViewer.prototype.bindViewSyncListeners = function () {
|
|
2403
|
+
var e_17, _a;
|
|
2404
|
+
try {
|
|
2405
|
+
var left = this.viewFor('left');
|
|
2406
|
+
var right = this.viewFor('right');
|
|
2407
|
+
left.events.viewChanged.addEventListener(this.handleLeftViewChanged);
|
|
2408
|
+
right.events.viewChanged.addEventListener(this.handleRightViewChanged);
|
|
2409
|
+
}
|
|
2410
|
+
catch (_b) {
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
try {
|
|
2414
|
+
for (var _c = __values([this.leftUi.canvas, this.rightUi.canvas]), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2415
|
+
var host = _d.value;
|
|
2416
|
+
host.addEventListener('pointerdown', this.markViewSyncUserInput, true);
|
|
2417
|
+
host.addEventListener('wheel', this.markViewSyncUserInput, {
|
|
2418
|
+
capture: true,
|
|
2419
|
+
passive: true
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
2424
|
+
finally {
|
|
2425
|
+
try {
|
|
2426
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
2427
|
+
}
|
|
2428
|
+
finally { if (e_17) throw e_17.error; }
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
/** Drops camera-sync listeners. Safe if the manager is already gone. */
|
|
2432
|
+
AcApDiffViewer.prototype.unbindViewSyncListeners = function () {
|
|
2433
|
+
var e_18, _a;
|
|
2434
|
+
try {
|
|
2435
|
+
for (var _b = __values([this.leftUi.canvas, this.rightUi.canvas]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2436
|
+
var host = _c.value;
|
|
2437
|
+
host.removeEventListener('pointerdown', this.markViewSyncUserInput, true);
|
|
2438
|
+
host.removeEventListener('wheel', this.markViewSyncUserInput, true);
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
2442
|
+
finally {
|
|
2443
|
+
try {
|
|
2444
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2445
|
+
}
|
|
2446
|
+
finally { if (e_18) throw e_18.error; }
|
|
2447
|
+
}
|
|
2448
|
+
try {
|
|
2449
|
+
var left = this.viewFor('left');
|
|
2450
|
+
var right = this.viewFor('right');
|
|
2451
|
+
left.events.viewChanged.removeEventListener(this.handleLeftViewChanged);
|
|
2452
|
+
right.events.viewChanged.removeEventListener(this.handleRightViewChanged);
|
|
2453
|
+
}
|
|
2454
|
+
catch (_d) {
|
|
2455
|
+
// Manager may already be gone.
|
|
2456
|
+
}
|
|
2457
|
+
};
|
|
2458
|
+
/**
|
|
2459
|
+
* Copies `source` onto the other pane. Programmatic zoom-to-fit on a newly
|
|
2460
|
+
* opened follower is discarded so the already-open drawing keeps its camera.
|
|
2461
|
+
*/
|
|
2462
|
+
AcApDiffViewer.prototype.onPaneViewChanged = function (source) {
|
|
2463
|
+
if (this.disposed || this.viewSyncLock || !this.isViewSyncActive())
|
|
2464
|
+
return;
|
|
2465
|
+
var other = source === 'left' ? 'right' : 'left';
|
|
2466
|
+
if (this.viewSyncFollowOpen &&
|
|
2467
|
+
source !== this.viewSyncLeader &&
|
|
2468
|
+
!this.viewSyncFromUser) {
|
|
2469
|
+
this.copyVisibleView(this.viewSyncLeader, source);
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
this.viewSyncFollowOpen = false;
|
|
2473
|
+
this.viewSyncFromUser = false;
|
|
2474
|
+
this.viewSyncLeader = source;
|
|
2475
|
+
this.copyVisibleView(source, other);
|
|
2476
|
+
};
|
|
2477
|
+
/**
|
|
2478
|
+
* Copies the visible world box of `from` onto `to` without echoing back
|
|
2479
|
+
* through {@link onPaneViewChanged}.
|
|
2480
|
+
*/
|
|
2481
|
+
AcApDiffViewer.prototype.copyVisibleView = function (from, to) {
|
|
2482
|
+
var _this = this;
|
|
2483
|
+
if (from === to || this.viewSyncLock)
|
|
2484
|
+
return;
|
|
2485
|
+
if (!this.documentFor(from) || !this.documentFor(to))
|
|
2486
|
+
return;
|
|
2487
|
+
var source;
|
|
2488
|
+
var target;
|
|
2489
|
+
try {
|
|
2490
|
+
source = this.viewFor(from);
|
|
2491
|
+
target = this.viewFor(to);
|
|
2492
|
+
}
|
|
2493
|
+
catch (_a) {
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
var width = source.width;
|
|
2497
|
+
var height = source.height;
|
|
2498
|
+
if (width < 2 || height < 2)
|
|
2499
|
+
return;
|
|
2500
|
+
var box;
|
|
2501
|
+
try {
|
|
2502
|
+
var a = source.screenToWorld({ x: 0, y: 0 });
|
|
2503
|
+
var b = source.screenToWorld({ x: width, y: height });
|
|
2504
|
+
box = new AcGeBox2d();
|
|
2505
|
+
box.expandByPoint(a);
|
|
2506
|
+
box.expandByPoint(b);
|
|
2507
|
+
}
|
|
2508
|
+
catch (_b) {
|
|
2509
|
+
return;
|
|
2510
|
+
}
|
|
2511
|
+
this.viewSyncLock = true;
|
|
2512
|
+
try {
|
|
2513
|
+
target.zoomTo(box, 1);
|
|
2514
|
+
}
|
|
2515
|
+
catch (_c) {
|
|
2516
|
+
// Layout view may not exist yet on an empty pane.
|
|
2517
|
+
}
|
|
2518
|
+
finally {
|
|
2519
|
+
requestAnimationFrame(function () {
|
|
2520
|
+
_this.viewSyncLock = false;
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
/**
|
|
2525
|
+
* Returns `doc` only while it still has a live session.
|
|
2526
|
+
*
|
|
2527
|
+
* @param doc - Candidate document stored on this widget.
|
|
2528
|
+
*/
|
|
2529
|
+
AcApDiffViewer.prototype.liveDoc = function (doc) {
|
|
2530
|
+
if (!doc)
|
|
2531
|
+
return undefined;
|
|
2532
|
+
try {
|
|
2533
|
+
return requireInstance().sessionFor(doc) ? doc : undefined;
|
|
2534
|
+
}
|
|
2535
|
+
catch (_a) {
|
|
2536
|
+
return undefined;
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
/** Display title for a pane header. */
|
|
2540
|
+
AcApDiffViewer.prototype.paneTitle = function (doc) {
|
|
2541
|
+
if (!doc)
|
|
2542
|
+
return acapDiffViewerT('noDrawing');
|
|
2543
|
+
return doc.docTitle || doc.fileName || AcApI18n.t('main.document.untitled');
|
|
2544
|
+
};
|
|
2545
|
+
/** Syncs pane titles, empty states, and focus rings with live documents. */
|
|
2546
|
+
AcApDiffViewer.prototype.syncChrome = function () {
|
|
2547
|
+
var left = this.leftDocument;
|
|
2548
|
+
var right = this.rightDocument;
|
|
2549
|
+
this.leftDoc = left;
|
|
2550
|
+
this.rightDoc = right;
|
|
2551
|
+
this.syncPaneChrome(this.leftUi, left);
|
|
2552
|
+
this.syncPaneChrome(this.rightUi, right);
|
|
2553
|
+
this.syncFocusRings();
|
|
2554
|
+
this.syncToolbarButtons();
|
|
2555
|
+
window.dispatchEvent(new Event('resize'));
|
|
2556
|
+
};
|
|
2557
|
+
/**
|
|
2558
|
+
* Sets `is-focused` immediately so the target pane's canvas receives
|
|
2559
|
+
* pointer events. Unfocused canvases use `pointer-events: none`.
|
|
2560
|
+
*/
|
|
2561
|
+
AcApDiffViewer.prototype.applyFocusClass = function (side) {
|
|
2562
|
+
this.leftUi.pane.classList.toggle('is-focused', side === 'left');
|
|
2563
|
+
this.rightUi.pane.classList.toggle('is-focused', side === 'right');
|
|
2564
|
+
};
|
|
2565
|
+
/** Updates pane focus rings from the active document. */
|
|
2566
|
+
AcApDiffViewer.prototype.syncFocusRings = function () {
|
|
2567
|
+
var right = this.rightDocument;
|
|
2568
|
+
var active;
|
|
2569
|
+
try {
|
|
2570
|
+
active = requireInstance().curDocument;
|
|
2571
|
+
}
|
|
2572
|
+
catch (_a) {
|
|
2573
|
+
active = undefined;
|
|
2574
|
+
}
|
|
2575
|
+
if (active === right && right)
|
|
2576
|
+
this.applyFocusClass('right');
|
|
2577
|
+
else
|
|
2578
|
+
this.applyFocusClass('left');
|
|
2579
|
+
};
|
|
2580
|
+
/**
|
|
2581
|
+
* Updates one pane's header and empty-state copy.
|
|
2582
|
+
*
|
|
2583
|
+
* @param ui - Pane DOM.
|
|
2584
|
+
* @param doc - Live document, if any.
|
|
2585
|
+
*/
|
|
2586
|
+
AcApDiffViewer.prototype.syncPaneChrome = function (ui, doc) {
|
|
2587
|
+
ui.pane.classList.toggle('is-empty', !doc);
|
|
2588
|
+
ui.empty.classList.toggle('is-hidden', Boolean(doc));
|
|
2589
|
+
ui.title.textContent = this.paneTitle(doc);
|
|
2590
|
+
ui.title.classList.toggle('is-empty', !doc);
|
|
2591
|
+
ui.openButton.setAttribute('aria-label', acapDiffViewerT('openFile'));
|
|
2592
|
+
ui.openButton.title = acapDiffViewerT('openFile');
|
|
2593
|
+
ui.emptyTitle.textContent = acapDiffViewerT('emptyTitle');
|
|
2594
|
+
ui.emptyHint.textContent = acapDiffViewerT('emptyHint');
|
|
2595
|
+
if (!ui.emptyError.classList.contains('is-hidden')) {
|
|
2596
|
+
ui.emptyError.textContent = acapDiffViewerT('invalidFile');
|
|
2597
|
+
}
|
|
2598
|
+
if (!ui.banner.classList.contains('is-hidden')) {
|
|
2599
|
+
ui.banner.textContent = acapDiffViewerT('invalidFile');
|
|
2600
|
+
}
|
|
2601
|
+
};
|
|
2602
|
+
/** Updates view-mode button labels and active states. */
|
|
2603
|
+
AcApDiffViewer.prototype.syncViewModeUi = function () {
|
|
2604
|
+
var e_19, _a;
|
|
2605
|
+
this.root.classList.toggle('is-overlay', this.viewMode === 'overlay');
|
|
2606
|
+
this.btnSideBySide.classList.toggle('is-active', this.viewMode === 'side-by-side');
|
|
2607
|
+
this.btnOverlay.classList.toggle('is-active', this.viewMode === 'overlay');
|
|
2608
|
+
var sideBySideLabel = acapDiffViewerT('toolbarSideBySide');
|
|
2609
|
+
var overlayLabel = acapDiffViewerT('toolbarOverlay');
|
|
2610
|
+
var togglePanelLabel = acapDiffViewerT('toolbarTogglePanel');
|
|
2611
|
+
this.btnSideBySide.title = sideBySideLabel;
|
|
2612
|
+
this.btnSideBySide.setAttribute('aria-label', sideBySideLabel);
|
|
2613
|
+
this.btnOverlay.title = overlayLabel;
|
|
2614
|
+
this.btnOverlay.setAttribute('aria-label', overlayLabel);
|
|
2615
|
+
var syncLabel = acapDiffViewerT('toolbarSyncViews');
|
|
2616
|
+
this.btnSyncViews.title = syncLabel;
|
|
2617
|
+
this.btnSyncViews.setAttribute('aria-label', syncLabel);
|
|
2618
|
+
this.btnSyncViews.setAttribute('aria-pressed', String(this.viewsSynced));
|
|
2619
|
+
this.btnSyncViews.classList.toggle('is-active', this.viewsSynced);
|
|
2620
|
+
this.btnSyncViews.hidden = this.viewMode !== 'side-by-side';
|
|
2621
|
+
this.btnTogglePanel.title = togglePanelLabel;
|
|
2622
|
+
this.btnTogglePanel.setAttribute('aria-label', togglePanelLabel);
|
|
2623
|
+
this.btnPrev.title = acapDiffViewerT('toolbarPrev');
|
|
2624
|
+
this.btnNext.title = acapDiffViewerT('toolbarNext');
|
|
2625
|
+
var settingsLabel = acapDiffViewerT('toolbarSettings');
|
|
2626
|
+
this.btnSettings.title = settingsLabel;
|
|
2627
|
+
this.btnSettings.setAttribute('aria-label', settingsLabel);
|
|
2628
|
+
this.syncToolbarButtons();
|
|
2629
|
+
this.syncMarkupVisibilityButton();
|
|
2630
|
+
this.syncThemeButton();
|
|
2631
|
+
this.syncLocaleSelect();
|
|
2632
|
+
try {
|
|
2633
|
+
for (var _b = __values(this.markupButtons), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2634
|
+
var btn = _c.value;
|
|
2635
|
+
var key = btn.dataset.labelKey;
|
|
2636
|
+
var label = acapDiffViewerT(key);
|
|
2637
|
+
btn.title = label;
|
|
2638
|
+
btn.setAttribute('aria-label', label);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
2642
|
+
finally {
|
|
2643
|
+
try {
|
|
2644
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2645
|
+
}
|
|
2646
|
+
finally { if (e_19) throw e_19.error; }
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
/** Updates side-panel visibility, tabs, and grouping toggles. */
|
|
2650
|
+
AcApDiffViewer.prototype.syncPanelUi = function () {
|
|
2651
|
+
this.sidePanel.classList.toggle('is-collapsed', !this.sidePanelOpen);
|
|
2652
|
+
this.btnTogglePanel.classList.toggle('is-active', this.sidePanelOpen);
|
|
2653
|
+
this.panelTitle.textContent = acapDiffViewerT('panelTitle');
|
|
2654
|
+
this.tabResults.textContent = acapDiffViewerT('tabResults');
|
|
2655
|
+
this.tabMarkups.textContent = acapDiffViewerT('tabMarkups');
|
|
2656
|
+
this.groupByKindBtn.textContent = acapDiffViewerT('groupByKind');
|
|
2657
|
+
this.groupByTypeBtn.textContent = acapDiffViewerT('groupByType');
|
|
2658
|
+
this.tabResults.classList.toggle('is-active', this.activeTab === 'results');
|
|
2659
|
+
this.tabMarkups.classList.toggle('is-active', this.activeTab === 'markups');
|
|
2660
|
+
this.resultsBody.hidden = this.activeTab !== 'results';
|
|
2661
|
+
this.markupsBody.hidden = this.activeTab !== 'markups';
|
|
2662
|
+
this.groupByKindBtn.classList.toggle('is-active', this.resultGroupMode === 'kind');
|
|
2663
|
+
this.groupByTypeBtn.classList.toggle('is-active', this.resultGroupMode === 'type');
|
|
2664
|
+
// Hide group toolbar on markups tab
|
|
2665
|
+
var groupBar = this.groupByKindBtn.parentElement;
|
|
2666
|
+
if (groupBar)
|
|
2667
|
+
groupBar.hidden = this.activeTab !== 'results';
|
|
2668
|
+
if (!this.sidePanelOpen || this.activeTab !== 'results') {
|
|
2669
|
+
this.hideDiffPopover(true);
|
|
2670
|
+
}
|
|
2671
|
+
};
|
|
2672
|
+
/**
|
|
2673
|
+
* Updates toolbar markup and diff-navigation controls from open documents
|
|
2674
|
+
* and the latest compare result.
|
|
2675
|
+
*/
|
|
2676
|
+
AcApDiffViewer.prototype.syncToolbarButtons = function () {
|
|
2677
|
+
var e_20, _a;
|
|
2678
|
+
var _b, _c, _d, _e;
|
|
2679
|
+
var hasDoc = Boolean(this.leftDocument || this.rightDocument);
|
|
2680
|
+
var compareDone = Boolean(this.compareResult);
|
|
2681
|
+
var nav = (_c = (_b = this.compareResult) === null || _b === void 0 ? void 0 : _b.navigation) !== null && _c !== void 0 ? _c : [];
|
|
2682
|
+
var navReady = compareDone && nav.length > 0;
|
|
2683
|
+
this.btnMarkupVis.disabled = !hasDoc;
|
|
2684
|
+
this.btnClearMarkups.disabled = !hasDoc;
|
|
2685
|
+
try {
|
|
2686
|
+
for (var _f = __values(this.markupButtons), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2687
|
+
var btn = _g.value;
|
|
2688
|
+
if (btn.dataset.command) {
|
|
2689
|
+
btn.disabled = !hasDoc;
|
|
2690
|
+
}
|
|
2691
|
+
else if (btn.dataset.labelKey === 'markupClear') {
|
|
2692
|
+
btn.disabled = !hasDoc;
|
|
2693
|
+
}
|
|
2694
|
+
else if (btn.dataset.labelKey === 'markupGenerateClouds') {
|
|
2695
|
+
btn.disabled =
|
|
2696
|
+
!compareDone || ((_e = (_d = this.compareResult) === null || _d === void 0 ? void 0 : _d.changeSets.length) !== null && _e !== void 0 ? _e : 0) === 0;
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
2701
|
+
finally {
|
|
2702
|
+
try {
|
|
2703
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
2704
|
+
}
|
|
2705
|
+
finally { if (e_20) throw e_20.error; }
|
|
2706
|
+
}
|
|
2707
|
+
this.btnPrev.disabled = !navReady || this.navIndex <= 0;
|
|
2708
|
+
this.btnNext.disabled = !navReady || this.navIndex >= nav.length - 1;
|
|
2709
|
+
};
|
|
2710
|
+
/**
|
|
2711
|
+
* Applies UI chrome theme tokens and refreshes the toolbar theme button.
|
|
2712
|
+
*
|
|
2713
|
+
* @param theme - Target light or dark chrome theme.
|
|
2714
|
+
*/
|
|
2715
|
+
AcApDiffViewer.prototype.setUiTheme = function (theme) {
|
|
2716
|
+
this.uiTheme = theme;
|
|
2717
|
+
acedApplyUiTheme(theme, this.root);
|
|
2718
|
+
this.syncThemeButton();
|
|
2719
|
+
};
|
|
2720
|
+
/**
|
|
2721
|
+
* Updates the markup visibility toggle icon and label (action: hide when
|
|
2722
|
+
* shown, show when hidden).
|
|
2723
|
+
*/
|
|
2724
|
+
AcApDiffViewer.prototype.syncMarkupVisibilityButton = function () {
|
|
2725
|
+
var visible = isMarkupVisible();
|
|
2726
|
+
this.btnMarkupVis.innerHTML = visible
|
|
2727
|
+
? ICON_ANNOTATION_HIDE
|
|
2728
|
+
: ICON_ANNOTATION_SHOW;
|
|
2729
|
+
var label = acapDiffViewerT(visible ? 'markupHide' : 'markupShow');
|
|
2730
|
+
this.btnMarkupVis.title = label;
|
|
2731
|
+
this.btnMarkupVis.setAttribute('aria-label', label);
|
|
2732
|
+
this.btnMarkupVis.setAttribute('aria-pressed', String(visible));
|
|
2733
|
+
this.btnMarkupVis.classList.toggle('is-active', visible);
|
|
2734
|
+
};
|
|
2735
|
+
/**
|
|
2736
|
+
* Shows the opposite-theme icon (sun in dark, moon in light), matching
|
|
2737
|
+
* cad-viewer's status-bar theme button.
|
|
2738
|
+
*/
|
|
2739
|
+
AcApDiffViewer.prototype.syncThemeButton = function () {
|
|
2740
|
+
var isDark = this.uiTheme === 'dark';
|
|
2741
|
+
this.btnTheme.innerHTML = isDark ? ICON_THEME_SUNNY : ICON_THEME_MOON;
|
|
2742
|
+
var label = isDark
|
|
2743
|
+
? acapDiffViewerT('toolbarThemeDark')
|
|
2744
|
+
: acapDiffViewerT('toolbarThemeLight');
|
|
2745
|
+
this.btnTheme.title = label;
|
|
2746
|
+
this.btnTheme.setAttribute('aria-label', label);
|
|
2747
|
+
};
|
|
2748
|
+
/** Throws if {@link destroy} has already run. */
|
|
2749
|
+
AcApDiffViewer.prototype.assertAlive = function () {
|
|
2750
|
+
if (this.disposed) {
|
|
2751
|
+
throw new Error('AcApDiffViewer has been destroyed');
|
|
2752
|
+
}
|
|
2753
|
+
};
|
|
2754
|
+
return AcApDiffViewer;
|
|
2755
|
+
}());
|
|
2756
|
+
export { AcApDiffViewer };
|
|
2757
|
+
//# sourceMappingURL=AcApDiffViewer.js.map
|