@meowdown/react 0.59.1 → 0.61.0

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 CHANGED
@@ -20,10 +20,8 @@ type EditorStateSnapshot = [markdown: string, selection: SelectionJSON$1];
20
20
  */
21
21
  interface EditorHandle {
22
22
  /**
23
- * Reconciles pending native input, then serializes the current document to
24
- * Markdown. If reconciliation changes the document, `onDocChange` runs
25
- * before this method returns. Can be expensive on large documents; call it
26
- * on demand (e.g. throttled) instead of on every change.
23
+ * Serializes the current document to Markdown. Can be expensive on large
24
+ * documents; call it on demand (e.g. throttled) instead of on every change.
27
25
  */
28
26
  getMarkdown: () => string;
29
27
  /** Replaces the whole document as a single undoable edit. */
@@ -38,10 +36,7 @@ interface EditorHandle {
38
36
  * `onDocChange`: the host cannot know the resulting document.
39
37
  */
40
38
  insertMarkdown: (markdown: string) => void;
41
- /**
42
- * Returns the current Markdown and selection, with the same pending-input
43
- * reconciliation (and possible synchronous `onDocChange`) as `getMarkdown`.
44
- */
39
+ /** Returns the current Markdown and selection. */
45
40
  getState: () => EditorStateSnapshot;
46
41
  /**
47
42
  * Replaces the document (if `markdown` is given) and restores `selection`:
package/dist/index.js CHANGED
@@ -1636,18 +1636,6 @@ function WikilinkMenu({ onWikilinkSearch }) {
1636
1636
 
1637
1637
  //#endregion
1638
1638
  //#region src/components/prosekit-editor.tsx
1639
- function isFlushableDOMObserver(value) {
1640
- if (typeof value !== "object" || value === null) return false;
1641
- const forceFlush = Reflect.get(value, "forceFlush");
1642
- return typeof Reflect.get(value, "flush") === "function" && (forceFlush === void 0 || typeof forceFlush === "function");
1643
- }
1644
- function flushPendingDOMChanges(editor) {
1645
- if (!editor.mounted) return;
1646
- const observer = Reflect.get(editor.view, "domObserver");
1647
- if (!isFlushableDOMObserver(observer)) return;
1648
- observer.forceFlush?.();
1649
- observer.flush();
1650
- }
1651
1639
  function resolveSelection(doc, selection) {
1652
1640
  if (selection === "start") return Selection.atStart(doc);
1653
1641
  if (selection === "end") return Selection.atEnd(doc);
@@ -1722,7 +1710,6 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
1722
1710
  }, []);
1723
1711
  useImperativeHandle(ref, () => {
1724
1712
  function getMarkdown() {
1725
- flushPendingDOMChanges(editor);
1726
1713
  return docToMarkdown(editor.state.doc, { frontmatter });
1727
1714
  }
1728
1715
  function getSelection() {
@@ -2176,7 +2163,8 @@ function WikilinkChip(props) {
2176
2163
  })]
2177
2164
  });
2178
2165
  }
2179
- function EmbedFrame({ embed }) {
2166
+ function EmbedFrame(props) {
2167
+ const { embed, width, height } = props;
2180
2168
  const iframeRef = useRef(null);
2181
2169
  useEffect(() => {
2182
2170
  if (embed.kind !== "tweet") return;
@@ -2184,6 +2172,8 @@ function EmbedFrame({ embed }) {
2184
2172
  if (!iframe) return;
2185
2173
  return listenForTweetHeight(iframe);
2186
2174
  }, [embed.kind, embed.key]);
2175
+ const youtubeWidth = embed.kind === "youtube" ? width : null;
2176
+ const tweetHeight = embed.kind === "tweet" ? height : null;
2187
2177
  return /* @__PURE__ */ jsx("span", {
2188
2178
  className: "md-image-view-preview md-atom-view-preview",
2189
2179
  contentEditable: false,
@@ -2197,14 +2187,20 @@ function EmbedFrame({ embed }) {
2197
2187
  referrerPolicy: "strict-origin-when-cross-origin",
2198
2188
  frameBorder: "0",
2199
2189
  allow: embed.allow,
2200
- allowFullScreen: embed.allowFullscreen
2190
+ allowFullScreen: embed.allowFullscreen,
2191
+ style: youtubeWidth != null ? { width: youtubeWidth } : tweetHeight != null ? { height: tweetHeight } : void 0,
2192
+ "data-sized": tweetHeight == null ? void 0 : ""
2201
2193
  }, embed.key)
2202
2194
  });
2203
2195
  }
2204
2196
  function ImagePreview(props) {
2205
- const { src, alt, width, resolveImageUrl, onImageClick, interactive } = props;
2197
+ const { src, alt, width, height, resolveImageUrl, onImageClick, interactive } = props;
2206
2198
  const embed = matchEmbed(src);
2207
- if (embed) return interactive ? /* @__PURE__ */ jsx(EmbedFrame, { embed }) : null;
2199
+ if (embed) return interactive ? /* @__PURE__ */ jsx(EmbedFrame, {
2200
+ embed,
2201
+ width,
2202
+ height
2203
+ }) : null;
2208
2204
  const url = (resolveImageUrl ?? defaultResolveImageUrl)(src);
2209
2205
  if (!url) return null;
2210
2206
  return /* @__PURE__ */ jsx("span", {
@@ -2225,13 +2221,14 @@ function ImagePreview(props) {
2225
2221
  });
2226
2222
  }
2227
2223
  function ImageView(props) {
2228
- const { src, alt, width, context, children } = props;
2224
+ const { src, alt, width, height, context, children } = props;
2229
2225
  return /* @__PURE__ */ jsxs("span", {
2230
2226
  className: "md-image-view md-atom-view",
2231
2227
  children: [/* @__PURE__ */ jsx(ImagePreview, {
2232
2228
  src,
2233
2229
  alt,
2234
2230
  width,
2231
+ height,
2235
2232
  resolveImageUrl: context.resolveImageUrl,
2236
2233
  onImageClick: context.onImageClick,
2237
2234
  interactive: context.interactive
@@ -2421,6 +2418,7 @@ function wrapMark(mark, children, context) {
2421
2418
  src: attrs.src,
2422
2419
  alt: attrs.alt,
2423
2420
  width: attrs.width,
2421
+ height: attrs.height,
2424
2422
  context,
2425
2423
  children
2426
2424
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/react",
3
3
  "type": "module",
4
- "version": "0.59.1",
4
+ "version": "0.61.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "github-slugger": "^2.0.0",
32
32
  "lucide-react": "^1.27.0",
33
33
  "react-property": "^2.0.2",
34
- "@meowdown/core": "0.59.1"
34
+ "@meowdown/core": "0.61.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^19.0.0",