@atproto/api 0.6.17 → 0.6.18
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 +6 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +2 -2
- package/dist/rich-text/rich-text.d.ts +3 -0
- package/package.json +2 -2
- package/src/rich-text/detection.ts +27 -0
- package/src/rich-text/rich-text.ts +13 -0
- package/tests/rich-text-detection.test.ts +104 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atproto/api
|
|
2
2
|
|
|
3
|
+
## 0.6.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1651](https://github.com/bluesky-social/atproto/pull/1651) [`2ce8a11b`](https://github.com/bluesky-social/atproto/commit/2ce8a11b8daf5d39027488c5dde8c47b0eb937bf) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Adds support for hashtags in the `RichText.detectFacets` method.
|
|
8
|
+
|
|
3
9
|
## 0.6.17
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -27697,6 +27697,29 @@ function detectFacets(text) {
|
|
|
27697
27697
|
});
|
|
27698
27698
|
}
|
|
27699
27699
|
}
|
|
27700
|
+
{
|
|
27701
|
+
const re = /(?:^|\s)(#[^\d\s]\S*)(?=\s)?/g;
|
|
27702
|
+
while (match = re.exec(text.utf16)) {
|
|
27703
|
+
let [tag] = match;
|
|
27704
|
+
const hasLeadingSpace = /^\s/.test(tag);
|
|
27705
|
+
tag = tag.trim().replace(/\p{P}+$/gu, "");
|
|
27706
|
+
if (tag.length > 66)
|
|
27707
|
+
continue;
|
|
27708
|
+
const index = match.index + (hasLeadingSpace ? 1 : 0);
|
|
27709
|
+
facets.push({
|
|
27710
|
+
index: {
|
|
27711
|
+
byteStart: text.utf16IndexToUtf8Index(index),
|
|
27712
|
+
byteEnd: text.utf16IndexToUtf8Index(index + tag.length)
|
|
27713
|
+
},
|
|
27714
|
+
features: [
|
|
27715
|
+
{
|
|
27716
|
+
$type: "app.bsky.richtext.facet#tag",
|
|
27717
|
+
tag
|
|
27718
|
+
}
|
|
27719
|
+
]
|
|
27720
|
+
});
|
|
27721
|
+
}
|
|
27722
|
+
}
|
|
27700
27723
|
return facets.length > 0 ? facets : void 0;
|
|
27701
27724
|
}
|
|
27702
27725
|
function isValidDomain(str) {
|
|
@@ -27735,6 +27758,16 @@ var RichTextSegment = class {
|
|
|
27735
27758
|
isMention() {
|
|
27736
27759
|
return !!this.mention;
|
|
27737
27760
|
}
|
|
27761
|
+
get tag() {
|
|
27762
|
+
const tag = this.facet?.features.find(facet_exports.isTag);
|
|
27763
|
+
if (facet_exports.isTag(tag)) {
|
|
27764
|
+
return tag;
|
|
27765
|
+
}
|
|
27766
|
+
return void 0;
|
|
27767
|
+
}
|
|
27768
|
+
isTag() {
|
|
27769
|
+
return !!this.tag;
|
|
27770
|
+
}
|
|
27738
27771
|
};
|
|
27739
27772
|
var RichText = class {
|
|
27740
27773
|
constructor(props, opts) {
|