@mlightcad/cad-pdf-plugin 1.8.0-preview.3 → 1.8.0-preview.4
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 -21
- package/README.md +280 -186
- package/dist/cad-pdf-plugin-register.js +29 -11
- package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
- package/dist/cad-pdf-plugin.js +17568 -8428
- package/dist/cad-pdf-plugin.umd.cjs +847 -13
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
- package/lib/AcApConvertToPdfCmd.js +14 -3
- package/lib/AcApConvertToPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfCmd.d.ts +5 -3
- package/lib/AcApImportPdfCmd.d.ts.map +1 -1
- package/lib/AcApImportPdfCmd.js +5 -3
- package/lib/AcApImportPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfPromptCmd.d.ts +16 -0
- package/lib/AcApImportPdfPromptCmd.d.ts.map +1 -0
- package/lib/AcApImportPdfPromptCmd.js +89 -0
- package/lib/AcApImportPdfPromptCmd.js.map +1 -0
- package/lib/AcApPdfBlockCmd.d.ts +15 -0
- package/lib/AcApPdfBlockCmd.d.ts.map +1 -0
- package/lib/AcApPdfBlockCmd.js +75 -0
- package/lib/AcApPdfBlockCmd.js.map +1 -0
- package/lib/AcApPdfDimCmd.d.ts +20 -0
- package/lib/AcApPdfDimCmd.d.ts.map +1 -0
- package/lib/AcApPdfDimCmd.js +413 -0
- package/lib/AcApPdfDimCmd.js.map +1 -0
- package/lib/AcApPdfDimSession.d.ts +82 -0
- package/lib/AcApPdfDimSession.d.ts.map +1 -0
- package/lib/AcApPdfDimSession.js +252 -0
- package/lib/AcApPdfDimSession.js.map +1 -0
- package/lib/AcApPdfFontResolver.d.ts.map +1 -1
- package/lib/AcApPdfFontResolver.js +2 -5
- package/lib/AcApPdfFontResolver.js.map +1 -1
- package/lib/AcApPdfHatchCmd.d.ts +33 -0
- package/lib/AcApPdfHatchCmd.d.ts.map +1 -0
- package/lib/AcApPdfHatchCmd.js +411 -0
- package/lib/AcApPdfHatchCmd.js.map +1 -0
- package/lib/AcApPdfHatchSession.d.ts +122 -0
- package/lib/AcApPdfHatchSession.d.ts.map +1 -0
- package/lib/AcApPdfHatchSession.js +357 -0
- package/lib/AcApPdfHatchSession.js.map +1 -0
- package/lib/AcApPdfImportConvertor.d.ts +47 -5
- package/lib/AcApPdfImportConvertor.d.ts.map +1 -1
- package/lib/AcApPdfImportConvertor.js +999 -108
- package/lib/AcApPdfImportConvertor.js.map +1 -1
- package/lib/AcApPdfImportOptions.d.ts +116 -0
- package/lib/AcApPdfImportOptions.d.ts.map +1 -0
- package/lib/AcApPdfImportOptions.js +31 -0
- package/lib/AcApPdfImportOptions.js.map +1 -0
- package/lib/AcApPdfImportResources.d.ts +41 -0
- package/lib/AcApPdfImportResources.d.ts.map +1 -0
- package/lib/AcApPdfImportResources.js +52 -0
- package/lib/AcApPdfImportResources.js.map +1 -0
- package/lib/AcApPdfPlugin.d.ts +3 -3
- package/lib/AcApPdfPlugin.d.ts.map +1 -1
- package/lib/AcApPdfPlugin.js +23 -5
- package/lib/AcApPdfPlugin.js.map +1 -1
- package/lib/AcApPdfScaleCmd.d.ts +22 -0
- package/lib/AcApPdfScaleCmd.d.ts.map +1 -0
- package/lib/AcApPdfScaleCmd.js +185 -0
- package/lib/AcApPdfScaleCmd.js.map +1 -0
- package/lib/AcApPdfTextCmd.d.ts +73 -0
- package/lib/AcApPdfTextCmd.d.ts.map +1 -0
- package/lib/AcApPdfTextCmd.js +777 -0
- package/lib/AcApPdfTextCmd.js.map +1 -0
- package/lib/AcApPdfTextSession.d.ts +232 -0
- package/lib/AcApPdfTextSession.d.ts.map +1 -0
- package/lib/AcApPdfTextSession.js +826 -0
- package/lib/AcApPdfTextSession.js.map +1 -0
- package/lib/acapPdfI18n.d.ts +11 -0
- package/lib/acapPdfI18n.d.ts.map +1 -0
- package/lib/acapPdfI18n.js +57 -0
- package/lib/acapPdfI18n.js.map +1 -0
- package/lib/acapPdfPrompts.d.ts +12 -0
- package/lib/acapPdfPrompts.d.ts.map +1 -0
- package/lib/acapPdfPrompts.js +100 -0
- package/lib/acapPdfPrompts.js.map +1 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -1
- package/lib/pdfDeprecatedMatching.d.ts +27 -0
- package/lib/pdfDeprecatedMatching.d.ts.map +1 -0
- package/lib/pdfDeprecatedMatching.js +20 -0
- package/lib/pdfDeprecatedMatching.js.map +1 -0
- package/lib/pdfDimStrokeTexts.d.ts +55 -0
- package/lib/pdfDimStrokeTexts.d.ts.map +1 -0
- package/lib/pdfDimStrokeTexts.js +274 -0
- package/lib/pdfDimStrokeTexts.js.map +1 -0
- package/lib/pdfDimensionConvert.d.ts +80 -0
- package/lib/pdfDimensionConvert.d.ts.map +1 -0
- package/lib/pdfDimensionConvert.js +566 -0
- package/lib/pdfDimensionConvert.js.map +1 -0
- package/lib/pdfEntityStrokes.d.ts +13 -0
- package/lib/pdfEntityStrokes.d.ts.map +1 -0
- package/lib/pdfEntityStrokes.js +86 -0
- package/lib/pdfEntityStrokes.js.map +1 -0
- package/lib/pdfHatchRecover.d.ts +57 -0
- package/lib/pdfHatchRecover.d.ts.map +1 -0
- package/lib/pdfHatchRecover.js +315 -0
- package/lib/pdfHatchRecover.js.map +1 -0
- package/lib/pdfImportAppend.d.ts +24 -0
- package/lib/pdfImportAppend.d.ts.map +1 -0
- package/lib/pdfImportAppend.js +35 -0
- package/lib/pdfImportAppend.js.map +1 -0
- package/lib/pdfImportEntities.d.ts +63 -0
- package/lib/pdfImportEntities.d.ts.map +1 -0
- package/lib/pdfImportEntities.js +307 -0
- package/lib/pdfImportEntities.js.map +1 -0
- package/lib/pdfImportImages.d.ts +90 -0
- package/lib/pdfImportImages.d.ts.map +1 -0
- package/lib/pdfImportImages.js +294 -0
- package/lib/pdfImportImages.js.map +1 -0
- package/lib/pdfImportShapes.d.ts +63 -0
- package/lib/pdfImportShapes.d.ts.map +1 -0
- package/lib/pdfImportShapes.js +248 -0
- package/lib/pdfImportShapes.js.map +1 -0
- package/lib/pdfVectorImport.d.ts +218 -5
- package/lib/pdfVectorImport.d.ts.map +1 -1
- package/lib/pdfVectorImport.js +566 -98
- package/lib/pdfVectorImport.js.map +1 -1
- package/lib/recognition/pdfCurveRecognition.d.ts +91 -0
- package/lib/recognition/pdfCurveRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfCurveRecognition.js +506 -0
- package/lib/recognition/pdfCurveRecognition.js.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts +18 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.js +520 -0
- package/lib/recognition/pdfDimDigitRecognition.js.map +1 -0
- package/lib/recognition/pdfDimensionPattern.d.ts +173 -0
- package/lib/recognition/pdfDimensionPattern.d.ts.map +1 -0
- package/lib/recognition/pdfDimensionPattern.js +1023 -0
- package/lib/recognition/pdfDimensionPattern.js.map +1 -0
- package/lib/recognition/pdfFormBlocks.d.ts +58 -0
- package/lib/recognition/pdfFormBlocks.d.ts.map +1 -0
- package/lib/recognition/pdfFormBlocks.js +260 -0
- package/lib/recognition/pdfFormBlocks.js.map +1 -0
- package/lib/recognition/pdfGlyphClustering.d.ts +81 -0
- package/lib/recognition/pdfGlyphClustering.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphClustering.js +1005 -0
- package/lib/recognition/pdfGlyphClustering.js.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts +49 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.js +188 -0
- package/lib/recognition/pdfGlyphDictionary.js.map +1 -0
- package/lib/recognition/pdfHatchFaces.d.ts +84 -0
- package/lib/recognition/pdfHatchFaces.d.ts.map +1 -0
- package/lib/recognition/pdfHatchFaces.js +1285 -0
- package/lib/recognition/pdfHatchFaces.js.map +1 -0
- package/lib/recognition/pdfHatchRecognition.d.ts +222 -0
- package/lib/recognition/pdfHatchRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfHatchRecognition.js +3781 -0
- package/lib/recognition/pdfHatchRecognition.js.map +1 -0
- package/lib/recognition/pdfRecGeometry.d.ts +67 -0
- package/lib/recognition/pdfRecGeometry.d.ts.map +1 -0
- package/lib/recognition/pdfRecGeometry.js +365 -0
- package/lib/recognition/pdfRecGeometry.js.map +1 -0
- package/lib/recognition/pdfTextFontKind.d.ts +16 -0
- package/lib/recognition/pdfTextFontKind.d.ts.map +1 -0
- package/lib/recognition/pdfTextFontKind.js +51 -0
- package/lib/recognition/pdfTextFontKind.js.map +1 -0
- package/lib/recognition/pdfTextMerge.d.ts +71 -0
- package/lib/recognition/pdfTextMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextMerge.js +382 -0
- package/lib/recognition/pdfTextMerge.js.map +1 -0
- package/lib/recognition/pdfTextRunMerge.d.ts +28 -0
- package/lib/recognition/pdfTextRunMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextRunMerge.js +90 -0
- package/lib/recognition/pdfTextRunMerge.js.map +1 -0
- package/lib/register.d.ts +8 -2
- package/lib/register.d.ts.map +1 -1
- package/lib/register.js +29 -4
- package/lib/register.js.map +1 -1
- package/lib/ui/AcUiPdfDimPanel.d.ts +55 -0
- package/lib/ui/AcUiPdfDimPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfDimPanel.js +347 -0
- package/lib/ui/AcUiPdfDimPanel.js.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts +57 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.js +420 -0
- package/lib/ui/AcUiPdfHatchPanel.js.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts +120 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.js +673 -0
- package/lib/ui/AcUiPdfImportDialog.js.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts +95 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.js +775 -0
- package/lib/ui/AcUiPdfTextPanel.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
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);
|
|
27
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
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;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __values = (this && this.__values) || function(o) {
|
|
53
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
54
|
+
if (m) return m.call(o);
|
|
55
|
+
if (o && typeof o.length === "number") return {
|
|
56
|
+
next: function () {
|
|
57
|
+
if (o && i >= o.length) o = void 0;
|
|
58
|
+
return { value: o && o[i++], done: !o };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
62
|
+
};
|
|
63
|
+
import { AcUiDialog } from '@mlightcad/cad-simple-viewer';
|
|
64
|
+
import { acapPdfT } from '../acapPdfI18n';
|
|
65
|
+
import { PDF_PT_TO_MM } from '../pdfVectorImport';
|
|
66
|
+
var STYLE_ID = 'ml-pdf-import-dialog-styles';
|
|
67
|
+
var MM_PER_INCH = 25.4;
|
|
68
|
+
/** Largest thumbnail edge in the grid view, CSS px. */
|
|
69
|
+
var THUMB_SIZE = 96;
|
|
70
|
+
/**
|
|
71
|
+
* "Import PDF" dialog of the `pdfimport` command, laid out after AutoCAD's
|
|
72
|
+
* IMPORTPDF dialog: file name with Browse, the page to import with a preview
|
|
73
|
+
* or thumbnail grid, the insertion point and scale, and the import mode.
|
|
74
|
+
*
|
|
75
|
+
* The dialog only collects options; the caller imports.
|
|
76
|
+
*/
|
|
77
|
+
var AcUiPdfImportDialog = /** @class */ (function (_super) {
|
|
78
|
+
__extends(AcUiPdfImportDialog, _super);
|
|
79
|
+
function AcUiPdfImportDialog(options) {
|
|
80
|
+
var e_1, _a;
|
|
81
|
+
var _b, _c, _d, _e;
|
|
82
|
+
var _this = _super.call(this, {
|
|
83
|
+
host: options.host,
|
|
84
|
+
title: t('title'),
|
|
85
|
+
closeLabel: t('close'),
|
|
86
|
+
dialogClassName: 'ml-pdf-import-dialog',
|
|
87
|
+
closeOnBackdrop: false
|
|
88
|
+
}) || this;
|
|
89
|
+
_this.view = 'single';
|
|
90
|
+
/** Bumped on every preview change; stale renders stop drawing. */
|
|
91
|
+
_this.generation = 0;
|
|
92
|
+
_this.tasks = new Set();
|
|
93
|
+
ensureStyles();
|
|
94
|
+
_this.source = options.source;
|
|
95
|
+
_this.browse = options.browse;
|
|
96
|
+
var initial = (_b = options.initial) !== null && _b !== void 0 ? _b : {};
|
|
97
|
+
_this.values = {
|
|
98
|
+
pageNumber: clampPage((_c = initial.pageNumber) !== null && _c !== void 0 ? _c : 1, _this.source),
|
|
99
|
+
mode: initial.mode === 'visual' ? 'visual' : 'recover',
|
|
100
|
+
scale: initial.scale !== undefined && initial.scale > 0 ? initial.scale : 1,
|
|
101
|
+
specifyOnScreen: (_d = initial.specifyOnScreen) !== null && _d !== void 0 ? _d : false,
|
|
102
|
+
insertionPoint: (_e = initial.insertionPoint) !== null && _e !== void 0 ? _e : { x: 0, y: 0 }
|
|
103
|
+
};
|
|
104
|
+
// File name + Browse.
|
|
105
|
+
var fileRow = h('div', 'ml-pdf-import-file');
|
|
106
|
+
_this.fileInput = h('input', 'ml-pdf-import-input');
|
|
107
|
+
_this.fileInput.readOnly = true;
|
|
108
|
+
_this.fileInput.setAttribute('aria-label', t('fileName'));
|
|
109
|
+
var browseButton = button(t('browse'), 'secondary', function () {
|
|
110
|
+
void _this.browseFile();
|
|
111
|
+
});
|
|
112
|
+
browseButton.classList.add('ml-pdf-import-browse');
|
|
113
|
+
browseButton.hidden = !_this.browse;
|
|
114
|
+
fileRow.append(h('span', 'ml-pdf-import-label', t('fileName')), _this.fileInput, browseButton);
|
|
115
|
+
// Pages to import.
|
|
116
|
+
var pages = group(t('pagesGroup'), 'ml-pdf-import-pages');
|
|
117
|
+
var pageBar = h('div', 'ml-pdf-import-pagebar');
|
|
118
|
+
_this.pageInput = numberField(1);
|
|
119
|
+
_this.pageInput.min = '1';
|
|
120
|
+
_this.pageInput.classList.add('ml-pdf-import-page');
|
|
121
|
+
_this.pageInput.addEventListener('change', function () { return _this.commitPageInput(); });
|
|
122
|
+
_this.totalEl = h('span', 'ml-pdf-import-total');
|
|
123
|
+
_this.singleButton = viewButton(t('singleView'), SINGLE_ICON, function () {
|
|
124
|
+
return _this.setView('single');
|
|
125
|
+
});
|
|
126
|
+
_this.gridButton = viewButton(t('gridView'), GRID_ICON, function () {
|
|
127
|
+
return _this.setView('grid');
|
|
128
|
+
});
|
|
129
|
+
var viewToggle = h('div', 'ml-pdf-import-views');
|
|
130
|
+
viewToggle.append(_this.singleButton, _this.gridButton);
|
|
131
|
+
pageBar.append(labelled(t('page'), _this.pageInput), _this.totalEl, viewToggle);
|
|
132
|
+
_this.previewEl = h('div', 'ml-pdf-import-preview');
|
|
133
|
+
_this.pageSizeEl = h('span', 'ml-pdf-import-pagesize');
|
|
134
|
+
pages.append(pageBar, _this.previewEl, _this.pageSizeEl);
|
|
135
|
+
// Position.
|
|
136
|
+
var position = group(t('positionGroup'));
|
|
137
|
+
_this.onScreenInput = h('input');
|
|
138
|
+
_this.onScreenInput.type = 'checkbox';
|
|
139
|
+
_this.onScreenInput.checked = _this.values.specifyOnScreen;
|
|
140
|
+
_this.onScreenInput.addEventListener('change', function () { return _this.updateState(); });
|
|
141
|
+
var onScreen = h('label', 'ml-pdf-import-check');
|
|
142
|
+
onScreen.append(_this.onScreenInput, h('span', undefined, t('onScreen')));
|
|
143
|
+
_this.xInput = numberField(_this.values.insertionPoint.x);
|
|
144
|
+
_this.yInput = numberField(_this.values.insertionPoint.y);
|
|
145
|
+
_this.scaleInput = numberField(_this.values.scale);
|
|
146
|
+
_this.scaleInput.min = '0';
|
|
147
|
+
try {
|
|
148
|
+
for (var _f = __values([_this.xInput, _this.yInput, _this.scaleInput]), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
149
|
+
var input = _g.value;
|
|
150
|
+
input.addEventListener('input', function () { return _this.updateState(); });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
154
|
+
finally {
|
|
155
|
+
try {
|
|
156
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
157
|
+
}
|
|
158
|
+
finally { if (e_1) throw e_1.error; }
|
|
159
|
+
}
|
|
160
|
+
var point = h('div', 'ml-pdf-import-point');
|
|
161
|
+
point.append(labelled(t('x'), _this.xInput), labelled(t('y'), _this.yInput));
|
|
162
|
+
position.append(onScreen, point, labelled(t('scale'), _this.scaleInput));
|
|
163
|
+
// Import mode.
|
|
164
|
+
var mode = group(t('modeGroup'));
|
|
165
|
+
var radioName = "ml-pdf-import-mode-".concat(nextId++);
|
|
166
|
+
_this.modeInputs = {
|
|
167
|
+
recover: radio(radioName, _this.values.mode === 'recover'),
|
|
168
|
+
visual: radio(radioName, _this.values.mode === 'visual')
|
|
169
|
+
};
|
|
170
|
+
mode.append(radioOption(_this.modeInputs.recover, t('modeRecover'), t('recoverHint')), radioOption(_this.modeInputs.visual, t('modeVisual'), t('visualHint')));
|
|
171
|
+
var side = h('div', 'ml-pdf-import-side');
|
|
172
|
+
side.append(position, mode);
|
|
173
|
+
var columns = h('div', 'ml-pdf-import-columns');
|
|
174
|
+
columns.append(pages, side);
|
|
175
|
+
_this.bodyEl.append(fileRow, columns);
|
|
176
|
+
// Enter in a field confirms, as in a desktop dialog.
|
|
177
|
+
_this.bodyEl.addEventListener('keydown', function (event) {
|
|
178
|
+
if (event.key !== 'Enter')
|
|
179
|
+
return;
|
|
180
|
+
var target = event.target;
|
|
181
|
+
if (target.tagName !== 'INPUT')
|
|
182
|
+
return;
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
if (target === _this.pageInput)
|
|
185
|
+
_this.commitPageInput();
|
|
186
|
+
_this.confirm();
|
|
187
|
+
});
|
|
188
|
+
var cancelButton = button(t('cancel'), 'secondary', function () { return _this.close(); });
|
|
189
|
+
_this.okButton = button(t('ok'), 'primary', function () { return _this.confirm(); });
|
|
190
|
+
_this.footerEl.append(_this.okButton, cancelButton);
|
|
191
|
+
_this.loadSource();
|
|
192
|
+
_this.updateState();
|
|
193
|
+
_this.focusAfterOpen(_this.okButton);
|
|
194
|
+
return _this;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Shows the dialog.
|
|
198
|
+
*
|
|
199
|
+
* @returns The chosen options, or `undefined` when the user cancels.
|
|
200
|
+
*/
|
|
201
|
+
AcUiPdfImportDialog.open = function (options) {
|
|
202
|
+
var dialog = new AcUiPdfImportDialog(options);
|
|
203
|
+
return dialog.show().then(function () { return dialog.result; });
|
|
204
|
+
};
|
|
205
|
+
/** @inheritdoc */
|
|
206
|
+
AcUiPdfImportDialog.prototype.close = function () {
|
|
207
|
+
var _a;
|
|
208
|
+
this.stopRendering();
|
|
209
|
+
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
210
|
+
_super.prototype.close.call(this);
|
|
211
|
+
};
|
|
212
|
+
/** Shows {@link source}: file name, page count, preview. */
|
|
213
|
+
AcUiPdfImportDialog.prototype.loadSource = function () {
|
|
214
|
+
this.fileInput.value = this.source.fileName;
|
|
215
|
+
this.fileInput.title = this.source.fileName;
|
|
216
|
+
var count = this.source.document.numPages;
|
|
217
|
+
this.pageInput.max = String(count);
|
|
218
|
+
this.pageInput.disabled = count <= 1;
|
|
219
|
+
this.totalEl.textContent = t('total', { count: count });
|
|
220
|
+
this.values.pageNumber = clampPage(this.values.pageNumber, this.source);
|
|
221
|
+
this.pageInput.value = String(this.values.pageNumber);
|
|
222
|
+
this.renderPreview();
|
|
223
|
+
};
|
|
224
|
+
AcUiPdfImportDialog.prototype.browseFile = function () {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
226
|
+
var picked;
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
switch (_a.label) {
|
|
229
|
+
case 0:
|
|
230
|
+
if (!this.browse)
|
|
231
|
+
return [2 /*return*/];
|
|
232
|
+
return [4 /*yield*/, this.browse()];
|
|
233
|
+
case 1:
|
|
234
|
+
picked = _a.sent();
|
|
235
|
+
if (!picked)
|
|
236
|
+
return [2 /*return*/];
|
|
237
|
+
this.source = picked;
|
|
238
|
+
this.values.pageNumber = 1;
|
|
239
|
+
this.loadSource();
|
|
240
|
+
return [2 /*return*/];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
AcUiPdfImportDialog.prototype.commitPageInput = function () {
|
|
246
|
+
var page = clampPage(Number(this.pageInput.value), this.source);
|
|
247
|
+
this.pageInput.value = String(page);
|
|
248
|
+
this.selectPage(page);
|
|
249
|
+
};
|
|
250
|
+
AcUiPdfImportDialog.prototype.selectPage = function (page) {
|
|
251
|
+
var e_2, _a;
|
|
252
|
+
if (page === this.values.pageNumber)
|
|
253
|
+
return;
|
|
254
|
+
this.values.pageNumber = page;
|
|
255
|
+
this.pageInput.value = String(page);
|
|
256
|
+
if (this.view === 'grid') {
|
|
257
|
+
var thumbs = this.previewEl.querySelectorAll('.ml-pdf-import-thumb');
|
|
258
|
+
try {
|
|
259
|
+
for (var _b = __values(Array.from(thumbs)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
260
|
+
var thumb = _c.value;
|
|
261
|
+
var selected = Number(thumb.dataset.page) === page;
|
|
262
|
+
thumb.classList.toggle('is-selected', selected);
|
|
263
|
+
thumb.setAttribute('aria-selected', String(selected));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
267
|
+
finally {
|
|
268
|
+
try {
|
|
269
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
270
|
+
}
|
|
271
|
+
finally { if (e_2) throw e_2.error; }
|
|
272
|
+
}
|
|
273
|
+
void this.showPageSize();
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.renderPreview();
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
AcUiPdfImportDialog.prototype.setView = function (view) {
|
|
280
|
+
if (this.view === view)
|
|
281
|
+
return;
|
|
282
|
+
this.view = view;
|
|
283
|
+
this.renderPreview();
|
|
284
|
+
};
|
|
285
|
+
/** Redraws the preview area for the current page / view. */
|
|
286
|
+
AcUiPdfImportDialog.prototype.renderPreview = function () {
|
|
287
|
+
var _a;
|
|
288
|
+
this.stopRendering();
|
|
289
|
+
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
290
|
+
this.observer = undefined;
|
|
291
|
+
var generation = ++this.generation;
|
|
292
|
+
this.singleButton.setAttribute('aria-pressed', String(this.view === 'single'));
|
|
293
|
+
this.gridButton.setAttribute('aria-pressed', String(this.view === 'grid'));
|
|
294
|
+
this.previewEl.replaceChildren();
|
|
295
|
+
this.previewEl.classList.toggle('is-grid', this.view === 'grid');
|
|
296
|
+
void this.showPageSize();
|
|
297
|
+
if (this.view === 'single') {
|
|
298
|
+
void this.renderSingle(generation);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
this.renderGrid(generation);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
AcUiPdfImportDialog.prototype.renderSingle = function (generation) {
|
|
305
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
306
|
+
var page, frame, canvas, caption, maxWidth, maxHeight;
|
|
307
|
+
return __generator(this, function (_a) {
|
|
308
|
+
switch (_a.label) {
|
|
309
|
+
case 0:
|
|
310
|
+
page = this.values.pageNumber;
|
|
311
|
+
frame = h('div', 'ml-pdf-import-page-frame');
|
|
312
|
+
canvas = h('canvas', 'ml-pdf-import-canvas');
|
|
313
|
+
canvas.setAttribute('role', 'img');
|
|
314
|
+
canvas.setAttribute('aria-label', t('pageLabel', { page: page }));
|
|
315
|
+
caption = h('div', 'ml-pdf-import-caption', "[".concat(page, "] ").concat(this.source.fileName));
|
|
316
|
+
frame.append(canvas);
|
|
317
|
+
this.previewEl.append(frame, caption);
|
|
318
|
+
maxWidth = Math.max(80, (this.previewEl.clientWidth || 300) - 24);
|
|
319
|
+
maxHeight = Math.max(80, (this.previewEl.clientHeight || 260) - 44);
|
|
320
|
+
return [4 /*yield*/, this.drawPage(generation, page, canvas, maxWidth, maxHeight)];
|
|
321
|
+
case 1:
|
|
322
|
+
_a.sent();
|
|
323
|
+
return [2 /*return*/];
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
AcUiPdfImportDialog.prototype.renderGrid = function (generation) {
|
|
329
|
+
var e_3, _a;
|
|
330
|
+
var _this = this;
|
|
331
|
+
var _b, _c;
|
|
332
|
+
var count = this.source.document.numPages;
|
|
333
|
+
var pending = new Map();
|
|
334
|
+
var thumbs = [];
|
|
335
|
+
var _loop_1 = function (page) {
|
|
336
|
+
var thumb = h('button', 'ml-pdf-import-thumb');
|
|
337
|
+
thumb.type = 'button';
|
|
338
|
+
thumb.dataset.page = String(page);
|
|
339
|
+
var selected = page === this_1.values.pageNumber;
|
|
340
|
+
thumb.classList.toggle('is-selected', selected);
|
|
341
|
+
thumb.setAttribute('aria-selected', String(selected));
|
|
342
|
+
thumb.title = t('pageLabel', { page: page });
|
|
343
|
+
var canvas = h('canvas', 'ml-pdf-import-canvas');
|
|
344
|
+
thumb.append(canvas, h('span', 'ml-pdf-import-thumb-label', String(page)));
|
|
345
|
+
thumb.addEventListener('click', function () { return _this.selectPage(page); });
|
|
346
|
+
thumb.addEventListener('dblclick', function () { return _this.setView('single'); });
|
|
347
|
+
this_1.previewEl.append(thumb);
|
|
348
|
+
thumbs.push(thumb);
|
|
349
|
+
pending.set(thumb, function () {
|
|
350
|
+
void _this.drawPage(generation, page, canvas, THUMB_SIZE, THUMB_SIZE);
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
var this_1 = this;
|
|
354
|
+
for (var page = 1; page <= count; page++) {
|
|
355
|
+
_loop_1(page);
|
|
356
|
+
}
|
|
357
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
358
|
+
// No observer (tests, old browsers): draw them one after another.
|
|
359
|
+
void (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
360
|
+
var thumbs_2, thumbs_2_1, thumb, e_4_1;
|
|
361
|
+
var e_4, _a;
|
|
362
|
+
var _b;
|
|
363
|
+
return __generator(this, function (_c) {
|
|
364
|
+
switch (_c.label) {
|
|
365
|
+
case 0:
|
|
366
|
+
_c.trys.push([0, 5, 6, 7]);
|
|
367
|
+
thumbs_2 = __values(thumbs), thumbs_2_1 = thumbs_2.next();
|
|
368
|
+
_c.label = 1;
|
|
369
|
+
case 1:
|
|
370
|
+
if (!!thumbs_2_1.done) return [3 /*break*/, 4];
|
|
371
|
+
thumb = thumbs_2_1.value;
|
|
372
|
+
if (generation !== this.generation)
|
|
373
|
+
return [2 /*return*/];
|
|
374
|
+
(_b = pending.get(thumb)) === null || _b === void 0 ? void 0 : _b();
|
|
375
|
+
return [4 /*yield*/, Promise.resolve()];
|
|
376
|
+
case 2:
|
|
377
|
+
_c.sent();
|
|
378
|
+
_c.label = 3;
|
|
379
|
+
case 3:
|
|
380
|
+
thumbs_2_1 = thumbs_2.next();
|
|
381
|
+
return [3 /*break*/, 1];
|
|
382
|
+
case 4: return [3 /*break*/, 7];
|
|
383
|
+
case 5:
|
|
384
|
+
e_4_1 = _c.sent();
|
|
385
|
+
e_4 = { error: e_4_1 };
|
|
386
|
+
return [3 /*break*/, 7];
|
|
387
|
+
case 6:
|
|
388
|
+
try {
|
|
389
|
+
if (thumbs_2_1 && !thumbs_2_1.done && (_a = thumbs_2.return)) _a.call(thumbs_2);
|
|
390
|
+
}
|
|
391
|
+
finally { if (e_4) throw e_4.error; }
|
|
392
|
+
return [7 /*endfinally*/];
|
|
393
|
+
case 7: return [2 /*return*/];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}); })();
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
// Draw thumbnails only when they scroll into view: large PDFs have
|
|
400
|
+
// hundreds of pages.
|
|
401
|
+
this.observer = new IntersectionObserver(function (entries) {
|
|
402
|
+
var e_5, _a;
|
|
403
|
+
var _b, _c;
|
|
404
|
+
try {
|
|
405
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
406
|
+
var entry = entries_1_1.value;
|
|
407
|
+
if (!entry.isIntersecting)
|
|
408
|
+
continue;
|
|
409
|
+
(_b = pending.get(entry.target)) === null || _b === void 0 ? void 0 : _b();
|
|
410
|
+
pending.delete(entry.target);
|
|
411
|
+
(_c = _this.observer) === null || _c === void 0 ? void 0 : _c.unobserve(entry.target);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
415
|
+
finally {
|
|
416
|
+
try {
|
|
417
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
418
|
+
}
|
|
419
|
+
finally { if (e_5) throw e_5.error; }
|
|
420
|
+
}
|
|
421
|
+
}, { root: this.previewEl });
|
|
422
|
+
try {
|
|
423
|
+
for (var thumbs_1 = __values(thumbs), thumbs_1_1 = thumbs_1.next(); !thumbs_1_1.done; thumbs_1_1 = thumbs_1.next()) {
|
|
424
|
+
var thumb = thumbs_1_1.value;
|
|
425
|
+
this.observer.observe(thumb);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
429
|
+
finally {
|
|
430
|
+
try {
|
|
431
|
+
if (thumbs_1_1 && !thumbs_1_1.done && (_a = thumbs_1.return)) _a.call(thumbs_1);
|
|
432
|
+
}
|
|
433
|
+
finally { if (e_3) throw e_3.error; }
|
|
434
|
+
}
|
|
435
|
+
(_c = (_b = thumbs[this.values.pageNumber - 1]) === null || _b === void 0 ? void 0 : _b.scrollIntoView) === null || _c === void 0 ? void 0 : _c.call(_b, { block: 'nearest' });
|
|
436
|
+
};
|
|
437
|
+
/** Draws `page` into `canvas`, fitting `maxWidth` × `maxHeight` CSS px. */
|
|
438
|
+
AcUiPdfImportDialog.prototype.drawPage = function (generation, pageNumber, canvas, maxWidth, maxHeight) {
|
|
439
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
+
var page, size, fit_1, ratio, scaled, task, error_1;
|
|
441
|
+
return __generator(this, function (_a) {
|
|
442
|
+
switch (_a.label) {
|
|
443
|
+
case 0:
|
|
444
|
+
_a.trys.push([0, 6, , 7]);
|
|
445
|
+
return [4 /*yield*/, this.source.document.getPage(pageNumber)];
|
|
446
|
+
case 1:
|
|
447
|
+
page = _a.sent();
|
|
448
|
+
if (generation !== this.generation)
|
|
449
|
+
return [2 /*return*/];
|
|
450
|
+
size = page.getSize(1);
|
|
451
|
+
fit_1 = Math.min(maxWidth / size.width, maxHeight / size.height);
|
|
452
|
+
ratio = Math.min(2, globalThis.devicePixelRatio || 1);
|
|
453
|
+
scaled = page.getSize(fit_1 * ratio);
|
|
454
|
+
canvas.width = Math.max(1, Math.floor(scaled.width));
|
|
455
|
+
canvas.height = Math.max(1, Math.floor(scaled.height));
|
|
456
|
+
canvas.style.width = "".concat(Math.floor(size.width * fit_1), "px");
|
|
457
|
+
canvas.style.height = "".concat(Math.floor(size.height * fit_1), "px");
|
|
458
|
+
task = page.render(canvas, fit_1 * ratio);
|
|
459
|
+
this.tasks.add(task);
|
|
460
|
+
_a.label = 2;
|
|
461
|
+
case 2:
|
|
462
|
+
_a.trys.push([2, , 4, 5]);
|
|
463
|
+
return [4 /*yield*/, task.promise];
|
|
464
|
+
case 3:
|
|
465
|
+
_a.sent();
|
|
466
|
+
return [3 /*break*/, 5];
|
|
467
|
+
case 4:
|
|
468
|
+
this.tasks.delete(task);
|
|
469
|
+
return [7 /*endfinally*/];
|
|
470
|
+
case 5: return [3 /*break*/, 7];
|
|
471
|
+
case 6:
|
|
472
|
+
error_1 = _a.sent();
|
|
473
|
+
if (generation !== this.generation || isCancelled(error_1))
|
|
474
|
+
return [2 /*return*/];
|
|
475
|
+
canvas.replaceWith(h('div', 'ml-pdf-import-error', t('previewError')));
|
|
476
|
+
return [3 /*break*/, 7];
|
|
477
|
+
case 7: return [2 /*return*/];
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
AcUiPdfImportDialog.prototype.showPageSize = function () {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
484
|
+
var generation, pageNumber, page, size, mm, inch, _a;
|
|
485
|
+
return __generator(this, function (_b) {
|
|
486
|
+
switch (_b.label) {
|
|
487
|
+
case 0:
|
|
488
|
+
generation = this.generation;
|
|
489
|
+
pageNumber = this.values.pageNumber;
|
|
490
|
+
_b.label = 1;
|
|
491
|
+
case 1:
|
|
492
|
+
_b.trys.push([1, 3, , 4]);
|
|
493
|
+
return [4 /*yield*/, this.source.document.getPage(pageNumber)];
|
|
494
|
+
case 2:
|
|
495
|
+
page = _b.sent();
|
|
496
|
+
if (generation !== this.generation ||
|
|
497
|
+
pageNumber !== this.values.pageNumber) {
|
|
498
|
+
return [2 /*return*/];
|
|
499
|
+
}
|
|
500
|
+
size = page.getSize(1);
|
|
501
|
+
mm = function (pt) { return round(pt * PDF_PT_TO_MM, 1); };
|
|
502
|
+
inch = function (pt) { return round((pt * PDF_PT_TO_MM) / MM_PER_INCH, 2); };
|
|
503
|
+
this.pageSizeEl.textContent = t('pageSize', {
|
|
504
|
+
width: mm(size.width),
|
|
505
|
+
height: mm(size.height),
|
|
506
|
+
widthIn: inch(size.width),
|
|
507
|
+
heightIn: inch(size.height)
|
|
508
|
+
});
|
|
509
|
+
return [3 /*break*/, 4];
|
|
510
|
+
case 3:
|
|
511
|
+
_a = _b.sent();
|
|
512
|
+
this.pageSizeEl.textContent = '';
|
|
513
|
+
return [3 /*break*/, 4];
|
|
514
|
+
case 4: return [2 /*return*/];
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
AcUiPdfImportDialog.prototype.stopRendering = function () {
|
|
520
|
+
var e_6, _a;
|
|
521
|
+
try {
|
|
522
|
+
for (var _b = __values(this.tasks), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
523
|
+
var task = _c.value;
|
|
524
|
+
task.cancel();
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
528
|
+
finally {
|
|
529
|
+
try {
|
|
530
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
531
|
+
}
|
|
532
|
+
finally { if (e_6) throw e_6.error; }
|
|
533
|
+
}
|
|
534
|
+
this.tasks.clear();
|
|
535
|
+
};
|
|
536
|
+
/** Enables X/Y with the on-screen box and OK with valid numbers. */
|
|
537
|
+
AcUiPdfImportDialog.prototype.updateState = function () {
|
|
538
|
+
var onScreen = this.onScreenInput.checked;
|
|
539
|
+
this.xInput.disabled = onScreen;
|
|
540
|
+
this.yInput.disabled = onScreen;
|
|
541
|
+
var scaleValid = parseNumber(this.scaleInput.value, true) !== undefined;
|
|
542
|
+
var xValid = onScreen || parseNumber(this.xInput.value) !== undefined;
|
|
543
|
+
var yValid = onScreen || parseNumber(this.yInput.value) !== undefined;
|
|
544
|
+
this.scaleInput.classList.toggle('is-invalid', !scaleValid);
|
|
545
|
+
this.xInput.classList.toggle('is-invalid', !xValid);
|
|
546
|
+
this.yInput.classList.toggle('is-invalid', !yValid);
|
|
547
|
+
this.scaleInput.setAttribute('aria-invalid', String(!scaleValid));
|
|
548
|
+
this.okButton.disabled = !(scaleValid && xValid && yValid);
|
|
549
|
+
};
|
|
550
|
+
AcUiPdfImportDialog.prototype.confirm = function () {
|
|
551
|
+
var _a, _b, _c;
|
|
552
|
+
this.updateState();
|
|
553
|
+
if (this.okButton.disabled)
|
|
554
|
+
return;
|
|
555
|
+
var onScreen = this.onScreenInput.checked;
|
|
556
|
+
this.result = {
|
|
557
|
+
source: this.source,
|
|
558
|
+
pageNumber: this.values.pageNumber,
|
|
559
|
+
mode: this.modeInputs.visual.checked ? 'visual' : 'recover',
|
|
560
|
+
scale: (_a = parseNumber(this.scaleInput.value, true)) !== null && _a !== void 0 ? _a : 1,
|
|
561
|
+
specifyOnScreen: onScreen,
|
|
562
|
+
insertionPoint: onScreen
|
|
563
|
+
? this.values.insertionPoint
|
|
564
|
+
: {
|
|
565
|
+
x: (_b = parseNumber(this.xInput.value)) !== null && _b !== void 0 ? _b : 0,
|
|
566
|
+
y: (_c = parseNumber(this.yInput.value)) !== null && _c !== void 0 ? _c : 0
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
this.close();
|
|
570
|
+
};
|
|
571
|
+
return AcUiPdfImportDialog;
|
|
572
|
+
}(AcUiDialog));
|
|
573
|
+
export { AcUiPdfImportDialog };
|
|
574
|
+
var nextId = 0;
|
|
575
|
+
var SINGLE_ICON = '<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><rect x="3.5" y="1.5" width="9" height="13" fill="none" stroke="currentColor"/></svg>';
|
|
576
|
+
var GRID_ICON = '<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><g fill="none" stroke="currentColor"><rect x="2.5" y="1.5" width="4.5" height="5.5"/><rect x="9" y="1.5" width="4.5" height="5.5"/><rect x="2.5" y="9" width="4.5" height="5.5"/><rect x="9" y="9" width="4.5" height="5.5"/></g></svg>';
|
|
577
|
+
/** Dialog string `jig.pdfimport.dialog.<key>`. */
|
|
578
|
+
function t(key, params) {
|
|
579
|
+
return acapPdfT("jig.pdfimport.dialog.".concat(key), params);
|
|
580
|
+
}
|
|
581
|
+
function clampPage(page, source) {
|
|
582
|
+
var count = Math.max(1, source.document.numPages);
|
|
583
|
+
if (!Number.isFinite(page))
|
|
584
|
+
return 1;
|
|
585
|
+
return Math.min(count, Math.max(1, Math.round(page)));
|
|
586
|
+
}
|
|
587
|
+
/** Parses a number field; `positive` also rejects zero and negatives. */
|
|
588
|
+
function parseNumber(text, positive) {
|
|
589
|
+
if (positive === void 0) { positive = false; }
|
|
590
|
+
if (text.trim() === '')
|
|
591
|
+
return undefined;
|
|
592
|
+
var value = Number(text);
|
|
593
|
+
if (!Number.isFinite(value))
|
|
594
|
+
return undefined;
|
|
595
|
+
if (positive && value <= 0)
|
|
596
|
+
return undefined;
|
|
597
|
+
return value;
|
|
598
|
+
}
|
|
599
|
+
function round(value, digits) {
|
|
600
|
+
return String(Number(value.toFixed(digits)));
|
|
601
|
+
}
|
|
602
|
+
function isCancelled(error) {
|
|
603
|
+
return (typeof error === 'object' &&
|
|
604
|
+
error !== null &&
|
|
605
|
+
error.name === 'RenderingCancelledException');
|
|
606
|
+
}
|
|
607
|
+
function h(tag, className, text) {
|
|
608
|
+
var el = document.createElement(tag);
|
|
609
|
+
if (className)
|
|
610
|
+
el.className = className;
|
|
611
|
+
if (text !== undefined)
|
|
612
|
+
el.textContent = text;
|
|
613
|
+
return el;
|
|
614
|
+
}
|
|
615
|
+
function group(title, className) {
|
|
616
|
+
var el = h('fieldset', 'ml-pdf-import-group');
|
|
617
|
+
if (className)
|
|
618
|
+
el.classList.add(className);
|
|
619
|
+
el.append(h('legend', undefined, title));
|
|
620
|
+
return el;
|
|
621
|
+
}
|
|
622
|
+
function labelled(label, control) {
|
|
623
|
+
var el = h('label', 'ml-pdf-import-field');
|
|
624
|
+
el.append(h('span', 'ml-pdf-import-label', label), control);
|
|
625
|
+
return el;
|
|
626
|
+
}
|
|
627
|
+
function numberField(value) {
|
|
628
|
+
var el = h('input', 'ml-pdf-import-input ml-pdf-import-number');
|
|
629
|
+
el.type = 'number';
|
|
630
|
+
el.step = 'any';
|
|
631
|
+
el.value = String(value);
|
|
632
|
+
return el;
|
|
633
|
+
}
|
|
634
|
+
function radio(name, checked) {
|
|
635
|
+
var el = h('input');
|
|
636
|
+
el.type = 'radio';
|
|
637
|
+
el.name = name;
|
|
638
|
+
el.checked = checked;
|
|
639
|
+
return el;
|
|
640
|
+
}
|
|
641
|
+
function radioOption(input, label, hint) {
|
|
642
|
+
var el = h('label', 'ml-pdf-import-radio');
|
|
643
|
+
var text = h('span', 'ml-pdf-import-radio-text');
|
|
644
|
+
text.append(h('span', undefined, label), h('span', 'ml-pdf-import-hint', hint));
|
|
645
|
+
el.append(input, text);
|
|
646
|
+
return el;
|
|
647
|
+
}
|
|
648
|
+
function button(label, kind, onClick) {
|
|
649
|
+
var el = h('button', kind === 'primary'
|
|
650
|
+
? 'ml-ui-dialog-btn ml-pdf-import-ok'
|
|
651
|
+
: 'ml-ui-dialog-btn ml-ui-dialog-btn-secondary', label);
|
|
652
|
+
el.type = 'button';
|
|
653
|
+
el.addEventListener('click', onClick);
|
|
654
|
+
return el;
|
|
655
|
+
}
|
|
656
|
+
function viewButton(label, icon, onClick) {
|
|
657
|
+
var el = h('button', 'ml-pdf-import-view');
|
|
658
|
+
el.type = 'button';
|
|
659
|
+
el.title = label;
|
|
660
|
+
el.setAttribute('aria-label', label);
|
|
661
|
+
el.innerHTML = icon;
|
|
662
|
+
el.addEventListener('click', onClick);
|
|
663
|
+
return el;
|
|
664
|
+
}
|
|
665
|
+
function ensureStyles() {
|
|
666
|
+
if (document.getElementById(STYLE_ID))
|
|
667
|
+
return;
|
|
668
|
+
var style = document.createElement('style');
|
|
669
|
+
style.id = STYLE_ID;
|
|
670
|
+
style.textContent = "\n.ml-ui-dialog.ml-pdf-import-dialog {\n width: 720px;\n max-width: calc(100% - 24px);\n font-size: 12px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-file {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 10px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-file .ml-pdf-import-input {\n flex: 1;\n min-width: 0;\n}\n.ml-pdf-import-dialog .ml-pdf-import-columns {\n display: grid;\n grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);\n gap: 10px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-side {\n display: flex;\n flex-direction: column;\n gap: 10px;\n min-width: 0;\n}\n.ml-pdf-import-dialog .ml-pdf-import-group {\n margin: 0;\n padding: 8px 10px 10px;\n min-width: 0;\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n border-radius: 4px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-group > legend {\n padding: 0 4px;\n font-weight: 600;\n}\n.ml-pdf-import-dialog .ml-pdf-import-pagebar {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-views {\n margin-left: auto;\n display: flex;\n}\n.ml-pdf-import-dialog .ml-pdf-import-view {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 22px;\n padding: 0;\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n background: var(--ml-ui-bg, #fff);\n color: var(--ml-ui-text-muted, #606266);\n cursor: pointer;\n}\n.ml-pdf-import-dialog .ml-pdf-import-view + .ml-pdf-import-view {\n border-left: none;\n}\n.ml-pdf-import-dialog .ml-pdf-import-view[aria-pressed='true'] {\n color: var(--ml-ui-accent, #0b84ff);\n background: color-mix(in srgb, var(--ml-ui-accent, #0b84ff) 14%, transparent);\n}\n.ml-pdf-import-dialog .ml-pdf-import-preview {\n height: 260px;\n box-sizing: border-box;\n padding: 10px;\n background: #808080;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 6px;\n overflow: hidden;\n}\n.ml-pdf-import-dialog .ml-pdf-import-preview.is-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(".concat(THUMB_SIZE + 12, "px, 1fr));\n align-content: start;\n justify-items: center;\n overflow-y: auto;\n}\n.ml-pdf-import-dialog .ml-pdf-import-page-frame {\n display: flex;\n min-height: 0;\n}\n.ml-pdf-import-dialog .ml-pdf-import-canvas {\n display: block;\n background: #fff;\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);\n}\n.ml-pdf-import-dialog .ml-pdf-import-caption {\n max-width: 100%;\n color: #fff;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ml-pdf-import-dialog .ml-pdf-import-thumb {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n padding: 4px;\n border: 2px solid transparent;\n border-radius: 3px;\n background: transparent;\n color: #fff;\n cursor: pointer;\n}\n.ml-pdf-import-dialog .ml-pdf-import-thumb .ml-pdf-import-canvas {\n min-width: 40px;\n min-height: 40px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-thumb.is-selected {\n border-color: var(--ml-ui-accent, #0b84ff);\n}\n.ml-pdf-import-dialog .ml-pdf-import-error {\n color: #fff;\n padding: 12px;\n text-align: center;\n}\n.ml-pdf-import-dialog .ml-pdf-import-pagesize {\n color: var(--ml-ui-text-muted, #606266);\n}\n.ml-pdf-import-dialog .ml-pdf-import-field {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-label {\n white-space: nowrap;\n}\n.ml-pdf-import-dialog .ml-pdf-import-input {\n box-sizing: border-box;\n height: 24px;\n padding: 2px 6px;\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n border-radius: 3px;\n background: var(--ml-ui-bg, #fff);\n color: var(--ml-ui-text, #303133);\n font: inherit;\n}\n.ml-pdf-import-dialog .ml-pdf-import-input:disabled {\n opacity: 0.55;\n}\n.ml-pdf-import-dialog .ml-pdf-import-input.is-invalid {\n border-color: var(--ml-ui-danger, #f56c6c);\n}\n.ml-pdf-import-dialog .ml-pdf-import-number {\n width: 90px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-page {\n width: 64px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-point {\n display: flex;\n flex-wrap: wrap;\n gap: 8px 14px;\n padding-left: 20px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-check,\n.ml-pdf-import-dialog .ml-pdf-import-radio {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n}\n.ml-pdf-import-dialog .ml-pdf-import-check input,\n.ml-pdf-import-dialog .ml-pdf-import-radio input {\n margin: 1px 0 0;\n}\n.ml-pdf-import-dialog .ml-pdf-import-radio-text {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.ml-pdf-import-dialog .ml-pdf-import-hint {\n color: var(--ml-ui-text-muted, #606266);\n font-size: 11px;\n}\n.ml-pdf-import-dialog .ml-ui-dialog-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n filter: none;\n}\n@media (max-width: 640px) {\n .ml-pdf-import-dialog .ml-pdf-import-columns {\n grid-template-columns: minmax(0, 1fr);\n }\n .ml-pdf-import-dialog .ml-pdf-import-preview {\n height: 200px;\n }\n}\n").trim();
|
|
671
|
+
document.head.appendChild(style);
|
|
672
|
+
}
|
|
673
|
+
//# sourceMappingURL=AcUiPdfImportDialog.js.map
|