From 2ab7e3010c704b803fff32854b6512297d03901d Mon Sep 17 00:00:00 2001 From: zfurtak <92310164+zfurtak@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:07:49 +0200 Subject: [PATCH 1/8] Unable pasting photos and styled text (#369) --- src/MarkdownTextInput.web.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 5cb0d0676..801eb0cda 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -519,8 +519,13 @@ const MarkdownTextInput = React.forwardRef( [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(() => { From a1d37e19d3c23d96e114b9d88f4a7b68889f0299 Mon Sep 17 00:00:00 2001 From: OSBotify <76178356+OSBotify@users.noreply.github.com> Date: Tue, 25 Jun 2024 21:09:26 +1000 Subject: [PATCH 2/8] Update version to 0.1.92 (#399) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3643fb444..b16b837b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.91", + "version": "0.1.92", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From ac00d554f79500788c9374865ed86e5aca791f75 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 26 Jun 2024 19:34:07 +0100 Subject: [PATCH 3/8] docs: update ExpensiMark link (#393) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e9c934c1..3faa42435 100644 --- a/README.md +++ b/README.md @@ -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 From 98e695655da06be945352bbf03691f76e8d17738 Mon Sep 17 00:00:00 2001 From: OSBotify <76178356+OSBotify@users.noreply.github.com> Date: Thu, 27 Jun 2024 04:35:46 +1000 Subject: [PATCH 4/8] Update version to 0.1.93 (#401) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b16b837b0..7c2746992 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.92", + "version": "0.1.93", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From 297379355b1a4fb328dfbf98aff78b397d92a5ac Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Thu, 27 Jun 2024 13:29:49 +0200 Subject: [PATCH 5/8] Fix missing `TEST_CONST` import in example app (#402) --- WebExample/__tests__/input.spec.ts | 2 +- WebExample/__tests__/styles.spec.ts | 2 +- WebExample/__tests__/textManipulation.spec.ts | 2 +- WebExample/__tests__/utils.ts | 2 +- WebExample/playwright.config.ts | 2 +- WebExample/tsconfig.json | 2 +- example/src/App.tsx | 2 +- {WebExample/__tests__ => example/src}/testConstants.ts | 0 example/tsconfig.json | 2 +- 9 files changed, 8 insertions(+), 8 deletions(-) rename {WebExample/__tests__ => example/src}/testConstants.ts (100%) diff --git a/WebExample/__tests__/input.spec.ts b/WebExample/__tests__/input.spec.ts index 7854dcb42..f3accc266 100644 --- a/WebExample/__tests__/input.spec.ts +++ b/WebExample/__tests__/input.spec.ts @@ -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}) => { diff --git a/WebExample/__tests__/styles.spec.ts b/WebExample/__tests__/styles.spec.ts index 2fc87dc58..665957f18 100644 --- a/WebExample/__tests__/styles.spec.ts +++ b/WebExample/__tests__/styles.spec.ts @@ -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}) => { diff --git a/WebExample/__tests__/textManipulation.spec.ts b/WebExample/__tests__/textManipulation.spec.ts index d117da397..5c83e3b47 100644 --- a/WebExample/__tests__/textManipulation.spec.ts +++ b/WebExample/__tests__/textManipulation.spec.ts @@ -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}) => { diff --git a/WebExample/__tests__/utils.ts b/WebExample/__tests__/utils.ts index f50e6684a..8b5883485 100644 --- a/WebExample/__tests__/utils.ts +++ b/WebExample/__tests__/utils.ts @@ -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}`); diff --git a/WebExample/playwright.config.ts b/WebExample/playwright.config.ts index 0cf53a251..b8905830a 100644 --- a/WebExample/playwright.config.ts +++ b/WebExample/playwright.config.ts @@ -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__', diff --git a/WebExample/tsconfig.json b/WebExample/tsconfig.json index 5ede51867..713db2f58 100644 --- a/WebExample/tsconfig.json +++ b/WebExample/tsconfig.json @@ -3,6 +3,6 @@ "compilerOptions": { "strict": true }, - "include": ["App.tsx", "**/*.ts", "__tests__/testConstants.ts"], + "include": ["App.tsx", "**/*.ts"], "exclude": ["node_modules"] } diff --git a/example/src/App.tsx b/example/src/App.tsx index 71648f563..aae9b063a 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -4,7 +4,7 @@ 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'; diff --git a/WebExample/__tests__/testConstants.ts b/example/src/testConstants.ts similarity index 100% rename from WebExample/__tests__/testConstants.ts rename to example/src/testConstants.ts diff --git a/example/tsconfig.json b/example/tsconfig.json index 77ef13fc0..0e875a5aa 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -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"] } From fa902fac266175ef832d781cc2f6a9f2a2fcca13 Mon Sep 17 00:00:00 2001 From: OSBotify <76178356+OSBotify@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:31:28 +1000 Subject: [PATCH 6/8] Update version to 0.1.94 (#403) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c2746992..36320f56a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.93", + "version": "0.1.94", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From a83eff4572282ddaeec376fcc02e90dc8e0d7995 Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Fri, 28 Jun 2024 04:36:00 -0700 Subject: [PATCH 7/8] Apply patch from E/App (#406) --- src/web/cursorUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/cursorUtils.ts b/src/web/cursorUtils.ts index 1cda6599a..ba5c3c3e4 100644 --- a/src/web/cursorUtils.ts +++ b/src/web/cursorUtils.ts @@ -66,7 +66,7 @@ function setCursorPosition(target: HTMLElement, start: number, end: number | nul // 3. Caret at the end of whole input, when pressing enter // 4. All other placements if (prevChar === '\n' && prevTextLength !== undefined && prevTextLength < textCharacters.length) { - if (nextChar !== '\n') { + if (nextChar && nextChar !== '\n' && i !== n - 1) { range.setStart(textNodes[i + 1] as Node, 0); } else if (i !== textNodes.length - 1) { range.setStart(textNodes[i] as Node, 1); From 1153e0d8e5aeed980ba47146b7f980dad3172a63 Mon Sep 17 00:00:00 2001 From: OSBotify <76178356+OSBotify@users.noreply.github.com> Date: Fri, 28 Jun 2024 21:37:34 +1000 Subject: [PATCH 8/8] Update version to 0.1.95 (#407) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36320f56a..5344e6bd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.94", + "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",