@expensify/react-native-live-markdown 0.1.29 → 0.1.31

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 (33) hide show
  1. package/android/src/main/java/com/expensify/livemarkdown/MarkdownEmojiSpan.java +9 -0
  2. package/android/src/main/java/com/expensify/livemarkdown/MarkdownStyle.java +7 -0
  3. package/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java +3 -0
  4. package/ios/RCTMarkdownStyle.h +1 -0
  5. package/ios/RCTMarkdownStyle.mm +4 -0
  6. package/ios/RCTMarkdownUtils.mm +8 -1
  7. package/lib/commonjs/MarkdownTextInput.web.js +0 -20
  8. package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
  9. package/lib/commonjs/MarkdownTextInputDecoratorViewNativeComponent.js.map +1 -1
  10. package/lib/commonjs/styleUtils.js +3 -0
  11. package/lib/commonjs/styleUtils.js.map +1 -1
  12. package/lib/commonjs/web/parserUtils.js +3 -0
  13. package/lib/commonjs/web/parserUtils.js.map +1 -1
  14. package/lib/module/MarkdownTextInput.web.js +0 -20
  15. package/lib/module/MarkdownTextInput.web.js.map +1 -1
  16. package/lib/module/MarkdownTextInputDecoratorViewNativeComponent.js.map +1 -1
  17. package/lib/module/styleUtils.js +3 -0
  18. package/lib/module/styleUtils.js.map +1 -1
  19. package/lib/module/web/parserUtils.js +3 -0
  20. package/lib/module/web/parserUtils.js.map +1 -1
  21. package/lib/parser/react-native-live-markdown-parser.js +18 -18
  22. package/lib/typescript/src/MarkdownTextInput.web.d.ts.map +1 -1
  23. package/lib/typescript/src/MarkdownTextInputDecoratorViewNativeComponent.d.ts +3 -0
  24. package/lib/typescript/src/MarkdownTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
  25. package/lib/typescript/src/styleUtils.d.ts.map +1 -1
  26. package/lib/typescript/src/web/parserUtils.d.ts +1 -1
  27. package/lib/typescript/src/web/parserUtils.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/parser/react-native-live-markdown-parser.js +18 -18
  30. package/src/MarkdownTextInput.web.tsx +0 -18
  31. package/src/MarkdownTextInputDecoratorViewNativeComponent.ts +3 -0
  32. package/src/styleUtils.ts +3 -0
  33. package/src/web/parserUtils.ts +4 -1
@@ -514,24 +514,6 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
514
514
  [numberOfLines],
515
515
  );
516
516
 
517
- useEffect(() => {
518
- // update event listeners events objects
519
- const originalAddEventListener = EventTarget.prototype.addEventListener;
520
- EventTarget.prototype.addEventListener = function (eventName, callback) {
521
- if (eventName === 'paste' && typeof callback === 'function') {
522
- originalAddEventListener.call(this, eventName, function (event) {
523
- if (divRef.current && divRef.current.contains(event.target as Node)) {
524
- // pasting returns styled span elements as event.target instead of the contentEditable div. We want to keep the div as the target
525
- Object.defineProperty(event, 'target', {writable: false, value: divRef.current});
526
- }
527
- callback(event);
528
- });
529
- } else {
530
- originalAddEventListener.call(this, eventName, callback);
531
- }
532
- };
533
- }, []);
534
-
535
517
  useEffect(() => {
536
518
  if (!divRef.current) {
537
519
  return;
@@ -7,6 +7,9 @@ interface MarkdownStyle {
7
7
  syntax: {
8
8
  color: ColorValue;
9
9
  };
10
+ emoji: {
11
+ fontSize: Float;
12
+ };
10
13
  link: {
11
14
  color: ColorValue;
12
15
  };
package/src/styleUtils.ts CHANGED
@@ -23,6 +23,9 @@ function makeDefaultMarkdownStyle(): MarkdownStyle {
23
23
  h1: {
24
24
  fontSize: 25,
25
25
  },
26
+ emoji: {
27
+ fontSize: 20,
28
+ },
26
29
  blockquote: {
27
30
  borderColor: 'gray',
28
31
  borderWidth: 6,
@@ -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' | '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';
8
8
 
9
9
  type MarkdownRange = {
10
10
  type: MarkdownType;
@@ -33,6 +33,9 @@ function addStyling(targetElement: HTMLElement, type: MarkdownType, markdownStyl
33
33
  case 'strikethrough':
34
34
  node.style.textDecoration = 'line-through';
35
35
  break;
36
+ case 'emoji':
37
+ Object.assign(node.style, markdownStyle.emoji);
38
+ break;
36
39
  case 'mention-here':
37
40
  Object.assign(node.style, markdownStyle.mentionHere);
38
41
  break;