Skip to content

Commit

Permalink
Merge branch 'main' into @Skalakid/web-parser-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Jun 28, 2024
2 parents 907c73b + 1153e0d commit 1017ebc
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The style object can be passed to multiple `MarkdownTextInput` components using
## Markdown flavors support

Currently, `react-native-live-markdown` supports only [ExpensiMark](https://github.com/Expensify/expensify-common/blob/main/lib/ExpensiMark.js) flavor. We are working on CommonMark support as well as possibility to use other Markdown parsers.
Currently, `react-native-live-markdown` supports only [ExpensiMark](https://github.com/Expensify/expensify-common/blob/main/lib/ExpensiMark.ts) flavor. We are working on CommonMark support as well as possibility to use other Markdown parsers.

## API reference

Expand Down
2 changes: 1 addition & 1 deletion WebExample/__tests__/input.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {test, expect} from '@playwright/test';
import * as TEST_CONST from './testConstants';
import * as TEST_CONST from '../../example/src/testConstants';
import {checkCursorPosition, setupInput} from './utils';

test.beforeEach(async ({page}) => {
Expand Down
2 changes: 1 addition & 1 deletion WebExample/__tests__/styles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test';
import type {Page} from '@playwright/test';
import * as TEST_CONST from './testConstants';
import * as TEST_CONST from '../../example/src/testConstants';
import {setupInput, getElementStyle} from './utils';

const testMarkdownContentStyle = async ({testContent, style, page}: {testContent: string; style: string; page: Page}) => {
Expand Down
2 changes: 1 addition & 1 deletion WebExample/__tests__/textManipulation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test';
import type {Locator, Page} from '@playwright/test';
import * as TEST_CONST from './testConstants';
import * as TEST_CONST from '../../example/src/testConstants';
import {checkCursorPosition, setupInput, getElementStyle, pressCmd} from './utils';

const pasteContent = async ({text, page, inputLocator}: {text: string; page: Page; inputLocator: Locator}) => {
Expand Down
2 changes: 1 addition & 1 deletion WebExample/__tests__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Locator, Page} from '@playwright/test';
import * as TEST_CONST from './testConstants';
import * as TEST_CONST from '../../example/src/testConstants';

const setupInput = async (page: Page, action?: 'clear' | 'reset') => {
const inputLocator = await page.locator(`div#${TEST_CONST.INPUT_ID}`);
Expand Down
2 changes: 1 addition & 1 deletion WebExample/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {defineConfig, devices} from '@playwright/test';
import * as TEST_CONST from './__tests__/testConstants';
import * as TEST_CONST from '../example/src/testConstants';

export default defineConfig({
testDir: './__tests__',
Expand Down
2 changes: 1 addition & 1 deletion WebExample/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"strict": true
},
"include": ["App.tsx", "**/*.ts", "__tests__/testConstants.ts"],
"include": ["App.tsx", "**/*.ts"],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import {Button, Platform, StyleSheet, Text, View} from 'react-native';
import {MarkdownTextInput} from '@expensify/react-native-live-markdown';
import type {TextInput} from 'react-native';
import * as TEST_CONST from '../../WebExample/__tests__/testConstants';
import * as TEST_CONST from './testConstants';

function isWeb() {
return Platform.OS === 'web';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"strict": true
},
"include": ["src/App.tsx", "./index.ts"],
"include": ["src/App.tsx", "src/testConstants.ts", "./index.ts"],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@expensify/react-native-live-markdown",
"version": "0.1.91",
"version": "0.1.95",
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
7 changes: 6 additions & 1 deletion src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,13 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
[onClick, updateSelection],
);

const handlePaste = useCallback(() => {
const handlePaste = useCallback((e) => {
pasteRef.current = true;
e.preventDefault();

const clipboardData = e.clipboardData;
const text = clipboardData.getData('text/plain');
document.execCommand('insertText', false, text);
}, []);

const startComposition = useCallback(() => {
Expand Down

0 comments on commit 1017ebc

Please sign in to comment.