Skip to content

Commit

Permalink
Merge branch 'main' into @tomekzaw/NSTextStorageDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Dec 10, 2024
2 parents 8400a91 + 540db5f commit 4b05c62
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.204",
"version": "0.1.205",
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
18 changes: 18 additions & 0 deletions src/parseExpensiMark.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
'worklet';

import {Platform} from 'react-native';
import {ExpensiMark} from 'expensify-common';
import {unescapeText} from 'expensify-common/dist/utils';
import {decode} from 'html-entities';
import type {WorkletFunction} from 'react-native-reanimated/lib/typescript/commonTypes';
import type {MarkdownType, MarkdownRange} from './commonTypes';

function isWeb() {
return Platform.OS === 'web';
}

function isJest() {
return !!global.process.env.JEST_WORKER_ID;
}

// eslint-disable-next-line no-underscore-dangle
if (__DEV__ && !isWeb() && !isJest() && (decode as WorkletFunction).__workletHash === undefined) {
throw new Error(
"[react-native-live-markdown] `parseExpensiMark` requires `html-entities` package to be workletized. Please add `'worklet';` directive at the top of `node_modules/html-entities/lib/index.js` using patch-package.",
);
}

const MAX_PARSABLE_LENGTH = 4000;

type Token = ['TEXT' | 'HTML', string];
Expand Down

0 comments on commit 4b05c62

Please sign in to comment.