@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/CHANGELOG.md +19 -0
- package/dist/index.css +16 -16
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +51 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
package/dist/index.mjs
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 = user?.avatarUrl;
|
|
@@ -747,8 +746,7 @@ var TumblrPostPreview = ({
|
|
|
747
746
|
/* @__PURE__ */ jsxs15("div", { className: "tumblr-preview__card", children: [
|
|
748
747
|
/* @__PURE__ */ jsx22(header_default, { user }),
|
|
749
748
|
/* @__PURE__ */ jsxs15("div", { className: "tumblr-preview__body", children: [
|
|
750
|
-
/* @__PURE__ */ jsx22("div", { className: "tumblr-preview__title", children: tumblrTitle(title) }),
|
|
751
|
-
customText && /* @__PURE__ */ jsx22("div", { className: "tumblr-preview__custom-text", children: customText }),
|
|
749
|
+
title ? /* @__PURE__ */ jsx22("div", { className: "tumblr-preview__title", children: tumblrTitle(title) }) : null,
|
|
752
750
|
description && /* @__PURE__ */ jsx22("div", { className: "tumblr-preview__description", children: preparePreviewText(tumblrDescription(description), {
|
|
753
751
|
platform: "tumblr"
|
|
754
752
|
}) }),
|
|
@@ -1167,6 +1165,10 @@ var MastodonPostActions = () => /* @__PURE__ */ jsxs24("div", { className: "mast
|
|
|
1167
1165
|
] });
|
|
1168
1166
|
var actions_default3 = MastodonPostActions;
|
|
1169
1167
|
|
|
1168
|
+
// src/mastodon-preview/post/card/index.tsx
|
|
1169
|
+
import { __ as __15 } from "@wordpress/i18n";
|
|
1170
|
+
import clsx3 from "clsx";
|
|
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
|
-
import { Fragment as Fragment3, jsx as jsx33, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
1201
|
-
var MastonPostBody = (props) => {
|
|
1202
|
-
const { title, description, customText, url, user, children } = props;
|
|
1203
|
-
const instance = user?.address ? getMastodonAddressDetails(user.address).instance : "";
|
|
1204
|
-
const options = {
|
|
1205
|
-
instance,
|
|
1206
|
-
offset: 0
|
|
1207
|
-
};
|
|
1208
|
-
let bodyTxt;
|
|
1209
|
-
if (customText) {
|
|
1210
|
-
bodyTxt = /* @__PURE__ */ jsx33("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__ */ jsxs25(Fragment3, { children: [
|
|
1216
|
-
/* @__PURE__ */ jsx33("p", { children: renderedTitle }),
|
|
1217
|
-
/* @__PURE__ */ jsx33("p", { children: mastodonBody(description, options) })
|
|
1218
|
-
] });
|
|
1219
|
-
} else {
|
|
1220
|
-
bodyTxt = /* @__PURE__ */ jsx33("p", { children: mastodonBody(description, options) });
|
|
1221
|
-
}
|
|
1222
|
-
} else {
|
|
1223
|
-
bodyTxt = /* @__PURE__ */ jsx33("p", { children: mastodonBody(title, options) });
|
|
1224
|
-
}
|
|
1225
|
-
return /* @__PURE__ */ jsxs25("div", { className: "mastodon-preview__body", children: [
|
|
1226
|
-
bodyTxt,
|
|
1227
|
-
/* @__PURE__ */ jsx33("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
|
-
import {
|
|
1235
|
-
import clsx3 from "clsx";
|
|
1236
|
-
import { jsx as jsx34, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
1202
|
+
import { jsx as jsx33, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
1237
1203
|
var MastodonPostCard = ({
|
|
1238
1204
|
siteName,
|
|
1239
1205
|
title,
|
|
@@ -1242,14 +1208,14 @@ var MastodonPostCard = ({
|
|
|
1242
1208
|
image,
|
|
1243
1209
|
customImage
|
|
1244
1210
|
}) => {
|
|
1245
|
-
return /* @__PURE__ */
|
|
1246
|
-
/* @__PURE__ */
|
|
1211
|
+
return /* @__PURE__ */ jsxs25("div", { className: clsx3("mastodon-preview__card", { "has-image": image }), children: [
|
|
1212
|
+
/* @__PURE__ */ jsx33("div", { className: "mastodon-preview__card-img", children: image || customImage ? /* @__PURE__ */ jsx33(
|
|
1247
1213
|
"img",
|
|
1248
1214
|
{
|
|
1249
1215
|
src: image || customImage,
|
|
1250
1216
|
alt: __15("Mastodon preview thumbnail", "social-previews")
|
|
1251
1217
|
}
|
|
1252
|
-
) : /* @__PURE__ */
|
|
1218
|
+
) : /* @__PURE__ */ jsx33("div", { className: "mastodon-preview__card-img--fallback", children: /* @__PURE__ */ jsx33(
|
|
1253
1219
|
"svg",
|
|
1254
1220
|
{
|
|
1255
1221
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1257,13 +1223,13 @@ var MastodonPostCard = ({
|
|
|
1257
1223
|
viewBox: "0 -960 960 960",
|
|
1258
1224
|
width: "24",
|
|
1259
1225
|
"aria-hidden": "true",
|
|
1260
|
-
children: /* @__PURE__ */
|
|
1226
|
+
children: /* @__PURE__ */ jsx33("path", { d: "M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520h200L520-800v200Z" })
|
|
1261
1227
|
}
|
|
1262
1228
|
) }) }),
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1229
|
+
/* @__PURE__ */ jsxs25("div", { className: "mastodon-preview__card-text", children: [
|
|
1230
|
+
/* @__PURE__ */ jsx33("span", { className: "mastodon-preview__card-site", children: siteName || baseDomain(url) }),
|
|
1231
|
+
/* @__PURE__ */ jsx33("span", { className: "mastodon-preview__card-title", children: mastodonTitle(title) || getTitleFromDescription(description) }),
|
|
1232
|
+
/* @__PURE__ */ jsx33("span", { className: "mastodon-preview__card-description", children: stripHtmlTags(description) })
|
|
1267
1233
|
] })
|
|
1268
1234
|
] });
|
|
1269
1235
|
};
|
|
@@ -1273,9 +1239,9 @@ var card_default = MastodonPostCard;
|
|
|
1273
1239
|
import { __ as __16 } from "@wordpress/i18n";
|
|
1274
1240
|
|
|
1275
1241
|
// src/mastodon-preview/post/icons/index.tsx
|
|
1276
|
-
import { jsx as
|
|
1242
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
1277
1243
|
function GlobeIcon() {
|
|
1278
|
-
return /* @__PURE__ */
|
|
1244
|
+
return /* @__PURE__ */ jsx34(
|
|
1279
1245
|
"svg",
|
|
1280
1246
|
{
|
|
1281
1247
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1283,26 +1249,26 @@ function GlobeIcon() {
|
|
|
1283
1249
|
viewBox: "0 -960 960 960",
|
|
1284
1250
|
width: "15",
|
|
1285
1251
|
role: "img",
|
|
1286
|
-
children: /* @__PURE__ */
|
|
1252
|
+
children: /* @__PURE__ */ jsx34("path", { d: "M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-40-82v-78q-33 0-56.5-23.5T360-320v-40L168-552q-3 18-5.5 36t-2.5 36q0 121 79.5 212T440-162Zm276-102q20-22 36-47.5t26.5-53q10.5-27.5 16-56.5t5.5-59q0-98-54.5-179T600-776v16q0 33-23.5 56.5T520-680h-80v80q0 17-11.5 28.5T400-560h-80v80h240q17 0 28.5 11.5T600-440v120h40q26 0 47 15.5t29 40.5Z" })
|
|
1287
1253
|
}
|
|
1288
1254
|
);
|
|
1289
1255
|
}
|
|
1290
1256
|
|
|
1291
1257
|
// src/mastodon-preview/post/header/index.tsx
|
|
1292
|
-
import { jsx as
|
|
1258
|
+
import { jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
1293
1259
|
var MastodonPostHeader = ({ user }) => {
|
|
1294
1260
|
const { displayName, address, avatarUrl } = user || {};
|
|
1295
|
-
return /* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
1297
|
-
/* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */
|
|
1261
|
+
return /* @__PURE__ */ jsxs26("div", { className: "mastodon-preview__post-header", children: [
|
|
1262
|
+
/* @__PURE__ */ jsxs26("div", { className: "mastodon-preview__post-header-user", children: [
|
|
1263
|
+
/* @__PURE__ */ jsx35(AvatarWithFallback, { className: "mastodon-preview__post-avatar", src: avatarUrl }),
|
|
1264
|
+
/* @__PURE__ */ jsxs26("div", { children: [
|
|
1265
|
+
/* @__PURE__ */ jsx35("div", { className: "mastodon-preview__post-header-displayname", children: displayName || // translators: username of a fictional Mastodon User
|
|
1300
1266
|
__16("anonymous-user", "social-previews") }),
|
|
1301
|
-
/* @__PURE__ */
|
|
1267
|
+
/* @__PURE__ */ jsx35("div", { className: "mastodon-preview__post-header-username", children: address?.replace(`@${DEFAULT_MASTODON_INSTANCE}`, "") || "@username" })
|
|
1302
1268
|
] })
|
|
1303
1269
|
] }),
|
|
1304
|
-
/* @__PURE__ */
|
|
1305
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ jsxs26("div", { className: "mastodon-preview__post-header-audience", children: [
|
|
1271
|
+
/* @__PURE__ */ jsx35(GlobeIcon, {}),
|
|
1306
1272
|
formatMastodonDate(/* @__PURE__ */ new Date())
|
|
1307
1273
|
] })
|
|
1308
1274
|
] });
|
|
@@ -1310,19 +1276,54 @@ var MastodonPostHeader = ({ user }) => {
|
|
|
1310
1276
|
var header_default3 = MastodonPostHeader;
|
|
1311
1277
|
|
|
1312
1278
|
// src/mastodon-preview/link-preview.tsx
|
|
1313
|
-
import { jsx as
|
|
1279
|
+
import { jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
1314
1280
|
var MastodonLinkPreview = (props) => {
|
|
1315
1281
|
const { user } = props;
|
|
1316
|
-
return /* @__PURE__ */
|
|
1317
|
-
/* @__PURE__ */
|
|
1318
|
-
/* @__PURE__ */
|
|
1319
|
-
/* @__PURE__ */
|
|
1320
|
-
/* @__PURE__ */ jsx37(actions_default3, {})
|
|
1282
|
+
return /* @__PURE__ */ jsxs27("div", { className: "mastodon-preview__post", children: [
|
|
1283
|
+
/* @__PURE__ */ jsx36(header_default3, { user }),
|
|
1284
|
+
/* @__PURE__ */ jsx36(card_default, { ...props, customImage: "" }),
|
|
1285
|
+
/* @__PURE__ */ jsx36(actions_default3, {})
|
|
1321
1286
|
] });
|
|
1322
1287
|
};
|
|
1323
1288
|
|
|
1324
1289
|
// src/mastodon-preview/post-preview.tsx
|
|
1325
1290
|
import clsx4 from "clsx";
|
|
1291
|
+
|
|
1292
|
+
// src/mastodon-preview/post/body/index.tsx
|
|
1293
|
+
import { Fragment as Fragment3, jsx as jsx37, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
1294
|
+
var MastonPostBody = (props) => {
|
|
1295
|
+
const { title, description, customText, url, user, children } = props;
|
|
1296
|
+
const instance = user?.address ? getMastodonAddressDetails(user.address).instance : "";
|
|
1297
|
+
const options = {
|
|
1298
|
+
instance,
|
|
1299
|
+
offset: 0
|
|
1300
|
+
};
|
|
1301
|
+
let bodyTxt;
|
|
1302
|
+
if (customText) {
|
|
1303
|
+
bodyTxt = /* @__PURE__ */ jsx37("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__ */ jsxs28(Fragment3, { children: [
|
|
1309
|
+
/* @__PURE__ */ jsx37("p", { children: renderedTitle }),
|
|
1310
|
+
/* @__PURE__ */ jsx37("p", { children: mastodonBody(description, options) })
|
|
1311
|
+
] });
|
|
1312
|
+
} else {
|
|
1313
|
+
bodyTxt = /* @__PURE__ */ jsx37("p", { children: mastodonBody(description, options) });
|
|
1314
|
+
}
|
|
1315
|
+
} else {
|
|
1316
|
+
bodyTxt = /* @__PURE__ */ jsx37("p", { children: mastodonBody(title, options) });
|
|
1317
|
+
}
|
|
1318
|
+
return /* @__PURE__ */ jsxs28("div", { className: "mastodon-preview__body", children: [
|
|
1319
|
+
bodyTxt,
|
|
1320
|
+
/* @__PURE__ */ jsx37("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
|
|
1326
1327
|
import { jsx as jsx38, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
1327
1328
|
var MastodonPostPreview = (props) => {
|
|
1328
1329
|
const { user, media } = props;
|
|
@@ -1852,6 +1853,9 @@ var BlueskyPreviews = ({
|
|
|
1852
1853
|
] });
|
|
1853
1854
|
};
|
|
1854
1855
|
|
|
1856
|
+
// src/threads-preview/link-preview.tsx
|
|
1857
|
+
import { __ as __25 } from "@wordpress/i18n";
|
|
1858
|
+
|
|
1855
1859
|
// src/threads-preview/card.tsx
|
|
1856
1860
|
import clsx7 from "clsx";
|
|
1857
1861
|
|
|
@@ -2014,6 +2018,12 @@ var ThreadsPostPreview = ({
|
|
|
2014
2018
|
// src/threads-preview/link-preview.tsx
|
|
2015
2019
|
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
2016
2020
|
var ThreadsLinkPreview = (props) => {
|
|
2021
|
+
if (!props.image) {
|
|
2022
|
+
return /* @__PURE__ */ jsx64("p", { className: "social-preview__section-desc", children: __25(
|
|
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__ */ jsx64(
|
|
2018
2028
|
ThreadsPostPreview,
|
|
2019
2029
|
{
|
|
@@ -2025,7 +2035,7 @@ var ThreadsLinkPreview = (props) => {
|
|
|
2025
2035
|
};
|
|
2026
2036
|
|
|
2027
2037
|
// src/threads-preview/previews.tsx
|
|
2028
|
-
import { __ as
|
|
2038
|
+
import { __ as __26 } from "@wordpress/i18n";
|
|
2029
2039
|
import { Fragment as Fragment7, jsx as jsx65, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
2030
2040
|
var ThreadsPreviews = ({
|
|
2031
2041
|
headingLevel,
|
|
@@ -2041,9 +2051,9 @@ var ThreadsPreviews = ({
|
|
|
2041
2051
|
/* @__PURE__ */ jsx65(section_heading_default, {
|
|
2042
2052
|
level: headingLevel,
|
|
2043
2053
|
// translators: refers to a social post on Threads
|
|
2044
|
-
children:
|
|
2054
|
+
children: __26("Your post", "social-previews")
|
|
2045
2055
|
}),
|
|
2046
|
-
/* @__PURE__ */ jsx65("p", { className: "social-preview__section-desc", children:
|
|
2056
|
+
/* @__PURE__ */ jsx65("p", { className: "social-preview__section-desc", children: __26("This is what your social post will look like on Threads:", "social-previews") }),
|
|
2047
2057
|
posts.map((post, index) => {
|
|
2048
2058
|
const isLast = index + 1 === posts.length;
|
|
2049
2059
|
return /* @__PURE__ */ jsx65(
|
|
@@ -2060,15 +2070,15 @@ var ThreadsPreviews = ({
|
|
|
2060
2070
|
/* @__PURE__ */ jsx65(section_heading_default, {
|
|
2061
2071
|
level: headingLevel,
|
|
2062
2072
|
// translators: refers to a link to a Threads post
|
|
2063
|
-
children:
|
|
2073
|
+
children: __26("Link preview", "social-previews")
|
|
2064
2074
|
}),
|
|
2065
2075
|
posts[0].image ? /* @__PURE__ */ jsxs46(Fragment7, { children: [
|
|
2066
|
-
/* @__PURE__ */ jsx65("p", { className: "social-preview__section-desc", children:
|
|
2076
|
+
/* @__PURE__ */ jsx65("p", { className: "social-preview__section-desc", children: __26(
|
|
2067
2077
|
"This is what it will look like when someone shares the link to your WordPress post on Threads.",
|
|
2068
2078
|
"social-previews"
|
|
2069
2079
|
) }),
|
|
2070
2080
|
/* @__PURE__ */ jsx65(ThreadsLinkPreview, { ...posts[0], name: "", profileImage: "" })
|
|
2071
|
-
] }) : /* @__PURE__ */ jsx65("p", { className: "social-preview__section-desc", children:
|
|
2081
|
+
] }) : /* @__PURE__ */ jsx65("p", { className: "social-preview__section-desc", children: __26(
|
|
2072
2082
|
"Threads link preview requires an image to be set for the post. Please add an image to see the preview.",
|
|
2073
2083
|
"social-previews"
|
|
2074
2084
|
) })
|
|
@@ -2077,7 +2087,7 @@ var ThreadsPreviews = ({
|
|
|
2077
2087
|
};
|
|
2078
2088
|
|
|
2079
2089
|
// src/instagram-preview/post-preview.tsx
|
|
2080
|
-
import { __ as
|
|
2090
|
+
import { __ as __27 } from "@wordpress/i18n";
|
|
2081
2091
|
|
|
2082
2092
|
// src/instagram-preview/constants.tsx
|
|
2083
2093
|
var FEED_TEXT_MAX_LENGTH3 = 520;
|
|
@@ -2272,13 +2282,13 @@ function InstagramPostPreview({
|
|
|
2272
2282
|
] })
|
|
2273
2283
|
] }) : null
|
|
2274
2284
|
] }),
|
|
2275
|
-
/* @__PURE__ */ jsx71("div", { className: "instagram-preview__content--footer", children: /* @__PURE__ */ jsx71("span", { children:
|
|
2285
|
+
/* @__PURE__ */ jsx71("div", { className: "instagram-preview__content--footer", children: /* @__PURE__ */ jsx71("span", { children: __27("View one comment", "social-previews") }) })
|
|
2276
2286
|
] })
|
|
2277
2287
|
] }) });
|
|
2278
2288
|
}
|
|
2279
2289
|
|
|
2280
2290
|
// src/instagram-preview/previews.tsx
|
|
2281
|
-
import { __ as
|
|
2291
|
+
import { __ as __28 } from "@wordpress/i18n";
|
|
2282
2292
|
import { jsx as jsx72, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
2283
2293
|
var InstagramPreviews = ({
|
|
2284
2294
|
headingLevel,
|
|
@@ -2289,9 +2299,9 @@ var InstagramPreviews = ({
|
|
|
2289
2299
|
/* @__PURE__ */ jsx72(section_heading_default, {
|
|
2290
2300
|
level: headingLevel,
|
|
2291
2301
|
// translators: refers to a social post on Instagram
|
|
2292
|
-
children:
|
|
2302
|
+
children: __28("Your post", "social-previews")
|
|
2293
2303
|
}),
|
|
2294
|
-
/* @__PURE__ */ jsx72("p", { className: "social-preview__section-desc", children:
|
|
2304
|
+
/* @__PURE__ */ jsx72("p", { className: "social-preview__section-desc", children: __28(
|
|
2295
2305
|
"This is what your social post will look like on Instagram:",
|
|
2296
2306
|
"social-previews"
|
|
2297
2307
|
) }),
|