@automattic/social-previews 3.0.6 → 3.0.8

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/dist/index.js CHANGED
@@ -737,7 +737,6 @@ var TumblrPostPreview = ({
737
737
  image,
738
738
  user,
739
739
  url,
740
- customText,
741
740
  media
742
741
  }) => {
743
742
  const avatarUrl = _optionalChain([user, 'optionalAccess', _9 => _9.avatarUrl]);
@@ -747,8 +746,7 @@ var TumblrPostPreview = ({
747
746
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tumblr-preview__card", children: [
748
747
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, header_default, { user }),
749
748
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tumblr-preview__body", children: [
750
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tumblr-preview__title", children: tumblrTitle(title) }),
751
- customText && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tumblr-preview__custom-text", children: customText }),
749
+ title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tumblr-preview__title", children: tumblrTitle(title) }) : null,
752
750
  description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tumblr-preview__description", children: preparePreviewText(tumblrDescription(description), {
753
751
  platform: "tumblr"
754
752
  }) }),
@@ -1167,6 +1165,10 @@ var MastodonPostActions = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "d
1167
1165
  ] });
1168
1166
  var actions_default3 = MastodonPostActions;
1169
1167
 
1168
+ // src/mastodon-preview/post/card/index.tsx
1169
+
1170
+
1171
+
1170
1172
  // src/mastodon-preview/constants.ts
1171
1173
  var DEFAULT_MASTODON_INSTANCE = "mastodon.social";
1172
1174
 
@@ -1196,44 +1198,8 @@ var getMastodonAddressDetails = (address) => {
1196
1198
  };
1197
1199
  };
1198
1200
 
1199
- // src/mastodon-preview/post/body/index.tsx
1200
-
1201
- var MastonPostBody = (props) => {
1202
- const { title, description, customText, url, user, children } = props;
1203
- const instance = _optionalChain([user, 'optionalAccess', _19 => _19.address]) ? getMastodonAddressDetails(user.address).instance : "";
1204
- const options = {
1205
- instance,
1206
- offset: 0
1207
- };
1208
- let bodyTxt;
1209
- if (customText) {
1210
- bodyTxt = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(customText, options) });
1211
- } else if (description) {
1212
- if (title) {
1213
- const renderedTitle = stripHtmlTags(title);
1214
- options.offset = renderedTitle.length;
1215
- bodyTxt = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1216
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: renderedTitle }),
1217
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(description, options) })
1218
- ] });
1219
- } else {
1220
- bodyTxt = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(description, options) });
1221
- }
1222
- } else {
1223
- bodyTxt = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(title, options) });
1224
- }
1225
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mastodon-preview__body", children: [
1226
- bodyTxt,
1227
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: url, target: "_blank", rel: "noreferrer noopener", children: mastodonUrl(url.replace(/^https?:\/\//, "")) }),
1228
- children
1229
- ] });
1230
- };
1231
- var body_default = MastonPostBody;
1232
-
1233
1201
  // src/mastodon-preview/post/card/index.tsx
1234
1202
 
1235
-
1236
-
1237
1203
  var MastodonPostCard = ({
1238
1204
  siteName,
1239
1205
  title,
@@ -1298,7 +1264,7 @@ var MastodonPostHeader = ({ user }) => {
1298
1264
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
1299
1265
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mastodon-preview__post-header-displayname", children: displayName || // translators: username of a fictional Mastodon User
1300
1266
  _i18n.__.call(void 0, "anonymous-user", "social-previews") }),
1301
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mastodon-preview__post-header-username", children: _optionalChain([address, 'optionalAccess', _20 => _20.replace, 'call', _21 => _21(`@${DEFAULT_MASTODON_INSTANCE}`, "")]) || "@username" })
1267
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mastodon-preview__post-header-username", children: _optionalChain([address, 'optionalAccess', _19 => _19.replace, 'call', _20 => _20(`@${DEFAULT_MASTODON_INSTANCE}`, "")]) || "@username" })
1302
1268
  ] })
1303
1269
  ] }),
1304
1270
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mastodon-preview__post-header-audience", children: [
@@ -1315,7 +1281,6 @@ var MastodonLinkPreview = (props) => {
1315
1281
  const { user } = props;
1316
1282
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mastodon-preview__post", children: [
1317
1283
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, header_default3, { user }),
1318
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, body_default, { ...props }),
1319
1284
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, card_default, { ...props, customImage: "" }),
1320
1285
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actions_default3, {})
1321
1286
  ] });
@@ -1324,6 +1289,42 @@ var MastodonLinkPreview = (props) => {
1324
1289
  // src/mastodon-preview/post-preview.tsx
1325
1290
 
1326
1291
 
1292
+ // src/mastodon-preview/post/body/index.tsx
1293
+
1294
+ var MastonPostBody = (props) => {
1295
+ const { title, description, customText, url, user, children } = props;
1296
+ const instance = _optionalChain([user, 'optionalAccess', _21 => _21.address]) ? getMastodonAddressDetails(user.address).instance : "";
1297
+ const options = {
1298
+ instance,
1299
+ offset: 0
1300
+ };
1301
+ let bodyTxt;
1302
+ if (customText) {
1303
+ bodyTxt = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(customText, options) });
1304
+ } else if (description) {
1305
+ if (title) {
1306
+ const renderedTitle = stripHtmlTags(title);
1307
+ options.offset = renderedTitle.length;
1308
+ bodyTxt = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1309
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: renderedTitle }),
1310
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(description, options) })
1311
+ ] });
1312
+ } else {
1313
+ bodyTxt = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(description, options) });
1314
+ }
1315
+ } else {
1316
+ bodyTxt = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: mastodonBody(title, options) });
1317
+ }
1318
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mastodon-preview__body", children: [
1319
+ bodyTxt,
1320
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: url, target: "_blank", rel: "noreferrer noopener", children: mastodonUrl(url.replace(/^https?:\/\//, "")) }),
1321
+ children
1322
+ ] });
1323
+ };
1324
+ var body_default = MastonPostBody;
1325
+
1326
+ // src/mastodon-preview/post-preview.tsx
1327
+
1327
1328
  var MastodonPostPreview = (props) => {
1328
1329
  const { user, media } = props;
1329
1330
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mastodon-preview__post", children: [
@@ -1852,6 +1853,9 @@ var BlueskyPreviews = ({
1852
1853
  ] });
1853
1854
  };
1854
1855
 
1856
+ // src/threads-preview/link-preview.tsx
1857
+
1858
+
1855
1859
  // src/threads-preview/card.tsx
1856
1860
 
1857
1861
 
@@ -2014,6 +2018,12 @@ var ThreadsPostPreview = ({
2014
2018
  // src/threads-preview/link-preview.tsx
2015
2019
 
2016
2020
  var ThreadsLinkPreview = (props) => {
2021
+ if (!props.image) {
2022
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "social-preview__section-desc", children: _i18n.__.call(void 0,
2023
+ "Threads link preview requires an image to be set for the post. Please add an image to see the preview.",
2024
+ "social-previews"
2025
+ ) });
2026
+ }
2017
2027
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2018
2028
  ThreadsPostPreview,
2019
2029
  {