tnx-shared 5.3.266 → 5.3.267
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/bundles/tnx-shared.umd.js +178 -1
- package/bundles/tnx-shared.umd.js.map +1 -1
- package/bundles/tnx-shared.umd.min.js +1 -1
- package/bundles/tnx-shared.umd.min.js.map +1 -1
- package/esm2015/components/html-preview/html-preview.component.js +2 -2
- package/esm2015/public-api.js +2 -1
- package/esm2015/services/common.service.js +11 -1
- package/esm2015/services/latex.service.js +105 -0
- package/fesm2015/tnx-shared.js +108 -2
- package/fesm2015/tnx-shared.js.map +1 -1
- package/package.json +2 -2
- package/public-api.d.ts +1 -0
- package/public-api.d.ts.map +1 -1
- package/services/common.service.d.ts +1 -0
- package/services/common.service.d.ts.map +1 -1
- package/services/latex.service.d.ts +11 -0
- package/services/latex.service.d.ts.map +1 -0
- package/services/latex.service.ngfactory.d.ts.map +1 -0
- package/tnx-shared.metadata.json +1 -1
|
@@ -4864,6 +4864,16 @@
|
|
|
4864
4864
|
var diff = (maxLength < stringIndex.length) ? 0 : maxLength - stringIndex.length;
|
|
4865
4865
|
return "" + Array(diff).map(function (x) { return ''; }).join(' ') + stringIndex;
|
|
4866
4866
|
};
|
|
4867
|
+
CommonService.prototype.dataURItoBlob = function (dataURI) {
|
|
4868
|
+
var byteString = window.atob(dataURI);
|
|
4869
|
+
var arrayBuffer = new ArrayBuffer(byteString.length);
|
|
4870
|
+
var int8Array = new Uint8Array(arrayBuffer);
|
|
4871
|
+
for (var i = 0; i < byteString.length; i++) {
|
|
4872
|
+
int8Array[i] = byteString.charCodeAt(i);
|
|
4873
|
+
}
|
|
4874
|
+
var blob = new Blob([int8Array], { type: 'image/png' });
|
|
4875
|
+
return blob;
|
|
4876
|
+
};
|
|
4867
4877
|
return CommonService;
|
|
4868
4878
|
}());
|
|
4869
4879
|
CommonService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CommonService_Factory() { return new CommonService(i0__namespace.ɵɵinject(ModuleConfigService)); }, token: CommonService, providedIn: "root" });
|
|
@@ -42512,6 +42522,172 @@
|
|
|
42512
42522
|
{ type: NotifierService }
|
|
42513
42523
|
]; };
|
|
42514
42524
|
|
|
42525
|
+
var LatexService = /** @class */ (function () {
|
|
42526
|
+
function LatexService(_commonService, _templateInstanceService, _fileObjectService) {
|
|
42527
|
+
this._commonService = _commonService;
|
|
42528
|
+
this._templateInstanceService = _templateInstanceService;
|
|
42529
|
+
this._fileObjectService = _fileObjectService;
|
|
42530
|
+
}
|
|
42531
|
+
// replace latex to image
|
|
42532
|
+
LatexService.prototype.replaceLatexData = function (data, oldData, fields, fontSize, ignoreCheckEdited) {
|
|
42533
|
+
if (ignoreCheckEdited === void 0) { ignoreCheckEdited = false; }
|
|
42534
|
+
var _a;
|
|
42535
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42536
|
+
var fields_1, fields_1_1, field, pattern, patternChild, temp, lstLatex, lstLatexDistint, _loop_1, this_1, lstLatexDistint_1, lstLatexDistint_1_1, latexItem, state_1, e_1_1, e_2_1, _b_1;
|
|
42537
|
+
var e_2, _c, e_1, _d;
|
|
42538
|
+
return __generator(this, function (_e) {
|
|
42539
|
+
switch (_e.label) {
|
|
42540
|
+
case 0:
|
|
42541
|
+
_e.trys.push([0, 16, , 17]);
|
|
42542
|
+
_e.label = 1;
|
|
42543
|
+
case 1:
|
|
42544
|
+
_e.trys.push([1, 13, 14, 15]);
|
|
42545
|
+
fields_1 = __values(fields), fields_1_1 = fields_1.next();
|
|
42546
|
+
_e.label = 2;
|
|
42547
|
+
case 2:
|
|
42548
|
+
if (!!fields_1_1.done) return [3 /*break*/, 12];
|
|
42549
|
+
field = fields_1_1.value;
|
|
42550
|
+
pattern = /\\\(.*?\\\)|\$\$.*?\$\$|\$.*?\$|\\\[.*?\\\]/gm;
|
|
42551
|
+
patternChild = /\\\(|\\\)|\$\$|\$\$|\$|\$|\\\[|\\\]/gm;
|
|
42552
|
+
if (!(data[field] && data[field] != oldData[field] || ignoreCheckEdited)) return [3 /*break*/, 11];
|
|
42553
|
+
temp = data[field];
|
|
42554
|
+
lstLatex = data[field].match(pattern);
|
|
42555
|
+
lstLatexDistint = lstLatex === null || lstLatex === void 0 ? void 0 : lstLatex.filter(function (current, index, self) { return self.indexOf(current) === index; });
|
|
42556
|
+
if (!(lstLatexDistint === null || lstLatexDistint === void 0 ? void 0 : lstLatexDistint.length)) {
|
|
42557
|
+
data[field + 'Print'] = temp;
|
|
42558
|
+
return [3 /*break*/, 11];
|
|
42559
|
+
}
|
|
42560
|
+
_loop_1 = function (latexItem) {
|
|
42561
|
+
var latex, base64, imageName, imageBlob, imageFile, uploadFile, preIndex, lstLatexSame, i, index, alignCenter, image, lastIndexOfParagraph, styleIndex;
|
|
42562
|
+
return __generator(this, function (_f) {
|
|
42563
|
+
switch (_f.label) {
|
|
42564
|
+
case 0:
|
|
42565
|
+
latex = latexItem.replace(patternChild, '');
|
|
42566
|
+
return [4 /*yield*/, this_1._templateInstanceService.laTexToBase64Image(latex, fontSize)];
|
|
42567
|
+
case 1:
|
|
42568
|
+
base64 = _f.sent();
|
|
42569
|
+
if (!base64.success) {
|
|
42570
|
+
return [2 /*return*/, { value: false }];
|
|
42571
|
+
}
|
|
42572
|
+
imageName = 'latex.png';
|
|
42573
|
+
imageBlob = this_1._commonService.dataURItoBlob(base64.data.replace('data:image/png;base64,', ''));
|
|
42574
|
+
imageFile = new File([imageBlob], imageName, { type: 'image/png' });
|
|
42575
|
+
return [4 /*yield*/, this_1._fileObjectService.uploadWithByteArray(imageFile)];
|
|
42576
|
+
case 2:
|
|
42577
|
+
uploadFile = _f.sent();
|
|
42578
|
+
if (!uploadFile) {
|
|
42579
|
+
return [2 /*return*/, { value: false }];
|
|
42580
|
+
}
|
|
42581
|
+
preIndex = temp.indexOf(latexItem);
|
|
42582
|
+
if (preIndex < 0) {
|
|
42583
|
+
return [2 /*return*/, "continue"];
|
|
42584
|
+
}
|
|
42585
|
+
lstLatexSame = lstLatex.filter(function (x) { return x == latexItem; });
|
|
42586
|
+
for (i = 0; i < lstLatexSame.length; i++) {
|
|
42587
|
+
index = temp.indexOf(latexItem, preIndex + i);
|
|
42588
|
+
alignCenter = ((_a = latexItem.match(/\$\$|\$\$|\\\[|\\\]/gm)) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
42589
|
+
image = "<img src=\"" + this_1._fileObjectService.getUrlImage(uploadFile) + "\" >";
|
|
42590
|
+
if (!fontSize) {
|
|
42591
|
+
image = "<img src=\"" + this_1._fileObjectService.getUrlImage(uploadFile) + "\" height=\"16.32px\">";
|
|
42592
|
+
}
|
|
42593
|
+
if (alignCenter) {
|
|
42594
|
+
lastIndexOfParagraph = temp.substring(0, index).lastIndexOf('<p');
|
|
42595
|
+
if (lastIndexOfParagraph < 0) {
|
|
42596
|
+
image = "<p style=\"text-align: center;\"><img src=\"" + this_1._fileObjectService.getUrlImage(uploadFile) + "\" ></p>";
|
|
42597
|
+
if (!fontSize) {
|
|
42598
|
+
image = "<p style=\"text-align: center;\"><img src=\"" + this_1._fileObjectService.getUrlImage(uploadFile) + "\" height=\"16.32px\" ></p>";
|
|
42599
|
+
}
|
|
42600
|
+
}
|
|
42601
|
+
else {
|
|
42602
|
+
image = "<img src=\"" + this_1._fileObjectService.getUrlImage(uploadFile) + "\" >";
|
|
42603
|
+
if (!fontSize) {
|
|
42604
|
+
image = "<img src=\"" + this_1._fileObjectService.getUrlImage(uploadFile) + "\" height=\"16.32px\" >";
|
|
42605
|
+
}
|
|
42606
|
+
styleIndex = temp.substring(0, index).lastIndexOf('<p style=');
|
|
42607
|
+
if (styleIndex < 0) {
|
|
42608
|
+
temp = temp.substring(0, lastIndexOfParagraph + 2) + ' style="text-align: center;"' + temp.substring(lastIndexOfParagraph + 2);
|
|
42609
|
+
}
|
|
42610
|
+
else {
|
|
42611
|
+
temp = temp.substring(0, styleIndex + 10) + 'text-align: center;' + temp.substring(styleIndex + 10);
|
|
42612
|
+
}
|
|
42613
|
+
}
|
|
42614
|
+
}
|
|
42615
|
+
index = temp.indexOf(latexItem);
|
|
42616
|
+
temp = temp.substring(0, index) + image + temp.substring(index + latexItem.length);
|
|
42617
|
+
}
|
|
42618
|
+
return [2 /*return*/];
|
|
42619
|
+
}
|
|
42620
|
+
});
|
|
42621
|
+
};
|
|
42622
|
+
this_1 = this;
|
|
42623
|
+
_e.label = 3;
|
|
42624
|
+
case 3:
|
|
42625
|
+
_e.trys.push([3, 8, 9, 10]);
|
|
42626
|
+
lstLatexDistint_1 = (e_1 = void 0, __values(lstLatexDistint)), lstLatexDistint_1_1 = lstLatexDistint_1.next();
|
|
42627
|
+
_e.label = 4;
|
|
42628
|
+
case 4:
|
|
42629
|
+
if (!!lstLatexDistint_1_1.done) return [3 /*break*/, 7];
|
|
42630
|
+
latexItem = lstLatexDistint_1_1.value;
|
|
42631
|
+
return [5 /*yield**/, _loop_1(latexItem)];
|
|
42632
|
+
case 5:
|
|
42633
|
+
state_1 = _e.sent();
|
|
42634
|
+
if (typeof state_1 === "object")
|
|
42635
|
+
return [2 /*return*/, state_1.value];
|
|
42636
|
+
_e.label = 6;
|
|
42637
|
+
case 6:
|
|
42638
|
+
lstLatexDistint_1_1 = lstLatexDistint_1.next();
|
|
42639
|
+
return [3 /*break*/, 4];
|
|
42640
|
+
case 7: return [3 /*break*/, 10];
|
|
42641
|
+
case 8:
|
|
42642
|
+
e_1_1 = _e.sent();
|
|
42643
|
+
e_1 = { error: e_1_1 };
|
|
42644
|
+
return [3 /*break*/, 10];
|
|
42645
|
+
case 9:
|
|
42646
|
+
try {
|
|
42647
|
+
if (lstLatexDistint_1_1 && !lstLatexDistint_1_1.done && (_d = lstLatexDistint_1.return)) _d.call(lstLatexDistint_1);
|
|
42648
|
+
}
|
|
42649
|
+
finally { if (e_1) throw e_1.error; }
|
|
42650
|
+
return [7 /*endfinally*/];
|
|
42651
|
+
case 10:
|
|
42652
|
+
data[field + 'Print'] = temp;
|
|
42653
|
+
_e.label = 11;
|
|
42654
|
+
case 11:
|
|
42655
|
+
fields_1_1 = fields_1.next();
|
|
42656
|
+
return [3 /*break*/, 2];
|
|
42657
|
+
case 12: return [3 /*break*/, 15];
|
|
42658
|
+
case 13:
|
|
42659
|
+
e_2_1 = _e.sent();
|
|
42660
|
+
e_2 = { error: e_2_1 };
|
|
42661
|
+
return [3 /*break*/, 15];
|
|
42662
|
+
case 14:
|
|
42663
|
+
try {
|
|
42664
|
+
if (fields_1_1 && !fields_1_1.done && (_c = fields_1.return)) _c.call(fields_1);
|
|
42665
|
+
}
|
|
42666
|
+
finally { if (e_2) throw e_2.error; }
|
|
42667
|
+
return [7 /*endfinally*/];
|
|
42668
|
+
case 15: return [2 /*return*/, true];
|
|
42669
|
+
case 16:
|
|
42670
|
+
_b_1 = _e.sent();
|
|
42671
|
+
return [2 /*return*/, false];
|
|
42672
|
+
case 17: return [2 /*return*/];
|
|
42673
|
+
}
|
|
42674
|
+
});
|
|
42675
|
+
});
|
|
42676
|
+
};
|
|
42677
|
+
return LatexService;
|
|
42678
|
+
}());
|
|
42679
|
+
LatexService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LatexService_Factory() { return new LatexService(i0__namespace.ɵɵinject(CommonService), i0__namespace.ɵɵinject(TemplateInstanceService), i0__namespace.ɵɵinject(FileObjectService)); }, token: LatexService, providedIn: "root" });
|
|
42680
|
+
LatexService.decorators = [
|
|
42681
|
+
{ type: i0.Injectable, args: [{
|
|
42682
|
+
providedIn: "root",
|
|
42683
|
+
},] }
|
|
42684
|
+
];
|
|
42685
|
+
LatexService.ctorParameters = function () { return [
|
|
42686
|
+
{ type: CommonService },
|
|
42687
|
+
{ type: TemplateInstanceService },
|
|
42688
|
+
{ type: FileObjectService }
|
|
42689
|
+
]; };
|
|
42690
|
+
|
|
42515
42691
|
var ItemStatus;
|
|
42516
42692
|
(function (ItemStatus) {
|
|
42517
42693
|
ItemStatus[ItemStatus["ChoDuyet"] = 0] = "ChoDuyet";
|
|
@@ -50800,7 +50976,7 @@
|
|
|
50800
50976
|
HtmlPreviewComponent.decorators = [
|
|
50801
50977
|
{ type: i0.Component, args: [{
|
|
50802
50978
|
selector: 'html-preview',
|
|
50803
|
-
template: "<div class=\"preview-box\" [ngClass]=\"{ 'disabled-box': control.disabled }\" id=\"math-preview-box-{{id}}\" [ngStyle]=\"{'height': control.disabled ? 'auto' : control.height + 'px'}\">\n <tn-custom-scrollbar [showScrollHorizontal]=\"true\">\n <div #mathContent id=\"mathPreview-{{id}}\"></div>\n </tn-custom-scrollbar>\n</div>",
|
|
50979
|
+
template: "<div class=\"preview-box\" [ngClass]=\"{ 'disabled-box': control.disabled }\" id=\"math-preview-box-{{id}}\" [ngStyle]=\"{'height': control.disabled ? 'auto' : control.height + 'px', 'min-height': control.height + 'px'}\">\n <tn-custom-scrollbar [showScrollHorizontal]=\"true\">\n <div #mathContent id=\"mathPreview-{{id}}\"></div>\n </tn-custom-scrollbar>\n</div>",
|
|
50804
50980
|
providers: [
|
|
50805
50981
|
ComponentContextService,
|
|
50806
50982
|
{
|
|
@@ -55831,6 +56007,7 @@
|
|
|
55831
56007
|
exports.LabelSchema = LabelSchema;
|
|
55832
56008
|
exports.LabelWFNhomTrangThai = LabelWFNhomTrangThai;
|
|
55833
56009
|
exports.LabelWorkflowCoreStatus = LabelWorkflowCoreStatus;
|
|
56010
|
+
exports.LatexService = LatexService;
|
|
55834
56011
|
exports.LengthValidator = LengthValidator;
|
|
55835
56012
|
exports.ListHelperService = ListHelperService;
|
|
55836
56013
|
exports.LocalCacheService = LocalCacheService;
|