react-native-enriched-markdown-scaffold 0.7.4-scaffold.9 → 1.0.2-scaffold.2
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/README.md +54 -8
- package/ReactNativeEnrichedMarkdown.podspec +82 -73
- package/android/build.gradle +186 -1
- package/android/consumer-rules.pro +1 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +9 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +24 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +8 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +9 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +3 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +75 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +63 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +35 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +886 -23
- package/android/src/main/baseline-prof.txt +1 -1
- package/android/src/main/cpp/jni-adapter.cpp +74 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +189 -13
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +50 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +48 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextLayoutManager.kt +10 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +82 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +54 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +901 -462
- package/android/src/main/java/com/swmansion/enriched/markdown/input/MarkdownClipboard.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/BlockEditCoordinator.kt +196 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/ClipboardCoordinator.kt +73 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditContext.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +248 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditSession.kt +52 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +101 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/LinkCoordinator.kt +69 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownTextWatcher.kt +3 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MentionCoordinator.kt +118 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeStateEvent.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnContextMenuItemPressEvent.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnInputKeyPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnPasteEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/BlockStore.kt +254 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/FormattingStore.kt +80 -87
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputFormatter.kt +109 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputParser.kt +116 -22
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/MarkdownSerializer.kt +167 -38
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/RangeEditAdjustment.kt +149 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +66 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputMeasurementStore.kt +4 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/BlockRange.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/BlockType.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/FormattingRange.kt +9 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/InputFormatterStyle.kt +39 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathAtom.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MutableRangeBounds.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputBulletSpan.kt +82 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputHeadingSpan.kt +58 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputListItemSpacingSpan.kt +37 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputOrderedListMarkerSpan.kt +63 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/BlockHandler.kt +54 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/HeadingBlockHandler.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/OrderedListBlockHandler.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/UnorderedListBlockHandler.kt +37 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/toolbar/InputContextMenu.kt +8 -26
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +9 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +100 -12
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +16 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListContextManager.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListItemRenderer.kt +74 -18
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListRenderer.kt +43 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +9 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SoftBreakRenderer.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +30 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BaseListSpan.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BlockquoteSpan.kt +174 -24
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +27 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +13 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/EmphasisSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +182 -46
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ListItemSpacingSpan.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ListMarkerAnchorSpan.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/OrderedListSpan.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/StrongSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/TaskListSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/UnorderedListSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/CodeBlockStyle.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ImageStyle.kt +7 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +4 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +13 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/TableStyle.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/CodeBlockHighlighter.kt +90 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/CodeBlockNode.kt +57 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownSegment.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +37 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/SegmentSignature.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/StreamingMarkdownFilter.kt +83 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +74 -44
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageCache.kt +26 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageDownloader.kt +22 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/LocalImageLoader.kt +161 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/TextPaintExtensions.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/CheckboxTouchHelper.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/TaskListTapUtils.kt +41 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +15 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +58 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +49 -15
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +45 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +396 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/ContextMenuPopup.kt +9 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CopyGlyph.kt +101 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +36 -9
- package/android/src/main/jni/CMakeLists.txt +53 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.cpp +10 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.h +11 -2
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.cpp +10 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.h +12 -2
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.cpp +9 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.h +24 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +16 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/input/math/MathChipControllerImpl.kt +21 -4
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +7 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +6 -4
- package/cpp/highlight/CodeBlockHighlighter.cpp +284 -0
- package/cpp/highlight/CodeBlockHighlighter.hpp +66 -0
- package/cpp/highlight/CodeBlockLanguages.cpp +138 -0
- package/cpp/highlight/CodeBlockLanguages.hpp +25 -0
- package/cpp/highlight/HighlightGrammars.hpp +28 -0
- package/cpp/highlight/code_highlight_podspec.rb +211 -0
- package/cpp/highlight/gen-registry.mjs +155 -0
- package/cpp/highlight/grammar-versions.json +159 -0
- package/cpp/highlight/vendor/generated/generated_queries.h +1665 -0
- package/cpp/highlight/vendor/generated/generated_registry.cpp +59 -0
- package/cpp/parser/MD4CParser.cpp +173 -61
- package/cpp/parser/MD4CParser.hpp +1 -0
- package/cpp/parser/MarkdownASTNode.hpp +2 -1
- package/cpp/wasm/ASTSerializer.cpp +2 -0
- package/cpp/wasm/build.sh +1 -0
- package/cpp/wasm/md4c_wasm.cpp +3 -1
- package/docs/ACCESSIBILITY.md +14 -2
- package/docs/API_REFERENCE.md +234 -12
- package/docs/BREAKING_CHANGES.md +129 -0
- package/docs/CODE_HIGHLIGHT.md +133 -0
- package/docs/COPY_OPTIONS.md +47 -3
- package/docs/ELEMENTS_STRUCTURE.md +52 -4
- package/docs/IMAGE_CACHING.md +30 -0
- package/docs/INPUT.md +108 -11
- package/docs/LATEX_MATH.md +87 -45
- package/docs/MACOS.md +1 -1
- package/docs/MARKDOWN_STREAMING.md +27 -1
- package/docs/NATIVE_ASSETS.md +127 -0
- package/docs/RTL.md +1 -1
- package/docs/STYLES.md +46 -6
- package/docs/TESTING.md +112 -0
- package/docs/TEXT.md +16 -6
- package/docs/WEB.md +3 -1
- package/ios/EnrichedMarkdown.h +7 -0
- package/ios/EnrichedMarkdown.mm +284 -75
- package/ios/EnrichedMarkdownText.h +7 -0
- package/ios/EnrichedMarkdownText.mm +101 -73
- package/ios/attachments/ENRMImageAttachment.h +9 -0
- package/ios/attachments/ENRMImageAttachment.m +143 -40
- package/ios/attachments/ENRMMathInlineAttachment.h +2 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +48 -81
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +2 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +75 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +63 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +35 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +886 -23
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +131 -0
- package/ios/input/ENRMAutoLinkDetector.h +2 -1
- package/ios/input/ENRMAutoLinkDetector.mm +79 -41
- package/ios/input/ENRMBlockEditCoordinator.h +71 -0
- package/ios/input/ENRMBlockEditCoordinator.mm +195 -0
- package/ios/input/ENRMBlockRange.h +28 -0
- package/ios/input/ENRMBlockRange.mm +30 -0
- package/ios/input/ENRMBlockStore.h +56 -0
- package/ios/input/ENRMBlockStore.mm +275 -0
- package/ios/input/ENRMClipboardCoordinator.h +45 -0
- package/ios/input/ENRMClipboardCoordinator.mm +120 -0
- package/ios/input/ENRMDetectorPipeline.h +2 -1
- package/ios/input/ENRMEditPipeline.h +76 -0
- package/ios/input/ENRMEditPipeline.mm +228 -0
- package/ios/input/ENRMEditSession.h +36 -0
- package/ios/input/ENRMEditSession.mm +63 -0
- package/ios/input/ENRMFormattingStore.h +17 -0
- package/ios/input/ENRMFormattingStore.mm +95 -105
- package/ios/input/ENRMInputBlockType.h +91 -0
- package/ios/input/ENRMInputBlockType.mm +5 -0
- package/ios/input/ENRMInputDecorationDrawer.h +18 -0
- package/ios/input/ENRMInputEventEmitter.h +56 -0
- package/ios/input/ENRMInputEventEmitter.mm +308 -0
- package/ios/input/ENRMInputFormatter.h +29 -69
- package/ios/input/ENRMInputFormatter.mm +216 -124
- package/ios/input/ENRMInputFormatterStyle.h +99 -0
- package/ios/input/ENRMInputFormatterStyle.mm +188 -0
- package/ios/input/ENRMInputLayoutManager.h +9 -0
- package/ios/input/ENRMInputLayoutManager.mm +30 -0
- package/ios/input/ENRMInputListMarkerDrawer.h +32 -0
- package/ios/input/ENRMInputListMarkerDrawer.mm +426 -0
- package/ios/input/ENRMInputParser.h +5 -6
- package/ios/input/ENRMInputParser.mm +461 -178
- package/ios/input/ENRMInputRemend.mm +2 -2
- package/ios/input/ENRMInputStyleStateBuilder.h +40 -0
- package/ios/input/ENRMInputStyleStateBuilder.mm +60 -0
- package/ios/input/ENRMInputTextView.mm +103 -8
- package/ios/input/ENRMInputTypingAttributesController.h +42 -0
- package/ios/input/ENRMInputTypingAttributesController.mm +203 -0
- package/ios/input/ENRMLinkCoordinator.h +41 -0
- package/ios/input/ENRMLinkCoordinator.mm +89 -0
- package/ios/input/ENRMMarkdownSerializer.h +29 -5
- package/ios/input/ENRMMarkdownSerializer.mm +170 -48
- package/ios/input/ENRMMathAtom.h +26 -0
- package/ios/input/ENRMMathAtom.mm +12 -0
- package/ios/input/ENRMMentionCoordinator.h +45 -0
- package/ios/input/ENRMMentionCoordinator.mm +167 -0
- package/ios/input/ENRMRangeEditAdjustment.h +38 -0
- package/ios/input/ENRMRangeEditAdjustment.mm +91 -0
- package/ios/input/ENRMRangeStoreUtils.h +39 -0
- package/ios/input/EnrichedMarkdownTextInput+ContextMenu.mm +6 -6
- package/ios/input/EnrichedMarkdownTextInput+Internal.h +11 -3
- package/ios/input/EnrichedMarkdownTextInput.h +7 -1
- package/ios/input/EnrichedMarkdownTextInput.mm +1089 -1023
- package/ios/input/InputStylePropsUtils.h +109 -68
- package/ios/input/internals/EnrichedMarkdownTextInputShadowNode.mm +2 -1
- package/ios/input/styles/ENRMBlockHandler.h +46 -0
- package/ios/input/styles/ENRMHeadingBlockHandler.h +15 -0
- package/ios/input/styles/ENRMHeadingBlockHandler.mm +38 -0
- package/ios/input/styles/ENRMOrderedListBlockHandler.h +14 -0
- package/ios/input/styles/ENRMOrderedListBlockHandler.mm +48 -0
- package/ios/input/styles/ENRMUnorderedListBlockHandler.h +15 -0
- package/ios/input/styles/ENRMUnorderedListBlockHandler.mm +51 -0
- package/ios/internals/ENRMViewFreeMeasurement.h +331 -0
- package/ios/internals/EnrichedMarkdownShadowNode.h +1 -3
- package/ios/internals/EnrichedMarkdownShadowNode.mm +16 -20
- package/ios/internals/EnrichedMarkdownTextShadowNode.h +1 -3
- package/ios/internals/EnrichedMarkdownTextShadowNode.mm +15 -20
- package/ios/internals/MeasurementCache.h +33 -7
- package/ios/internals/ShadowMeasurementUtils.h +63 -58
- package/ios/math/ENRMMathChipController.h +74 -0
- package/ios/math/ENRMMathChipController.mm +476 -0
- package/ios/math/ENRMRaTeXBridge.swift +4 -1
- package/ios/parser/ENRMMarkdownParser.h +1 -8
- package/ios/parser/ENRMMarkdownParser.mm +2 -11
- package/ios/parser/MarkdownASTNode.h +2 -1
- package/ios/parser/MarkdownParserBridge.mm +4 -0
- package/ios/renderer/AttributedRenderer.m +20 -2
- package/ios/renderer/BaseRenderer.h +17 -2
- package/ios/renderer/BaseRenderer.m +30 -0
- package/ios/renderer/BlockquoteRenderer.h +1 -1
- package/ios/renderer/BlockquoteRenderer.m +144 -35
- package/ios/renderer/CodeBlockRenderer.h +1 -1
- package/ios/renderer/CodeBlockRenderer.m +27 -23
- package/ios/renderer/CodeRenderer.h +1 -1
- package/ios/renderer/CodeRenderer.m +3 -1
- package/ios/renderer/ENRMImageRenderer.h +1 -1
- package/ios/renderer/ENRMImageRenderer.m +5 -1
- package/ios/renderer/ENRMMathInlineRenderer.h +1 -1
- package/ios/renderer/ENRMMathInlineRenderer.m +5 -1
- package/ios/renderer/ENRMSpoilerRenderer.h +1 -1
- package/ios/renderer/ENRMSpoilerRenderer.m +3 -1
- package/ios/renderer/EmphasisRenderer.h +1 -1
- package/ios/renderer/EmphasisRenderer.m +3 -1
- package/ios/renderer/HeadingRenderer.h +1 -1
- package/ios/renderer/HeadingRenderer.m +13 -6
- package/ios/renderer/HighlightRenderer.h +1 -1
- package/ios/renderer/HighlightRenderer.m +3 -1
- package/ios/renderer/LinkRenderer.h +1 -1
- package/ios/renderer/LinkRenderer.m +3 -1
- package/ios/renderer/ListItemRenderer.h +13 -1
- package/ios/renderer/ListItemRenderer.m +102 -44
- package/ios/renderer/ListRenderer.h +2 -2
- package/ios/renderer/ListRenderer.m +63 -25
- package/ios/renderer/ParagraphRenderer.h +1 -1
- package/ios/renderer/ParagraphRenderer.m +16 -8
- package/ios/renderer/RenderContext.h +10 -0
- package/ios/renderer/RenderContext.m +44 -0
- package/ios/renderer/RendererFactory.m +14 -0
- package/ios/renderer/StrikethroughRenderer.h +1 -1
- package/ios/renderer/StrikethroughRenderer.m +3 -1
- package/ios/renderer/StrongRenderer.h +1 -1
- package/ios/renderer/StrongRenderer.m +3 -1
- package/ios/renderer/SubscriptRenderer.h +1 -1
- package/ios/renderer/SubscriptRenderer.m +3 -1
- package/ios/renderer/SuperscriptRenderer.h +1 -1
- package/ios/renderer/SuperscriptRenderer.m +3 -1
- package/ios/renderer/TextRenderer.h +2 -2
- package/ios/renderer/TextRenderer.m +3 -1
- package/ios/renderer/ThematicBreakRenderer.h +1 -1
- package/ios/renderer/ThematicBreakRenderer.m +3 -1
- package/ios/renderer/UnderlineRenderer.h +1 -1
- package/ios/renderer/UnderlineRenderer.m +3 -1
- package/ios/styles/StyleConfig.h +22 -0
- package/ios/styles/StyleConfig.mm +132 -0
- package/ios/utils/BlockquoteBorder.h +6 -0
- package/ios/utils/BlockquoteBorder.m +249 -52
- package/ios/utils/CodeBlockBackground.m +16 -2
- package/ios/utils/ENRMAtomicSize.h +65 -0
- package/ios/utils/ENRMBlockMenu.h +57 -0
- package/ios/utils/ENRMCodeBlockContent.h +37 -0
- package/ios/utils/ENRMCodeBlockContent.mm +79 -0
- package/ios/utils/ENRMCodeBlockHighlighter.h +37 -0
- package/ios/utils/ENRMCodeBlockHighlighter.mm +51 -0
- package/ios/utils/ENRMFeatureFlags.h +7 -0
- package/ios/utils/ENRMImageDownloader.h +11 -1
- package/ios/utils/ENRMImageDownloader.m +60 -16
- package/ios/utils/ENRMLocalImageLoader.h +31 -0
- package/ios/utils/ENRMLocalImageLoader.m +68 -0
- package/ios/utils/ENRMMathFallback.h +26 -0
- package/ios/utils/ENRMMathFallback.m +18 -0
- package/ios/utils/ENRMTextViewSetup.h +35 -17
- package/ios/utils/EditMenuUtils.h +22 -5
- package/ios/utils/EditMenuUtils.m +53 -9
- package/ios/utils/ImageRequestHeaderUtils.h +35 -0
- package/ios/utils/LastElementUtils.h +1 -0
- package/ios/utils/ListMarkerDrawer.m +29 -42
- package/ios/utils/MarkdownASTSerializer.m +4 -0
- package/ios/utils/ParagraphStyleUtils.h +5 -0
- package/ios/utils/ParagraphStyleUtils.m +77 -17
- package/ios/utils/RenderedMarkdownSegment.h +13 -1
- package/ios/utils/RenderedMarkdownSegment.m +20 -0
- package/ios/utils/SegmentRenderer.m +17 -4
- package/ios/utils/StreamingMarkdownFilter.h +11 -1
- package/ios/utils/StreamingMarkdownFilter.m +98 -2
- package/ios/utils/StylePropsUtils.h +63 -0
- package/ios/utils/TaskListTapUtils.m +24 -0
- package/ios/views/ENRMCodeBlockContainerView.h +53 -0
- package/ios/views/ENRMCodeBlockContainerView.m +559 -0
- package/ios/views/ENRMMathContainerView.h +16 -0
- package/ios/views/ENRMMathContainerView.m +74 -19
- package/ios/views/TableContainerView.h +22 -0
- package/ios/views/TableContainerView.m +261 -175
- package/jest.d.ts +1 -0
- package/jest.js +5 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +73 -0
- package/lib/module/EnrichedMarkdownTextInput.js +84 -5
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +74 -0
- package/lib/module/headingDefaults.js +34 -0
- package/lib/module/headingDefaults.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +191 -0
- package/lib/module/jest/index.js.map +1 -0
- package/lib/module/native/EnrichedMarkdownText.js +37 -5
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +81 -19
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +56 -18
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/normalizeMarkdownTextInputStyle.js +62 -15
- package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
- package/lib/module/normalizeMenuItem.js +1 -1
- package/lib/module/utils/textInputState.js +26 -0
- package/lib/module/utils/textInputState.js.map +1 -0
- package/lib/module/web/EnrichedMarkdownText.js +9 -5
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/parseMarkdown.js +4 -3
- package/lib/module/web/parseMarkdown.js.map +1 -1
- package/lib/module/web/renderers/InlineRenderers.js +6 -0
- package/lib/module/web/renderers/InlineRenderers.js.map +1 -1
- package/lib/module/web/renderers/ListRenderers.js +7 -2
- package/lib/module/web/renderers/ListRenderers.js.map +1 -1
- package/lib/module/web/renderers/index.js +7 -4
- package/lib/module/web/renderers/index.js.map +1 -1
- package/lib/module/web/styles.js +83 -6
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/utils.js +1 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/module/web/wasm/md4c.js +0 -0
- package/lib/module/web/wasm/md4c.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +66 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +94 -9
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +69 -5
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +66 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/headingDefaults.d.ts +9 -0
- package/lib/typescript/src/headingDefaults.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/jest/index.d.ts +6 -0
- package/lib/typescript/src/jest/index.d.ts.map +1 -0
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +19 -5
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +72 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +27 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +104 -9
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +19 -0
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +19 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/utils/textInputState.d.ts +24 -0
- package/lib/typescript/src/utils/textInputState.d.ts.map +1 -0
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
- package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/InlineRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/ListRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/index.d.ts +2 -1
- package/lib/typescript/src/web/renderers/index.d.ts.map +1 -1
- package/lib/typescript/src/web/styles.d.ts +2 -1
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +6 -2
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils.d.ts.map +1 -1
- package/package.json +36 -9
- package/postinstall.mjs +131 -0
- package/ratex-version.json +21 -0
- package/src/EnrichedMarkdownNativeComponent.ts +73 -0
- package/src/EnrichedMarkdownTextInput.tsx +159 -8
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
- package/src/EnrichedMarkdownTextNativeComponent.ts +74 -0
- package/src/headingDefaults.ts +21 -0
- package/src/index.tsx +9 -0
- package/src/index.web.tsx +1 -0
- package/src/jest/index.tsx +215 -0
- package/src/native/EnrichedMarkdownText.tsx +53 -2
- package/src/normalizeMarkdownStyle.ts +102 -16
- package/src/normalizeMarkdownStyle.web.ts +63 -15
- package/src/normalizeMarkdownTextInputStyle.ts +110 -35
- package/src/normalizeMenuItem.ts +1 -1
- package/src/types/MarkdownStyle.ts +74 -0
- package/src/types/MarkdownStyleInternal.ts +39 -0
- package/src/types/MarkdownTextProps.ts +101 -9
- package/src/types/MarkdownTextProps.web.ts +19 -0
- package/src/types/events.ts +21 -0
- package/src/utils/textInputState.ts +35 -0
- package/src/web/EnrichedMarkdownText.tsx +16 -2
- package/src/web/parseMarkdown.ts +6 -2
- package/src/web/renderers/InlineRenderers.tsx +5 -0
- package/src/web/renderers/ListRenderers.tsx +14 -2
- package/src/web/renderers/index.tsx +6 -2
- package/src/web/styles.ts +89 -5
- package/src/web/types.ts +6 -1
- package/src/web/utils.ts +1 -0
- package/src/web/wasm/md4c.js +0 -0
- package/vendor-grammars.mjs +511 -0
- package/vendor-ratex.mjs +173 -0
- package/app.plugin.js +0 -2
- package/plugin/build/withAndroidMath.js +0 -19
- package/plugin/build/withIosMath.js +0 -28
- package/plugin/build/withReactNativeEnrichedMarkdown.js +0 -11
- package/plugin/src/withAndroidMath.ts +0 -24
- package/plugin/src/withIosMath.ts +0 -35
- package/plugin/src/withReactNativeEnrichedMarkdown.ts +0 -17
- package/plugin/tsconfig.build.json +0 -16
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#import "ENRMInputFormatterStyle.h"
|
|
2
|
+
#import "FontUtils.h"
|
|
3
|
+
|
|
4
|
+
@implementation ENRMInputLinkVariantStyle
|
|
5
|
+
@end
|
|
6
|
+
|
|
7
|
+
@implementation ENRMInputFormatterStyle {
|
|
8
|
+
NSMutableDictionary<NSNumber *, UIFont *> *_fontCache;
|
|
9
|
+
UIFont *_lastBaseFont;
|
|
10
|
+
CGFloat _headingFontSizes[7];
|
|
11
|
+
NSString *_headingFontWeights[7];
|
|
12
|
+
RCTUIColor *_headingColors[7];
|
|
13
|
+
UIFont *_headingFontCache[7];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
- (instancetype)init
|
|
17
|
+
{
|
|
18
|
+
if (self = [super init]) {
|
|
19
|
+
_baseFont = [UIFont systemFontOfSize:16.0];
|
|
20
|
+
_baseTextColor = [RCTUIColor labelColor];
|
|
21
|
+
_linkVariants = @[];
|
|
22
|
+
_inlineMathFontSize = 16.0;
|
|
23
|
+
_mathFontSize = 20.0;
|
|
24
|
+
_mathPaddingHorizontal = 12.0;
|
|
25
|
+
_mathPaddingVertical = 8.0;
|
|
26
|
+
_mathMarginTop = 8.0;
|
|
27
|
+
_mathMarginBottom = 8.0;
|
|
28
|
+
_mathTextAlign = NSTextAlignmentCenter;
|
|
29
|
+
_fontCache = [NSMutableDictionary dictionary];
|
|
30
|
+
for (NSInteger level = 0; level <= 6; level++) {
|
|
31
|
+
_headingFontSizes[level] = 0.0;
|
|
32
|
+
_headingFontWeights[level] = nil;
|
|
33
|
+
_headingColors[level] = nil;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (id)copyWithZone:(NSZone *)zone
|
|
40
|
+
{
|
|
41
|
+
ENRMInputFormatterStyle *copy = [[ENRMInputFormatterStyle allocWithZone:zone] init];
|
|
42
|
+
copy.baseFont = _baseFont;
|
|
43
|
+
copy.baseTextColor = _baseTextColor;
|
|
44
|
+
copy.boldColor = _boldColor;
|
|
45
|
+
copy.italicColor = _italicColor;
|
|
46
|
+
copy.linkColor = _linkColor;
|
|
47
|
+
copy.linkUnderline = _linkUnderline;
|
|
48
|
+
copy.linkBackgroundColor = _linkBackgroundColor;
|
|
49
|
+
copy.linkVariants = [_linkVariants copy];
|
|
50
|
+
copy.spoilerColor = _spoilerColor;
|
|
51
|
+
copy.spoilerBackgroundColor = _spoilerBackgroundColor;
|
|
52
|
+
copy.listItemSpacing = _listItemSpacing;
|
|
53
|
+
copy.inlineMathColor = _inlineMathColor;
|
|
54
|
+
copy.inlineMathFontSize = _inlineMathFontSize;
|
|
55
|
+
copy.inlineMathBackgroundColor = _inlineMathBackgroundColor;
|
|
56
|
+
copy.inlineMathBorderColor = _inlineMathBorderColor;
|
|
57
|
+
copy.inlineMathBorderWidth = _inlineMathBorderWidth;
|
|
58
|
+
copy.inlineMathBorderRadius = _inlineMathBorderRadius;
|
|
59
|
+
copy.inlineMathPaddingHorizontal = _inlineMathPaddingHorizontal;
|
|
60
|
+
copy.inlineMathPaddingVertical = _inlineMathPaddingVertical;
|
|
61
|
+
copy.inlineMathSelectedBackgroundColor = _inlineMathSelectedBackgroundColor;
|
|
62
|
+
copy.inlineMathSelectedBorderColor = _inlineMathSelectedBorderColor;
|
|
63
|
+
copy.inlineMathFontWeight = _inlineMathFontWeight;
|
|
64
|
+
copy.mathColor = _mathColor;
|
|
65
|
+
copy.mathFontSize = _mathFontSize;
|
|
66
|
+
copy.mathBackgroundColor = _mathBackgroundColor;
|
|
67
|
+
copy.mathBorderColor = _mathBorderColor;
|
|
68
|
+
copy.mathBorderWidth = _mathBorderWidth;
|
|
69
|
+
copy.mathBorderRadius = _mathBorderRadius;
|
|
70
|
+
copy.mathPaddingHorizontal = _mathPaddingHorizontal;
|
|
71
|
+
copy.mathPaddingVertical = _mathPaddingVertical;
|
|
72
|
+
copy.mathSelectedBackgroundColor = _mathSelectedBackgroundColor;
|
|
73
|
+
copy.mathSelectedBorderColor = _mathSelectedBorderColor;
|
|
74
|
+
copy.mathMarginTop = _mathMarginTop;
|
|
75
|
+
copy.mathMarginBottom = _mathMarginBottom;
|
|
76
|
+
copy.mathTextAlign = _mathTextAlign;
|
|
77
|
+
copy.mathFontWeight = _mathFontWeight;
|
|
78
|
+
for (NSInteger level = 1; level <= 6; level++) {
|
|
79
|
+
[copy setHeadingFontSize:_headingFontSizes[level] forLevel:level];
|
|
80
|
+
[copy setHeadingFontWeight:_headingFontWeights[level] forLevel:level];
|
|
81
|
+
[copy setHeadingColor:_headingColors[level] forLevel:level];
|
|
82
|
+
}
|
|
83
|
+
return copy;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (BOOL)isValidHeadingLevel:(NSInteger)level
|
|
87
|
+
{
|
|
88
|
+
return level >= 1 && level <= 6;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
- (void)setHeadingFontSize:(CGFloat)fontSize forLevel:(NSInteger)level
|
|
92
|
+
{
|
|
93
|
+
if ([self isValidHeadingLevel:level]) {
|
|
94
|
+
_headingFontSizes[level] = fontSize;
|
|
95
|
+
_headingFontCache[level] = nil;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (void)setHeadingFontWeight:(nullable NSString *)fontWeight forLevel:(NSInteger)level
|
|
100
|
+
{
|
|
101
|
+
if ([self isValidHeadingLevel:level]) {
|
|
102
|
+
_headingFontWeights[level] = [fontWeight copy];
|
|
103
|
+
_headingFontCache[level] = nil;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void)setHeadingColor:(nullable RCTUIColor *)color forLevel:(NSInteger)level
|
|
108
|
+
{
|
|
109
|
+
if ([self isValidHeadingLevel:level]) {
|
|
110
|
+
_headingColors[level] = color;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- (RCTUIColor *)headingColorForLevel:(NSInteger)level
|
|
115
|
+
{
|
|
116
|
+
return [self isValidHeadingLevel:level] ? _headingColors[level] : nil;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (UIFont *)headingFontForLevel:(NSInteger)level
|
|
120
|
+
{
|
|
121
|
+
if (![self isValidHeadingLevel:level]) {
|
|
122
|
+
return _baseFont;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
[self invalidateCacheIfNeeded];
|
|
126
|
+
|
|
127
|
+
UIFont *cached = _headingFontCache[level];
|
|
128
|
+
if (cached) {
|
|
129
|
+
return cached;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
CGFloat size = _headingFontSizes[level];
|
|
133
|
+
if (size <= 0.0) {
|
|
134
|
+
size = _baseFont.pointSize;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
NSString *weightString = _headingFontWeights[level];
|
|
138
|
+
UIFont *font = weightString.length > 0 ? [UIFont systemFontOfSize:size weight:ENRMFontWeightFromString(weightString)]
|
|
139
|
+
: [_baseFont fontWithSize:size];
|
|
140
|
+
_headingFontCache[level] = font;
|
|
141
|
+
return font;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)clearHeadingFontCache
|
|
145
|
+
{
|
|
146
|
+
for (NSInteger level = 0; level <= 6; level++) {
|
|
147
|
+
_headingFontCache[level] = nil;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (void)invalidateCacheIfNeeded
|
|
152
|
+
{
|
|
153
|
+
if (_lastBaseFont != _baseFont) {
|
|
154
|
+
[_fontCache removeAllObjects];
|
|
155
|
+
[self clearHeadingFontCache];
|
|
156
|
+
_lastBaseFont = _baseFont;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (void)invalidateFontCache
|
|
161
|
+
{
|
|
162
|
+
[_fontCache removeAllObjects];
|
|
163
|
+
[self clearHeadingFontCache];
|
|
164
|
+
_lastBaseFont = nil;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
- (UIFont *)fontForTraits:(UIFontDescriptorSymbolicTraits)traits
|
|
168
|
+
{
|
|
169
|
+
[self invalidateCacheIfNeeded];
|
|
170
|
+
|
|
171
|
+
if (traits == 0) {
|
|
172
|
+
return _baseFont;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
NSNumber *key = @(traits);
|
|
176
|
+
UIFont *cached = _fontCache[key];
|
|
177
|
+
if (cached) {
|
|
178
|
+
return cached;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
UIFontDescriptor *descriptor =
|
|
182
|
+
[_baseFont.fontDescriptor fontDescriptorWithSymbolicTraits:_baseFont.fontDescriptor.symbolicTraits | traits];
|
|
183
|
+
UIFont *derived = descriptor ? [UIFont fontWithDescriptor:descriptor size:0] : _baseFont;
|
|
184
|
+
_fontCache[key] = derived;
|
|
185
|
+
return derived;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@end
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#import "ENRMInputDecorationDrawer.h"
|
|
3
4
|
#import "ENRMUIKit.h"
|
|
4
5
|
|
|
5
6
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
7
|
|
|
8
|
+
@class ENRMInputListMarkerDrawer;
|
|
9
|
+
|
|
10
|
+
/// Thin orchestrator that iterates registered decoration drawers during the draw pass.
|
|
7
11
|
@interface ENRMInputLayoutManager : NSLayoutManager
|
|
8
12
|
|
|
13
|
+
@property (nonatomic, strong, readonly) ENRMInputListMarkerDrawer *listMarkerDrawer;
|
|
14
|
+
@property (nonatomic, copy) NSArray<id<ENRMInputDecorationDrawer>> *decorationDrawers;
|
|
15
|
+
|
|
16
|
+
- (void)drawEmptyEditorDecorationsWithInset:(UIEdgeInsets)inset;
|
|
17
|
+
|
|
9
18
|
@end
|
|
10
19
|
|
|
11
20
|
NS_ASSUME_NONNULL_END
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
#import "ENRMInputLayoutManager.h"
|
|
2
|
+
#import "ENRMInputListMarkerDrawer.h"
|
|
2
3
|
|
|
3
4
|
@implementation ENRMInputLayoutManager
|
|
4
5
|
|
|
6
|
+
- (instancetype)init
|
|
7
|
+
{
|
|
8
|
+
if (self = [super init]) {
|
|
9
|
+
_listMarkerDrawer = [[ENRMInputListMarkerDrawer alloc] init];
|
|
10
|
+
_decorationDrawers = @[ _listMarkerDrawer ];
|
|
11
|
+
}
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#pragma mark - NSLayoutManager Overrides
|
|
16
|
+
|
|
17
|
+
- (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(CGPoint)origin
|
|
18
|
+
{
|
|
19
|
+
[super drawGlyphsForGlyphRange:glyphsToShow atPoint:origin];
|
|
20
|
+
|
|
21
|
+
for (id<ENRMInputDecorationDrawer> drawer in _decorationDrawers) {
|
|
22
|
+
[drawer drawDecorationsForGlyphRange:glyphsToShow layoutManager:self atPoint:origin];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#pragma mark - Empty Editor
|
|
27
|
+
|
|
28
|
+
- (void)drawEmptyEditorDecorationsWithInset:(UIEdgeInsets)inset
|
|
29
|
+
{
|
|
30
|
+
for (id<ENRMInputDecorationDrawer> drawer in _decorationDrawers) {
|
|
31
|
+
[drawer drawEmptyEditorDecorationsWithInset:inset layoutManager:self];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
5
35
|
@end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import "ENRMInputDecorationDrawer.h"
|
|
4
|
+
#import "ENRMUIKit.h"
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
/// Draws list markers (bullets / ordered numbers) into the head-indent column.
|
|
9
|
+
@interface ENRMInputListMarkerDrawer : NSObject <ENRMInputDecorationDrawer>
|
|
10
|
+
|
|
11
|
+
@property (nonatomic, assign) NSInteger emptyBulletDepth;
|
|
12
|
+
@property (nonatomic, assign) BOOL emptyBulletOrdered;
|
|
13
|
+
@property (nonatomic, assign) NSInteger emptyBulletOrdinal;
|
|
14
|
+
@property (nonatomic, assign) NSUInteger emptyBulletLocation;
|
|
15
|
+
@property (nonatomic, strong, nullable) UIFont *emptyBulletFont;
|
|
16
|
+
@property (nonatomic, strong, nullable) RCTUIColor *emptyBulletColor;
|
|
17
|
+
@property (nonatomic, assign) BOOL emptyBulletRTL;
|
|
18
|
+
@property (nonatomic, assign) CGFloat listItemSpacing;
|
|
19
|
+
|
|
20
|
+
#if !TARGET_OS_OSX
|
|
21
|
+
/// Shows or updates a subview overlay that draws the trailing empty line's
|
|
22
|
+
/// bullet. drawGlyphsForGlyphRange: clips to the glyph area, which excludes
|
|
23
|
+
/// the extra line fragment -- a subview is immune to that clipping.
|
|
24
|
+
- (void)showTrailingBulletInTextView:(UITextView *)textView
|
|
25
|
+
textContainer:(NSTextContainer *)container
|
|
26
|
+
usedRect:(CGRect)usedRect;
|
|
27
|
+
- (void)hideTrailingBullet;
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
#import "ENRMInputListMarkerDrawer.h"
|
|
2
|
+
#import "ENRMInputBlockType.h"
|
|
3
|
+
#import "ParagraphStyleUtils.h"
|
|
4
|
+
|
|
5
|
+
static UIFont *ENRMFallbackFont(void)
|
|
6
|
+
{
|
|
7
|
+
return [UIFont systemFontOfSize:16];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static RCTUIColor *ENRMFallbackColor(void)
|
|
11
|
+
{
|
|
12
|
+
return [RCTUIColor labelColor];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static CGFloat ENRMTrailingMarkerX(CGPoint origin, NSTextContainer *container, CGFloat leadingOffset)
|
|
16
|
+
{
|
|
17
|
+
return origin.x + container.size.width - leadingOffset;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@interface ENRMInputListMarkerDrawer ()
|
|
21
|
+
- (void)drawTrailingBulletMarkerInRect:(CGRect)bounds;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
#if !TARGET_OS_OSX
|
|
25
|
+
|
|
26
|
+
#pragma mark - Trailing bullet overlay
|
|
27
|
+
|
|
28
|
+
/// A lightweight overlay that draws the trailing empty line's list marker.
|
|
29
|
+
/// drawGlyphsForGlyphRange: clips its context to the glyph area, which excludes
|
|
30
|
+
/// the extra line fragment. A subview is immune to that clipping.
|
|
31
|
+
@interface ENRMTrailingBulletView : UIView
|
|
32
|
+
@property (nonatomic, weak) ENRMInputListMarkerDrawer *drawer;
|
|
33
|
+
@end
|
|
34
|
+
|
|
35
|
+
@implementation ENRMTrailingBulletView
|
|
36
|
+
|
|
37
|
+
- (void)drawRect:(CGRect)rect
|
|
38
|
+
{
|
|
39
|
+
[_drawer drawTrailingBulletMarkerInRect:self.bounds];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@end
|
|
43
|
+
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
#pragma mark -
|
|
47
|
+
|
|
48
|
+
@implementation ENRMInputListMarkerDrawer {
|
|
49
|
+
NSMutableSet<NSNumber *> *_drawnParagraphLocations;
|
|
50
|
+
#if !TARGET_OS_OSX
|
|
51
|
+
ENRMTrailingBulletView *_trailingBulletView;
|
|
52
|
+
__weak NSTextContainer *_trailingBulletTextContainer;
|
|
53
|
+
CGFloat _trailingBulletInsetLeft;
|
|
54
|
+
CGFloat _trailingBulletHeadIndent;
|
|
55
|
+
#endif
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (instancetype)init
|
|
59
|
+
{
|
|
60
|
+
if (self = [super init]) {
|
|
61
|
+
_emptyBulletDepth = -1;
|
|
62
|
+
_drawnParagraphLocations = [NSMutableSet set];
|
|
63
|
+
}
|
|
64
|
+
return self;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#pragma mark - Primitive Drawing
|
|
68
|
+
|
|
69
|
+
- (void)drawBulletAtX:(CGFloat)markerX
|
|
70
|
+
centerY:(CGFloat)centerY
|
|
71
|
+
depth:(NSInteger)depth
|
|
72
|
+
font:(UIFont *)font
|
|
73
|
+
color:(RCTUIColor *)color
|
|
74
|
+
{
|
|
75
|
+
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
|
76
|
+
if (!ctx || isnan(markerX) || isnan(centerY)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
CGFloat size = MAX(4.0, font.pointSize * 0.30);
|
|
81
|
+
CGRect bulletRect = CGRectMake(markerX - size / 2.0, centerY - size / 2.0, size, size);
|
|
82
|
+
|
|
83
|
+
CGContextSaveGState(ctx);
|
|
84
|
+
NSInteger style = depth >= 2 ? 2 : depth;
|
|
85
|
+
switch (style) {
|
|
86
|
+
case 0:
|
|
87
|
+
[color setFill];
|
|
88
|
+
CGContextFillEllipseInRect(ctx, bulletRect);
|
|
89
|
+
break;
|
|
90
|
+
case 1: {
|
|
91
|
+
CGFloat lineWidth = MAX(1.0, size * 0.15);
|
|
92
|
+
[color setStroke];
|
|
93
|
+
CGContextSetLineWidth(ctx, lineWidth);
|
|
94
|
+
CGContextStrokeEllipseInRect(ctx, CGRectInset(bulletRect, lineWidth / 2.0, lineWidth / 2.0));
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
[color setFill];
|
|
99
|
+
CGContextFillRect(ctx, bulletRect);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
CGContextRestoreGState(ctx);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (void)drawOrderedMarkerEndingAtX:(CGFloat)markerRight
|
|
106
|
+
baselineY:(CGFloat)baselineY
|
|
107
|
+
ordinal:(NSInteger)ordinal
|
|
108
|
+
font:(UIFont *)font
|
|
109
|
+
color:(RCTUIColor *)color
|
|
110
|
+
{
|
|
111
|
+
NSString *label = [NSString stringWithFormat:@"%ld.", (long)MAX(ordinal, (NSInteger)1)];
|
|
112
|
+
NSDictionary *attrs = @{NSFontAttributeName : font, NSForegroundColorAttributeName : color};
|
|
113
|
+
CGSize labelSize = [label sizeWithAttributes:attrs];
|
|
114
|
+
[label drawAtPoint:CGPointMake(markerRight - labelSize.width, baselineY - font.ascender) withAttributes:attrs];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
- (void)drawOrderedMarkerStartingAtX:(CGFloat)markerLeft
|
|
118
|
+
baselineY:(CGFloat)baselineY
|
|
119
|
+
ordinal:(NSInteger)ordinal
|
|
120
|
+
font:(UIFont *)font
|
|
121
|
+
color:(RCTUIColor *)color
|
|
122
|
+
{
|
|
123
|
+
NSString *label = [NSString stringWithFormat:@".%ld", (long)MAX(ordinal, (NSInteger)1)];
|
|
124
|
+
NSDictionary *attrs = @{NSFontAttributeName : font, NSForegroundColorAttributeName : color};
|
|
125
|
+
[label drawAtPoint:CGPointMake(markerLeft, baselineY - font.ascender) withAttributes:attrs];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#pragma mark - Composite Marker
|
|
129
|
+
|
|
130
|
+
- (void)drawListMarkerOrdered:(BOOL)isOrdered
|
|
131
|
+
depth:(NSInteger)depth
|
|
132
|
+
ordinal:(NSInteger)ordinal
|
|
133
|
+
rtl:(BOOL)isRTL
|
|
134
|
+
baselineY:(CGFloat)baselineY
|
|
135
|
+
origin:(CGPoint)origin
|
|
136
|
+
usedRect:(CGRect)usedRect
|
|
137
|
+
container:(NSTextContainer *)container
|
|
138
|
+
font:(UIFont *)font
|
|
139
|
+
color:(RCTUIColor *)color
|
|
140
|
+
{
|
|
141
|
+
CGFloat leadingOffset = container.lineFragmentPadding + (depth + 1) * kENRMListIndentPerDepth;
|
|
142
|
+
|
|
143
|
+
if (isOrdered) {
|
|
144
|
+
if (isRTL) {
|
|
145
|
+
CGFloat anchorX = ENRMTrailingMarkerX(origin, container, leadingOffset) + kENRMListBulletGap / 2.0;
|
|
146
|
+
[self drawOrderedMarkerStartingAtX:anchorX baselineY:baselineY ordinal:ordinal font:font color:color];
|
|
147
|
+
} else {
|
|
148
|
+
CGFloat anchorX = origin.x + usedRect.origin.x - kENRMListBulletGap / 2.0;
|
|
149
|
+
[self drawOrderedMarkerEndingAtX:anchorX baselineY:baselineY ordinal:ordinal font:font color:color];
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
CGFloat markerX = isRTL ? ENRMTrailingMarkerX(origin, container, leadingOffset) + kENRMListBulletGap
|
|
155
|
+
: origin.x + usedRect.origin.x - kENRMListBulletGap;
|
|
156
|
+
CGFloat centerY = baselineY - (font.xHeight + font.capHeight) / 4.0;
|
|
157
|
+
[self drawBulletAtX:markerX centerY:centerY depth:depth font:font color:color];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#pragma mark - Attribute Resolution
|
|
161
|
+
|
|
162
|
+
- (BOOL)readListAttributesAtIndex:(NSUInteger)charIndex
|
|
163
|
+
storage:(NSTextStorage *)storage
|
|
164
|
+
paraStart:(NSUInteger)paraStart
|
|
165
|
+
isOrdered:(out BOOL *)outOrdered
|
|
166
|
+
depth:(out NSInteger *)outDepth
|
|
167
|
+
ordinal:(out NSInteger *)outOrdinal
|
|
168
|
+
{
|
|
169
|
+
if (charIndex >= storage.length) {
|
|
170
|
+
return NO;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
NSNumber *type = [storage attribute:ENRMBlockTypeAttributeName atIndex:charIndex effectiveRange:NULL];
|
|
174
|
+
if (!type || !ENRMBlockTypeIsListItem((ENRMInputBlockType)type.integerValue) || charIndex != paraStart) {
|
|
175
|
+
return NO;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
*outOrdered = (type.integerValue == ENRMInputBlockTypeOrderedListItem);
|
|
179
|
+
|
|
180
|
+
NSNumber *depthValue = [storage attribute:ENRMBlockLevelAttributeName atIndex:charIndex effectiveRange:NULL];
|
|
181
|
+
*outDepth = depthValue ? depthValue.integerValue : 0;
|
|
182
|
+
|
|
183
|
+
NSNumber *ordinalValue = [storage attribute:ENRMBlockOrdinalAttributeName atIndex:charIndex effectiveRange:NULL];
|
|
184
|
+
*outOrdinal = ordinalValue ? ordinalValue.integerValue : 1;
|
|
185
|
+
|
|
186
|
+
return YES;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (void)resolveMarkerFont:(out UIFont **)outFont
|
|
190
|
+
color:(out RCTUIColor **)outColor
|
|
191
|
+
atIndex:(NSUInteger)charIndex
|
|
192
|
+
storage:(NSTextStorage *)storage
|
|
193
|
+
isEmptyListLine:(BOOL)isEmptyListLine
|
|
194
|
+
{
|
|
195
|
+
UIFont *font = nil;
|
|
196
|
+
RCTUIColor *color = nil;
|
|
197
|
+
|
|
198
|
+
if (isEmptyListLine) {
|
|
199
|
+
font = self.emptyBulletFont;
|
|
200
|
+
color = self.emptyBulletColor;
|
|
201
|
+
}
|
|
202
|
+
if (!font && charIndex < storage.length) {
|
|
203
|
+
font = [storage attribute:NSFontAttributeName atIndex:charIndex effectiveRange:NULL];
|
|
204
|
+
}
|
|
205
|
+
if (!color && charIndex < storage.length) {
|
|
206
|
+
color = [storage attribute:NSForegroundColorAttributeName atIndex:charIndex effectiveRange:NULL];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
*outFont = font ?: ENRMFallbackFont();
|
|
210
|
+
*outColor = color ?: ENRMFallbackColor();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
#pragma mark - Fragment Processing
|
|
214
|
+
|
|
215
|
+
- (void)processLineFragmentRect:(CGRect)rect
|
|
216
|
+
usedRect:(CGRect)usedRect
|
|
217
|
+
container:(NSTextContainer *)container
|
|
218
|
+
glyphRange:(NSRange)glyphRange
|
|
219
|
+
origin:(CGPoint)origin
|
|
220
|
+
layoutManager:(NSLayoutManager *)layoutManager
|
|
221
|
+
storage:(NSTextStorage *)storage
|
|
222
|
+
string:(NSString *)string
|
|
223
|
+
{
|
|
224
|
+
NSRange charRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
|
|
225
|
+
if (charRange.location == NSNotFound) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
NSRange paraRange = (charRange.location < string.length) ? [string paragraphRangeForRange:charRange]
|
|
230
|
+
: NSMakeRange(charRange.location, 0);
|
|
231
|
+
|
|
232
|
+
if ([_drawnParagraphLocations containsObject:@(paraRange.location)]) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
BOOL isOrdered = NO;
|
|
237
|
+
NSInteger depth = 0;
|
|
238
|
+
NSInteger ordinal = 1;
|
|
239
|
+
BOOL isAttributedListLine = [self readListAttributesAtIndex:charRange.location
|
|
240
|
+
storage:storage
|
|
241
|
+
paraStart:paraRange.location
|
|
242
|
+
isOrdered:&isOrdered
|
|
243
|
+
depth:&depth
|
|
244
|
+
ordinal:&ordinal];
|
|
245
|
+
|
|
246
|
+
BOOL isEmptyListLine =
|
|
247
|
+
!isAttributedListLine && self.emptyBulletDepth >= 0 && charRange.location == self.emptyBulletLocation;
|
|
248
|
+
if (isEmptyListLine) {
|
|
249
|
+
depth = self.emptyBulletDepth;
|
|
250
|
+
isOrdered = self.emptyBulletOrdered;
|
|
251
|
+
ordinal = self.emptyBulletOrdinal;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (!isAttributedListLine && !isEmptyListLine) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
[_drawnParagraphLocations addObject:@(paraRange.location)];
|
|
258
|
+
|
|
259
|
+
UIFont *font;
|
|
260
|
+
RCTUIColor *color;
|
|
261
|
+
[self resolveMarkerFont:&font
|
|
262
|
+
color:&color
|
|
263
|
+
atIndex:charRange.location
|
|
264
|
+
storage:storage
|
|
265
|
+
isEmptyListLine:isEmptyListLine];
|
|
266
|
+
|
|
267
|
+
CGFloat baselineOffset = isEmptyListLine ? self.listItemSpacing + font.ascender
|
|
268
|
+
: [layoutManager locationForGlyphAtIndex:glyphRange.location].y;
|
|
269
|
+
CGFloat baselineY = origin.y + rect.origin.y + baselineOffset;
|
|
270
|
+
|
|
271
|
+
BOOL isRTL = isEmptyListLine ? self.emptyBulletRTL
|
|
272
|
+
: ENRMParagraphIsRTL([storage attribute:NSParagraphStyleAttributeName
|
|
273
|
+
atIndex:charRange.location
|
|
274
|
+
effectiveRange:NULL]);
|
|
275
|
+
|
|
276
|
+
[self drawListMarkerOrdered:isOrdered
|
|
277
|
+
depth:depth
|
|
278
|
+
ordinal:ordinal
|
|
279
|
+
rtl:isRTL
|
|
280
|
+
baselineY:baselineY
|
|
281
|
+
origin:origin
|
|
282
|
+
usedRect:usedRect
|
|
283
|
+
container:container
|
|
284
|
+
font:font
|
|
285
|
+
color:color];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
#pragma mark - ENRMInputDecorationDrawer
|
|
289
|
+
|
|
290
|
+
- (void)drawDecorationsForGlyphRange:(NSRange)glyphRange
|
|
291
|
+
layoutManager:(NSLayoutManager *)layoutManager
|
|
292
|
+
atPoint:(CGPoint)origin
|
|
293
|
+
{
|
|
294
|
+
NSTextStorage *storage = layoutManager.textStorage;
|
|
295
|
+
NSString *string = storage.string;
|
|
296
|
+
[_drawnParagraphLocations removeAllObjects];
|
|
297
|
+
|
|
298
|
+
[layoutManager enumerateLineFragmentsForGlyphRange:glyphRange
|
|
299
|
+
usingBlock:^(CGRect rect, CGRect usedRect, NSTextContainer *container,
|
|
300
|
+
NSRange fragmentGlyphRange, __unused BOOL *stop) {
|
|
301
|
+
[self processLineFragmentRect:rect
|
|
302
|
+
usedRect:usedRect
|
|
303
|
+
container:container
|
|
304
|
+
glyphRange:fragmentGlyphRange
|
|
305
|
+
origin:origin
|
|
306
|
+
layoutManager:layoutManager
|
|
307
|
+
storage:storage
|
|
308
|
+
string:string];
|
|
309
|
+
}];
|
|
310
|
+
|
|
311
|
+
#if TARGET_OS_OSX
|
|
312
|
+
if (self.emptyBulletDepth >= 0 && self.emptyBulletLocation >= storage.length &&
|
|
313
|
+
layoutManager.extraLineFragmentTextContainer != nil) {
|
|
314
|
+
UIFont *font = self.emptyBulletFont ?: ENRMFallbackFont();
|
|
315
|
+
RCTUIColor *color = self.emptyBulletColor ?: ENRMFallbackColor();
|
|
316
|
+
CGRect used = layoutManager.extraLineFragmentUsedRect;
|
|
317
|
+
CGFloat baselineY = origin.y + used.origin.y + font.ascender;
|
|
318
|
+
[self drawListMarkerOrdered:self.emptyBulletOrdered
|
|
319
|
+
depth:self.emptyBulletDepth
|
|
320
|
+
ordinal:self.emptyBulletOrdinal
|
|
321
|
+
rtl:self.emptyBulletRTL
|
|
322
|
+
baselineY:baselineY
|
|
323
|
+
origin:origin
|
|
324
|
+
usedRect:used
|
|
325
|
+
container:layoutManager.extraLineFragmentTextContainer
|
|
326
|
+
font:font
|
|
327
|
+
color:color];
|
|
328
|
+
}
|
|
329
|
+
#endif
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
- (void)drawEmptyEditorDecorationsWithInset:(UIEdgeInsets)inset layoutManager:(NSLayoutManager *)layoutManager
|
|
333
|
+
{
|
|
334
|
+
if (self.emptyBulletDepth < 0) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
UIFont *font = self.emptyBulletFont ?: ENRMFallbackFont();
|
|
339
|
+
RCTUIColor *color = self.emptyBulletColor ?: ENRMFallbackColor();
|
|
340
|
+
NSTextContainer *container = layoutManager.textContainers.firstObject;
|
|
341
|
+
BOOL isRTL = self.emptyBulletRTL && container != nil;
|
|
342
|
+
|
|
343
|
+
CGFloat headIndent = (self.emptyBulletDepth + 1) * kENRMListIndentPerDepth;
|
|
344
|
+
CGFloat padding = container ? container.lineFragmentPadding : 0;
|
|
345
|
+
CGRect syntheticUsedRect = CGRectMake(padding + headIndent, 0, 0, 0);
|
|
346
|
+
CGPoint syntheticOrigin = CGPointMake(inset.left, 0);
|
|
347
|
+
NSTextContainer *drawContainer = container ?: [[NSTextContainer alloc] initWithSize:CGSizeMake(0, CGFLOAT_MAX)];
|
|
348
|
+
|
|
349
|
+
CGFloat baselineY = inset.top + font.ascender;
|
|
350
|
+
|
|
351
|
+
[self drawListMarkerOrdered:self.emptyBulletOrdered
|
|
352
|
+
depth:self.emptyBulletDepth
|
|
353
|
+
ordinal:self.emptyBulletOrdinal
|
|
354
|
+
rtl:isRTL
|
|
355
|
+
baselineY:baselineY
|
|
356
|
+
origin:syntheticOrigin
|
|
357
|
+
usedRect:syntheticUsedRect
|
|
358
|
+
container:drawContainer
|
|
359
|
+
font:font
|
|
360
|
+
color:color];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#if !TARGET_OS_OSX
|
|
364
|
+
|
|
365
|
+
#pragma mark - Trailing Bullet Overlay
|
|
366
|
+
|
|
367
|
+
- (void)drawTrailingBulletMarkerInRect:(CGRect)bounds
|
|
368
|
+
{
|
|
369
|
+
if (self.emptyBulletDepth < 0 || !_trailingBulletTextContainer) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
UIFont *font = self.emptyBulletFont ?: ENRMFallbackFont();
|
|
374
|
+
RCTUIColor *color = self.emptyBulletColor ?: ENRMFallbackColor();
|
|
375
|
+
|
|
376
|
+
CGRect usedRect = CGRectMake(_trailingBulletHeadIndent, 0, 0, bounds.size.height);
|
|
377
|
+
CGPoint origin = CGPointMake(_trailingBulletInsetLeft, 0);
|
|
378
|
+
|
|
379
|
+
[self drawListMarkerOrdered:self.emptyBulletOrdered
|
|
380
|
+
depth:self.emptyBulletDepth
|
|
381
|
+
ordinal:self.emptyBulletOrdinal
|
|
382
|
+
rtl:self.emptyBulletRTL
|
|
383
|
+
baselineY:font.ascender
|
|
384
|
+
origin:origin
|
|
385
|
+
usedRect:usedRect
|
|
386
|
+
container:_trailingBulletTextContainer
|
|
387
|
+
font:font
|
|
388
|
+
color:color];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
- (void)showTrailingBulletInTextView:(UITextView *)textView
|
|
392
|
+
textContainer:(NSTextContainer *)container
|
|
393
|
+
usedRect:(CGRect)usedRect
|
|
394
|
+
{
|
|
395
|
+
if (!_trailingBulletView) {
|
|
396
|
+
_trailingBulletView = [[ENRMTrailingBulletView alloc] init];
|
|
397
|
+
_trailingBulletView.backgroundColor = [RCTUIColor clearColor];
|
|
398
|
+
_trailingBulletView.opaque = NO;
|
|
399
|
+
_trailingBulletView.userInteractionEnabled = NO;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (_trailingBulletView.superview != textView) {
|
|
403
|
+
[_trailingBulletView removeFromSuperview];
|
|
404
|
+
[textView addSubview:_trailingBulletView];
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
UIEdgeInsets inset = textView.textContainerInset;
|
|
408
|
+
_trailingBulletView.frame =
|
|
409
|
+
CGRectMake(0, inset.top + usedRect.origin.y, textView.bounds.size.width, usedRect.size.height);
|
|
410
|
+
_trailingBulletView.drawer = self;
|
|
411
|
+
_trailingBulletTextContainer = container;
|
|
412
|
+
_trailingBulletInsetLeft = inset.left;
|
|
413
|
+
_trailingBulletHeadIndent = usedRect.origin.x;
|
|
414
|
+
_trailingBulletView.hidden = NO;
|
|
415
|
+
[textView bringSubviewToFront:_trailingBulletView];
|
|
416
|
+
[_trailingBulletView setNeedsDisplay];
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
- (void)hideTrailingBullet
|
|
420
|
+
{
|
|
421
|
+
_trailingBulletView.hidden = YES;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
#endif
|
|
425
|
+
|
|
426
|
+
@end
|