@expensify/react-native-live-markdown 0.1.61 → 0.1.63
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/android/src/main/java/com/expensify/livemarkdown/MarkdownStyle.java +18 -0
- package/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java +4 -0
- package/ios/RCTMarkdownStyle.h +2 -0
- package/ios/RCTMarkdownStyle.mm +6 -0
- package/ios/RCTMarkdownUtils.mm +3 -0
- package/lib/commonjs/MarkdownTextInput.web.js +7 -3
- package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
- package/lib/commonjs/MarkdownTextInputDecoratorViewNativeComponent.js.map +1 -1
- package/lib/commonjs/styleUtils.js +4 -0
- package/lib/commonjs/styleUtils.js.map +1 -1
- package/lib/commonjs/web/cursorUtils.js +4 -0
- package/lib/commonjs/web/cursorUtils.js.map +1 -1
- package/lib/commonjs/web/parserUtils.js +3 -0
- package/lib/commonjs/web/parserUtils.js.map +1 -1
- package/lib/module/MarkdownTextInput.web.js +7 -3
- package/lib/module/MarkdownTextInput.web.js.map +1 -1
- package/lib/module/MarkdownTextInputDecoratorViewNativeComponent.js.map +1 -1
- package/lib/module/styleUtils.js +4 -0
- package/lib/module/styleUtils.js.map +1 -1
- package/lib/module/web/cursorUtils.js +4 -0
- package/lib/module/web/cursorUtils.js.map +1 -1
- package/lib/module/web/parserUtils.js +3 -0
- package/lib/module/web/parserUtils.js.map +1 -1
- package/lib/parser/react-native-live-markdown-parser.js +17 -17
- package/lib/typescript/src/MarkdownTextInput.web.d.ts.map +1 -1
- package/lib/typescript/src/MarkdownTextInputDecoratorViewNativeComponent.d.ts +4 -0
- package/lib/typescript/src/MarkdownTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/styleUtils.d.ts.map +1 -1
- package/lib/typescript/src/web/cursorUtils.d.ts.map +1 -1
- package/lib/typescript/src/web/parserUtils.d.ts +1 -1
- package/lib/typescript/src/web/parserUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/parser/react-native-live-markdown-parser.js +17 -17
- package/src/MarkdownTextInput.web.tsx +7 -3
- package/src/MarkdownTextInputDecoratorViewNativeComponent.ts +4 -0
- package/src/styleUtils.ts +4 -0
- package/src/web/cursorUtils.ts +5 -0
- package/src/web/parserUtils.ts +4 -1
|
@@ -437,9 +437,13 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
|
|
|
437
437
|
currentlyFocusedField.current = hostNode;
|
|
438
438
|
setEventProps(e);
|
|
439
439
|
if (divRef.current) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
if (contentSelection.current) {
|
|
441
|
+
CursorUtils.setCursorPosition(divRef.current, contentSelection.current.start, contentSelection.current.end);
|
|
442
|
+
} else {
|
|
443
|
+
const valueLength = value ? value.length : divRef.current.innerText.length;
|
|
444
|
+
CursorUtils.setCursorPosition(divRef.current, valueLength, null);
|
|
445
|
+
}
|
|
446
|
+
updateSelection(event, contentSelection.current);
|
|
443
447
|
}
|
|
444
448
|
|
|
445
449
|
if (onFocus) {
|
package/src/styleUtils.ts
CHANGED
package/src/web/cursorUtils.ts
CHANGED
|
@@ -28,6 +28,11 @@ function setPrevText(target: HTMLElement) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function setCursorPosition(target: HTMLElement, start: number, end: number | null = null) {
|
|
31
|
+
// We don't want to move the cursor if the target is not focused
|
|
32
|
+
if (target !== document.activeElement) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
const range = document.createRange();
|
|
32
37
|
range.selectNodeContents(target);
|
|
33
38
|
|
package/src/web/parserUtils.ts
CHANGED
|
@@ -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,
|