react-native-enriched-html 1.0.0 → 1.0.1
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/swmansion/enriched/common/EnrichedSpanFlags.kt +39 -0
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java +43 -20
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt +8 -5
- package/android/src/main/java/com/swmansion/enriched/textinput/events/MentionHandler.kt +12 -2
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnMentionEvent.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/AlignmentStyles.kt +6 -7
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/InlineStyles.kt +13 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +4 -3
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +4 -3
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +38 -11
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/Utils.kt +2 -1
- package/cpp/parser/GumboNormalizer.c +61 -3
- package/cpp/tests/GumboParserTest.cpp +54 -0
- package/ios/EnrichedTextInputView.mm +37 -25
- package/ios/extensions/LayoutManagerExtension.mm +73 -62
- package/ios/extensions/StringExtension.mm +75 -0
- package/ios/htmlParser/HtmlParser.h +4 -1
- package/ios/htmlParser/HtmlParser.mm +23 -5
- package/ios/inputHtmlParser/InputHtmlParser.mm +6 -3
- package/ios/interfaces/StyleHeaders.h +4 -0
- package/ios/styles/LinkStyle.mm +20 -34
- package/ios/styles/MentionStyle.mm +55 -4
- package/ios/textHtmlParser/TextHtmlParser.mm +2 -1
- package/ios/utils/ParagraphAttributesUtils.mm +7 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/expandMentionStylesForIndicators.js +2 -3
- package/lib/module/utils/expandMentionStylesForIndicators.js.map +1 -1
- package/lib/module/utils/normalizeHtmlStyle.js +1 -1
- package/lib/module/utils/normalizeHtmlStyle.js.map +1 -1
- package/lib/module/web/EnrichedText.css +343 -0
- package/lib/module/web/EnrichedText.js +55 -0
- package/lib/module/web/EnrichedText.js.map +1 -0
- package/lib/module/web/EnrichedTextInput.js +54 -52
- package/lib/module/web/EnrichedTextInput.js.map +1 -1
- package/lib/module/web/constants/brokenImageGlyph.js +9 -0
- package/lib/module/web/constants/brokenImageGlyph.js.map +1 -0
- package/lib/module/web/constants/classNames.js +5 -0
- package/lib/module/web/constants/classNames.js.map +1 -0
- package/lib/module/web/emitLinkDetected.js +12 -0
- package/lib/module/web/emitLinkDetected.js.map +1 -0
- package/lib/module/web/formats/EnrichedBlockquote.js +1 -1
- package/lib/module/web/formats/EnrichedBlockquote.js.map +1 -1
- package/lib/module/web/formats/EnrichedCheckboxList.js +2 -2
- package/lib/module/web/formats/EnrichedCheckboxList.js.map +1 -1
- package/lib/module/web/formats/EnrichedCodeBlock.js +1 -1
- package/lib/module/web/formats/EnrichedCodeBlock.js.map +1 -1
- package/lib/module/web/formats/EnrichedHeading.js +1 -1
- package/lib/module/web/formats/EnrichedHeading.js.map +1 -1
- package/lib/module/web/formats/EnrichedImageNodeView.js +1 -1
- package/lib/module/web/formats/EnrichedImageNodeView.js.map +1 -1
- package/lib/module/web/formats/EnrichedLink.js +43 -3
- package/lib/module/web/formats/EnrichedLink.js.map +1 -1
- package/lib/module/web/formats/EnrichedOrderedList.js +2 -2
- package/lib/module/web/formats/EnrichedOrderedList.js.map +1 -1
- package/lib/module/web/formats/EnrichedTextAlign.js +82 -0
- package/lib/module/web/formats/EnrichedTextAlign.js.map +1 -0
- package/lib/module/web/formats/EnrichedUnorderedList.js +2 -2
- package/lib/module/web/formats/EnrichedUnorderedList.js.map +1 -1
- package/lib/module/web/formats/applyWrappingListToSelection.js +3 -2
- package/lib/module/web/formats/applyWrappingListToSelection.js.map +1 -1
- package/lib/module/web/formats/formatRules.js +39 -3
- package/lib/module/web/formats/formatRules.js.map +1 -1
- package/lib/module/web/formats/listKeyboard.js +4 -1
- package/lib/module/web/formats/listKeyboard.js.map +1 -1
- package/lib/module/web/normalization/checkboxHtmlNormalizer.js.map +1 -0
- package/lib/module/web/normalization/htmlNormalizer.js +514 -0
- package/lib/module/web/normalization/htmlNormalizer.js.map +1 -0
- package/lib/module/web/normalization/prepareHtmlForWeb.js +78 -0
- package/lib/module/web/normalization/prepareHtmlForWeb.js.map +1 -0
- package/lib/module/web/{tiptapHtmlNormalizer.js → normalization/tiptapHtmlNormalizer.js} +6 -2
- package/lib/module/web/normalization/tiptapHtmlNormalizer.js.map +1 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/autolinkRegex.js +27 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/autolinkRegex.js.map +1 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/index.js +178 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/index.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/index.js +1 -1
- package/lib/module/web/pmPlugins/MentionPlugin/index.js.map +1 -1
- package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js +23 -4
- package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js.map +1 -1
- package/lib/module/web/pmPlugins/MentionPlugin/setMention.js +17 -18
- package/lib/module/web/pmPlugins/MentionPlugin/setMention.js.map +1 -1
- package/lib/module/web/pmPlugins/MentionPlugin/useMentionEvents.js +105 -0
- package/lib/module/web/pmPlugins/MentionPlugin/useMentionEvents.js.map +1 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js +11 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js.map +1 -1
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js +2 -0
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js.map +1 -1
- package/lib/module/web/pmPlugins/StripBoldInStyledHeadingsPlugin.js.map +1 -1
- package/lib/module/web/sanitization/htmlSanitizer.js +10 -0
- package/lib/module/web/sanitization/htmlSanitizer.js.map +1 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js +12 -6
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js.map +1 -1
- package/lib/module/web/styleConversion/enrichedBaseStyleToCSSProperties.js +159 -0
- package/lib/module/web/styleConversion/enrichedBaseStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js +3 -155
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js.map +1 -1
- package/lib/module/web/styleConversion/enrichedTextStyleToCSSProperties.js +44 -0
- package/lib/module/web/styleConversion/enrichedTextStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/{enrichedInputThemingToCSSProperties.js → enrichedThemingToCSSProperties.js} +3 -3
- package/lib/module/web/styleConversion/enrichedThemingToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js +87 -64
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js.map +1 -1
- package/lib/module/web/styleConversion/inlineImageCSSVariables.js +7 -0
- package/lib/module/web/styleConversion/inlineImageCSSVariables.js.map +1 -0
- package/lib/module/web/useImageErrorFallback.js +33 -0
- package/lib/module/web/useImageErrorFallback.js.map +1 -0
- package/lib/module/web/useOnChangeHtml.js +1 -1
- package/lib/module/web/useOnChangeHtml.js.map +1 -1
- package/lib/module/web/useOnChangeState.js +6 -3
- package/lib/module/web/useOnChangeState.js.map +1 -1
- package/lib/module/web/useOnLinkDetected.js +32 -45
- package/lib/module/web/useOnLinkDetected.js.map +1 -1
- package/lib/module/web/usePressInteractions.js +19 -0
- package/lib/module/web/usePressInteractions.js.map +1 -0
- package/lib/module/web/useStableRef.js +13 -0
- package/lib/module/web/useStableRef.js.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedText.d.ts +1 -1
- package/lib/typescript/src/native/EnrichedText.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedTextInput.d.ts +1 -1
- package/lib/typescript/src/native/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +1 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts +1 -1
- package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/EnrichedText.d.ts +4 -0
- package/lib/typescript/src/web/EnrichedText.d.ts.map +1 -0
- package/lib/typescript/src/web/EnrichedTextInput.d.ts +2 -2
- package/lib/typescript/src/web/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/web/constants/brokenImageGlyph.d.ts +3 -0
- package/lib/typescript/src/web/constants/brokenImageGlyph.d.ts.map +1 -0
- package/lib/typescript/src/web/constants/classNames.d.ts +3 -0
- package/lib/typescript/src/web/constants/classNames.d.ts.map +1 -0
- package/lib/typescript/src/web/emitLinkDetected.d.ts +10 -0
- package/lib/typescript/src/web/emitLinkDetected.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedBlockquote.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedCheckboxList.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedCodeBlock.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedHeading.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts +1 -1
- package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedLink.d.ts +4 -1
- package/lib/typescript/src/web/formats/EnrichedLink.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedOrderedList.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/EnrichedTextAlign.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedTextAlign.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedUnorderedList.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/applyWrappingListToSelection.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/formatRules.d.ts +3 -1
- package/lib/typescript/src/web/formats/formatRules.d.ts.map +1 -1
- package/lib/typescript/src/web/formats/listKeyboard.d.ts.map +1 -1
- package/lib/typescript/src/web/normalization/checkboxHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/normalization/htmlNormalizer.d.ts +2 -0
- package/lib/typescript/src/web/normalization/htmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/normalization/prepareHtmlForWeb.d.ts +2 -0
- package/lib/typescript/src/web/normalization/prepareHtmlForWeb.d.ts.map +1 -0
- package/lib/typescript/src/web/normalization/tiptapHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/normalization/tiptapHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.d.ts +7 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/index.d.ts +8 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/index.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts +1 -1
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts.map +1 -1
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.d.ts.map +1 -1
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/setMention.d.ts.map +1 -1
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/useMentionEvents.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/useMentionEvents.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/ShortcutPlugin.d.ts.map +1 -1
- package/lib/typescript/src/web/pmPlugins/StrictMarksPlugin.d.ts.map +1 -1
- package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts +6 -1
- package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts.map +1 -1
- package/lib/typescript/src/web/sanitization/htmlSanitizer.d.ts +2 -0
- package/lib/typescript/src/web/sanitization/htmlSanitizer.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts +2 -2
- package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts.map +1 -1
- package/lib/typescript/src/web/styleConversion/enrichedBaseStyleToCSSProperties.d.ts +8 -0
- package/lib/typescript/src/web/styleConversion/enrichedBaseStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts +2 -5
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts.map +1 -1
- package/lib/typescript/src/web/styleConversion/enrichedTextStyleToCSSProperties.d.ts +4 -0
- package/lib/typescript/src/web/styleConversion/enrichedTextStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/{enrichedInputThemingToCSSProperties.d.ts → enrichedThemingToCSSProperties.d.ts} +1 -1
- package/lib/typescript/src/web/styleConversion/enrichedThemingToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts +5 -4
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts.map +1 -1
- package/lib/typescript/src/web/styleConversion/inlineImageCSSVariables.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/inlineImageCSSVariables.d.ts.map +1 -0
- package/lib/typescript/src/web/useImageErrorFallback.d.ts +3 -0
- package/lib/typescript/src/web/useImageErrorFallback.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeState.d.ts.map +1 -1
- package/lib/typescript/src/web/useOnLinkDetected.d.ts +2 -2
- package/lib/typescript/src/web/useOnLinkDetected.d.ts.map +1 -1
- package/lib/typescript/src/web/usePressInteractions.d.ts +2 -0
- package/lib/typescript/src/web/usePressInteractions.d.ts.map +1 -0
- package/lib/typescript/src/web/useStableRef.d.ts +3 -0
- package/lib/typescript/src/web/useStableRef.d.ts.map +1 -0
- package/package.json +54 -28
- package/src/index.tsx +1 -0
- package/src/types.ts +5 -3
- package/src/utils/expandMentionStylesForIndicators.ts +3 -3
- package/src/utils/normalizeHtmlStyle.ts +2 -1
- package/src/web/EnrichedText.css +343 -0
- package/src/web/EnrichedText.tsx +82 -0
- package/src/web/EnrichedTextInput.tsx +69 -55
- package/src/web/constants/brokenImageGlyph.ts +7 -0
- package/src/web/constants/classNames.ts +2 -0
- package/src/web/emitLinkDetected.ts +29 -0
- package/src/web/formats/EnrichedBlockquote.ts +2 -1
- package/src/web/formats/EnrichedCheckboxList.ts +5 -2
- package/src/web/formats/EnrichedCodeBlock.ts +2 -1
- package/src/web/formats/EnrichedHeading.ts +2 -1
- package/src/web/formats/EnrichedImageNodeView.tsx +1 -3
- package/src/web/formats/EnrichedLink.ts +59 -4
- package/src/web/formats/EnrichedOrderedList.ts +5 -2
- package/src/web/formats/EnrichedTextAlign.ts +88 -0
- package/src/web/formats/EnrichedUnorderedList.ts +5 -2
- package/src/web/formats/applyWrappingListToSelection.ts +4 -4
- package/src/web/formats/formatRules.ts +48 -4
- package/src/web/formats/listKeyboard.ts +6 -1
- package/src/web/normalization/htmlNormalizer.ts +656 -0
- package/src/web/normalization/prepareHtmlForWeb.ts +93 -0
- package/src/web/{tiptapHtmlNormalizer.ts → normalization/tiptapHtmlNormalizer.ts} +12 -2
- package/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.ts +43 -0
- package/src/web/pmPlugins/AutolinkPlugin/index.ts +274 -0
- package/src/web/pmPlugins/MentionPlugin/index.ts +1 -1
- package/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.ts +32 -5
- package/src/web/pmPlugins/MentionPlugin/setMention.ts +19 -29
- package/src/web/pmPlugins/MentionPlugin/useMentionEvents.ts +114 -0
- package/src/web/pmPlugins/ShortcutPlugin.ts +7 -0
- package/src/web/pmPlugins/StrictMarksPlugin.ts +3 -0
- package/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts +41 -36
- package/src/web/sanitization/htmlSanitizer.ts +8 -0
- package/src/web/styleConversion/buildMentionRulesCSS.ts +30 -11
- package/src/web/styleConversion/enrichedBaseStyleToCSSProperties.ts +228 -0
- package/src/web/styleConversion/enrichedInputStyleToCSSProperties.ts +6 -217
- package/src/web/styleConversion/enrichedTextStyleToCSSProperties.ts +53 -0
- package/src/web/styleConversion/{enrichedInputThemingToCSSProperties.ts → enrichedThemingToCSSProperties.ts} +4 -4
- package/src/web/styleConversion/htmlStyleToCSSVariables.ts +121 -70
- package/src/web/styleConversion/inlineImageCSSVariables.ts +6 -0
- package/src/web/useImageErrorFallback.ts +37 -0
- package/src/web/useOnChangeHtml.ts +1 -1
- package/src/web/useOnChangeState.ts +7 -5
- package/src/web/useOnLinkDetected.ts +38 -50
- package/src/web/usePressInteractions.tsx +22 -0
- package/src/web/useStableRef.ts +12 -0
- package/lib/module/web/EnrichedTextInput.css +0 -201
- package/lib/module/web/checkboxHtmlNormalizer.js.map +0 -1
- package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js +0 -100
- package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js.map +0 -1
- package/lib/module/web/styleConversion/enrichedInputThemingToCSSProperties.js.map +0 -1
- package/lib/module/web/tiptapHtmlNormalizer.js.map +0 -1
- package/lib/typescript/src/web/checkboxHtmlNormalizer.d.ts.map +0 -1
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts +0 -4
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts.map +0 -1
- package/lib/typescript/src/web/styleConversion/enrichedInputThemingToCSSProperties.d.ts.map +0 -1
- package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts +0 -3
- package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts.map +0 -1
- package/src/web/EnrichedTextInput.css +0 -201
- package/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.ts +0 -105
- /package/lib/module/web/{checkboxHtmlNormalizer.js → normalization/checkboxHtmlNormalizer.js} +0 -0
- /package/lib/typescript/src/web/{checkboxHtmlNormalizer.d.ts → normalization/checkboxHtmlNormalizer.d.ts} +0 -0
- /package/src/web/{checkboxHtmlNormalizer.ts → normalization/checkboxHtmlNormalizer.ts} +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { DEFAULT_HTML_STYLE } from "../../utils/defaultHtmlStyle.js";
|
|
3
|
+
import { DEFAULT_ENRICHED_TEXT_STYLE, DEFAULT_HTML_STYLE } from "../../utils/defaultHtmlStyle.js";
|
|
4
4
|
import { expandMentionStylesForIndicators } from "../../utils/expandMentionStylesForIndicators.js";
|
|
5
5
|
import { HEADING_TAGS } from "../formats/EnrichedHeading.js";
|
|
6
6
|
import { indicatorToMentionCssKey, MENTION_STYLE_DEFAULT_KEY } from "./mentionIndicatorCssKey.js";
|
|
7
7
|
import { toColor } from "./toColor.js";
|
|
8
8
|
import { isMentionStyleRecord } from "../../utils/isMentionStyleRecord.js";
|
|
9
|
-
export function mergeWithDefaultHtmlStyle(htmlStyle) {
|
|
9
|
+
export function mergeWithDefaultHtmlStyle(htmlStyle, htmlStyleToMergeWith = DEFAULT_HTML_STYLE) {
|
|
10
10
|
const style = htmlStyle ?? {};
|
|
11
|
-
const mentionMap = expandMentionStylesForIndicatorsIncludeDefault(style);
|
|
11
|
+
const mentionMap = expandMentionStylesForIndicatorsIncludeDefault(style, htmlStyleToMergeWith);
|
|
12
12
|
const converted = {
|
|
13
13
|
...style,
|
|
14
14
|
mention: mentionMap
|
|
15
15
|
};
|
|
16
16
|
const merged = {
|
|
17
|
-
...
|
|
17
|
+
...htmlStyleToMergeWith
|
|
18
18
|
};
|
|
19
19
|
for (const key in converted) {
|
|
20
20
|
if (key === 'mention') {
|
|
@@ -24,41 +24,63 @@ export function mergeWithDefaultHtmlStyle(htmlStyle) {
|
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
26
26
|
merged[key] = {
|
|
27
|
-
...
|
|
27
|
+
...htmlStyleToMergeWith[key],
|
|
28
28
|
...converted[key]
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
return merged;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
export function mergeWithDefaultEnrichedTextHtmlStyle(htmlStyle) {
|
|
34
|
+
const merged = mergeWithDefaultHtmlStyle(htmlStyle, DEFAULT_ENRICHED_TEXT_STYLE);
|
|
35
|
+
const a = {
|
|
36
|
+
...DEFAULT_ENRICHED_TEXT_STYLE.a,
|
|
37
|
+
...htmlStyle?.a
|
|
38
|
+
};
|
|
39
|
+
const mentionDefaults = DEFAULT_ENRICHED_TEXT_STYLE.mention;
|
|
40
|
+
const passedMentionMap = htmlStyle?.mention;
|
|
41
|
+
const mergedMentionMap = merged.mention;
|
|
42
|
+
const mention = {};
|
|
43
|
+
for (const indicator in mergedMentionMap) {
|
|
44
|
+
mention[indicator] = {
|
|
45
|
+
...mentionDefaults,
|
|
46
|
+
...(isMentionStyleRecord(passedMentionMap) ? passedMentionMap[indicator] ?? passedMentionMap[MENTION_STYLE_DEFAULT_KEY] : passedMentionMap)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
...merged,
|
|
51
|
+
a,
|
|
52
|
+
mention
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const ET_CSS_VARS = {
|
|
56
|
+
codeColor: '--et-code-color',
|
|
57
|
+
codeBgColor: '--et-code-bg-color',
|
|
58
|
+
blockquoteBorderColor: '--et-blockquote-border-color',
|
|
59
|
+
blockquoteBorderWidth: '--et-blockquote-border-width',
|
|
60
|
+
blockquoteGapWidth: '--et-blockquote-gap-width',
|
|
61
|
+
blockquoteColor: '--et-blockquote-color',
|
|
62
|
+
codeblockBgColor: '--et-codeblock-bg-color',
|
|
63
|
+
codeblockColor: '--et-codeblock-color',
|
|
64
|
+
codeblockBorderRadius: '--et-codeblock-border-radius',
|
|
65
|
+
linkColor: '--et-link-color',
|
|
66
|
+
linkTextDecorationLine: '--et-link-text-decoration-line',
|
|
67
|
+
ulBulletColor: '--et-ul-bullet-color',
|
|
68
|
+
ulBulletSize: '--et-ul-bullet-size',
|
|
69
|
+
ulMarginLeft: '--et-ul-margin-left',
|
|
70
|
+
ulGapWidth: '--et-ul-gap-width',
|
|
71
|
+
olMarginLeft: '--et-ol-margin-left',
|
|
72
|
+
olGapWidth: '--et-ol-gap-width',
|
|
73
|
+
olMarkerColor: '--et-ol-marker-color',
|
|
74
|
+
olMarkerFontWeight: '--et-ol-marker-font-weight',
|
|
75
|
+
checkboxBoxSize: '--et-checkbox-box-size',
|
|
76
|
+
checkboxGapWidth: '--et-checkbox-gap-width',
|
|
77
|
+
checkboxMarginLeft: '--et-checkbox-margin-left',
|
|
78
|
+
checkboxBoxColor: '--et-checkbox-box-color'
|
|
57
79
|
};
|
|
58
|
-
export const
|
|
59
|
-
color: indicator => `--
|
|
60
|
-
backgroundColor: indicator => `--
|
|
61
|
-
textDecorationLine: indicator => `--
|
|
80
|
+
export const ET_MENTION_CSS_VARS = {
|
|
81
|
+
color: indicator => `--et-mention-${indicatorToMentionCssKey(indicator)}-color`,
|
|
82
|
+
backgroundColor: indicator => `--et-mention-${indicatorToMentionCssKey(indicator)}-background-color`,
|
|
83
|
+
textDecorationLine: indicator => `--et-mention-${indicatorToMentionCssKey(indicator)}-text-decoration-line`
|
|
62
84
|
};
|
|
63
85
|
function setColorVar(vars, name, value) {
|
|
64
86
|
const c = toColor(value);
|
|
@@ -68,66 +90,67 @@ function setPxVar(vars, name, n) {
|
|
|
68
90
|
if (n != null) vars[name] = `${n}px`;
|
|
69
91
|
}
|
|
70
92
|
function applyCodeVars(vars, code) {
|
|
71
|
-
setColorVar(vars,
|
|
72
|
-
setColorVar(vars,
|
|
93
|
+
setColorVar(vars, ET_CSS_VARS.codeColor, code?.color);
|
|
94
|
+
setColorVar(vars, ET_CSS_VARS.codeBgColor, code?.backgroundColor);
|
|
73
95
|
}
|
|
74
96
|
function applyHeadingVars(vars, htmlStyle) {
|
|
75
97
|
for (const level of HEADING_TAGS) {
|
|
76
98
|
const h = htmlStyle?.[level];
|
|
77
|
-
if (h?.fontSize != null) vars[`--
|
|
78
|
-
if (h?.bold != null) vars[`--
|
|
99
|
+
if (h?.fontSize != null) vars[`--et-${level}-font-size`] = `${h.fontSize}px`;
|
|
100
|
+
if (h?.bold != null) vars[`--et-${level}-font-weight`] = h.bold ? 'bold' : 'normal';
|
|
79
101
|
}
|
|
80
102
|
}
|
|
81
103
|
function applyBlockquoteVars(vars, bq) {
|
|
82
|
-
setColorVar(vars,
|
|
83
|
-
setPxVar(vars,
|
|
84
|
-
setPxVar(vars,
|
|
85
|
-
setColorVar(vars,
|
|
104
|
+
setColorVar(vars, ET_CSS_VARS.blockquoteBorderColor, bq?.borderColor);
|
|
105
|
+
setPxVar(vars, ET_CSS_VARS.blockquoteBorderWidth, bq?.borderWidth);
|
|
106
|
+
setPxVar(vars, ET_CSS_VARS.blockquoteGapWidth, bq?.gapWidth);
|
|
107
|
+
setColorVar(vars, ET_CSS_VARS.blockquoteColor, bq?.color);
|
|
86
108
|
}
|
|
87
109
|
function applyCodeblockVars(vars, cb) {
|
|
88
|
-
setColorVar(vars,
|
|
89
|
-
setColorVar(vars,
|
|
90
|
-
setPxVar(vars,
|
|
110
|
+
setColorVar(vars, ET_CSS_VARS.codeblockBgColor, cb?.backgroundColor);
|
|
111
|
+
setColorVar(vars, ET_CSS_VARS.codeblockColor, cb?.color);
|
|
112
|
+
setPxVar(vars, ET_CSS_VARS.codeblockBorderRadius, cb?.borderRadius);
|
|
91
113
|
}
|
|
92
114
|
function applyLinkVars(vars, anchor) {
|
|
93
|
-
setColorVar(vars,
|
|
115
|
+
setColorVar(vars, ET_CSS_VARS.linkColor, anchor?.color);
|
|
94
116
|
if (anchor?.textDecorationLine != null) {
|
|
95
|
-
vars[
|
|
117
|
+
vars[ET_CSS_VARS.linkTextDecorationLine] = anchor.textDecorationLine;
|
|
96
118
|
}
|
|
97
119
|
}
|
|
98
120
|
function applyUnorderedListVars(vars, ul) {
|
|
99
|
-
setColorVar(vars,
|
|
100
|
-
setPxVar(vars,
|
|
101
|
-
setPxVar(vars,
|
|
102
|
-
setPxVar(vars,
|
|
121
|
+
setColorVar(vars, ET_CSS_VARS.ulBulletColor, ul?.bulletColor);
|
|
122
|
+
setPxVar(vars, ET_CSS_VARS.ulBulletSize, ul?.bulletSize);
|
|
123
|
+
setPxVar(vars, ET_CSS_VARS.ulMarginLeft, ul?.marginLeft);
|
|
124
|
+
setPxVar(vars, ET_CSS_VARS.ulGapWidth, ul?.gapWidth);
|
|
103
125
|
}
|
|
104
126
|
function applyOrderedListVars(vars, ol) {
|
|
105
|
-
setPxVar(vars,
|
|
106
|
-
setPxVar(vars,
|
|
107
|
-
setColorVar(vars,
|
|
127
|
+
setPxVar(vars, ET_CSS_VARS.olMarginLeft, ol?.marginLeft);
|
|
128
|
+
setPxVar(vars, ET_CSS_VARS.olGapWidth, ol?.gapWidth);
|
|
129
|
+
setColorVar(vars, ET_CSS_VARS.olMarkerColor, ol?.markerColor);
|
|
108
130
|
if (ol?.markerFontWeight != null) {
|
|
109
|
-
vars[
|
|
131
|
+
vars[ET_CSS_VARS.olMarkerFontWeight] = String(ol.markerFontWeight);
|
|
110
132
|
}
|
|
111
133
|
}
|
|
112
134
|
function applyCheckboxListVars(vars, ulCheckbox) {
|
|
113
|
-
setPxVar(vars,
|
|
114
|
-
setPxVar(vars,
|
|
115
|
-
setPxVar(vars,
|
|
116
|
-
setColorVar(vars,
|
|
135
|
+
setPxVar(vars, ET_CSS_VARS.checkboxBoxSize, ulCheckbox?.boxSize);
|
|
136
|
+
setPxVar(vars, ET_CSS_VARS.checkboxGapWidth, ulCheckbox?.gapWidth);
|
|
137
|
+
setPxVar(vars, ET_CSS_VARS.checkboxMarginLeft, ulCheckbox?.marginLeft);
|
|
138
|
+
setColorVar(vars, ET_CSS_VARS.checkboxBoxColor, ulCheckbox?.boxColor);
|
|
117
139
|
}
|
|
118
140
|
function applyMentionVars(vars, mention) {
|
|
141
|
+
if (!mention) return;
|
|
119
142
|
for (const [indicator, mentionStyle] of Object.entries(mention)) {
|
|
120
|
-
setColorVar(vars,
|
|
121
|
-
setColorVar(vars,
|
|
143
|
+
setColorVar(vars, ET_MENTION_CSS_VARS.color(indicator), mentionStyle.color);
|
|
144
|
+
setColorVar(vars, ET_MENTION_CSS_VARS.backgroundColor(indicator), mentionStyle.backgroundColor);
|
|
122
145
|
if (mentionStyle.textDecorationLine != null) {
|
|
123
|
-
vars[
|
|
146
|
+
vars[ET_MENTION_CSS_VARS.textDecorationLine(indicator)] = mentionStyle.textDecorationLine;
|
|
124
147
|
}
|
|
125
148
|
}
|
|
126
149
|
}
|
|
127
|
-
function expandMentionStylesForIndicatorsIncludeDefault(htmlStyle) {
|
|
150
|
+
function expandMentionStylesForIndicatorsIncludeDefault(htmlStyle, htmlStyleToMergeWith) {
|
|
128
151
|
const mentionIndicators = isMentionStyleRecord(htmlStyle?.mention) ? Object.keys(htmlStyle?.mention) : [];
|
|
129
152
|
if (!mentionIndicators.includes(MENTION_STYLE_DEFAULT_KEY)) mentionIndicators.push(MENTION_STYLE_DEFAULT_KEY);
|
|
130
|
-
return expandMentionStylesForIndicators(htmlStyle?.mention, mentionIndicators);
|
|
153
|
+
return expandMentionStylesForIndicators(htmlStyle?.mention, mentionIndicators, htmlStyleToMergeWith);
|
|
131
154
|
}
|
|
132
155
|
export function htmlStyleToCSSVariables(htmlStyle) {
|
|
133
156
|
const vars = {};
|
|
@@ -139,7 +162,7 @@ export function htmlStyleToCSSVariables(htmlStyle) {
|
|
|
139
162
|
applyUnorderedListVars(vars, htmlStyle?.ul);
|
|
140
163
|
applyOrderedListVars(vars, htmlStyle?.ol);
|
|
141
164
|
applyCheckboxListVars(vars, htmlStyle?.ulCheckbox);
|
|
142
|
-
applyMentionVars(vars,
|
|
165
|
+
applyMentionVars(vars, htmlStyle.mention);
|
|
143
166
|
return vars;
|
|
144
167
|
}
|
|
145
168
|
//# sourceMappingURL=htmlStyleToCSSVariables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_HTML_STYLE","expandMentionStylesForIndicators","HEADING_TAGS","indicatorToMentionCssKey","MENTION_STYLE_DEFAULT_KEY","toColor","isMentionStyleRecord","mergeWithDefaultHtmlStyle","htmlStyle","style","mentionMap","expandMentionStylesForIndicatorsIncludeDefault","converted","mention","merged","key","
|
|
1
|
+
{"version":3,"names":["DEFAULT_ENRICHED_TEXT_STYLE","DEFAULT_HTML_STYLE","expandMentionStylesForIndicators","HEADING_TAGS","indicatorToMentionCssKey","MENTION_STYLE_DEFAULT_KEY","toColor","isMentionStyleRecord","mergeWithDefaultHtmlStyle","htmlStyle","htmlStyleToMergeWith","style","mentionMap","expandMentionStylesForIndicatorsIncludeDefault","converted","mention","merged","key","mergeWithDefaultEnrichedTextHtmlStyle","a","mentionDefaults","passedMentionMap","mergedMentionMap","indicator","ET_CSS_VARS","codeColor","codeBgColor","blockquoteBorderColor","blockquoteBorderWidth","blockquoteGapWidth","blockquoteColor","codeblockBgColor","codeblockColor","codeblockBorderRadius","linkColor","linkTextDecorationLine","ulBulletColor","ulBulletSize","ulMarginLeft","ulGapWidth","olMarginLeft","olGapWidth","olMarkerColor","olMarkerFontWeight","checkboxBoxSize","checkboxGapWidth","checkboxMarginLeft","checkboxBoxColor","ET_MENTION_CSS_VARS","color","backgroundColor","textDecorationLine","setColorVar","vars","name","value","c","setPxVar","n","applyCodeVars","code","applyHeadingVars","level","h","fontSize","bold","applyBlockquoteVars","bq","borderColor","borderWidth","gapWidth","applyCodeblockVars","cb","borderRadius","applyLinkVars","anchor","applyUnorderedListVars","ul","bulletColor","bulletSize","marginLeft","applyOrderedListVars","ol","markerColor","markerFontWeight","String","applyCheckboxListVars","ulCheckbox","boxSize","boxColor","applyMentionVars","mentionStyle","Object","entries","mentionIndicators","keys","includes","push","htmlStyleToCSSVariables","blockquote","codeblock"],"sourceRoot":"../../../../src","sources":["web/styleConversion/htmlStyleToCSSVariables.ts"],"mappings":";;AAQA,SACEA,2BAA2B,EAC3BC,kBAAkB,QACb,iCAA8B;AACrC,SAASC,gCAAgC,QAAQ,iDAA8C;AAC/F,SAASC,YAAY,QAAQ,+BAA4B;AACzD,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,6BAA0B;AACjC,SAASC,OAAO,QAAQ,cAAW;AACnC,SAASC,oBAAoB,QAAQ,qCAAkC;AAEvE,OAAO,SAASC,yBAAyBA,CACvCC,SAAqB,EACrBC,oBAA+B,GAAGT,kBAAkB,EAC/B;EACrB,MAAMU,KAAK,GAAGF,SAAS,IAAI,CAAC,CAAC;EAE7B,MAA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_VARIABLES"],"sourceRoot":"../../../../src","sources":["web/styleConversion/inlineImageCSSVariables.ts"],"mappings":";;AACA,SAASA,uBAAuB,QAAQ,kCAA+B;AAEvE,OAAO,MAAMC,0BAA0B,GAAG;EACxC,yBAAyB,EAAED;AAC7B,CAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Flag images that fail to load so CSS can swap in a broken-image placeholder.
|
|
7
|
+
*/
|
|
8
|
+
export const useImageErrorFallback = containerRef => {
|
|
9
|
+
// listen for errors
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const container = containerRef.current;
|
|
12
|
+
if (!container) return;
|
|
13
|
+
const handleImageError = e => {
|
|
14
|
+
const target = e.target;
|
|
15
|
+
if (target && target.tagName && target.tagName.toLowerCase() === 'img') {
|
|
16
|
+
target.classList.add('error');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
container.addEventListener('error', handleImageError, true);
|
|
20
|
+
|
|
21
|
+
// handle <img> elements that emitted an error event before we could set up a listener
|
|
22
|
+
const images = container.querySelectorAll('img:not(.error)');
|
|
23
|
+
images.forEach(img => {
|
|
24
|
+
if (img.complete && img.naturalHeight === 0) {
|
|
25
|
+
img.classList.add('error');
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
container.removeEventListener('error', handleImageError, true);
|
|
30
|
+
};
|
|
31
|
+
}, [containerRef]);
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=useImageErrorFallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useImageErrorFallback","containerRef","container","current","handleImageError","e","target","tagName","toLowerCase","classList","add","addEventListener","images","querySelectorAll","forEach","img","complete","naturalHeight","removeEventListener"],"sourceRoot":"../../../src","sources":["web/useImageErrorFallback.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAwB,OAAO;;AAEjD;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAChCC,YAA2C,IACxC;EACH;EACAF,SAAS,CAAC,MAAM;IACd,MAAMG,SAAS,GAAGD,YAAY,CAACE,OAAO;IACtC,IAAI,CAACD,SAAS,EAAE;IAEhB,MAAME,gBAAgB,GAAIC,CAAQ,IAAK;MACrC,MAAMC,MAAM,GAAGD,CAAC,CAACC,MAAqB;MACtC,IAAIA,MAAM,IAAIA,MAAM,CAACC,OAAO,IAAID,MAAM,CAACC,OAAO,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK,EAAE;QACtEF,MAAM,CAACG,SAAS,CAACC,GAAG,CAAC,OAAO,CAAC;MAC/B;IACF,CAAC;IAEDR,SAAS,CAACS,gBAAgB,CAAC,OAAO,EAAEP,gBAAgB,EAAE,IAAI,CAAC;;IAE3D;IACA,MAAMQ,MAAM,GACVV,SAAS,CAACW,gBAAgB,CAAmB,iBAAiB,CAAC;IAEjED,MAAM,CAACE,OAAO,CAAEC,GAAG,IAAK;MACtB,IAAIA,GAAG,CAACC,QAAQ,IAAID,GAAG,CAACE,aAAa,KAAK,CAAC,EAAE;QAC3CF,GAAG,CAACN,SAAS,CAACC,GAAG,CAAC,OAAO,CAAC;MAC5B;IACF,CAAC,CAAC;IAEF,OAAO,MAAM;MACXR,SAAS,CAACgB,mBAAmB,CAAC,OAAO,EAAEd,gBAAgB,EAAE,IAAI,CAAC;IAChE,CAAC;EACH,CAAC,EAAE,CAACH,YAAY,CAAC,CAAC;AACpB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useOnEditorChange } from "./useOnEditorChange.js";
|
|
4
|
-
import { normalizeHtmlFromTiptap } from "./tiptapHtmlNormalizer.js";
|
|
4
|
+
import { normalizeHtmlFromTiptap } from "./normalization/tiptapHtmlNormalizer.js";
|
|
5
5
|
export const useOnChangeHtml = (editor, onChangeHtml) => {
|
|
6
6
|
useOnEditorChange(editor, onChangeHtml, e => normalizeHtmlFromTiptap(e.getHTML()));
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useOnEditorChange","normalizeHtmlFromTiptap","useOnChangeHtml","editor","onChangeHtml","e","getHTML"],"sourceRoot":"../../../src","sources":["web/useOnChangeHtml.ts"],"mappings":";;AAGA,SAASA,iBAAiB,QAAQ,wBAAqB;AACvD,SAASC,uBAAuB,QAAQ,
|
|
1
|
+
{"version":3,"names":["useOnEditorChange","normalizeHtmlFromTiptap","useOnChangeHtml","editor","onChangeHtml","e","getHTML"],"sourceRoot":"../../../src","sources":["web/useOnChangeHtml.ts"],"mappings":";;AAGA,SAASA,iBAAiB,QAAQ,wBAAqB;AACvD,SAASC,uBAAuB,QAAQ,yCAAsC;AAE9E,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,MAAc,EACdC,YAAmE,KAChE;EACHJ,iBAAiB,CAACG,MAAM,EAAEC,YAAY,EAAGC,CAAC,IACxCJ,uBAAuB,CAACI,CAAC,CAACC,OAAO,CAAC,CAAC,CACrC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
import { adaptWebToNativeEvent } from "./adaptWebToNativeEvent.js";
|
|
5
|
-
import { isAnyParagraphFormatActive, isFormatBlocked } from "./formats/formatRules.js";
|
|
5
|
+
import { getCurrentAlignment, isAnyParagraphFormatActive, isFormatBlocked } from "./formats/formatRules.js";
|
|
6
6
|
export const useOnChangeState = (editor, htmlStyle, onChangeState) => {
|
|
7
7
|
const lastStateHashRef = useRef(null);
|
|
8
8
|
useEffect(() => {
|
|
@@ -75,11 +75,14 @@ function buildState(editor, htmlStyle) {
|
|
|
75
75
|
isConflicting: editor.isActive('link'),
|
|
76
76
|
isBlocking: isFormatBlocked('image', editor, htmlStyle)
|
|
77
77
|
},
|
|
78
|
-
alignment: '
|
|
78
|
+
alignment: getCurrentAlignment(editor) ?? 'auto'
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function hashState(state) {
|
|
82
|
-
return Object.values(state).map(formatState =>
|
|
82
|
+
return Object.values(state).map(formatState => {
|
|
83
|
+
if (typeof formatState === 'string') return formatState;
|
|
84
|
+
return String(getFormatHash(formatState.isActive, formatState.isConflicting, formatState.isBlocking));
|
|
85
|
+
}).join('');
|
|
83
86
|
}
|
|
84
87
|
function getFormatHash(isActive, isConflicting, isBlocking) {
|
|
85
88
|
// eslint-disable-next-line no-bitwise
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","adaptWebToNativeEvent","isAnyParagraphFormatActive","isFormatBlocked","useOnChangeState","editor","htmlStyle","onChangeState","lastStateHashRef","handleUpdate","state","buildState","stateHash","hashState","current","on","off","isAnyBlockActive","inlineFormat","tiptapName","isConflicting","isActive","isBlocking","paragraphFormat","additionalIsConflicting","bold","italic","underline","strikeThrough","inlineCode","h1","level","h2","h3","h4","h5","h6","blockQuote","codeBlock","orderedList","unorderedList","checkboxList","link","mention","image","alignment","Object","values","map","formatState","String","getFormatHash","join"],"sourceRoot":"../../../src","sources":["web/useOnChangeState.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAIzC,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SACEC,0BAA0B,EAC1BC,eAAe,QACV,0BAAuB;AAG9B,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,MAAqB,EACrBC,SAA8B,EAC9BC,aAAqE,KAClE;EACH,MAAMC,gBAAgB,
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","adaptWebToNativeEvent","getCurrentAlignment","isAnyParagraphFormatActive","isFormatBlocked","useOnChangeState","editor","htmlStyle","onChangeState","lastStateHashRef","handleUpdate","state","buildState","stateHash","hashState","current","on","off","isAnyBlockActive","inlineFormat","tiptapName","isConflicting","isActive","isBlocking","paragraphFormat","additionalIsConflicting","bold","italic","underline","strikeThrough","inlineCode","h1","level","h2","h3","h4","h5","h6","blockQuote","codeBlock","orderedList","unorderedList","checkboxList","link","mention","image","alignment","Object","values","map","formatState","String","getFormatHash","join"],"sourceRoot":"../../../src","sources":["web/useOnChangeState.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAIzC,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SACEC,mBAAmB,EACnBC,0BAA0B,EAC1BC,eAAe,QACV,0BAAuB;AAG9B,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,MAAqB,EACrBC,SAA8B,EAC9BC,aAAqE,KAClE;EACH,MAAMC,gBAAgB,GAAGT,MAAM,CAAgB,IAAI,CAAC;EAEpDD,SAAS,CAAC,MAAM;IACd,IAAI,CAACO,MAAM,IAAI,CAACE,aAAa,EAAE;IAE/B,MAAME,YAAY,GAAGA,CAAA,KAAM;MACzB,MAAMC,KAAK,GAAGC,UAAU,CAACN,MAAM,EAAEC,SAAS,CAAC;MAC3C,MAAMM,SAAS,GAAGC,SAAS,CAACH,KAAK,CAAC;MAElC,IAAIF,gBAAgB,CAACM,OAAO,KAAKF,SAAS,EAAE;QAC1C;MACF;MAEAJ,gBAAgB,CAACM,OAAO,GAAGF,SAAS;MACpCL,aAAa,CAACP,qBAAqB,CAAC,IAAI,EAAEU,KAAK,CAAC,CAAC;IACnD,CAAC;IAEDD,YAAY,CAAC,CAAC;IACdJ,MAAM,CAACU,EAAE,CAAC,aAAa,EAAEN,YAAY,CAAC;IAEtC,OAAO,MAAM;MACXJ,MAAM,CAACW,GAAG,CAAC,aAAa,EAAEP,YAAY,CAAC;IACzC,CAAC;EACH,CAAC,EAAE,CAACJ,MAAM,EAAEE,aAAa,EAAED,SAAS,CAAC,CAAC;AACxC,CAAC;AAED,SAASK,UAAUA,CACjBN,MAAc,EACdC,SAA8B,EACV;EACpB,MAAMW,gB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;IACxD,CAAC;IACDuC,SAAS,EAAE5C,mBAAmB,CAACI,MAAM,CAAC,IAAI;EAC5C,CAAC;AACH;AAEA,SAASQ,SAASA,CAACH,KAAyB,EAAU;EACpD,OAAOoC,MAAM,CAACC,MAAM,CAACrC,KAAK,CAAC,CACxBsC,GAAG,CAAEC,WAAW,IAAK;IACpB,IAAI,OAAOA,WAAW,KAAK,QAAQ,EAAE,OAAOA,WAAW;IACvD,OAAOC,MAAM,CACXC,aAAa,CACXF,WAAW,CAAC5B,QAAQ,EACpB4B,WAAW,CAAC7B,aAAa,EACzB6B,WAAW,CAAC3B,UACd,CACF,CAAC;EACH,CAAC,CAAC,CACD8B,IAAI,CAAC,EAAE,CAAC;AACb;AAEA,SAASD,aAAaA,CACpB9B,QAAiB,EACjBD,aAAsB,EACtBE,UAAmB,EACX;EACR;EACA,OAAQ,CAACD,QAAQ,IAAI,CAAC,GAAK,CAACD,aAAa,IAAI,CAAE,GAAI,CAACE,UAAU,IAAI,CAAE;AACtE","ignoreList":[]}
|
|
@@ -1,68 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useEffect
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
4
|
import { getMarkRange, getMarksBetween } from '@tiptap/core';
|
|
5
|
+
import { emitLinkDetected } from "./emitLinkDetected.js";
|
|
5
6
|
import { tiptapPosToNativePos } from "./positionMapping.js";
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
function findLinkRangeAt(state, linkType) {
|
|
8
|
+
const $pos = state.selection.$from;
|
|
9
|
+
const direct = getMarkRange($pos, linkType);
|
|
10
|
+
if (direct) return direct;
|
|
11
|
+
if ($pos.pos > 0) {
|
|
12
|
+
const $before = state.doc.resolve($pos.pos - 1);
|
|
13
|
+
const before = getMarkRange($before, linkType);
|
|
14
|
+
if (before && before.to === $pos.pos) return before;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export const useOnLinkDetected = (editor, ref) => {
|
|
9
19
|
useEffect(() => {
|
|
10
|
-
if (!editor
|
|
20
|
+
if (!editor) return;
|
|
11
21
|
const handleUpdate = () => {
|
|
12
22
|
const {
|
|
13
23
|
state
|
|
14
24
|
} = editor;
|
|
15
25
|
const linkType = state.schema.marks.link;
|
|
16
26
|
if (!linkType) return;
|
|
17
|
-
const
|
|
18
|
-
const range = getMarkRange($pos, linkType);
|
|
27
|
+
const range = findLinkRangeAt(state, linkType);
|
|
19
28
|
if (!range) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
lastEmittedRef.current = null;
|
|
29
|
+
const last = ref.current.lastEmitted;
|
|
30
|
+
if (!last || last.url === '') return;
|
|
31
|
+
emitLinkDetected(ref.current, {
|
|
32
|
+
text: '',
|
|
33
|
+
url: '',
|
|
34
|
+
start: 0,
|
|
35
|
+
end: 0
|
|
36
|
+
});
|
|
30
37
|
return;
|
|
31
38
|
}
|
|
32
39
|
const linkMark = getMarksBetween(range.from, range.to, state.doc).find(entry => entry.mark.type === linkType)?.mark;
|
|
33
|
-
if (!linkMark)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
from,
|
|
41
|
-
to
|
|
42
|
-
} = range;
|
|
43
|
-
const url = linkMark.attrs.href ?? '';
|
|
44
|
-
const text = state.doc.textBetween(from, to, '\n');
|
|
45
|
-
const start = tiptapPosToNativePos(state.doc, from);
|
|
46
|
-
const end = tiptapPosToNativePos(state.doc, to);
|
|
47
|
-
const next = {
|
|
48
|
-
text,
|
|
49
|
-
url,
|
|
50
|
-
start,
|
|
51
|
-
end
|
|
52
|
-
};
|
|
53
|
-
const prev = lastEmittedRef.current;
|
|
54
|
-
if (prev !== null && prev.text === next.text && prev.url === next.url && prev.start === next.start && prev.end === next.end) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
lastEmittedRef.current = next;
|
|
58
|
-
onLinkDetected(next);
|
|
40
|
+
if (!linkMark) return;
|
|
41
|
+
emitLinkDetected(ref.current, {
|
|
42
|
+
text: state.doc.textBetween(range.from, range.to, '\n'),
|
|
43
|
+
url: linkMark.attrs.href ?? '',
|
|
44
|
+
start: tiptapPosToNativePos(state.doc, range.from),
|
|
45
|
+
end: tiptapPosToNativePos(state.doc, range.to)
|
|
46
|
+
});
|
|
59
47
|
};
|
|
60
48
|
handleUpdate();
|
|
61
49
|
editor.on('transaction', handleUpdate);
|
|
62
50
|
return () => {
|
|
63
|
-
wasInLinkRef.current = false;
|
|
64
51
|
editor.off('transaction', handleUpdate);
|
|
65
52
|
};
|
|
66
|
-
}, [editor,
|
|
53
|
+
}, [editor, ref]);
|
|
67
54
|
};
|
|
68
55
|
//# sourceMappingURL=useOnLinkDetected.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","
|
|
1
|
+
{"version":3,"names":["useEffect","getMarkRange","getMarksBetween","emitLinkDetected","tiptapPosToNativePos","findLinkRangeAt","state","linkType","$pos","selection","$from","direct","pos","$before","doc","resolve","before","to","useOnLinkDetected","editor","ref","handleUpdate","schema","marks","link","range","last","current","lastEmitted","url","text","start","end","linkMark","from","find","entry","mark","type","textBetween","attrs","href","on","off"],"sourceRoot":"../../../src","sources":["web/useOnLinkDetected.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,YAAY,EAAEC,eAAe,QAAQ,cAAc;AAG5D,SAASC,gBAAgB,QAA6B,uBAAoB;AAC1E,SAASC,oBAAoB,QAAQ,sBAAmB;AAExD,SAASC,eAAeA,CACtBC,KAAkB,EAClBC,QAAkB,EACmB;EACrC,MAAMC,IAAI,GAAGF,KAAK,CAACG,SAAS,CAACC,KAAK;EAClC,MAAMC,MAAM,GAAGV,YAAY,CAACO,IAAI,EAAED,QAA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A,KAAK,CAACC,IAAI,CAACC,IAAI,KAAK/B,QACjC,CAAC,EAAE8B,IAAI;MACP,IAAI,CAACJ,QAAQ,EAAE;MAEf9B,gBAAgB,CAACiB,GAAG,CAACO,OAAO,EAAE;QAC5BG,IAAI,EAAExB,KAAK,CAACQ,GAAG,CAACyB,WAAW,CAACd,KAAK,CAACS,IAAI,EAAET,KAAK,CAACR,EAAE,EAAE,IAAI,CAAC;QACvDY,GAAG,EAAGI,QAAQ,CAACO,KAAK,CAACC,IAAI,IAA2B,EAAE;QACtDV,KAAK,EAAE3B,oBAAoB,CAACE,KAAK,CAACQ,GAAG,EAAEW,KAAK,CAACS,IAAI,CAAC;QAClDF,GAAG,EAAE5B,oBAAoB,CAACE,KAAK,CAACQ,GAAG,EAAEW,KAAK,CAACR,EAAE;MAC/C,CAAC,CAAC;IACJ,CAAC;IAEDI,YAAY,CAAC,CAAC;IACdF,MAAM,CAACuB,EAAE,CAAC,aAAa,EAAErB,YAAY,CAAC;IAEtC,OAAO,MAAM;MACXF,MAAM,CAACwB,GAAG,CAAC,aAAa,EAAEtB,YAAY,CAAC;IACzC,CAAC;EACH,CAAC,EAAE,CAACF,MAAM,EAAEC,GAAG,CAAC,CAAC;AACnB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
export function usePressInteractions(containerRef) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const container = containerRef.current;
|
|
7
|
+
if (!container) return;
|
|
8
|
+
const handleClick = e => {
|
|
9
|
+
const target = e.target;
|
|
10
|
+
const anchor = target.closest('a');
|
|
11
|
+
if (anchor && container.contains(anchor)) {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
container.addEventListener('click', handleClick);
|
|
16
|
+
return () => container.removeEventListener('click', handleClick);
|
|
17
|
+
}, [containerRef]);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=usePressInteractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","usePressInteractions","containerRef","container","current","handleClick","e","target","anchor","closest","contains","preventDefault","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["web/usePressInteractions.tsx"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,OAAO,SAASC,oBAAoBA,CAClCC,YAAoD,EACpD;EACAF,SAAS,CAAC,MAAM;IACd,MAAMG,SAAS,GAAGD,YAAY,CAACE,OAAO;IACtC,IAAI,CAACD,SAAS,EAAE;IAEhB,MAAME,WAAW,GAAIC,CAAa,IAAK;MACrC,MAAMC,MAAM,GAAGD,CAAC,CAACC,MAAqB;MAEtC,MAAMC,MAAM,GAAGD,MAAM,CAACE,OAAO,CAAC,GAAG,CAAC;MAClC,IAAID,MAAM,IAAIL,SAAS,CAACO,QAAQ,CAACF,MAAM,CAAC,EAAE;QACxCF,CAAC,CAACK,cAAc,CAAC,CAAC;MACpB;IACF,CAAC;IAEDR,SAAS,CAACS,gBAAgB,CAAC,OAAO,EAAEP,WAAW,CAAC;IAChD,OAAO,MAAMF,SAAS,CAACU,mBAAmB,CAAC,OAAO,EAAER,WAAW,CAAC;EAClE,CAAC,EAAE,CAACH,YAAY,CAAC,CAAC;AACpB","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
//TODO: When upgrading to React 19.2 migrate to useEffectEvent instead
|
|
6
|
+
export const useStableRef = value => {
|
|
7
|
+
const ref = useRef(value);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
ref.current = value;
|
|
10
|
+
}, [value]);
|
|
11
|
+
return ref;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useStableRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useStableRef","value","ref","current"],"sourceRoot":"../../../src","sources":["web/useStableRef.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAwB,OAAO;;AAEzD;AACA,OAAO,MAAMC,YAAY,GAAOC,KAAQ,IAAmB;EACzD,MAAMC,GAAG,GAAGH,MAAM,CAAIE,KAAK,CAAC;EAE5BH,SAAS,CAAC,MAAM;IACdI,GAAG,CAACC,OAAO,GAAGF,KAAK;EACrB,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAOC,GAAG;AACZ,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { EnrichedTextInput } from './web/EnrichedTextInput';
|
|
2
|
+
export { EnrichedText } from './web/EnrichedText';
|
|
2
3
|
export type { EnrichedInputStyle, EnrichedTextInputProps, OnChangeTextEvent, OnChangeHtmlEvent, OnChangeStateEvent, OnLinkDetected, OnMentionDetected, OnChangeSelectionEvent, OnKeyPressEvent, OnPasteImagesEvent, OnSubmitEditing, HtmlStyle, MentionStyleProperties, FocusEvent, BlurEvent, EnrichedTextInputInstance, ContextMenuItem, OnChangeMentionEvent, EnrichedTextHtmlStyle, OnMentionPressEvent, OnLinkPressEvent, } from './types';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { EnrichedTextProps } from '../types';
|
|
2
|
-
export declare const EnrichedText: ({ ref, children, style, htmlStyle: _htmlStyle, useHtmlNormalizer, ellipsizeMode, numberOfLines, selectable, selectionColor, allowFontScaling, onLinkPress: _onLinkPress, onMentionPress: _onMentionPress, ...rest }: EnrichedTextProps) => import("react
|
|
2
|
+
export declare const EnrichedText: ({ ref, children, style, htmlStyle: _htmlStyle, useHtmlNormalizer, ellipsizeMode, numberOfLines, selectable, selectionColor, allowFontScaling, onLinkPress: _onLinkPress, onMentionPress: _onMentionPress, ...rest }: EnrichedTextProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=EnrichedText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrichedText.d.ts","sourceRoot":"","sources":["../../../../src/native/EnrichedText.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKlD,eAAO,MAAM,YAAY,GAAI,qNAc1B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"EnrichedText.d.ts","sourceRoot":"","sources":["../../../../src/native/EnrichedText.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKlD,eAAO,MAAM,YAAY,GAAI,qNAc1B,iBAAiB,gCA0EnB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { EnrichedTextInputProps } from '../types';
|
|
2
|
-
export declare const EnrichedTextInput: ({ ref, autoFocus, editable, mentionIndicators, defaultValue, placeholder, placeholderTextColor, cursorColor, selectionColor, style, autoCapitalize, htmlStyle, linkRegex: _linkRegex, onFocus, onBlur, onChangeText, onChangeHtml, onChangeState, onLinkDetected, onMentionDetected, onStartMention, onChangeMention, onEndMention, onChangeSelection, onKeyPress, onSubmitEditing, returnKeyType, returnKeyLabel, submitBehavior, contextMenuItems, textShortcuts, androidExperimentalSynchronousEvents, useHtmlNormalizer, scrollEnabled, allowFontScaling, ...rest }: EnrichedTextInputProps) => import("react
|
|
2
|
+
export declare const EnrichedTextInput: ({ ref, autoFocus, editable, mentionIndicators, defaultValue, placeholder, placeholderTextColor, cursorColor, selectionColor, style, autoCapitalize, htmlStyle, linkRegex: _linkRegex, onFocus, onBlur, onChangeText, onChangeHtml, onChangeState, onLinkDetected, onMentionDetected, onStartMention, onChangeMention, onEndMention, onChangeSelection, onKeyPress, onSubmitEditing, returnKeyType, returnKeyLabel, submitBehavior, contextMenuItems, textShortcuts, androidExperimentalSynchronousEvents, useHtmlNormalizer, scrollEnabled, allowFontScaling, ...rest }: EnrichedTextInputProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=EnrichedTextInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrichedTextInput.d.ts","sourceRoot":"","sources":["../../../../src/native/EnrichedTextInput.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAelB,eAAO,MAAM,iBAAiB,GAAI,yiBAqC/B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"EnrichedTextInput.d.ts","sourceRoot":"","sources":["../../../../src/native/EnrichedTextInput.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAelB,eAAO,MAAM,iBAAiB,GAAI,yiBAqC/B,sBAAsB,gCAgSxB,CAAC"}
|
|
@@ -699,7 +699,7 @@ export interface EnrichedTextProps extends ViewProps {
|
|
|
699
699
|
/** Called when the user taps a mention node inside the rendered content. */
|
|
700
700
|
onMentionPress?: (event: OnMentionPressEvent) => void;
|
|
701
701
|
}
|
|
702
|
-
interface EnrichedTextMentionStyleProperties extends MentionStyleProperties {
|
|
702
|
+
export interface EnrichedTextMentionStyleProperties extends MentionStyleProperties {
|
|
703
703
|
pressColor?: ColorValue;
|
|
704
704
|
pressBackgroundColor?: ColorValue;
|
|
705
705
|
}
|