@ampless/runtime 1.0.0-alpha.55 → 1.0.0-alpha.56
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.d.ts +11 -2
- package/dist/index.js +9 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Post, MediaMetadata, AmplessPlugin, ContentFieldRenderer, PluginPublicRenderContext, TiptapNodeMarkdownAdapters, Config, ThemeModule, ThemeManifest, PluginPackageManifest } from 'ampless';
|
|
1
|
+
import { Post, MediaMetadata, AmplessPlugin, ContentFieldRenderer, PluginPublicRenderContext, TiptapNodeHtmlAdapters, TiptapNodeMarkdownAdapters, Config, ThemeModule, ThemeManifest, PluginPackageManifest } from 'ampless';
|
|
2
2
|
export { Config, Post, ThemeManifest } from 'ampless';
|
|
3
3
|
import { Metadata } from 'next';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
@@ -210,8 +210,17 @@ declare function renderBodyHtmlString(post: Post): string;
|
|
|
210
210
|
* markdown without editing) can still hand us a raw HTML string
|
|
211
211
|
* here. In that case, return it as-is rather than walking it as a
|
|
212
212
|
* malformed tiptap node and producing empty output.
|
|
213
|
+
*
|
|
214
|
+
* `opts.nodeAdapters` lets callers supply per-nodeType serialisers —
|
|
215
|
+
* the admin post-form passes the registry populated by
|
|
216
|
+
* `installAdminTiptapNodeHtml` so that plugin-registered embed nodes
|
|
217
|
+
* (e.g. `amplessYoutube`) are serialised to placeholder div strings
|
|
218
|
+
* instead of falling through with empty children. Callers that omit
|
|
219
|
+
* `opts` get the original behaviour unchanged.
|
|
213
220
|
*/
|
|
214
|
-
declare function tiptapToHtml(doc: unknown
|
|
221
|
+
declare function tiptapToHtml(doc: unknown, opts?: {
|
|
222
|
+
nodeAdapters?: TiptapNodeHtmlAdapters;
|
|
223
|
+
}): string;
|
|
215
224
|
/** Convert markdown to HTML using marked + GFM. */
|
|
216
225
|
declare function markdownToHtml(md: string): string;
|
|
217
226
|
/**
|
package/dist/index.js
CHANGED
|
@@ -264,7 +264,12 @@ function textAlignStyle(attrs) {
|
|
|
264
264
|
}
|
|
265
265
|
return "";
|
|
266
266
|
}
|
|
267
|
-
function renderTiptapString(node) {
|
|
267
|
+
function renderTiptapString(node, opts) {
|
|
268
|
+
const adapter = opts?.nodeAdapters?.[node.type];
|
|
269
|
+
if (adapter) {
|
|
270
|
+
const out = adapter(node);
|
|
271
|
+
if (typeof out === "string") return out;
|
|
272
|
+
}
|
|
268
273
|
if (node.type === "text") {
|
|
269
274
|
let html = escape(node.text ?? "");
|
|
270
275
|
for (const mark of node.marks ?? []) {
|
|
@@ -281,7 +286,7 @@ function renderTiptapString(node) {
|
|
|
281
286
|
}
|
|
282
287
|
return html;
|
|
283
288
|
}
|
|
284
|
-
const children = (node.content ?? []).map(renderTiptapString).join("");
|
|
289
|
+
const children = (node.content ?? []).map((c) => renderTiptapString(c, opts)).join("");
|
|
285
290
|
switch (node.type) {
|
|
286
291
|
case "doc":
|
|
287
292
|
return children;
|
|
@@ -599,9 +604,9 @@ function renderBodyHtmlString(post) {
|
|
|
599
604
|
}
|
|
600
605
|
return "";
|
|
601
606
|
}
|
|
602
|
-
function tiptapToHtml(doc) {
|
|
607
|
+
function tiptapToHtml(doc, opts) {
|
|
603
608
|
if (typeof doc === "string") return doc;
|
|
604
|
-
return renderTiptapString(doc);
|
|
609
|
+
return renderTiptapString(doc, opts);
|
|
605
610
|
}
|
|
606
611
|
function markdownToHtml(md) {
|
|
607
612
|
return renderMarkdownString(md);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/runtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.56",
|
|
4
4
|
"description": "Public-side runtime for ampless: post fetching, theme dispatch, middleware, public route handlers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"marked": "^18.0.4",
|
|
51
51
|
"sanitize-html": "^2.17.4",
|
|
52
52
|
"tailwind-merge": "^3.6.0",
|
|
53
|
-
"@ampless/plugin-og-image": "0.2.0-alpha.
|
|
54
|
-
"ampless": "1.0.0-alpha.
|
|
53
|
+
"@ampless/plugin-og-image": "0.2.0-alpha.47",
|
|
54
|
+
"ampless": "1.0.0-alpha.47"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@aws-amplify/adapter-nextjs": "^1",
|