]>
git.kianting.info Git - clo/blob - src/libclo/index.js
e5ae1bdcf4fb83f30629f92196360894a8e8b254
2 Object
.defineProperty(exports
, "__esModule", { value
: true });
3 exports
.a
= exports
.Clo
= void 0;
4 const canva_1
= require("../canva");
15 (function (Direction
) {
16 Direction
[Direction
["LTR"] = 0] = "LTR";
17 Direction
[Direction
["RTL"] = 1] = "RTL";
18 Direction
[Direction
["TTB"] = 2] = "TTB";
19 Direction
[Direction
["BTT"] = 3] = "BTT";
20 })(Direction
|| (Direction
= {}));
24 const A4_IN_PX
= { "width": 793.7,
26 const defaultTextStyle
= {
29 textWeight
: canva_1
.TextWeight
.REGULAR
,
30 textStyle
: canva_1
.TextStyle
.ITALIC
,
32 const defaultFrameStyle
= {
33 directionInsideLine
: Direction
.LTR
,
34 direction
: Direction
.TTB
,
35 baseLineskip
: ptToPx(15),
36 fontStyle
: defaultTextStyle
,
37 x
: A4_IN_PX
.width
* 0.10,
38 y
: A4_IN_PX
.height
* 0.10,
39 width
: A4_IN_PX
.width
* 0.80,
40 height
: A4_IN_PX
.height
* 0.80,
43 const cjkvBlocksInRegex
= ["Hani"];
44 const cjkvRegexPattern
= new RegExp("((?:" +
45 cjkvBlocksInRegex
.map((x
) => "\\p{Script_Extensions=" + x
+ "}").join("|") + ")+)", "gu");
51 * @param pt pt size value
52 * @returns the corresponding px value
61 * split CJKV and non-CJKV
63 * @param arr : input tkTree
66 function splitCJKV(arr
) {
69 for (let i
= 0; i
< arr
.length
; i
++) {
71 if (!Array
.isArray(item
)) {
72 console
.log(item
.split(cjkvRegexPattern
));
73 result
= result
.concat(item
.split(cjkvRegexPattern
));
84 this.preprocessors
= [];
86 this.attributes
= { "page": A4_IN_PX
};
87 // register the precessor functions
88 this.preprocessorRegister(splitCJKV
);
91 Object
.assign(this.attributes
, attr
, val
);
94 if (Object
.keys(this.attributes
).length
=== 0) {
95 return this.attributes
[attr
];
102 * register a function of preprocessor
103 * @param f a function
105 preprocessorRegister(f
) {
106 this.preprocessors
.push(f
);
110 var prepro
= this.mainStream
;
111 for (var i
= 0; i
< this.preprocessors
.length
; i
++) {
112 prepro
= this.preprocessors
[i
](prepro
);
115 console
.log("test" + prepro
);
119 exports
.a
= new Clo();
120 exports
.default = exports
.a
;