@expensify/react-native-live-markdown 0.1.171 → 0.1.173

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.
@@ -61,6 +61,7 @@ type MarkdownTextInputElement = HTMLDivElement &
61
61
  HTMLInputElement & {
62
62
  tree: TreeNode;
63
63
  selection: Selection;
64
+ imageElements: HTMLImageElement[];
64
65
  };
65
66
 
66
67
  type HTMLMarkdownElement = HTMLElement & {
@@ -75,11 +75,17 @@ function handleOnLoad(
75
75
  justifyContent: 'center',
76
76
  }),
77
77
  });
78
-
79
78
  Object.assign(img.style, !err && imgStyle);
80
79
 
81
80
  targetElement.appendChild(imageContainer);
82
81
 
82
+ const currentInputElement = currentInput;
83
+ if (currentInput.imageElements) {
84
+ currentInputElement.imageElements.push(img);
85
+ } else {
86
+ currentInputElement.imageElements = [img];
87
+ }
88
+
83
89
  const imageClientHeight = Math.max(img.clientHeight, imageContainer.clientHeight);
84
90
  Object.assign(imageContainer.style, {
85
91
  height: `${imageClientHeight}px`,
@@ -164,7 +170,7 @@ function addInlineImagePreview(
164
170
 
165
171
  // If the inline image markdown with the same href exists in the current input, use it instead of creating new one.
166
172
  // Prevents from image flickering and layout jumps
167
- const alreadyLoadedPreview = currentInput.querySelector(`img[src="${imageHref}"]`);
173
+ const alreadyLoadedPreview = currentInput.imageElements?.find((el) => el?.src === imageHref);
168
174
  const loadedImageContainer = alreadyLoadedPreview?.parentElement;
169
175
 
170
176
  if (loadedImageContainer && loadedImageContainer.getAttribute('data-type') === 'inline-container') {