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
|
@@ -39,6 +39,13 @@ export const ShortcutPlugin = Extension.create<ShortcutPluginOptions>({
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
return {
|
|
42
|
+
'Mod-a': ({ editor }) => {
|
|
43
|
+
const { doc } = editor.state;
|
|
44
|
+
return editor.commands.setTextSelection({
|
|
45
|
+
from: 0,
|
|
46
|
+
to: doc.content.size,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
42
49
|
'Mod-Shift-v': ({ editor }) => {
|
|
43
50
|
if (!editor.isEditable) return false;
|
|
44
51
|
insertPlainTextFromClipboard(editor).catch(() => {});
|
|
@@ -104,6 +104,9 @@ export const StrictMarksPlugin = Extension.create({
|
|
|
104
104
|
if (!selection.empty) return null;
|
|
105
105
|
|
|
106
106
|
const docChanged = !oldState.doc.eq(newState.doc);
|
|
107
|
+
const selChanged = !oldState.selection.eq(newState.selection);
|
|
108
|
+
if (!docChanged && !selChanged) return null;
|
|
109
|
+
|
|
107
110
|
const isExplicitToggle =
|
|
108
111
|
!docChanged && transactions.some((tr) => tr.storedMarks !== null);
|
|
109
112
|
if (isExplicitToggle) return null;
|
|
@@ -17,6 +17,10 @@ declare module '@tiptap/core' {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
interface StripBoldInStyledHeadingsPluginOptions {
|
|
21
|
+
getHtmlStyle: () => Required<HtmlStyle>;
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
function transactionStripBoldInCssBoldHeadings(
|
|
21
25
|
state: EditorState,
|
|
22
26
|
htmlStyle: Required<HtmlStyle>
|
|
@@ -39,41 +43,42 @@ function transactionStripBoldInCssBoldHeadings(
|
|
|
39
43
|
return tr.steps.length > 0 ? tr : null;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
export const StripBoldInStyledHeadingsPlugin =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
addCommands() {
|
|
54
|
-
return {
|
|
55
|
-
normalizeBoldInStyledHeadings:
|
|
56
|
-
() =>
|
|
57
|
-
({ state, dispatch }: CommandProps) => {
|
|
58
|
-
const htmlStyle = this.options.getHtmlStyle();
|
|
59
|
-
const tr = transactionStripBoldInCssBoldHeadings(state, htmlStyle);
|
|
60
|
-
if (!tr) return false;
|
|
61
|
-
if (dispatch) dispatch(tr);
|
|
62
|
-
return true;
|
|
46
|
+
export const StripBoldInStyledHeadingsPlugin =
|
|
47
|
+
Extension.create<StripBoldInStyledHeadingsPluginOptions>({
|
|
48
|
+
name: 'stripBoldInStyledHeadings',
|
|
49
|
+
addOptions() {
|
|
50
|
+
return {
|
|
51
|
+
getHtmlStyle: () => {
|
|
52
|
+
throw new Error(
|
|
53
|
+
'StripBoldInStyledHeadingsPlugin.configure({ getHtmlStyle }) is required'
|
|
54
|
+
);
|
|
63
55
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
addCommands() {
|
|
59
|
+
return {
|
|
60
|
+
normalizeBoldInStyledHeadings:
|
|
61
|
+
() =>
|
|
62
|
+
({ state, dispatch }: CommandProps) => {
|
|
63
|
+
const htmlStyle = this.options.getHtmlStyle();
|
|
64
|
+
const tr = transactionStripBoldInCssBoldHeadings(state, htmlStyle);
|
|
65
|
+
if (!tr) return false;
|
|
66
|
+
if (dispatch) dispatch(tr);
|
|
67
|
+
return true;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
addProseMirrorPlugins() {
|
|
72
|
+
return [
|
|
73
|
+
new Plugin({
|
|
74
|
+
key: new PluginKey('stripBoldInStyledHeadings'),
|
|
75
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
76
|
+
if (!transactions.some((tr) => tr.docChanged)) return;
|
|
77
|
+
const htmlStyle = this.options.getHtmlStyle();
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
79
|
+
return transactionStripBoldInCssBoldHeadings(newState, htmlStyle);
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
];
|
|
83
|
+
},
|
|
84
|
+
});
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
EnrichedTextHtmlStyle,
|
|
3
|
+
HtmlStyle,
|
|
4
|
+
MentionStyleProperties,
|
|
5
|
+
} from '../../types';
|
|
2
6
|
import { isMentionStyleRecord } from '../../utils/isMentionStyleRecord';
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ENRICHED_TEXT_CLASSNAME,
|
|
9
|
+
ENRICHED_TEXT_INPUT_CLASSNAME,
|
|
10
|
+
} from '../constants/classNames';
|
|
11
|
+
import { ET_MENTION_CSS_VARS } from './htmlStyleToCSSVariables';
|
|
4
12
|
import { MENTION_STYLE_DEFAULT_KEY } from './mentionIndicatorCssKey';
|
|
5
13
|
|
|
6
14
|
function escapeIndicatorForCssAttributeSelector(indicator: string): string {
|
|
@@ -10,7 +18,15 @@ function escapeIndicatorForCssAttributeSelector(indicator: string): string {
|
|
|
10
18
|
return indicator.replace(/["\\]/g, '\\$&');
|
|
11
19
|
}
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
function mentionSelector(className: string, indicator: string): string {
|
|
22
|
+
return indicator === MENTION_STYLE_DEFAULT_KEY
|
|
23
|
+
? `.${className} mention`
|
|
24
|
+
: `.${className} mention[indicator="${escapeIndicatorForCssAttributeSelector(indicator)}"]`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function buildMentionRulesCSS(
|
|
28
|
+
htmlStyle?: HtmlStyle | EnrichedTextHtmlStyle
|
|
29
|
+
): string {
|
|
14
30
|
const mapRaw = htmlStyle?.mention;
|
|
15
31
|
if (!mapRaw || typeof mapRaw !== 'object' || !isMentionStyleRecord(mapRaw)) {
|
|
16
32
|
return '';
|
|
@@ -23,17 +39,20 @@ export function buildMentionRulesCSS(htmlStyle?: HtmlStyle): string {
|
|
|
23
39
|
}
|
|
24
40
|
|
|
25
41
|
const lines: string[] = [];
|
|
42
|
+
|
|
26
43
|
for (const indicator of keys) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
const inputSelector = mentionSelector(
|
|
45
|
+
ENRICHED_TEXT_INPUT_CLASSNAME,
|
|
46
|
+
indicator
|
|
47
|
+
);
|
|
48
|
+
const textSelector = mentionSelector(ENRICHED_TEXT_CLASSNAME, indicator);
|
|
31
49
|
|
|
32
50
|
lines.push(
|
|
33
|
-
`${
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
`${inputSelector},
|
|
52
|
+
${textSelector} {
|
|
53
|
+
color: var(${ET_MENTION_CSS_VARS.color(indicator)});
|
|
54
|
+
background-color: var(${ET_MENTION_CSS_VARS.backgroundColor(indicator)});
|
|
55
|
+
text-decoration-line: var(${ET_MENTION_CSS_VARS.textDecorationLine(indicator)});
|
|
37
56
|
}`.trim()
|
|
38
57
|
);
|
|
39
58
|
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { EnrichedInputStyle } from '../../types';
|
|
3
|
+
import type {
|
|
4
|
+
AnimatableNumericValue,
|
|
5
|
+
DimensionValue,
|
|
6
|
+
TextStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { toColor } from './toColor';
|
|
9
|
+
|
|
10
|
+
export interface StyleConversionExtraOptions {
|
|
11
|
+
scrollEnabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function enrichedBaseStyleToCSSProperties(
|
|
15
|
+
style: EnrichedInputStyle | TextStyle,
|
|
16
|
+
extraOptions: StyleConversionExtraOptions = {}
|
|
17
|
+
): CSSProperties {
|
|
18
|
+
const css: CSSProperties = {
|
|
19
|
+
// Dimensions
|
|
20
|
+
width: toPx(style.width),
|
|
21
|
+
height: toPx(style.height),
|
|
22
|
+
minWidth: toPx(style.minWidth),
|
|
23
|
+
maxWidth: toPx(style.maxWidth),
|
|
24
|
+
minHeight: toPx(style.minHeight),
|
|
25
|
+
maxHeight: toPx(style.maxHeight),
|
|
26
|
+
top: toPx(style.top),
|
|
27
|
+
bottom: toPx(style.bottom),
|
|
28
|
+
left: toPx(style.left),
|
|
29
|
+
right: toPx(style.right),
|
|
30
|
+
inset: toPx(style.inset),
|
|
31
|
+
insetBlock: toPx(style.insetBlock),
|
|
32
|
+
insetBlockEnd: toPx(style.insetBlockEnd),
|
|
33
|
+
insetBlockStart: toPx(style.insetBlockStart),
|
|
34
|
+
insetInline: toPx(style.insetInline),
|
|
35
|
+
insetInlineEnd: toPx(style.insetInlineEnd ?? style.end),
|
|
36
|
+
insetInlineStart: toPx(style.insetInlineStart ?? style.start),
|
|
37
|
+
|
|
38
|
+
// Margin - specific properties take precedence over shorthands (RN behavior)
|
|
39
|
+
margin: toPx(style.margin),
|
|
40
|
+
marginTop: toPx(style.marginTop ?? style.marginVertical),
|
|
41
|
+
marginBottom: toPx(style.marginBottom ?? style.marginVertical),
|
|
42
|
+
marginLeft: toPx(style.marginLeft ?? style.marginHorizontal),
|
|
43
|
+
marginRight: toPx(style.marginRight ?? style.marginHorizontal),
|
|
44
|
+
marginBlock: toPx(style.marginBlock),
|
|
45
|
+
marginBlockEnd: toPx(style.marginBlockEnd),
|
|
46
|
+
marginBlockStart: toPx(style.marginBlockStart),
|
|
47
|
+
marginInline: toPx(style.marginInline),
|
|
48
|
+
marginInlineEnd: toPx(style.marginInlineEnd ?? style.marginEnd),
|
|
49
|
+
marginInlineStart: toPx(style.marginInlineStart ?? style.marginStart),
|
|
50
|
+
|
|
51
|
+
// Padding - specific properties take precedence over shorthands (RN behavior)
|
|
52
|
+
padding: toPx(style.padding),
|
|
53
|
+
paddingTop: toPx(style.paddingTop ?? style.paddingVertical),
|
|
54
|
+
paddingBottom: toPx(style.paddingBottom ?? style.paddingVertical),
|
|
55
|
+
paddingLeft: toPx(style.paddingLeft ?? style.paddingHorizontal),
|
|
56
|
+
paddingRight: toPx(style.paddingRight ?? style.paddingHorizontal),
|
|
57
|
+
paddingBlock: toPx(style.paddingBlock),
|
|
58
|
+
paddingBlockEnd: toPx(style.paddingBlockEnd),
|
|
59
|
+
paddingBlockStart: toPx(style.paddingBlockStart),
|
|
60
|
+
paddingInline: toPx(style.paddingInline),
|
|
61
|
+
paddingInlineEnd: toPx(style.paddingInlineEnd ?? style.paddingEnd),
|
|
62
|
+
paddingInlineStart: toPx(style.paddingInlineStart ?? style.paddingStart),
|
|
63
|
+
|
|
64
|
+
// Border widths
|
|
65
|
+
borderInlineStartWidth: toPx(style.borderStartWidth),
|
|
66
|
+
borderInlineEndWidth: toPx(style.borderEndWidth),
|
|
67
|
+
borderWidth: toPx(style.borderWidth),
|
|
68
|
+
borderTopWidth: toPx(style.borderTopWidth),
|
|
69
|
+
borderBottomWidth: toPx(style.borderBottomWidth),
|
|
70
|
+
borderLeftWidth: toPx(style.borderLeftWidth),
|
|
71
|
+
borderRightWidth: toPx(style.borderRightWidth),
|
|
72
|
+
|
|
73
|
+
// Border radius (physical)
|
|
74
|
+
borderRadius: toPx(style.borderRadius),
|
|
75
|
+
borderTopLeftRadius: toPx(style.borderTopLeftRadius),
|
|
76
|
+
borderTopRightRadius: toPx(style.borderTopRightRadius),
|
|
77
|
+
borderBottomLeftRadius: toPx(style.borderBottomLeftRadius),
|
|
78
|
+
borderBottomRightRadius: toPx(style.borderBottomRightRadius),
|
|
79
|
+
|
|
80
|
+
// Border radius (logical)
|
|
81
|
+
borderStartStartRadius: toPx(
|
|
82
|
+
style.borderStartStartRadius ?? style.borderTopStartRadius
|
|
83
|
+
),
|
|
84
|
+
borderStartEndRadius: toPx(
|
|
85
|
+
style.borderStartEndRadius ?? style.borderTopEndRadius
|
|
86
|
+
),
|
|
87
|
+
borderEndStartRadius: toPx(
|
|
88
|
+
style.borderEndStartRadius ?? style.borderBottomStartRadius
|
|
89
|
+
),
|
|
90
|
+
borderEndEndRadius: toPx(
|
|
91
|
+
style.borderEndEndRadius ?? style.borderBottomEndRadius
|
|
92
|
+
),
|
|
93
|
+
|
|
94
|
+
// Border colors
|
|
95
|
+
borderColor: toColor(style.borderColor),
|
|
96
|
+
borderBlockColor: toColor(style.borderBlockColor),
|
|
97
|
+
borderBlockEndColor: toColor(style.borderBlockEndColor),
|
|
98
|
+
borderBlockStartColor: toColor(style.borderBlockStartColor),
|
|
99
|
+
borderBottomColor: toColor(style.borderBottomColor),
|
|
100
|
+
borderInlineEndColor: toColor(style.borderEndColor),
|
|
101
|
+
borderLeftColor: toColor(style.borderLeftColor),
|
|
102
|
+
borderRightColor: toColor(style.borderRightColor),
|
|
103
|
+
borderInlineStartColor: toColor(style.borderStartColor),
|
|
104
|
+
borderTopColor: toColor(style.borderTopColor),
|
|
105
|
+
borderStyle:
|
|
106
|
+
style.borderStyle ??
|
|
107
|
+
(style.borderWidth != null ||
|
|
108
|
+
style.borderTopWidth != null ||
|
|
109
|
+
style.borderBottomWidth != null ||
|
|
110
|
+
style.borderLeftWidth != null ||
|
|
111
|
+
style.borderRightWidth != null ||
|
|
112
|
+
style.borderStartWidth != null ||
|
|
113
|
+
style.borderEndWidth != null ||
|
|
114
|
+
style.borderColor != null
|
|
115
|
+
? 'solid'
|
|
116
|
+
: undefined),
|
|
117
|
+
|
|
118
|
+
// Typography
|
|
119
|
+
color: toColor(style.color),
|
|
120
|
+
fontFamily: style.fontFamily,
|
|
121
|
+
fontSize: toPx(style.fontSize),
|
|
122
|
+
fontStyle: style.fontStyle,
|
|
123
|
+
fontWeight: style.fontWeight,
|
|
124
|
+
lineHeight: toPx(style.lineHeight),
|
|
125
|
+
letterSpacing: toPx(style.letterSpacing),
|
|
126
|
+
|
|
127
|
+
// View appearance
|
|
128
|
+
backgroundColor: toColor(style.backgroundColor),
|
|
129
|
+
// boxShadow/filter: RN accepts arrays, CSS only strings
|
|
130
|
+
boxShadow:
|
|
131
|
+
typeof style.boxShadow === 'string' ? style.boxShadow : undefined,
|
|
132
|
+
display: style.display,
|
|
133
|
+
position: style.position,
|
|
134
|
+
alignSelf: style.alignSelf,
|
|
135
|
+
backfaceVisibility: style.backfaceVisibility,
|
|
136
|
+
cursor: style.cursor,
|
|
137
|
+
filter: typeof style.filter === 'string' ? style.filter : undefined,
|
|
138
|
+
mixBlendMode: style.mixBlendMode,
|
|
139
|
+
boxSizing: style.boxSizing,
|
|
140
|
+
// pointerEvents: RN 'box-none'/'box-only' have no CSS equivalent
|
|
141
|
+
pointerEvents:
|
|
142
|
+
style.pointerEvents === 'auto' || style.pointerEvents === 'none'
|
|
143
|
+
? style.pointerEvents
|
|
144
|
+
: undefined,
|
|
145
|
+
|
|
146
|
+
// Outline
|
|
147
|
+
outlineColor: toColor(style.outlineColor),
|
|
148
|
+
outlineStyle:
|
|
149
|
+
style.outlineStyle ?? (style.outlineWidth != null ? 'solid' : undefined),
|
|
150
|
+
outlineOffset: toPx(style.outlineOffset),
|
|
151
|
+
outlineWidth: toPx(style.outlineWidth),
|
|
152
|
+
|
|
153
|
+
// Transforms
|
|
154
|
+
transform: resolveTransform(style.transform),
|
|
155
|
+
// transformOrigin: RN accepts strings or arrays, CSS only strings
|
|
156
|
+
transformOrigin:
|
|
157
|
+
typeof style.transformOrigin === 'string'
|
|
158
|
+
? style.transformOrigin
|
|
159
|
+
: undefined,
|
|
160
|
+
|
|
161
|
+
// Flex
|
|
162
|
+
flex: style.flex,
|
|
163
|
+
flexGrow: style.flexGrow,
|
|
164
|
+
flexShrink: style.flexShrink,
|
|
165
|
+
flexBasis: toPx(style.flexBasis),
|
|
166
|
+
|
|
167
|
+
// Misc
|
|
168
|
+
zIndex: style.zIndex,
|
|
169
|
+
// opacity: RN AnimatableNumericValue includes AnimatedNode; CSS only number
|
|
170
|
+
opacity: typeof style.opacity === 'number' ? style.opacity : undefined,
|
|
171
|
+
aspectRatio: style.aspectRatio,
|
|
172
|
+
|
|
173
|
+
// Extra options
|
|
174
|
+
overflowY:
|
|
175
|
+
extraOptions.scrollEnabled != null
|
|
176
|
+
? extraOptions.scrollEnabled
|
|
177
|
+
? 'auto'
|
|
178
|
+
: 'hidden'
|
|
179
|
+
: undefined,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Clean undefined values
|
|
183
|
+
return Object.fromEntries(
|
|
184
|
+
Object.entries(css).filter(([, v]) => v !== undefined)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function toPx(
|
|
189
|
+
value?: DimensionValue | AnimatableNumericValue | string
|
|
190
|
+
): string | undefined {
|
|
191
|
+
if (value == null) return undefined;
|
|
192
|
+
if (typeof value === 'number') return `${value}px`;
|
|
193
|
+
if (typeof value === 'string') return value;
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function resolveTransform(
|
|
198
|
+
transform: EnrichedInputStyle['transform']
|
|
199
|
+
): string | undefined {
|
|
200
|
+
if (typeof transform === 'string') return transform;
|
|
201
|
+
if (!Array.isArray(transform)) return undefined;
|
|
202
|
+
|
|
203
|
+
const parts = transform.map((item) => {
|
|
204
|
+
if ('translateX' in item) return `translateX(${item.translateX}px)`;
|
|
205
|
+
if ('translateY' in item) return `translateY(${item.translateY}px)`;
|
|
206
|
+
if ('translateZ' in item) return `translateZ(${item.translateZ}px)`;
|
|
207
|
+
if ('scale' in item) return `scale(${item.scale})`;
|
|
208
|
+
if ('scaleX' in item) return `scaleX(${item.scaleX})`;
|
|
209
|
+
if ('scaleY' in item) return `scaleY(${item.scaleY})`;
|
|
210
|
+
if ('scaleZ' in item) return `scaleZ(${item.scaleZ})`;
|
|
211
|
+
if ('rotate' in item) return `rotate(${item.rotate})`;
|
|
212
|
+
if ('rotateX' in item) return `rotateX(${item.rotateX})`;
|
|
213
|
+
if ('rotateY' in item) return `rotateY(${item.rotateY})`;
|
|
214
|
+
if ('rotateZ' in item) return `rotateZ(${item.rotateZ})`;
|
|
215
|
+
if ('skewX' in item) return `skewX(${item.skewX})`;
|
|
216
|
+
if ('skewY' in item) return `skewY(${item.skewY})`;
|
|
217
|
+
if ('perspective' in item) return `perspective(${item.perspective}px)`;
|
|
218
|
+
if ('matrix' in item) {
|
|
219
|
+
return item.matrix.length === 16
|
|
220
|
+
? `matrix3d(${item.matrix.join(', ')})`
|
|
221
|
+
: `matrix(${item.matrix.join(', ')})`;
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const css = parts.filter(Boolean).join(' ');
|
|
227
|
+
return css || undefined;
|
|
228
|
+
}
|
|
@@ -1,224 +1,13 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
2
|
import type { EnrichedInputStyle } from '../../types';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
scrollEnabled?: boolean;
|
|
8
|
-
}
|
|
3
|
+
import {
|
|
4
|
+
enrichedBaseStyleToCSSProperties,
|
|
5
|
+
type StyleConversionExtraOptions,
|
|
6
|
+
} from './enrichedBaseStyleToCSSProperties';
|
|
9
7
|
|
|
10
8
|
export function enrichedInputStyleToCSSProperties(
|
|
11
9
|
style: EnrichedInputStyle,
|
|
12
|
-
extraOptions
|
|
10
|
+
extraOptions?: StyleConversionExtraOptions
|
|
13
11
|
): CSSProperties {
|
|
14
|
-
|
|
15
|
-
// Dimensions
|
|
16
|
-
width: toPx(style.width),
|
|
17
|
-
height: toPx(style.height),
|
|
18
|
-
minWidth: toPx(style.minWidth),
|
|
19
|
-
maxWidth: toPx(style.maxWidth),
|
|
20
|
-
minHeight: toPx(style.minHeight),
|
|
21
|
-
maxHeight: toPx(style.maxHeight),
|
|
22
|
-
top: toPx(style.top),
|
|
23
|
-
bottom: toPx(style.bottom),
|
|
24
|
-
left: toPx(style.left),
|
|
25
|
-
right: toPx(style.right),
|
|
26
|
-
inset: toPx(style.inset),
|
|
27
|
-
insetBlock: toPx(style.insetBlock),
|
|
28
|
-
insetBlockEnd: toPx(style.insetBlockEnd),
|
|
29
|
-
insetBlockStart: toPx(style.insetBlockStart),
|
|
30
|
-
insetInline: toPx(style.insetInline),
|
|
31
|
-
insetInlineEnd: toPx(style.insetInlineEnd ?? style.end),
|
|
32
|
-
insetInlineStart: toPx(style.insetInlineStart ?? style.start),
|
|
33
|
-
|
|
34
|
-
// Margin - specific properties take precedence over shorthands (RN behavior)
|
|
35
|
-
margin: toPx(style.margin),
|
|
36
|
-
marginTop: toPx(style.marginTop ?? style.marginVertical),
|
|
37
|
-
marginBottom: toPx(style.marginBottom ?? style.marginVertical),
|
|
38
|
-
marginLeft: toPx(style.marginLeft ?? style.marginHorizontal),
|
|
39
|
-
marginRight: toPx(style.marginRight ?? style.marginHorizontal),
|
|
40
|
-
marginBlock: toPx(style.marginBlock),
|
|
41
|
-
marginBlockEnd: toPx(style.marginBlockEnd),
|
|
42
|
-
marginBlockStart: toPx(style.marginBlockStart),
|
|
43
|
-
marginInline: toPx(style.marginInline),
|
|
44
|
-
marginInlineEnd: toPx(style.marginInlineEnd ?? style.marginEnd),
|
|
45
|
-
marginInlineStart: toPx(style.marginInlineStart ?? style.marginStart),
|
|
46
|
-
|
|
47
|
-
// Padding - specific properties take precedence over shorthands (RN behavior)
|
|
48
|
-
padding: toPx(style.padding),
|
|
49
|
-
paddingTop: toPx(style.paddingTop ?? style.paddingVertical),
|
|
50
|
-
paddingBottom: toPx(style.paddingBottom ?? style.paddingVertical),
|
|
51
|
-
paddingLeft: toPx(style.paddingLeft ?? style.paddingHorizontal),
|
|
52
|
-
paddingRight: toPx(style.paddingRight ?? style.paddingHorizontal),
|
|
53
|
-
paddingBlock: toPx(style.paddingBlock),
|
|
54
|
-
paddingBlockEnd: toPx(style.paddingBlockEnd),
|
|
55
|
-
paddingBlockStart: toPx(style.paddingBlockStart),
|
|
56
|
-
paddingInline: toPx(style.paddingInline),
|
|
57
|
-
paddingInlineEnd: toPx(style.paddingInlineEnd ?? style.paddingEnd),
|
|
58
|
-
paddingInlineStart: toPx(style.paddingInlineStart ?? style.paddingStart),
|
|
59
|
-
|
|
60
|
-
// Border widths
|
|
61
|
-
borderInlineStartWidth: toPx(style.borderStartWidth),
|
|
62
|
-
borderInlineEndWidth: toPx(style.borderEndWidth),
|
|
63
|
-
borderWidth: toPx(style.borderWidth),
|
|
64
|
-
borderTopWidth: toPx(style.borderTopWidth),
|
|
65
|
-
borderBottomWidth: toPx(style.borderBottomWidth),
|
|
66
|
-
borderLeftWidth: toPx(style.borderLeftWidth),
|
|
67
|
-
borderRightWidth: toPx(style.borderRightWidth),
|
|
68
|
-
|
|
69
|
-
// Border radius (physical)
|
|
70
|
-
borderRadius: toPx(style.borderRadius),
|
|
71
|
-
borderTopLeftRadius: toPx(style.borderTopLeftRadius),
|
|
72
|
-
borderTopRightRadius: toPx(style.borderTopRightRadius),
|
|
73
|
-
borderBottomLeftRadius: toPx(style.borderBottomLeftRadius),
|
|
74
|
-
borderBottomRightRadius: toPx(style.borderBottomRightRadius),
|
|
75
|
-
|
|
76
|
-
// Border radius (logical)
|
|
77
|
-
borderStartStartRadius: toPx(
|
|
78
|
-
style.borderStartStartRadius ?? style.borderTopStartRadius
|
|
79
|
-
),
|
|
80
|
-
borderStartEndRadius: toPx(
|
|
81
|
-
style.borderStartEndRadius ?? style.borderTopEndRadius
|
|
82
|
-
),
|
|
83
|
-
borderEndStartRadius: toPx(
|
|
84
|
-
style.borderEndStartRadius ?? style.borderBottomStartRadius
|
|
85
|
-
),
|
|
86
|
-
borderEndEndRadius: toPx(
|
|
87
|
-
style.borderEndEndRadius ?? style.borderBottomEndRadius
|
|
88
|
-
),
|
|
89
|
-
|
|
90
|
-
// Border colors
|
|
91
|
-
borderColor: toColor(style.borderColor),
|
|
92
|
-
borderBlockColor: toColor(style.borderBlockColor),
|
|
93
|
-
borderBlockEndColor: toColor(style.borderBlockEndColor),
|
|
94
|
-
borderBlockStartColor: toColor(style.borderBlockStartColor),
|
|
95
|
-
borderBottomColor: toColor(style.borderBottomColor),
|
|
96
|
-
borderInlineEndColor: toColor(style.borderEndColor),
|
|
97
|
-
borderLeftColor: toColor(style.borderLeftColor),
|
|
98
|
-
borderRightColor: toColor(style.borderRightColor),
|
|
99
|
-
borderInlineStartColor: toColor(style.borderStartColor),
|
|
100
|
-
borderTopColor: toColor(style.borderTopColor),
|
|
101
|
-
borderStyle:
|
|
102
|
-
style.borderStyle ??
|
|
103
|
-
(style.borderWidth != null ||
|
|
104
|
-
style.borderTopWidth != null ||
|
|
105
|
-
style.borderBottomWidth != null ||
|
|
106
|
-
style.borderLeftWidth != null ||
|
|
107
|
-
style.borderRightWidth != null ||
|
|
108
|
-
style.borderStartWidth != null ||
|
|
109
|
-
style.borderEndWidth != null ||
|
|
110
|
-
style.borderColor != null
|
|
111
|
-
? 'solid'
|
|
112
|
-
: undefined),
|
|
113
|
-
|
|
114
|
-
// Typography
|
|
115
|
-
color: toColor(style.color),
|
|
116
|
-
fontFamily: style.fontFamily,
|
|
117
|
-
fontSize: toPx(style.fontSize),
|
|
118
|
-
fontStyle: style.fontStyle,
|
|
119
|
-
fontWeight: style.fontWeight,
|
|
120
|
-
lineHeight: toPx(style.lineHeight),
|
|
121
|
-
letterSpacing: toPx(style.letterSpacing),
|
|
122
|
-
|
|
123
|
-
// View appearance
|
|
124
|
-
backgroundColor: toColor(style.backgroundColor),
|
|
125
|
-
// boxShadow/filter: RN accepts arrays, CSS only strings
|
|
126
|
-
boxShadow:
|
|
127
|
-
typeof style.boxShadow === 'string' ? style.boxShadow : undefined,
|
|
128
|
-
display: style.display,
|
|
129
|
-
position: style.position,
|
|
130
|
-
alignSelf: style.alignSelf,
|
|
131
|
-
backfaceVisibility: style.backfaceVisibility,
|
|
132
|
-
cursor: style.cursor,
|
|
133
|
-
filter: typeof style.filter === 'string' ? style.filter : undefined,
|
|
134
|
-
mixBlendMode: style.mixBlendMode,
|
|
135
|
-
boxSizing: style.boxSizing,
|
|
136
|
-
// pointerEvents: RN 'box-none'/'box-only' have no CSS equivalent
|
|
137
|
-
pointerEvents:
|
|
138
|
-
style.pointerEvents === 'auto' || style.pointerEvents === 'none'
|
|
139
|
-
? style.pointerEvents
|
|
140
|
-
: undefined,
|
|
141
|
-
|
|
142
|
-
// Outline
|
|
143
|
-
outlineColor: toColor(style.outlineColor),
|
|
144
|
-
outlineStyle:
|
|
145
|
-
style.outlineStyle ?? (style.outlineWidth != null ? 'solid' : undefined),
|
|
146
|
-
outlineOffset: toPx(style.outlineOffset),
|
|
147
|
-
outlineWidth: toPx(style.outlineWidth),
|
|
148
|
-
|
|
149
|
-
// Transforms
|
|
150
|
-
transform: resolveTransform(style.transform),
|
|
151
|
-
// transformOrigin: RN accepts strings or arrays, CSS only strings
|
|
152
|
-
transformOrigin:
|
|
153
|
-
typeof style.transformOrigin === 'string'
|
|
154
|
-
? style.transformOrigin
|
|
155
|
-
: undefined,
|
|
156
|
-
|
|
157
|
-
// Flex
|
|
158
|
-
flex: style.flex,
|
|
159
|
-
flexGrow: style.flexGrow,
|
|
160
|
-
flexShrink: style.flexShrink,
|
|
161
|
-
flexBasis: toPx(style.flexBasis),
|
|
162
|
-
|
|
163
|
-
// Misc
|
|
164
|
-
zIndex: style.zIndex,
|
|
165
|
-
// opacity: RN AnimatableNumericValue includes AnimatedNode; CSS only number
|
|
166
|
-
opacity: typeof style.opacity === 'number' ? style.opacity : undefined,
|
|
167
|
-
aspectRatio: style.aspectRatio,
|
|
168
|
-
|
|
169
|
-
// Extra options
|
|
170
|
-
overflowY:
|
|
171
|
-
extraOptions.scrollEnabled != null
|
|
172
|
-
? extraOptions.scrollEnabled
|
|
173
|
-
? 'auto'
|
|
174
|
-
: 'hidden'
|
|
175
|
-
: undefined,
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
// Clean undefined values
|
|
179
|
-
return Object.fromEntries(
|
|
180
|
-
Object.entries(css).filter(([, v]) => v !== undefined)
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function toPx(
|
|
185
|
-
value?: DimensionValue | AnimatableNumericValue | string
|
|
186
|
-
): string | undefined {
|
|
187
|
-
if (value == null) return undefined;
|
|
188
|
-
if (typeof value === 'number') return `${value}px`;
|
|
189
|
-
if (typeof value === 'string') return value;
|
|
190
|
-
return undefined;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function resolveTransform(
|
|
194
|
-
transform: EnrichedInputStyle['transform']
|
|
195
|
-
): string | undefined {
|
|
196
|
-
if (typeof transform === 'string') return transform;
|
|
197
|
-
if (!Array.isArray(transform)) return undefined;
|
|
198
|
-
|
|
199
|
-
const parts = transform.map((item) => {
|
|
200
|
-
if ('translateX' in item) return `translateX(${item.translateX}px)`;
|
|
201
|
-
if ('translateY' in item) return `translateY(${item.translateY}px)`;
|
|
202
|
-
if ('translateZ' in item) return `translateZ(${item.translateZ}px)`;
|
|
203
|
-
if ('scale' in item) return `scale(${item.scale})`;
|
|
204
|
-
if ('scaleX' in item) return `scaleX(${item.scaleX})`;
|
|
205
|
-
if ('scaleY' in item) return `scaleY(${item.scaleY})`;
|
|
206
|
-
if ('scaleZ' in item) return `scaleZ(${item.scaleZ})`;
|
|
207
|
-
if ('rotate' in item) return `rotate(${item.rotate})`;
|
|
208
|
-
if ('rotateX' in item) return `rotateX(${item.rotateX})`;
|
|
209
|
-
if ('rotateY' in item) return `rotateY(${item.rotateY})`;
|
|
210
|
-
if ('rotateZ' in item) return `rotateZ(${item.rotateZ})`;
|
|
211
|
-
if ('skewX' in item) return `skewX(${item.skewX})`;
|
|
212
|
-
if ('skewY' in item) return `skewY(${item.skewY})`;
|
|
213
|
-
if ('perspective' in item) return `perspective(${item.perspective}px)`;
|
|
214
|
-
if ('matrix' in item) {
|
|
215
|
-
return item.matrix.length === 16
|
|
216
|
-
? `matrix3d(${item.matrix.join(', ')})`
|
|
217
|
-
: `matrix(${item.matrix.join(', ')})`;
|
|
218
|
-
}
|
|
219
|
-
return null;
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
const css = parts.filter(Boolean).join(' ');
|
|
223
|
-
return css || undefined;
|
|
12
|
+
return enrichedBaseStyleToCSSProperties(style, extraOptions);
|
|
224
13
|
}
|