@pie-lib/editable-html-tip-tap 1.2.0-next.31 → 1.2.0-next.33

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.
@@ -100,7 +100,7 @@ describe('MediaNodeView Component', () => {
100
100
  updateAttributes={mockUpdateAttributes}
101
101
  deleteNode={mockDeleteNode}
102
102
  options={{}}
103
- />
103
+ />,
104
104
  );
105
105
 
106
106
  // Verify the component rendered successfully
@@ -130,7 +130,7 @@ describe('MediaNodeView Component', () => {
130
130
  updateAttributes={mockUpdateAttributes}
131
131
  deleteNode={mockDeleteNode}
132
132
  options={{}}
133
- />
133
+ />,
134
134
  );
135
135
 
136
136
  // Verify the component rendered successfully
@@ -159,7 +159,7 @@ describe('MediaNodeView Component', () => {
159
159
  updateAttributes={mockUpdateAttributes}
160
160
  deleteNode={mockDeleteNode}
161
161
  options={{}}
162
- />
162
+ />,
163
163
  );
164
164
 
165
165
  // Empty string is falsy, so dialog WOULD open with current implementation
@@ -185,7 +185,7 @@ describe('MediaNodeView Component', () => {
185
185
  updateAttributes={mockUpdateAttributes}
186
186
  deleteNode={mockDeleteNode}
187
187
  options={{}}
188
- />
188
+ />,
189
189
  );
190
190
 
191
191
  expect(getByTestId('edit-button')).toBeTruthy();
@@ -210,7 +210,7 @@ describe('MediaNodeView Component', () => {
210
210
  updateAttributes={mockUpdateAttributes}
211
211
  deleteNode={mockDeleteNode}
212
212
  options={{}}
213
- />
213
+ />,
214
214
  );
215
215
 
216
216
  const audio = container.querySelector('audio');
@@ -237,12 +237,14 @@ describe('MediaNodeView Component', () => {
237
237
  updateAttributes={mockUpdateAttributes}
238
238
  deleteNode={mockDeleteNode}
239
239
  options={{}}
240
- />
240
+ />,
241
241
  );
242
242
 
243
243
  const iframe = container.querySelector('iframe');
244
244
  expect(iframe).toBeTruthy();
245
245
  expect(iframe.getAttribute('src')).toBe('https://www.youtube.com/embed/dQw4w9WgXcQ');
246
+ expect(iframe.getAttribute('width')).toBe('640');
247
+ expect(iframe.getAttribute('height')).toBe('480');
246
248
  });
247
249
 
248
250
  it('should render MediaToolbar', () => {
@@ -261,7 +263,7 @@ describe('MediaNodeView Component', () => {
261
263
  updateAttributes={mockUpdateAttributes}
262
264
  deleteNode={mockDeleteNode}
263
265
  options={{}}
264
- />
266
+ />,
265
267
  );
266
268
 
267
269
  expect(getByTestId('media-toolbar')).toBeTruthy();
@@ -285,7 +287,7 @@ describe('MediaNodeView Component', () => {
285
287
  updateAttributes={mockUpdateAttributes}
286
288
  deleteNode={mockDeleteNode}
287
289
  options={{}}
288
- />
290
+ />,
289
291
  );
290
292
 
291
293
  fireEvent.click(getByTestId('remove-button'));
@@ -74,15 +74,14 @@ function ImageComponent(props) {
74
74
  editor,
75
75
  attributes,
76
76
  onFocus,
77
+ getPos,
77
78
  selected,
78
79
  options,
79
80
  maxImageWidth = 700,
80
81
  maxImageHeight = 900,
81
- latex,
82
- handleChange,
83
- handleDone,
84
82
  } = props;
85
83
  const { alt } = node.attrs;
84
+ const pos = getPos();
86
85
 
87
86
  const [showToolbar, setShowToolbar] = useState(false);
88
87
 
@@ -111,8 +110,8 @@ function ImageComponent(props) {
111
110
 
112
111
  // keep ref in sync with latest node
113
112
  useEffect(() => {
114
- latestNodeRef.current = node;
115
- }, [node]);
113
+ latestNodeRef.current = { ...node, pos };
114
+ }, [node, pos]);
116
115
 
117
116
  useEffect(() => {
118
117
  const { selection } = editor.state;
@@ -120,21 +119,26 @@ function ImageComponent(props) {
120
119
 
121
120
  if (selected) {
122
121
  if (onlyThisNodeSelected) {
122
+ // Only open the upload UI for a fresh placeholder. Remounting after tab switch
123
+ // would otherwise call insertImageRequested again and reopen the file modal.
124
+ const hasImageSrc = String(node.attrs?.src ?? '').trim();
125
+
126
+ if (!hasImageSrc && options.imageHandling?.insertImageRequested) {
127
+ options.imageHandling.insertImageRequested(
128
+ editor,
129
+ [node, pos],
130
+ (finish) => new InsertImageHandler(editor, [node, pos], finish),
131
+ );
132
+ }
133
+
123
134
  setShowToolbar(selected);
124
135
  }
125
136
  } else {
126
137
  setShowToolbar(selected);
127
138
  }
128
- }, [editor, node, selected]);
139
+ }, [editor, node, pos, selected]);
129
140
 
130
141
  useEffect(() => {
131
- // Only open the upload UI for a fresh placeholder. Remounting after tab switch
132
- // would otherwise call insertImageRequested again and reopen the file modal.
133
- const hasImageSrc = String(node.attrs?.src ?? '').trim();
134
- if (!hasImageSrc && options.imageHandling?.insertImageRequested) {
135
- options.imageHandling.insertImageRequested(node, (finish) => new InsertImageHandler(editor, node, finish));
136
- }
137
-
138
142
  applySizeData();
139
143
 
140
144
  const resizeHandle = resizeRef.current;
@@ -302,7 +306,7 @@ function ImageComponent(props) {
302
306
  }}
303
307
  onDone={() => {
304
308
  setShowToolbar(false);
305
- options.imageHandling?.onDone?.();
309
+ options.imageHandling?.onDone?.(editor);
306
310
  editor.commands.focus('end');
307
311
  }}
308
312
  >
@@ -179,7 +179,7 @@ export default function MediaNodeView({ editor, node, updateAttributes, deleteNo
179
179
  <source type="audio/mp3" src={src} />
180
180
  </audio>
181
181
  ) : (
182
- <iframe src={src} allowFullScreen frameBorder="0" />
182
+ <iframe src={src} allowFullScreen frameBorder="0" width={width} height={height} />
183
183
  )}
184
184
 
185
185
  <MediaToolbar onEdit={handleEdit} onRemove={deleteNode} />