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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isTextSelection } from '@tiptap/core';
|
|
4
|
+
import { TextAlign } from '@tiptap/extension-text-align';
|
|
5
|
+
export const EnrichedTextAlign = TextAlign.extend({
|
|
6
|
+
addCommands() {
|
|
7
|
+
return {
|
|
8
|
+
...this.parent?.(),
|
|
9
|
+
setTextAlign: alignment => props => {
|
|
10
|
+
const {
|
|
11
|
+
state,
|
|
12
|
+
dispatch,
|
|
13
|
+
tr
|
|
14
|
+
} = props;
|
|
15
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
$from
|
|
20
|
+
} = state.selection;
|
|
21
|
+
let listNode = null;
|
|
22
|
+
let listPos = -1;
|
|
23
|
+
|
|
24
|
+
// Walk up the tree to see if the cursor is inside a list wrapper
|
|
25
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
26
|
+
const node = $from.node(depth);
|
|
27
|
+
if (['orderedList', 'unorderedList', 'checkboxList'].includes(node.type.name)) {
|
|
28
|
+
listNode = node;
|
|
29
|
+
listPos = $from.before(depth);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// If in a list, manually apply the alignment to the parent wrapper
|
|
35
|
+
if (listNode) {
|
|
36
|
+
if (dispatch) {
|
|
37
|
+
tr.setNodeMarkup(listPos, undefined, {
|
|
38
|
+
...listNode.attrs,
|
|
39
|
+
textAlign: alignment
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// If not in a list, fire the original Tiptap command
|
|
46
|
+
return this.parent?.().setTextAlign?.(alignment)(props) ?? false;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
addKeyboardShortcuts() {
|
|
51
|
+
return {
|
|
52
|
+
...this.parent?.(),
|
|
53
|
+
Backspace: () => {
|
|
54
|
+
const {
|
|
55
|
+
selection
|
|
56
|
+
} = this.editor.state;
|
|
57
|
+
if (!selection.empty || !isTextSelection(selection)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const {
|
|
61
|
+
$cursor
|
|
62
|
+
} = selection;
|
|
63
|
+
if (!$cursor || !this.editor.isEmpty) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const currentAlignment = $cursor.parent.attrs.textAlign;
|
|
67
|
+
const hasAlignment = currentAlignment && currentAlignment !== 'auto';
|
|
68
|
+
|
|
69
|
+
// If the input is empty and has an alignment, clear the alignment
|
|
70
|
+
if (hasAlignment) {
|
|
71
|
+
return this.editor.commands.unsetTextAlign();
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}).configure({
|
|
78
|
+
types: ['paragraph', 'heading', 'orderedList', 'unorderedList', 'checkboxList'],
|
|
79
|
+
defaultAlignment: null,
|
|
80
|
+
alignments: ['left', 'center', 'right', 'justify']
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=EnrichedTextAlign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isTextSelection","TextAlign","EnrichedTextAlign","extend","addCommands","parent","setTextAlign","alignment","props","state","dispatch","tr","options","alignments","includes","$from","selection","listNode","listPos","depth","node","type","name","before","setNodeMarkup","undefined","attrs","textAlign","addKeyboardShortcuts","Backspace","editor","empty","$cursor","isEmpty","currentAlignment","hasAlignment","commands","unsetTextAlign","configure","types","defaultAlignment"],"sourceRoot":"../../../../src","sources":["web/formats/EnrichedTextAlign.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,SAASC,SAAS,QAAQ,8BAA8B;AAExD,OAAO,MAAMC,iBAAiB,GAAGD,SAAS,CAACE,MAAM,CAAC;EAChDC,WAAWA,CAAA,EAAG;IACZ,OAAO;MACL,GAAG,IAAI,CAACC,MAAM,GAAG,CAAC;MAClBC,YAAY,EAAGC,SAAS,IAAMC,KAAK,IAAK;QACtC,MAAM;UAAEC,KAAK;UAAEC,QAAQ;UAAEC;QAAG,CAAC,GAAGH,KAAK;QAErC,IAAI,CAAC,IAAI,CAACI,OAAO,CAACC,UAAU,CAACC,QAAQ,CAACP,SAAS,CAAC,EAAE;UAChD,OAAO,KAAK;QACd;QAEA,MAAM;UAAEQ;QAAM,CAAC,GAAGN,KAAK,CAACO,SAAS;QACjC,IAAIC,QAAoC,GAAG,IAAI;QAC/C,IAAIC,OAAO,GAAG,CAAC,CAAC;;QAEhB;QACA,KAAK,IAAIC,KAAK,GAAGJ,KAAK,CAACI,KAAK,EAAEA,KAAK,GAAG,CAAC,EAAEA,KAAK,EAAE,EAAE;UAChD,MAAMC,IAAI,GAAGL,KAAK,CAACK,IAAI,CAACD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AACC,cAAc,CAAC,CAAC;QAC9C;QAEA,OAAO,KAAK;MACd;IACF,CAAC;EACH;AACF,CAAC,CAAC,CAACC,SAAS,CAAC;EACXC,KAAK,EAAE,CACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,CACf;EACDC,gBAAgB,EAAE,IAAI;EACtB3B,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;AACnD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { wrappingInputRule } from '@tiptap/core';
|
|
4
4
|
import { BulletList } from '@tiptap/extension-list';
|
|
5
5
|
import { applyWrappingListToSelection } from "./applyWrappingListToSelection.js";
|
|
6
|
+
import { withPreservedAlignment } from "./formatRules.js";
|
|
6
7
|
const BULLET_LIST_INPUT_REGEX = /^\s*-\s$/;
|
|
7
8
|
export const EnrichedUnorderedList = BulletList.extend({
|
|
8
9
|
name: 'unorderedList',
|
|
@@ -19,11 +20,10 @@ export const EnrichedUnorderedList = BulletList.extend({
|
|
|
19
20
|
return {
|
|
20
21
|
toggleUnorderedList: () => ({
|
|
21
22
|
editor,
|
|
22
|
-
commands,
|
|
23
23
|
chain
|
|
24
24
|
}) => {
|
|
25
25
|
if (editor.isActive('unorderedList')) {
|
|
26
|
-
return
|
|
26
|
+
return withPreservedAlignment(editor, chain(), c => c.clearNodes().setParagraph());
|
|
27
27
|
}
|
|
28
28
|
return applyWrappingListToSelection(editor, chain, 'unorderedList', 'listItem');
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wrappingInputRule","BulletList","applyWrappingListToSelection","BULLET_LIST_INPUT_REGEX","EnrichedUnorderedList","extend","name","addInputRules","find","type","addKeyboardShortcuts","addCommands","toggleUnorderedList","editor","
|
|
1
|
+
{"version":3,"names":["wrappingInputRule","BulletList","applyWrappingListToSelection","withPreservedAlignment","BULLET_LIST_INPUT_REGEX","EnrichedUnorderedList","extend","name","addInputRules","find","type","addKeyboardShortcuts","addCommands","toggleUnorderedList","editor","chain","isActive","c","clearNodes","setParagraph"],"sourceRoot":"../../../../src","sources":["web/formats/EnrichedUnorderedList.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAA2B,cAAc;AACnE,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,4BAA4B,QAAQ,mCAAgC;AAC7E,SAASC,sBAAsB,QAAQ,kBAAe;AAUtD,MAAMC,uBAAuB,GAAG,UAAU;AAE1C,OAAO,MAAMC,qBAAqB,GAAGJ,UAAU,CAACK,MAAM,CAAC;EACrDC,IAAI,EAAE,eAAe;EAErBC,aAAaA,CAAA,EAAG;IACd,OAAO,CACLR,iBAAiB,CAAC;MAChBS,IAAI,EAAEL,uBAAuB;MAC7BM,IAAI,EAAE,IAAI,CAACA;IACb,CAAC,CAAC,CACH;EACH,CAAC;EAEDC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,CAAC,CAAC;EACX,CAAC;EAEDC,WAAWA,CAAA,EAAG;IACZ,OAAO;MACLC,mBAAmB,EACjBA,CAAA,KACA,CAAC;QAAEC,MAAM;QAAEC;MAAoB,CAAC,KAAK;QACnC,IAAID,MAAM,CAACE,QAAQ,CAAC,eAAe,CAAC,EAAE;UACpC,OAAOb,sBAAsB,CAACW,MAAM,EAAEC,KAAK,CAAC,CAAC,EAAGE,CAAC,IAC/CA,CAAC,CAACC,UAAU,CAAC,CAAC,CAACC,YAAY,CAAC,CAC9B,CAAC;QACH;QAEA,OAAOjB,4BAA4B,CACjCY,MAAM,EACNC,KAAK,EACL,eAAe,EACf,UACF,CAAC;MACH;IACJ,CAAC;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Fragment } from '@tiptap/pm/model';
|
|
4
4
|
import { TextSelection } from '@tiptap/pm/state';
|
|
5
5
|
import { nativePosToTiptapPos, tiptapPosToNativePos } from "../positionMapping.js";
|
|
6
|
+
import { withPreservedAlignment } from "./formatRules.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Clears block styling with `clearNodes`, then wraps the selection’s blocks in a flat
|
|
@@ -26,7 +27,7 @@ export function applyWrappingListToSelection(editor, chain, listTypeName, itemTy
|
|
|
26
27
|
} = editor.state;
|
|
27
28
|
const nativeAnchor = tiptapPosToNativePos(docBefore, selBefore.anchor);
|
|
28
29
|
const nativeHead = tiptapPosToNativePos(docBefore, selBefore.head);
|
|
29
|
-
return chain().clearNodes().command(({
|
|
30
|
+
return withPreservedAlignment(editor, chain(), c => c.clearNodes().command(({
|
|
30
31
|
tr,
|
|
31
32
|
state
|
|
32
33
|
}) => {
|
|
@@ -58,6 +59,6 @@ export function applyWrappingListToSelection(editor, chain, listTypeName, itemTy
|
|
|
58
59
|
const pmHead = nativePosToTiptapPos(docAfter, nativeHead);
|
|
59
60
|
tr.setSelection(TextSelection.between(docAfter.resolve(pmAnchor), docAfter.resolve(pmHead)));
|
|
60
61
|
return true;
|
|
61
|
-
})
|
|
62
|
+
}));
|
|
62
63
|
}
|
|
63
64
|
//# sourceMappingURL=applyWrappingListToSelection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Fragment","TextSelection","nativePosToTiptapPos","tiptapPosToNativePos","applyWrappingListToSelection","editor","chain","listTypeName","itemTypeName","itemAttrs","doc","docBefore","selection","selBefore","state","nativeAnchor","anchor","nativeHead","head","clearNodes","command","tr","listType","schema","nodes","itemType","$from","$to","range","blockRange","listItems","i","startIndex","endIndex","block","parent","child","push","create","from","copy","content","length","list","replaceWith","start","end","docAfter","pmAnchor","pmHead","setSelection","between","resolve"
|
|
1
|
+
{"version":3,"names":["Fragment","TextSelection","nativePosToTiptapPos","tiptapPosToNativePos","withPreservedAlignment","applyWrappingListToSelection","editor","chain","listTypeName","itemTypeName","itemAttrs","doc","docBefore","selection","selBefore","state","nativeAnchor","anchor","nativeHead","head","c","clearNodes","command","tr","listType","schema","nodes","itemType","$from","$to","range","blockRange","listItems","i","startIndex","endIndex","block","parent","child","push","create","from","copy","content","length","list","replaceWith","start","end","docAfter","pmAnchor","pmHead","setSelection","between","resolve"],"sourceRoot":"../../../../src","sources":["web/formats/applyWrappingListToSelection.ts"],"mappings":";;AAEA,SAASA,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,uBAAoB;AAC/E,SAASC,sBAAsB,QAAQ,kBAAe;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC1CC,MAAc,EACdC,KAA4B,EAC5BC,YAAoB,EACpBC,YAAoB,EACpBC,SAAyC,GAAG,IAAI,EACvC;EACT,MAAM;IAAEC,GAAG,EAAEC,SAAS;IAAEC,SAAS,EAAEC;EAAU,CAAC,GAAGR,MAAM,CAACS,KAAK;EAC7D,MAAMC,YAAY,GAAGb,oBAAoB,CAACS,SAAS,EAAEE,SAAS,CAACG,MAAM,CAAC;EACtE,MAAMC,UAAU,GAAGf,oBAAoB,CAACS,SAAS,EAAEE,SAAS,CAACK,IAAI,CAAC;EAElE,OAAOf,sBAAsB,CAACE,MAAM,EAAEC,KAAK,CAAC,CAAC,EAAGa,CAAC,IAC/CA,CAAC,CAACC,UAAU,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;IAAEC,EAAE;IAAER;EAAM,CAAC,KAAK;IACxC,MAAMS,QAAQ,GAAGT,KAAK,CAACU,MAAM,CAACC,KAAK,CAAClB,YAAY,CAAC;IACjD,MAAMmB,QAAQ,GAAGZ,KAAK,CAACU,MAAM,CAACC,KAAK,CAACjB,YAAY,CAAC;IACjD,IAAI,CAACe,QAAQ,IAAI,CAACG,QAAQ,EAAE;MAC1B,OAAO,KAAK;IACd;IAEA,MAAM;MAAEC,KAAK;MAAEC;IAAI,CAAC,GAAGd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@ -41,8 +41,44 @@ export function isFormatBlocked(tiptapName, editor, htmlStyle) {
|
|
|
41
41
|
}
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
|
-
export function toggleParagraphFormat(isActive, deactivate, activate, chain) {
|
|
45
|
-
if (isActive())
|
|
46
|
-
|
|
44
|
+
export function toggleParagraphFormat(isActive, deactivate, activate, chain, editor) {
|
|
45
|
+
if (isActive()) {
|
|
46
|
+
return withPreservedAlignment(editor, chain(), c => {
|
|
47
|
+
deactivate();
|
|
48
|
+
return c;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return withPreservedAlignment(editor, chain(), c => activate(c.clearNodes()));
|
|
52
|
+
}
|
|
53
|
+
export function getCurrentAlignment(editor) {
|
|
54
|
+
const {
|
|
55
|
+
doc,
|
|
56
|
+
selection
|
|
57
|
+
} = editor.state;
|
|
58
|
+
let {
|
|
59
|
+
$from
|
|
60
|
+
} = selection;
|
|
61
|
+
|
|
62
|
+
// If the user presses Cmd+A, the selection anchors to the document root (depth 0).
|
|
63
|
+
// We resolve position '1' to step exactly inside the first paragraph node
|
|
64
|
+
// so the loop can correctly read its alignment.
|
|
65
|
+
if ($from.depth === 0 && doc.content.size > 0) {
|
|
66
|
+
$from = doc.resolve(1);
|
|
67
|
+
}
|
|
68
|
+
for (let depth = $from.depth; depth >= 0; depth--) {
|
|
69
|
+
const node = $from.node(depth);
|
|
70
|
+
if (node.attrs.textAlign) {
|
|
71
|
+
return node.attrs.textAlign;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
export function withPreservedAlignment(editor, chain, mutateChain) {
|
|
77
|
+
const currentAlignment = getCurrentAlignment(editor);
|
|
78
|
+
const c = mutateChain(chain);
|
|
79
|
+
if (currentAlignment && currentAlignment !== 'auto') {
|
|
80
|
+
c.setTextAlign(currentAlignment);
|
|
81
|
+
}
|
|
82
|
+
return c.run();
|
|
47
83
|
}
|
|
48
84
|
//# sourceMappingURL=formatRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HEADING_LEVELS","HEADING_TAGS","isAnyParagraphFormatActive","editor","isActive","some","level","isLinkBlocked","isMentionBlocked","isImageBlocked","isFormatBlocked","tiptapName","htmlStyle","includes","key","bold","toggleParagraphFormat","deactivate","activate","chain","clearNodes","run"],"sourceRoot":"../../../../src","sources":["web/formats/formatRules.ts"],"mappings":";;AAEA,SAASA,cAAc,EAAEC,YAAY,QAAQ,sBAAmB;
|
|
1
|
+
{"version":3,"names":["HEADING_LEVELS","HEADING_TAGS","isAnyParagraphFormatActive","editor","isActive","some","level","isLinkBlocked","isMentionBlocked","isImageBlocked","isFormatBlocked","tiptapName","htmlStyle","includes","key","bold","toggleParagraphFormat","deactivate","activate","chain","withPreservedAlignment","c","clearNodes","getCurrentAlignment","doc","selection","state","$from","depth","content","size","resolve","node","attrs","textAlign","mutateChain","currentAlignment","setTextAlign","run"],"sourceRoot":"../../../../src","sources":["web/formats/formatRules.ts"],"mappings":";;AAEA,SAASA,cAAc,EAAEC,YAAY,QAAQ,sBAAmB;AAGhE,OAAO,SAASC,0BAA0BA,CAACC,MAAc,EAAW;EAClE,OACEA,MAAM,CAACC,QAAQ,CAAC,YAAY,CAAC,IAC7BD,MAAM,CAACC,QAAQ,CAAC,WAAW,CAAC,IAC5BJ,cAAc,CAACK,IAAI,CAAEC,KAAK,IAAKH,MAAM,CAACC,QAAQ,CAAC,SAAS,EAAE;IAAEE;EAAM,CAAC,CAAC,CAAC,IACrEH,MAAM,CAACC,QAAQ,CAAC,aAAa,CAAC,IAC9BD,MAAM,CAACC,QAAQ,CAAC,eAAe,CAAC,IAChCD,MAAM,CAACC,QAAQ,CAAC,cAAc,CAAC;AAEnC;AAEA,OAAO,SAASG,aAAaA,CAACJ,MAAc,EAAW;EACrD,OACEA,MAAM,CAACC,QAAQ,CAAC,MAAM,CAAC,IACvBD,MAAM,CAACC,QAAQ,CAAC,WAAW,CAAC,IAC5B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AS;IAC7B;EACF;EACA,OAAO,IAAI;AACb;AAEA,OAAO,SAASd,sBAAsBA,CACpCjB,MAAc,EACdgB,KAAsB,EACtBgB,WAAoD,EAC3C;EACT,MAAMC,gBAAgB,GAAGb,mBAAmB,CAACpB,MAAM,CAAC;EAEpD,MAAMkB,CAAC,GAAGc,WAAW,CAAChB,KAAK,CAAC;EAE5B,IAAIiB,gBAAgB,IAAIA,gBAAgB,KAAK,MAAM,EAAE;IACnDf,CAAC,CAACgB,YAAY,CAACD,gBAAgB,CAAC;EAClC;EAEA,OAAOf,CAAC,CAACiB,GAAG,CAAC,CAAC;AAChB","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { isTextSelection } from '@tiptap/core';
|
|
4
4
|
import { lineStartBackspace } from "./wrappedBlockKeyboard.js";
|
|
5
|
+
import { withPreservedAlignment } from "./formatRules.js";
|
|
5
6
|
function emptyListItemContent(itemName) {
|
|
6
7
|
return {
|
|
7
8
|
type: itemName,
|
|
@@ -43,7 +44,9 @@ export function listEnter(editor, itemName) {
|
|
|
43
44
|
export function listBackspace(editor, itemName, wrapperNames) {
|
|
44
45
|
return lineStartBackspace(editor, {
|
|
45
46
|
isActive: () => editor.isActive(itemName),
|
|
46
|
-
lift: () =>
|
|
47
|
+
lift: () => {
|
|
48
|
+
return withPreservedAlignment(editor, editor.chain(), c => c.focus().liftListItem(itemName));
|
|
49
|
+
},
|
|
47
50
|
shouldJoinBefore: beforeName => beforeName != null && wrapperNames.includes(beforeName)
|
|
48
51
|
});
|
|
49
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isTextSelection","lineStartBackspace","emptyListItemContent","itemName","type","content","listEnter","editor","isActive","chain","focus","splitListItem","scrollIntoView","run","selection","state","empty","$from","parent","size","itemDepth","depth","insertPos","after","insertContentAt","listBackspace","wrapperNames","lift","liftListItem","shouldJoinBefore","beforeName","includes"],"sourceRoot":"../../../../src","sources":["web/formats/listKeyboard.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAuC,cAAc;AAE7E,SAASC,kBAAkB,QAAQ,2BAAwB;
|
|
1
|
+
{"version":3,"names":["isTextSelection","lineStartBackspace","withPreservedAlignment","emptyListItemContent","itemName","type","content","listEnter","editor","isActive","chain","focus","splitListItem","scrollIntoView","run","selection","state","empty","$from","parent","size","itemDepth","depth","insertPos","after","insertContentAt","listBackspace","wrapperNames","lift","c","liftListItem","shouldJoinBefore","beforeName","includes"],"sourceRoot":"../../../../src","sources":["web/formats/listKeyboard.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAuC,cAAc;AAE7E,SAASC,kBAAkB,QAAQ,2BAAwB;AAC3D,SAASC,sBAAsB,QAAQ,kBAAe;AAEtD,SAASC,oBAAoBA,CAACC,QAAgB,EAAe;EAC3D,OAAO;IACLC,IAAI,EAAED,QAAQ;IACdE,OAAO,EAAE,CAAC;MAAED,IAAI,EAAE;IAAY,CAAC;EACjC,CAAC;AACH;;AAEA;AACA,OAAO,SAASE,SAASA,CAACC,MAAc,EAAEJ,QAAgB,EAAW;EACnE,IAAI,CAACI,MAAM,CAACC,QAAQ,CAACL,QAAQ,CAAC,EAAE;IAC9B,OAAO,KAAK;EACd;EACA,IAAII,MAAM,CAACE,KAAK,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,CAACC,aAAa,CAACR,QAAQ,CAAC,CAACS,cAAc,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,EAAE;IACzE,OAAO,IAAI;EACb;EAEA,MAAM;IAAEC;EAAU,CAAC,GAAGP,MAAM,CAACQ,KAAK;EAClC,IAAI,CAACD,SAAS,CAACE,KAAK,IAAI,CAACjB,eAAe,CAACe,SAAS,CAAC,EAAE;IACnD,OAAO,KAAK;EACd;EAEA,MAAMG,KAAK,GAAGH,SAAS,CAACG,KAAK;EAC7B,IAAIA,KAAK,CAACC,MAAM,CAACb,OAAO,CAACc,IAAI,GAAG,CAAC,EAAE;IACjC,OAAO,KAAK;EACd;;EAEA;EACA,MAAMC,SAAS,GAAGH,KAAK,CAACI,KAAK,GAAG,CAAC;EACjC,IAAID,SAAS,GAAG,CAAC,EAAE;IACjB,OAAO,KAAK;EACd;EACA,MAAME,SAAS,GAAGL,KAAK,CAACM,KAAK,CAACH,SAAS,CAAC;EAExC,OAAOb,MAAM,CACVE,KAAK,CAAC,CAAC,CACPC,KAAK,CAAC,CAAC,CACPc,eAAe,CAACF,SAAS,EAAEpB,oBAAoB,CAACC,QAAQ,CAAC,CAAC,CAC1DS,cAAc,CAAC,CAAC,CAChBC,GAAG,CAAC,CAAC;AACV;;AAEA;AACA,OAAO,SAASY,aAAaA,CAC3BlB,MAAc,EACdJ,QAAgB,EAChBuB,YAA+B,EACtB;EACT,OAAO1B,kBAAkB,CAACO,MAAM,EAAE;IAChCC,QAAQ,EAAEA,CAAA,KAAMD,MAAM,CAACC,QAAQ,CAACL,QAAQ,CAAC;IACzCwB,IAAI,EAAEA,CAAA,KAAM;MACV,OAAO1B,sBAAsB,CAACM,MAAM,EAAEA,MAAM,CAACE,KAAK,CAAC,CAAC,EAAGmB,CAAC,IACtDA,CAAC,CAAClB,KAAK,CAAC,CAAC,CAACmB,YAAY,CAAC1B,QAAQ,CACjC,CAAC;IACH,CAAC;IACD2B,gBAAgB,EAAGC,UAAU,IAC3BA,UAAU,IAAI,IAAI,IAAIL,YAAY,CAACM,QAAQ,CAACD,UAAU;EAC1D,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["checkboxHtmlForTiptap","html","parser","DOMParser","doc","parseFromString","querySelectorAll","forEach","ul","setAttribute","li","hasAttribute","removeAttribute","innerContent","innerHTML","body","checkboxHtmlFromTiptap","getAttribute","pTag","querySelector","replace"],"sourceRoot":"../../../../src","sources":["web/normalization/checkboxHtmlNormalizer.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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