@nativescript-community/ui-label 1.2.11 → 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 CHANGED
@@ -3,6 +3,14 @@
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
+
6
14
  ## [1.2.11](https://github.com/nativescript-community/ui-label/compare/v1.2.10...v1.2.11) (2022-09-09)
7
15
 
8
16
  **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
- textViewShouldInteractWithURLInRangeInteraction?(textView: UITextView, URL: NSURL, characterRange: NSRange, interaction: UITextItemInteraction): boolean;
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
- // _htmlTappable = false;
284
- // _htmlTapGestureRecognizer;
285
- textViewShouldInteractWithURLInRangeInteraction(textView, URL, characterRange, interaction) {
286
- this.notify({ eventName: 'linkTap', object: this, link: URL.toString() });
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-label",
3
- "version": "1.2.11",
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.4.36"
35
+ "@nativescript-community/text": "^1.5.9"
36
36
  },
37
- "gitHead": "86f278fd95f98489d04c7050672f73e101863277"
37
+ "gitHead": "475f4a72bd7416c42596977a0a170183d057f6dd"
38
38
  }