@ampless/plugin-x-embed 1.0.0-alpha.8 → 1.0.0-beta.14
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.
|
@@ -22,7 +22,7 @@ function hasTweetIn(post) {
|
|
|
22
22
|
}
|
|
23
23
|
if (post.format === "html") {
|
|
24
24
|
if (typeof post.body !== "string") return false;
|
|
25
|
-
return post.body.includes("twitter-tweet");
|
|
25
|
+
return post.body.includes("twitter-tweet") || post.body.toLowerCase().includes("data-ampless-tweet");
|
|
26
26
|
}
|
|
27
27
|
return false;
|
|
28
28
|
}
|
package/dist/editor.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
TWEET_URL,
|
|
4
4
|
parseTweetUrl
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZB3Q7IQG.js";
|
|
6
6
|
|
|
7
7
|
// src/editor.tsx
|
|
8
8
|
import { Node, mergeAttributes } from "@tiptap/core";
|
|
@@ -175,7 +175,8 @@ var tiptapNodeToHtml = {
|
|
|
175
175
|
const tweetId = String(node.attrs?.tweetId ?? "").trim();
|
|
176
176
|
if (!tweetId) return null;
|
|
177
177
|
const attrs = placeholderAttrs(node.attrs ?? {});
|
|
178
|
-
|
|
178
|
+
const url = `https://x.com/i/status/${tweetId}`;
|
|
179
|
+
return `<div ${attrsToHtmlString(attrs)}><a href="${escapeAttr(url)}">${escapeAttr(url)}</a></div>`;
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
export {
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TweetEmbed,
|
|
4
4
|
hasTweetIn,
|
|
5
5
|
parseTweetUrl
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZB3Q7IQG.js";
|
|
7
7
|
|
|
8
8
|
// src/index.tsx
|
|
9
9
|
import { definePlugin } from "ampless";
|
|
@@ -23,6 +23,18 @@ function xEmbedPlugin(opts = {}) {
|
|
|
23
23
|
render: (node) => {
|
|
24
24
|
const tweetId = String(node.attrs?.tweetId ?? "");
|
|
25
25
|
return /* @__PURE__ */ jsx(TweetEmbed, { tweetId });
|
|
26
|
+
},
|
|
27
|
+
// Opt into the public html walker so `format: 'html'` posts expand
|
|
28
|
+
// the canonical placeholder div (emitted by the admin's tiptap→html
|
|
29
|
+
// switch) into the same `<TweetEmbed>` the tiptap / markdown walkers
|
|
30
|
+
// render. Attribute names match `placeholderAttrs()` in ./editor.tsx
|
|
31
|
+
// (the canonical definition site). The page-level widgets.js is
|
|
32
|
+
// injected via `publicPostScript` + the `hasTweetIn` html branch.
|
|
33
|
+
htmlPlaceholder: {
|
|
34
|
+
flagAttr: "data-ampless-tweet",
|
|
35
|
+
attrsFromElement: (attribs) => ({
|
|
36
|
+
tweetId: attribs["data-tweet-id"] ?? ""
|
|
37
|
+
})
|
|
26
38
|
}
|
|
27
39
|
},
|
|
28
40
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/plugin-x-embed",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
4
4
|
"description": "x.com (Twitter) embed plugin for ampless — renders tweet URLs inline as blockquotes hydrated by widgets.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@tiptap/core": "^3",
|
|
34
34
|
"react": "^18 || ^19",
|
|
35
|
-
"ampless": "1.0.0-
|
|
35
|
+
"ampless": "^1.0.0-beta.51"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tiptap/core": "^3.23.6",
|