@expensify/react-native-live-markdown 0.1.60 → 0.1.62

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.
Files changed (32) hide show
  1. package/android/src/main/java/com/expensify/livemarkdown/MarkdownStyle.java +18 -0
  2. package/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java +4 -0
  3. package/ios/RCTMarkdownStyle.h +2 -0
  4. package/ios/RCTMarkdownStyle.mm +6 -0
  5. package/ios/RCTMarkdownUtils.mm +3 -0
  6. package/lib/commonjs/MarkdownTextInput.web.js +8 -3
  7. package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
  8. package/lib/commonjs/MarkdownTextInputDecoratorViewNativeComponent.js.map +1 -1
  9. package/lib/commonjs/styleUtils.js +4 -0
  10. package/lib/commonjs/styleUtils.js.map +1 -1
  11. package/lib/commonjs/web/parserUtils.js +3 -0
  12. package/lib/commonjs/web/parserUtils.js.map +1 -1
  13. package/lib/module/MarkdownTextInput.web.js +8 -3
  14. package/lib/module/MarkdownTextInput.web.js.map +1 -1
  15. package/lib/module/MarkdownTextInputDecoratorViewNativeComponent.js.map +1 -1
  16. package/lib/module/styleUtils.js +4 -0
  17. package/lib/module/styleUtils.js.map +1 -1
  18. package/lib/module/web/parserUtils.js +3 -0
  19. package/lib/module/web/parserUtils.js.map +1 -1
  20. package/lib/parser/react-native-live-markdown-parser.js +17 -17
  21. package/lib/typescript/src/MarkdownTextInput.web.d.ts.map +1 -1
  22. package/lib/typescript/src/MarkdownTextInputDecoratorViewNativeComponent.d.ts +4 -0
  23. package/lib/typescript/src/MarkdownTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
  24. package/lib/typescript/src/styleUtils.d.ts.map +1 -1
  25. package/lib/typescript/src/web/parserUtils.d.ts +1 -1
  26. package/lib/typescript/src/web/parserUtils.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/parser/react-native-live-markdown-parser.js +17 -17
  29. package/src/MarkdownTextInput.web.tsx +6 -3
  30. package/src/MarkdownTextInputDecoratorViewNativeComponent.ts +4 -0
  31. package/src/styleUtils.ts +4 -0
  32. package/src/web/parserUtils.ts +4 -1
@@ -310,9 +310,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
310
310
  return;
311
311
  }
312
312
 
313
- const hostNode = (divRef.current.firstChild as HTMLElement) ?? divRef.current;
314
- const newWidth = hostNode.offsetWidth;
315
- const newHeight = hostNode.offsetHeight;
313
+ const {offsetWidth: newWidth, offsetHeight: newHeight} = divRef.current;
316
314
 
317
315
  if (newHeight !== dimensions.current?.height || newWidth !== dimensions.current.width) {
318
316
  dimensions.current = {height: newHeight, width: newWidth};
@@ -569,6 +567,11 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
569
567
  }
570
568
  }, [autoFocus]);
571
569
 
570
+ useEffect(() => {
571
+ // update content size when the input styles change
572
+ handleContentSizeChange();
573
+ }, [handleContentSizeChange, inputStyles]);
574
+
572
575
  useEffect(() => {
573
576
  if (!divRef.current || !selection || (contentSelection.current && selection.start === contentSelection.current.start && selection.end === contentSelection.current.end)) {
574
577
  return;
@@ -42,6 +42,10 @@ interface MarkdownStyle {
42
42
  color: ColorValue;
43
43
  backgroundColor: ColorValue;
44
44
  };
45
+ mentionReport: {
46
+ color: ColorValue;
47
+ backgroundColor: ColorValue;
48
+ };
45
49
  }
46
50
 
47
51
  interface NativeProps extends ViewProps {
package/src/styleUtils.ts CHANGED
@@ -52,6 +52,10 @@ function makeDefaultMarkdownStyle(): MarkdownStyle {
52
52
  color: 'blue',
53
53
  backgroundColor: 'cyan',
54
54
  },
55
+ mentionReport: {
56
+ color: 'red',
57
+ backgroundColor: 'pink',
58
+ },
55
59
  };
56
60
  }
57
61
 
@@ -4,7 +4,7 @@ import * as BrowserUtils from './browserUtils';
4
4
 
5
5
  type PartialMarkdownStyle = StyleUtilsTypes.PartialMarkdownStyle;
6
6
 
7
- type MarkdownType = 'bold' | 'italic' | 'strikethrough' | 'emoji' | 'link' | 'code' | 'pre' | 'blockquote' | 'h1' | 'syntax' | 'mention-here' | 'mention-user';
7
+ type MarkdownType = 'bold' | 'italic' | 'strikethrough' | 'emoji' | 'link' | 'code' | 'pre' | 'blockquote' | 'h1' | 'syntax' | 'mention-here' | 'mention-user' | 'mention-report';
8
8
 
9
9
  type MarkdownRange = {
10
10
  type: MarkdownType;
@@ -42,6 +42,9 @@ function addStyling(targetElement: HTMLElement, type: MarkdownType, markdownStyl
42
42
  case 'mention-user':
43
43
  Object.assign(node.style, markdownStyle.mentionUser);
44
44
  break;
45
+ case 'mention-report':
46
+ Object.assign(node.style, markdownStyle.mentionReport);
47
+ break;
45
48
  case 'link':
46
49
  Object.assign(node.style, {
47
50
  ...markdownStyle.link,