dompdf.js 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.versionrc +8 -0
- package/CHANGELOG.md +32 -543
- package/README.md +201 -155
- package/README_CN.md +233 -238
- package/dist/dompdf.esm.js +26010 -14837
- package/dist/dompdf.esm.js.map +1 -1
- package/dist/dompdf.js +40542 -29369
- package/dist/dompdf.js.map +1 -1
- package/dist/dompdf.min.js +67 -0
- package/dist/index.d.ts +7 -6
- package/dist/lib/dom/node-parser.js +0 -62
- package/dist/lib/dom/node-parser.js.map +1 -1
- package/dist/lib/index.js +41 -34
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/render/canvas/pdf-renderer.js +358 -228
- package/dist/lib/render/canvas/pdf-renderer.js.map +1 -1
- package/dist/lib/render/paginate copy 2.js +178 -0
- package/dist/lib/render/paginate copy 2.js.map +1 -0
- package/dist/lib/render/paginate.js +68 -29
- package/dist/lib/render/paginate.js.map +1 -1
- package/dist/lib/utils/css-utils.js +19 -0
- package/dist/lib/utils/css-utils.js.map +1 -0
- package/dist/lib/utils/element-utils.js +25 -0
- package/dist/lib/utils/element-utils.js.map +1 -0
- package/dist/lib/utils/font-utils.js +70 -0
- package/dist/lib/utils/font-utils.js.map +1 -0
- package/dist/lib/utils/index.js +22 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/type-utils.js +40 -0
- package/dist/lib/utils/type-utils.js.map +1 -0
- package/dist/lib/utils/url-path.js +22 -0
- package/dist/lib/utils/url-path.js.map +1 -0
- package/dist/render/canvas/pdf-renderer.d.ts +29 -24
- package/dist/render/paginate copy 2.d.ts +3 -0
- package/dist/render/paginate.d.ts +1 -1
- package/dist/types/index.d.ts +7 -6
- package/dist/types/render/canvas/pdf-renderer.d.ts +29 -24
- package/dist/types/render/paginate copy 2.d.ts +3 -0
- package/dist/types/render/paginate.d.ts +1 -1
- package/dist/types/utils/css-utils.d.ts +2 -0
- package/dist/types/utils/element-utils.d.ts +7 -0
- package/dist/types/utils/font-utils.d.ts +9 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/type-utils.d.ts +4 -0
- package/dist/types/utils/url-path.d.ts +7 -0
- package/dist/utils/css-utils.d.ts +2 -0
- package/dist/utils/element-utils.d.ts +7 -0
- package/dist/utils/font-utils.d.ts +9 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/type-utils.d.ts +4 -0
- package/dist/utils/url-path.d.ts +7 -0
- package/fontconverter/FileSaver.js +2 -0
- package/fontconverter/filereader.js +432 -0
- package/fontconverter/fontconverter.html +66 -0
- package/fontconverter/pure-min.css +11 -0
- package/package.json +135 -135
- package/page_sizes.md +50 -0
- package/.vscode/settings.json +0 -5
- package/html2pdf-userscript.js +0 -936
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBackgroundRepeat = void 0;
|
|
4
|
+
function getBackgroundRepeat(value) {
|
|
5
|
+
switch (value) {
|
|
6
|
+
case 1 /* BACKGROUND_REPEAT.NO_REPEAT */:
|
|
7
|
+
return 'no-repeat';
|
|
8
|
+
case 2 /* BACKGROUND_REPEAT.REPEAT_X */:
|
|
9
|
+
return 'repeat-x';
|
|
10
|
+
case 3 /* BACKGROUND_REPEAT.REPEAT_Y */:
|
|
11
|
+
return 'repeat-y';
|
|
12
|
+
case 0 /* BACKGROUND_REPEAT.REPEAT */:
|
|
13
|
+
return 'repeat';
|
|
14
|
+
default:
|
|
15
|
+
return 'no-repeat';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.getBackgroundRepeat = getBackgroundRepeat;
|
|
19
|
+
//# sourceMappingURL=css-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-utils.js","sourceRoot":"","sources":["../../../src/utils/css-utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mBAAmB,CAAC,KAAwB;IACxD,QAAQ,KAAK,EAAE;QACX;YACI,OAAO,WAAW,CAAC;QACvB;YACI,OAAO,UAAU,CAAC;QACtB;YACI,OAAO,UAAU,CAAC;QACtB;YACI,OAAO,QAAQ,CAAC;QACpB;YACI,OAAO,WAAW,CAAC;KAC1B;AACL,CAAC;AAbD,kDAaC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAllTextNodesEmpty = void 0;
|
|
4
|
+
var type_utils_1 = require("./type-utils");
|
|
5
|
+
/**
|
|
6
|
+
* Recursively traverse the nodes and check whether the textNodes of all levels are empty arrays
|
|
7
|
+
* @param {ElementContainer} node
|
|
8
|
+
* @returns {boolean} - If all textNodes are empty, return true; otherwise, return false
|
|
9
|
+
*/
|
|
10
|
+
function checkAllTextNodesEmpty(node) {
|
|
11
|
+
if (!(0, type_utils_1.isArray)(node.textNodes) || node.textNodes.length > 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if ((0, type_utils_1.isArray)(node.elements)) {
|
|
15
|
+
for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
|
|
16
|
+
var child = _a[_i];
|
|
17
|
+
if (!checkAllTextNodesEmpty(child)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
exports.checkAllTextNodesEmpty = checkAllTextNodesEmpty;
|
|
25
|
+
//# sourceMappingURL=element-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-utils.js","sourceRoot":"","sources":["../../../src/utils/element-utils.ts"],"names":[],"mappings":";;;AACA,2CAAqC;AACrC;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,IAAsB;IACzD,IAAI,CAAC,IAAA,oBAAO,EAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACvD,OAAO,KAAK,CAAC;KAChB;IACD,IAAI,IAAA,oBAAO,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAoB,UAAa,EAAb,KAAA,IAAI,CAAC,QAAQ,EAAb,cAAa,EAAb,IAAa,EAAE;YAA9B,IAAM,KAAK,SAAA;YACZ,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE;gBAChC,OAAO,KAAK,CAAC;aAChB;SACJ;KACJ;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAZD,wDAYC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.setOptionFontConfig = exports.validateFontConfig = void 0;
|
|
15
|
+
var type_utils_1 = require("./type-utils");
|
|
16
|
+
// check fontConfig object structure and types
|
|
17
|
+
function validateFontConfig(fontConfig) {
|
|
18
|
+
if (fontConfig === undefined) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var configList = (0, type_utils_1.isArray)(fontConfig) ? fontConfig : [fontConfig];
|
|
22
|
+
for (var _i = 0, configList_1 = configList; _i < configList_1.length; _i++) {
|
|
23
|
+
var config = configList_1[_i];
|
|
24
|
+
if (!(0, type_utils_1.isObject)(config) || config === null) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
var requiredFields = [
|
|
28
|
+
{ key: 'fontFamily', type: 'string' },
|
|
29
|
+
{ key: 'fontBase64', type: 'string' },
|
|
30
|
+
{ key: 'fontStyle', type: 'string' },
|
|
31
|
+
{ key: 'fontWeight', type: 'number' }
|
|
32
|
+
];
|
|
33
|
+
for (var _a = 0, requiredFields_1 = requiredFields; _a < requiredFields_1.length; _a++) {
|
|
34
|
+
var _b = requiredFields_1[_a], key = _b.key, type = _b.type;
|
|
35
|
+
if (!(key in config)) {
|
|
36
|
+
console.error("The font configuration is missing required fields: ".concat(key));
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (typeof config[key] !== type) {
|
|
40
|
+
console.error("The field ".concat(key, " has a type error. Expected ").concat(type, ", but received ").concat(typeof config[key]));
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// check:fontWeight is only 400 or 700
|
|
45
|
+
if (![400, 700].includes(config.fontWeight)) {
|
|
46
|
+
console.error("The fontWeight value is invalid. It can only be 400 or 700. Actual value:".concat(config.fontWeight));
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (config.iconFont !== undefined && typeof config.iconFont !== 'boolean') {
|
|
50
|
+
console.error("The field iconFont has a type error. Expected boolean, but received ".concat(typeof config.iconFont));
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
exports.validateFontConfig = validateFontConfig;
|
|
57
|
+
// The core function for handling configuration and populating default values
|
|
58
|
+
function setOptionFontConfig(rawConfig) {
|
|
59
|
+
if (!validateFontConfig(rawConfig)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
var configList = (0, type_utils_1.isArray)(rawConfig) ? rawConfig : [rawConfig];
|
|
63
|
+
var processedList = configList.map(function (config) {
|
|
64
|
+
var _a;
|
|
65
|
+
return (__assign(__assign({}, config), { iconFont: (_a = config.iconFont) !== null && _a !== void 0 ? _a : false }));
|
|
66
|
+
});
|
|
67
|
+
return processedList;
|
|
68
|
+
}
|
|
69
|
+
exports.setOptionFontConfig = setOptionFontConfig;
|
|
70
|
+
//# sourceMappingURL=font-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-utils.js","sourceRoot":"","sources":["../../../src/utils/font-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAA+C;AAS/C,8CAA8C;AAC9C,SAAgB,kBAAkB,CAAC,UAAiD;IAChF,IAAI,UAAU,KAAK,SAAS,EAAE;QAC1B,OAAO,KAAK,CAAC;KAChB;IAED,IAAM,UAAU,GAAiB,IAAA,oBAAO,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAwB,CAAC,CAAC;IAE/F,KAAqB,UAAU,EAAV,yBAAU,EAAV,wBAAU,EAAV,IAAU,EAAE;QAA5B,IAAM,MAAM,mBAAA;QACb,IAAI,CAAC,IAAA,qBAAQ,EAAC,MAAM,CAAC,IAAI,MAAM,KAAK,IAAI,EAAE;YACtC,OAAO,KAAK,CAAC;SAChB;QAED,IAAM,cAAc,GAAiD;YACjE,EAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAC;YACnC,EAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAC;YACnC,EAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAC;YAClC,EAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAC;SACtC,CAAC;QAEF,KAA0B,UAAc,EAAd,iCAAc,EAAd,4BAAc,EAAd,IAAc,EAAE;YAA/B,IAAA,yBAAW,EAAV,GAAG,SAAA,EAAE,IAAI,UAAA;YACjB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;gBAClB,OAAO,CAAC,KAAK,CAAC,6DAAsD,GAAG,CAAE,CAAC,CAAC;gBAC3E,OAAO,KAAK,CAAC;aAChB;YAED,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBAC7B,OAAO,CAAC,KAAK,CACT,oBAAa,GAAG,yCAA+B,IAAI,4BAAkB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAE,CAC5F,CAAC;gBACF,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,sCAAsC;QACtC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACzC,OAAO,CAAC,KAAK,CACT,mFAA4E,MAAM,CAAC,UAAU,CAAE,CAClG,CAAC;YACF,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;YACvE,OAAO,CAAC,KAAK,CACT,8EAAuE,OAAO,MAAM,CAAC,QAAQ,CAAE,CAClG,CAAC;YACF,OAAO,KAAK,CAAC;SAChB;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAjDD,gDAiDC;AAED,6EAA6E;AAC7E,SAAgB,mBAAmB,CAAC,SAAgD;IAChF,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KACpB;IAED,IAAM,UAAU,GAAiB,IAAA,oBAAO,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAuB,CAAC,CAAC;IAE5F,IAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,UAAC,MAAM;;QAAK,OAAA,uBAC1C,MAAM,KACT,QAAQ,EAAE,MAAA,MAAM,CAAC,QAAQ,mCAAI,KAAK,IACpC,CAAA;KAAA,CAAC,CAAC;IACJ,OAAO,aAAa,CAAC;AACzB,CAAC;AAZD,kDAYC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./css-utils"), exports);
|
|
18
|
+
__exportStar(require("./element-utils"), exports);
|
|
19
|
+
__exportStar(require("./font-utils"), exports);
|
|
20
|
+
__exportStar(require("./type-utils"), exports);
|
|
21
|
+
__exportStar(require("./url-path"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,kDAAgC;AAChC,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFunction = exports.isObject = exports.isArray = exports.isEmptyValue = void 0;
|
|
4
|
+
function isEmptyValue(obj) {
|
|
5
|
+
if (obj === undefined) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
else if (obj === null) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
else if (obj === false) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
else if (obj === '') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
else if (isArray(obj) && obj.length === 0) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
else if (isObject(obj) && JSON.stringify(obj) === '{}') {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.isEmptyValue = isEmptyValue;
|
|
28
|
+
function isArray(obj) {
|
|
29
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
30
|
+
}
|
|
31
|
+
exports.isArray = isArray;
|
|
32
|
+
function isObject(obj) {
|
|
33
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
34
|
+
}
|
|
35
|
+
exports.isObject = isObject;
|
|
36
|
+
function isFunction(fn) {
|
|
37
|
+
return typeof fn === 'function';
|
|
38
|
+
}
|
|
39
|
+
exports.isFunction = isFunction;
|
|
40
|
+
//# sourceMappingURL=type-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../../src/utils/type-utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,GAAY;IACrC,IAAI,GAAG,KAAK,SAAS,EAAE;QACnB,OAAO,IAAI,CAAC;KACf;SAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACrB,OAAO,IAAI,CAAC;KACf;SAAM,IAAI,GAAG,KAAK,KAAK,EAAE;QACtB,OAAO,IAAI,CAAC;KACf;SAAM,IAAI,GAAG,KAAK,EAAE,EAAE;QACnB,OAAO,IAAI,CAAC;KACf;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QACzC,OAAO,IAAI,CAAC;KACf;SAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;QACtD,OAAO,IAAI,CAAC;KACf;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AAhBD,oCAgBC;AAED,SAAgB,OAAO,CAAC,GAAY;IAChC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC;AACpE,CAAC;AAFD,0BAEC;AAED,SAAgB,QAAQ,CAAC,GAAY;IACjC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,iBAAiB,CAAC;AACrE,CAAC;AAFD,4BAEC;AACD,SAAgB,UAAU,CAAC,EAAW;IAClC,OAAO,OAAO,EAAE,KAAK,UAAU,CAAC;AACpC,CAAC;AAFD,gCAEC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImageTypeByPath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 判断图片路径是否为指定类型的图片
|
|
6
|
+
* @param {string} path 图片路径/URL(如 "../tests/assets/image.svg"、"https://xxx.com/photo.webp")
|
|
7
|
+
* @param {("svg" | "webp" | "png" | "jpg" | "gif" | "unknown")} type 要判断的图片类型
|
|
8
|
+
* @returns {boolean} 是否为指定类型的图片
|
|
9
|
+
*/
|
|
10
|
+
function getImageTypeByPath(path, type) {
|
|
11
|
+
var _a;
|
|
12
|
+
if (!path || !type)
|
|
13
|
+
return false;
|
|
14
|
+
var purePath = path.split('?')[0].split('#')[0];
|
|
15
|
+
var ext = ((_a = purePath.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
16
|
+
if (type === 'jpg') {
|
|
17
|
+
return ext === 'jpg' || ext === 'jpeg';
|
|
18
|
+
}
|
|
19
|
+
return ext === type;
|
|
20
|
+
}
|
|
21
|
+
exports.getImageTypeByPath = getImageTypeByPath;
|
|
22
|
+
//# sourceMappingURL=url-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-path.js","sourceRoot":"","sources":["../../../src/utils/url-path.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,IAAY,EAAE,IAAwD;;IACrG,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACjC,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,IAAM,GAAG,GAAG,CAAA,MAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,WAAW,EAAE,KAAI,EAAE,CAAC;IAC3D,IAAI,IAAI,KAAK,KAAK,EAAE;QAChB,OAAO,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,CAAC;KAC1C;IACD,OAAO,GAAG,KAAK,IAAI,CAAC;AACxB,CAAC;AARD,gDAQC"}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
+
import { Context2d, EncryptionOptions, jsPDF } from 'jspdf';
|
|
2
|
+
import 'jspdf/dist/polyfills.es.js';
|
|
1
3
|
import { Context } from '../../core/context';
|
|
2
4
|
import { CSSParsedDeclaration } from '../../css';
|
|
5
|
+
import { Bounds } from '../../css/layout/bounds';
|
|
3
6
|
import { TextBounds } from '../../css/layout/text';
|
|
4
7
|
import { BORDER_STYLE } from '../../css/property-descriptors/border-style';
|
|
5
8
|
import { Color } from '../../css/types/color';
|
|
6
9
|
import { ElementContainer } from '../../dom/element-container';
|
|
7
|
-
import {
|
|
10
|
+
import { CanvasElementContainer } from '../../dom/replaced-elements/canvas-element-container';
|
|
11
|
+
import { ImageElementContainer } from '../../dom/replaced-elements/image-element-container';
|
|
12
|
+
import { SVGElementContainer } from '../../dom/replaced-elements/svg-element-container';
|
|
8
13
|
import { TextContainer } from '../../dom/text-container';
|
|
9
14
|
import { BoundCurves } from '../bound-curves';
|
|
10
15
|
import { IElementEffect } from '../effects';
|
|
16
|
+
import { FontConfig } from '../../utils';
|
|
11
17
|
import { Path } from '../path';
|
|
12
18
|
import { Renderer } from '../renderer';
|
|
13
19
|
import { ElementPaint, StackingContext } from '../stacking-context';
|
|
14
|
-
interface FontConfig {
|
|
15
|
-
fontFamily: string;
|
|
16
|
-
fontBase64: string;
|
|
17
|
-
}
|
|
18
20
|
export type RenderConfigurations = RenderOptions & {
|
|
19
21
|
backgroundColor: Color | null;
|
|
20
|
-
fontConfig: FontConfig;
|
|
22
|
+
fontConfig: FontConfig | FontConfig[] | undefined;
|
|
21
23
|
};
|
|
22
24
|
export type pageConfigOptions = {
|
|
23
25
|
header: {
|
|
24
|
-
content: string;
|
|
26
|
+
content: string | ((renderer: any, pageNum: string) => void);
|
|
25
27
|
height: number;
|
|
26
28
|
contentPosition: 'center' | 'centerLeft' | 'centerRight' | 'centerTop' | 'centerBottom' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | [number, number];
|
|
27
29
|
contentColor: string;
|
|
@@ -29,7 +31,7 @@ export type pageConfigOptions = {
|
|
|
29
31
|
padding?: [number, number, number, number];
|
|
30
32
|
};
|
|
31
33
|
footer: {
|
|
32
|
-
content: string;
|
|
34
|
+
content: string | ((renderer: any, pageNum: string) => void);
|
|
33
35
|
height: number;
|
|
34
36
|
contentPosition: 'center' | 'centerLeft' | 'centerRight' | 'centerTop' | 'centerBottom' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | [number, number];
|
|
35
37
|
contentColor: string;
|
|
@@ -45,31 +47,33 @@ export interface RenderOptions {
|
|
|
45
47
|
width: number;
|
|
46
48
|
height: number;
|
|
47
49
|
pdfFileName?: string;
|
|
48
|
-
encryption?:
|
|
49
|
-
userPassword?: string;
|
|
50
|
-
ownerPassword?: string;
|
|
51
|
-
userPermissions?: string[];
|
|
52
|
-
};
|
|
50
|
+
encryption?: EncryptionOptions | undefined;
|
|
53
51
|
precision?: number;
|
|
54
52
|
floatPrecision?: number | 'smart';
|
|
55
53
|
compress?: boolean;
|
|
56
54
|
putOnlyUsedFonts?: boolean;
|
|
57
55
|
pagination?: boolean;
|
|
58
|
-
format?: 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6' | 'a7' | 'a8' | 'a9' | 'a10' | 'b0' | 'b1' | 'b2' | 'b3' | 'b4' | 'b5' | 'b6' | 'b7' | 'b8' | 'b9' | 'b10' | 'c0' | 'c1' | 'c2' | 'c3' | 'c4' | 'c5' | 'c6' | 'c7' | 'c8' | 'c9' | 'c10' | 'dl' | 'letter' | 'government-letter' | 'legal' | 'junior-legal' | 'ledger' | 'tabloid' | 'credit-card';
|
|
56
|
+
format?: 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6' | 'a7' | 'a8' | 'a9' | 'a10' | 'b0' | 'b1' | 'b2' | 'b3' | 'b4' | 'b5' | 'b6' | 'b7' | 'b8' | 'b9' | 'b10' | 'c0' | 'c1' | 'c2' | 'c3' | 'c4' | 'c5' | 'c6' | 'c7' | 'c8' | 'c9' | 'c10' | 'dl' | 'letter' | 'government-letter' | 'legal' | 'junior-legal' | 'ledger' | 'tabloid' | 'credit-card' | [number, number];
|
|
59
57
|
pageConfig?: pageConfigOptions;
|
|
60
58
|
}
|
|
59
|
+
export declare class JsPdfContext2d {
|
|
60
|
+
}
|
|
61
|
+
export interface JsPdfContext2d extends Context2d {
|
|
62
|
+
getLineDash(): number[];
|
|
63
|
+
setLineDash(segments: number[]): void;
|
|
64
|
+
}
|
|
61
65
|
export declare class CanvasRenderer extends Renderer {
|
|
62
66
|
canvas: HTMLCanvasElement;
|
|
63
|
-
|
|
64
|
-
readonly
|
|
65
|
-
readonly context2dCtx: any;
|
|
67
|
+
readonly jspdfCtx: jsPDF;
|
|
68
|
+
readonly context2dCtx: JsPdfContext2d;
|
|
66
69
|
private readonly _activeEffects;
|
|
67
70
|
private readonly fontMetrics;
|
|
68
71
|
private readonly pxToPt;
|
|
69
72
|
private totalPages;
|
|
70
73
|
constructor(context: Context, options: RenderConfigurations);
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
addFontToJsPDF(): void;
|
|
75
|
+
resetJsPDFFont(): void;
|
|
76
|
+
setTextFont(styles: CSSParsedDeclaration): string;
|
|
73
77
|
applyEffects(effects: IElementEffect[]): void;
|
|
74
78
|
applyEffect(effect: IElementEffect): void;
|
|
75
79
|
popEffect(): void;
|
|
@@ -79,13 +83,15 @@ export declare class CanvasRenderer extends Renderer {
|
|
|
79
83
|
private createFontStyle;
|
|
80
84
|
private convertColor;
|
|
81
85
|
renderTextNode(text: TextContainer, styles: CSSParsedDeclaration): Promise<void>;
|
|
82
|
-
|
|
86
|
+
renderReplacedJsPdfImage(container: ImageElementContainer, image: HTMLImageElement | HTMLCanvasElement): void;
|
|
87
|
+
renderReplacedJsPdfSvg(container: SVGElementContainer, image: HTMLImageElement | HTMLCanvasElement): void;
|
|
88
|
+
renderReplacedJsPdfCanvasImage(container: CanvasElementContainer): void;
|
|
83
89
|
renderNodeContent(paint: ElementPaint): Promise<void>;
|
|
84
90
|
renderStackContent(stack: StackingContext): Promise<void>;
|
|
85
91
|
mask(paths: Path[]): void;
|
|
86
|
-
path(paths: Path[]): void;
|
|
87
|
-
formatPath(paths: Path[]): void;
|
|
88
|
-
renderRepeat(path: Path[], pattern: CanvasPattern | CanvasGradient
|
|
92
|
+
path(paths: Path[], ctx2d?: Context2d | CanvasRenderingContext2D): void;
|
|
93
|
+
formatPath(paths: Path[], ctx2d?: Context2d | CanvasRenderingContext2D): void;
|
|
94
|
+
renderRepeat(boxs: Bounds, ctx: CanvasRenderingContext2D, path: Path[], pattern: CanvasPattern | CanvasGradient): void;
|
|
89
95
|
resizeImage(image: HTMLImageElement, width: number, height: number): HTMLCanvasElement | HTMLImageElement;
|
|
90
96
|
renderBackgroundImage(container: ElementContainer): Promise<void>;
|
|
91
97
|
renderSolidBorder(color: Color, side: number, curvePoints: BoundCurves): Promise<void>;
|
|
@@ -102,4 +108,3 @@ export declare class CanvasRenderer extends Renderer {
|
|
|
102
108
|
private addImagePdf;
|
|
103
109
|
output(): Promise<Blob>;
|
|
104
110
|
}
|
|
105
|
-
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ElementContainer } from '../dom/element-container';
|
|
2
|
+
import { pageConfigOptions } from './canvas/pdf-renderer';
|
|
3
|
+
export declare const paginateNode: (root: ElementContainer, pageHeight: number, initialOffset?: number, totalHeight?: number, pageConfig?: pageConfigOptions) => ElementContainer[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ElementContainer } from '../dom/element-container';
|
|
2
2
|
import { pageConfigOptions } from './canvas/pdf-renderer';
|
|
3
|
-
export declare const paginateNode: (root: ElementContainer, pageHeight: number, initialOffset?: number, pageConfig?: pageConfigOptions) => ElementContainer[];
|
|
3
|
+
export declare const paginateNode: (root: ElementContainer, pageHeight: number, initialOffset?: number, totalHeight?: number, pageConfig?: pageConfigOptions) => ElementContainer[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { jsPDF } from 'jspdf';
|
|
1
2
|
import { ContextOptions } from './core/context';
|
|
2
3
|
import { CloneOptions, WindowOptions } from './dom/document-cloner';
|
|
3
4
|
import { RenderOptions } from './render/canvas/pdf-renderer';
|
|
4
|
-
|
|
5
|
-
fontFamily: string;
|
|
6
|
-
fontBase64: string;
|
|
7
|
-
}
|
|
5
|
+
import { FontConfig } from './utils';
|
|
8
6
|
export type Options = CloneOptions & WindowOptions & RenderOptions & ContextOptions & {
|
|
9
7
|
backgroundColor: string | null;
|
|
10
8
|
foreignObjectRendering: boolean;
|
|
11
9
|
divisionDisable?: boolean;
|
|
12
10
|
removeContainer?: boolean;
|
|
13
|
-
fontConfig?: FontConfig;
|
|
11
|
+
fontConfig?: FontConfig | FontConfig[] | undefined;
|
|
12
|
+
onJspdfReady?: (jspdfCtx: jsPDF) => void;
|
|
13
|
+
onJspdfFinish?: (jspdfCtx: jsPDF) => void;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
export type DompdfResult = HTMLCanvasElement | Blob;
|
|
16
|
+
declare const dompdf: (element: HTMLElement, options?: Partial<Options>) => Promise<DompdfResult>;
|
|
16
17
|
export default dompdf;
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
+
import { Context2d, EncryptionOptions, jsPDF } from 'jspdf';
|
|
2
|
+
import 'jspdf/dist/polyfills.es.js';
|
|
1
3
|
import { Context } from '../../core/context';
|
|
2
4
|
import { CSSParsedDeclaration } from '../../css';
|
|
5
|
+
import { Bounds } from '../../css/layout/bounds';
|
|
3
6
|
import { TextBounds } from '../../css/layout/text';
|
|
4
7
|
import { BORDER_STYLE } from '../../css/property-descriptors/border-style';
|
|
5
8
|
import { Color } from '../../css/types/color';
|
|
6
9
|
import { ElementContainer } from '../../dom/element-container';
|
|
7
|
-
import {
|
|
10
|
+
import { CanvasElementContainer } from '../../dom/replaced-elements/canvas-element-container';
|
|
11
|
+
import { ImageElementContainer } from '../../dom/replaced-elements/image-element-container';
|
|
12
|
+
import { SVGElementContainer } from '../../dom/replaced-elements/svg-element-container';
|
|
8
13
|
import { TextContainer } from '../../dom/text-container';
|
|
9
14
|
import { BoundCurves } from '../bound-curves';
|
|
10
15
|
import { IElementEffect } from '../effects';
|
|
16
|
+
import { FontConfig } from '../../utils';
|
|
11
17
|
import { Path } from '../path';
|
|
12
18
|
import { Renderer } from '../renderer';
|
|
13
19
|
import { ElementPaint, StackingContext } from '../stacking-context';
|
|
14
|
-
interface FontConfig {
|
|
15
|
-
fontFamily: string;
|
|
16
|
-
fontBase64: string;
|
|
17
|
-
}
|
|
18
20
|
export type RenderConfigurations = RenderOptions & {
|
|
19
21
|
backgroundColor: Color | null;
|
|
20
|
-
fontConfig: FontConfig;
|
|
22
|
+
fontConfig: FontConfig | FontConfig[] | undefined;
|
|
21
23
|
};
|
|
22
24
|
export type pageConfigOptions = {
|
|
23
25
|
header: {
|
|
24
|
-
content: string;
|
|
26
|
+
content: string | ((renderer: any, pageNum: string) => void);
|
|
25
27
|
height: number;
|
|
26
28
|
contentPosition: 'center' | 'centerLeft' | 'centerRight' | 'centerTop' | 'centerBottom' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | [number, number];
|
|
27
29
|
contentColor: string;
|
|
@@ -29,7 +31,7 @@ export type pageConfigOptions = {
|
|
|
29
31
|
padding?: [number, number, number, number];
|
|
30
32
|
};
|
|
31
33
|
footer: {
|
|
32
|
-
content: string;
|
|
34
|
+
content: string | ((renderer: any, pageNum: string) => void);
|
|
33
35
|
height: number;
|
|
34
36
|
contentPosition: 'center' | 'centerLeft' | 'centerRight' | 'centerTop' | 'centerBottom' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | [number, number];
|
|
35
37
|
contentColor: string;
|
|
@@ -45,31 +47,33 @@ export interface RenderOptions {
|
|
|
45
47
|
width: number;
|
|
46
48
|
height: number;
|
|
47
49
|
pdfFileName?: string;
|
|
48
|
-
encryption?:
|
|
49
|
-
userPassword?: string;
|
|
50
|
-
ownerPassword?: string;
|
|
51
|
-
userPermissions?: string[];
|
|
52
|
-
};
|
|
50
|
+
encryption?: EncryptionOptions | undefined;
|
|
53
51
|
precision?: number;
|
|
54
52
|
floatPrecision?: number | 'smart';
|
|
55
53
|
compress?: boolean;
|
|
56
54
|
putOnlyUsedFonts?: boolean;
|
|
57
55
|
pagination?: boolean;
|
|
58
|
-
format?: 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6' | 'a7' | 'a8' | 'a9' | 'a10' | 'b0' | 'b1' | 'b2' | 'b3' | 'b4' | 'b5' | 'b6' | 'b7' | 'b8' | 'b9' | 'b10' | 'c0' | 'c1' | 'c2' | 'c3' | 'c4' | 'c5' | 'c6' | 'c7' | 'c8' | 'c9' | 'c10' | 'dl' | 'letter' | 'government-letter' | 'legal' | 'junior-legal' | 'ledger' | 'tabloid' | 'credit-card';
|
|
56
|
+
format?: 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6' | 'a7' | 'a8' | 'a9' | 'a10' | 'b0' | 'b1' | 'b2' | 'b3' | 'b4' | 'b5' | 'b6' | 'b7' | 'b8' | 'b9' | 'b10' | 'c0' | 'c1' | 'c2' | 'c3' | 'c4' | 'c5' | 'c6' | 'c7' | 'c8' | 'c9' | 'c10' | 'dl' | 'letter' | 'government-letter' | 'legal' | 'junior-legal' | 'ledger' | 'tabloid' | 'credit-card' | [number, number];
|
|
59
57
|
pageConfig?: pageConfigOptions;
|
|
60
58
|
}
|
|
59
|
+
export declare class JsPdfContext2d {
|
|
60
|
+
}
|
|
61
|
+
export interface JsPdfContext2d extends Context2d {
|
|
62
|
+
getLineDash(): number[];
|
|
63
|
+
setLineDash(segments: number[]): void;
|
|
64
|
+
}
|
|
61
65
|
export declare class CanvasRenderer extends Renderer {
|
|
62
66
|
canvas: HTMLCanvasElement;
|
|
63
|
-
|
|
64
|
-
readonly
|
|
65
|
-
readonly context2dCtx: any;
|
|
67
|
+
readonly jspdfCtx: jsPDF;
|
|
68
|
+
readonly context2dCtx: JsPdfContext2d;
|
|
66
69
|
private readonly _activeEffects;
|
|
67
70
|
private readonly fontMetrics;
|
|
68
71
|
private readonly pxToPt;
|
|
69
72
|
private totalPages;
|
|
70
73
|
constructor(context: Context, options: RenderConfigurations);
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
addFontToJsPDF(): void;
|
|
75
|
+
resetJsPDFFont(): void;
|
|
76
|
+
setTextFont(styles: CSSParsedDeclaration): string;
|
|
73
77
|
applyEffects(effects: IElementEffect[]): void;
|
|
74
78
|
applyEffect(effect: IElementEffect): void;
|
|
75
79
|
popEffect(): void;
|
|
@@ -79,13 +83,15 @@ export declare class CanvasRenderer extends Renderer {
|
|
|
79
83
|
private createFontStyle;
|
|
80
84
|
private convertColor;
|
|
81
85
|
renderTextNode(text: TextContainer, styles: CSSParsedDeclaration): Promise<void>;
|
|
82
|
-
|
|
86
|
+
renderReplacedJsPdfImage(container: ImageElementContainer, image: HTMLImageElement | HTMLCanvasElement): void;
|
|
87
|
+
renderReplacedJsPdfSvg(container: SVGElementContainer, image: HTMLImageElement | HTMLCanvasElement): void;
|
|
88
|
+
renderReplacedJsPdfCanvasImage(container: CanvasElementContainer): void;
|
|
83
89
|
renderNodeContent(paint: ElementPaint): Promise<void>;
|
|
84
90
|
renderStackContent(stack: StackingContext): Promise<void>;
|
|
85
91
|
mask(paths: Path[]): void;
|
|
86
|
-
path(paths: Path[]): void;
|
|
87
|
-
formatPath(paths: Path[]): void;
|
|
88
|
-
renderRepeat(path: Path[], pattern: CanvasPattern | CanvasGradient
|
|
92
|
+
path(paths: Path[], ctx2d?: Context2d | CanvasRenderingContext2D): void;
|
|
93
|
+
formatPath(paths: Path[], ctx2d?: Context2d | CanvasRenderingContext2D): void;
|
|
94
|
+
renderRepeat(boxs: Bounds, ctx: CanvasRenderingContext2D, path: Path[], pattern: CanvasPattern | CanvasGradient): void;
|
|
89
95
|
resizeImage(image: HTMLImageElement, width: number, height: number): HTMLCanvasElement | HTMLImageElement;
|
|
90
96
|
renderBackgroundImage(container: ElementContainer): Promise<void>;
|
|
91
97
|
renderSolidBorder(color: Color, side: number, curvePoints: BoundCurves): Promise<void>;
|
|
@@ -102,4 +108,3 @@ export declare class CanvasRenderer extends Renderer {
|
|
|
102
108
|
private addImagePdf;
|
|
103
109
|
output(): Promise<Blob>;
|
|
104
110
|
}
|
|
105
|
-
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ElementContainer } from '../dom/element-container';
|
|
2
|
+
import { pageConfigOptions } from './canvas/pdf-renderer';
|
|
3
|
+
export declare const paginateNode: (root: ElementContainer, pageHeight: number, initialOffset?: number, totalHeight?: number, pageConfig?: pageConfigOptions) => ElementContainer[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ElementContainer } from '../dom/element-container';
|
|
2
2
|
import { pageConfigOptions } from './canvas/pdf-renderer';
|
|
3
|
-
export declare const paginateNode: (root: ElementContainer, pageHeight: number, initialOffset?: number, pageConfig?: pageConfigOptions) => ElementContainer[];
|
|
3
|
+
export declare const paginateNode: (root: ElementContainer, pageHeight: number, initialOffset?: number, totalHeight?: number, pageConfig?: pageConfigOptions) => ElementContainer[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementContainer } from '../dom/element-container';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively traverse the nodes and check whether the textNodes of all levels are empty arrays
|
|
4
|
+
* @param {ElementContainer} node
|
|
5
|
+
* @returns {boolean} - If all textNodes are empty, return true; otherwise, return false
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkAllTextNodesEmpty(node: ElementContainer): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FontConfig {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
fontBase64: string;
|
|
4
|
+
fontStyle: string;
|
|
5
|
+
fontWeight: 400 | 700;
|
|
6
|
+
iconFont?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function validateFontConfig(fontConfig: FontConfig | FontConfig[] | undefined): boolean;
|
|
9
|
+
export declare function setOptionFontConfig(rawConfig: FontConfig | FontConfig[] | undefined): FontConfig[] | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isEmptyValue(obj: unknown): boolean;
|
|
2
|
+
export declare function isArray(obj: unknown): obj is Array<unknown>;
|
|
3
|
+
export declare function isObject(obj: unknown): obj is Record<string, unknown>;
|
|
4
|
+
export declare function isFunction(fn: unknown): fn is (...args: unknown[]) => unknown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断图片路径是否为指定类型的图片
|
|
3
|
+
* @param {string} path 图片路径/URL(如 "../tests/assets/image.svg"、"https://xxx.com/photo.webp")
|
|
4
|
+
* @param {("svg" | "webp" | "png" | "jpg" | "gif" | "unknown")} type 要判断的图片类型
|
|
5
|
+
* @returns {boolean} 是否为指定类型的图片
|
|
6
|
+
*/
|
|
7
|
+
export declare function getImageTypeByPath(path: string, type: 'svg' | 'webp' | 'png' | 'jpg' | 'gif' | 'unknown'): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementContainer } from '../dom/element-container';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively traverse the nodes and check whether the textNodes of all levels are empty arrays
|
|
4
|
+
* @param {ElementContainer} node
|
|
5
|
+
* @returns {boolean} - If all textNodes are empty, return true; otherwise, return false
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkAllTextNodesEmpty(node: ElementContainer): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FontConfig {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
fontBase64: string;
|
|
4
|
+
fontStyle: string;
|
|
5
|
+
fontWeight: 400 | 700;
|
|
6
|
+
iconFont?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function validateFontConfig(fontConfig: FontConfig | FontConfig[] | undefined): boolean;
|
|
9
|
+
export declare function setOptionFontConfig(rawConfig: FontConfig | FontConfig[] | undefined): FontConfig[] | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isEmptyValue(obj: unknown): boolean;
|
|
2
|
+
export declare function isArray(obj: unknown): obj is Array<unknown>;
|
|
3
|
+
export declare function isObject(obj: unknown): obj is Record<string, unknown>;
|
|
4
|
+
export declare function isFunction(fn: unknown): fn is (...args: unknown[]) => unknown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断图片路径是否为指定类型的图片
|
|
3
|
+
* @param {string} path 图片路径/URL(如 "../tests/assets/image.svg"、"https://xxx.com/photo.webp")
|
|
4
|
+
* @param {("svg" | "webp" | "png" | "jpg" | "gif" | "unknown")} type 要判断的图片类型
|
|
5
|
+
* @returns {boolean} 是否为指定类型的图片
|
|
6
|
+
*/
|
|
7
|
+
export declare function getImageTypeByPath(path: string, type: 'svg' | 'webp' | 'png' | 'jpg' | 'gif' | 'unknown'): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
|
2
|
+
var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",d=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,d)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(a){u(a)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,d){if(!d){t=p(t)}var v=this,w=t.type,m=w===s,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&i)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;a(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define("FileSaver.js",function(){return saveAs})}
|