@nativescript-community/ui-label 1.2.10 → 1.2.12
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/CHANGELOG.md +16 -0
- package/label.ios.d.ts +3 -1
- package/label.ios.js +43 -16
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [1.2.12](https://github.com/nativescript-community/ui-label/compare/v1.2.11...v1.2.12) (2022-09-16)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.2.11](https://github.com/nativescript-community/ui-label/compare/v1.2.10...v1.2.11) (2022-09-09)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
6
22
|
## [1.2.10](https://github.com/nativescript-community/ui-label/compare/v1.2.9...v1.2.10) (2022-09-01)
|
7
23
|
|
8
24
|
**Note:** Version bump only for package @nativescript-community/ui-label
|
package/label.ios.d.ts
CHANGED
@@ -29,7 +29,9 @@ export declare class Label extends LabelBase {
|
|
29
29
|
_requestLayoutOnTextChanged(): void;
|
30
30
|
onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
|
31
31
|
_onSizeChanged(): void;
|
32
|
-
|
32
|
+
_tappable: any;
|
33
|
+
_setTappableState(tappable: any): void;
|
34
|
+
textViewShouldInteractWithURLInRangeInteraction?(textView: UITextView, url: NSURL, characterRange: NSRange, interaction: UITextItemInteraction): boolean;
|
33
35
|
_updateHTMLString(fontSize?: number): void;
|
34
36
|
updateHTMLString(fontSize?: number): void;
|
35
37
|
_setColor(color: any): void;
|
package/label.ios.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
var _a, _b, _c, _d;
|
2
2
|
import { createNativeAttributedString, verticalTextAlignmentProperty } from '@nativescript-community/text';
|
3
|
-
import { Color, Font, View } from '@nativescript/core';
|
3
|
+
import { Color, Font, Span, View } from '@nativescript/core';
|
4
4
|
import { borderBottomWidthProperty, borderLeftWidthProperty, borderRightWidthProperty, borderTopWidthProperty, fontInternalProperty, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty } from '@nativescript/core/ui/styling/style-properties';
|
5
5
|
import { formattedTextProperty, letterSpacingProperty, lineHeightProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
|
6
6
|
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
|
@@ -280,10 +280,32 @@ export class Label extends LabelBase {
|
|
280
280
|
this.updateAutoFontSize({ textView: this.nativeTextViewProtected });
|
281
281
|
}
|
282
282
|
}
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
283
|
+
_setTappableState(tappable) {
|
284
|
+
if (this._tappable !== tappable) {
|
285
|
+
this._tappable = tappable;
|
286
|
+
// we dont want the label gesture recognizer for linkTap
|
287
|
+
// so we override
|
288
|
+
}
|
289
|
+
}
|
290
|
+
textViewShouldInteractWithURLInRangeInteraction(textView, url, characterRange, interaction) {
|
291
|
+
for (let i = 0, spanStart = 0, length = this.formattedText.spans.length; i < length; i++) {
|
292
|
+
const span = this.formattedText.spans.getItem(i);
|
293
|
+
const text = span.text;
|
294
|
+
const textTransform = this.formattedText.parent.textTransform;
|
295
|
+
let spanText = isNullOrUndefined(text) ? '' : `${text}`;
|
296
|
+
if (textTransform !== 'none' && textTransform !== 'initial') {
|
297
|
+
spanText = getTransformedText(spanText, textTransform);
|
298
|
+
}
|
299
|
+
spanStart += spanText.length;
|
300
|
+
if (characterRange.location - 1 <= spanStart && characterRange.location - 1 + characterRange.length > spanStart) {
|
301
|
+
const span = this.formattedText.spans.getItem(i);
|
302
|
+
if (span && span.tappable) {
|
303
|
+
// if the span is found and tappable emit the linkTap event
|
304
|
+
span.notify({ eventName: Span.linkTapEvent, link: url === null || url === void 0 ? void 0 : url.toString() });
|
305
|
+
}
|
306
|
+
break;
|
307
|
+
}
|
308
|
+
}
|
287
309
|
return false;
|
288
310
|
}
|
289
311
|
_updateHTMLString(fontSize) {
|
@@ -309,13 +331,14 @@ export class Label extends LabelBase {
|
|
309
331
|
textAlignment: this.nativeTextViewProtected.textAlignment
|
310
332
|
}, this, this.autoFontSize, this.fontSizeRatio);
|
311
333
|
let hasLink = false;
|
312
|
-
result
|
334
|
+
if (result) {
|
313
335
|
result.enumerateAttributeInRangeOptionsUsingBlock(NSLinkAttributeName, { location: 0, length: result.length }, 0, (value, range, stop) => {
|
314
336
|
hasLink = hasLink || (!!value && range.length > 0);
|
315
337
|
if (hasLink) {
|
316
338
|
stop[0] = true;
|
317
339
|
}
|
318
340
|
});
|
341
|
+
}
|
319
342
|
this.nativeTextViewProtected.selectable = this.selectable === true || hasLink;
|
320
343
|
this.attributedString = result;
|
321
344
|
}
|
@@ -482,27 +505,31 @@ export class Label extends LabelBase {
|
|
482
505
|
default:
|
483
506
|
throw new Error(`Invalid text decoration value: ${style.textDecoration}. Valid values are: 'none', 'underline', 'line-through', 'underline line-through'.`);
|
484
507
|
}
|
508
|
+
let paragraphStyle;
|
509
|
+
const createParagraphStyle = () => {
|
510
|
+
if (!paragraphStyle) {
|
511
|
+
paragraphStyle = NSMutableParagraphStyle.alloc().init();
|
512
|
+
paragraphStyle.alignment = this.nativeTextViewProtected.textAlignment;
|
513
|
+
// make sure a possible previously set text alignment setting is not lost when line height is specified
|
514
|
+
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
|
515
|
+
}
|
516
|
+
};
|
485
517
|
if (style.letterSpacing !== 0 && this.nativeTextViewProtected.font) {
|
486
518
|
const kern = style.letterSpacing * this.nativeTextViewProtected.font.pointSize;
|
487
519
|
dict.set(NSKernAttributeName, kern);
|
520
|
+
createParagraphStyle();
|
488
521
|
}
|
489
|
-
const isTextView = false;
|
522
|
+
// const isTextView = false;
|
490
523
|
if (style.lineHeight !== undefined) {
|
491
524
|
let lineHeight = style.lineHeight;
|
492
525
|
if (lineHeight === 0) {
|
493
526
|
lineHeight = 0.00001;
|
494
527
|
}
|
495
|
-
|
528
|
+
createParagraphStyle();
|
496
529
|
paragraphStyle.minimumLineHeight = lineHeight;
|
497
530
|
paragraphStyle.maximumLineHeight = lineHeight;
|
498
|
-
//
|
499
|
-
|
500
|
-
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
|
501
|
-
}
|
502
|
-
else if (isTextView) {
|
503
|
-
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
|
504
|
-
paragraphStyle.alignment = this.nativeTextViewProtected.textAlignment;
|
505
|
-
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
|
531
|
+
// } else if (isTextView) {
|
532
|
+
// createParagraphStyle();
|
506
533
|
}
|
507
534
|
const source = getTransformedText(isNullOrUndefined(this.text) ? '' : `${this.text}`, this.textTransform);
|
508
535
|
if (dict.size > 0) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-label",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.12",
|
4
4
|
"description": "Alternative to the built-in NativeScript Label but with better performance and additional features such as HTML rendering and more.",
|
5
5
|
"main": "./label",
|
6
6
|
"sideEffects": false,
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"license": "Apache-2.0",
|
33
33
|
"readmeFilename": "README.md",
|
34
34
|
"dependencies": {
|
35
|
-
"@nativescript-community/text": "^1.
|
35
|
+
"@nativescript-community/text": "^1.5.9"
|
36
36
|
},
|
37
|
-
"gitHead": "
|
37
|
+
"gitHead": "475f4a72bd7416c42596977a0a170183d057f6dd"
|
38
38
|
}
|