react-native-marcus 0.1.1 → 0.2.0
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 +220 -63
- package/RNMarcus.podspec +6 -0
- package/android/src/main/java/app/getbullet/marcus/MarcusPackage.kt +2 -1
- package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorView.kt +168 -0
- package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorViewManager.kt +38 -0
- package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorViewManagerSpec.kt +19 -0
- package/android/src/main/java/app/getbullet/marcus/MarcusTextInputDecoratorView.kt +23 -1
- package/android/src/main/java/app/getbullet/marcus/MarkdownBackgroundPainter.kt +147 -0
- package/android/src/main/java/app/getbullet/marcus/MarkdownBackgroundPass.kt +19 -0
- package/android/src/main/java/app/getbullet/marcus/MarkdownCopy.kt +87 -0
- package/android/src/main/java/app/getbullet/marcus/MarkdownFormatter.kt +652 -113
- package/android/src/main/java/app/getbullet/marcus/MarkdownRanges.kt +47 -0
- package/android/src/main/java/app/getbullet/marcus/MarkdownStyle.kt +140 -61
- package/android/src/main/java/app/getbullet/marcus/MarkdownUtils.kt +37 -7
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownAbsoluteLineHeightSpan.kt +48 -0
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundSpan.kt +102 -48
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBlockIndentSpan.kt +22 -4
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBulletSpan.kt +78 -0
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownCodeBlockSpan.kt +177 -0
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontStyleSpan.kt +32 -0
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontWeightSpan.kt +34 -0
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownGapSpan.kt +24 -11
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownLetterSpacingSpan.kt +32 -0
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownTextShadowSpan.kt +32 -0
- package/android/src/main/new_arch/CMakeLists.txt +17 -0
- package/android/src/main/new_arch/RNMarcusSpec.h +1 -0
- package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorShadowNode.cpp +235 -0
- package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorShadowNode.h +62 -0
- package/android/src/reactNativeVersionPatch/CustomMountingManager/81/app/getbullet/marcus/CustomFabricUIManager.java +22 -3
- package/android/src/reactNativeVersionPatch/CustomMountingManager/latest/app/getbullet/marcus/CustomFabricUIManager.java +22 -3
- package/android/src/test/java/app/getbullet/marcus/MarkdownCopyTest.kt +69 -0
- package/android/src/test/java/app/getbullet/marcus/MarkdownFormatterTest.kt +170 -25
- package/android/src/test/java/app/getbullet/marcus/RenderModel.kt +22 -5
- package/android/src/test/java/app/getbullet/marcus/spans/MarkdownCodeBlockSpanTest.kt +91 -0
- package/android/src/test/resources/render-model.txt +221 -16
- package/apple/MarcusSwizzle.h +25 -0
- package/apple/MarcusTextDecoratorComponentView.h +22 -0
- package/apple/MarcusTextDecoratorComponentView.mm +72 -0
- package/apple/MarcusTextDecoratorShadowNode.h +62 -0
- package/apple/MarcusTextDecoratorShadowNode.mm +192 -0
- package/apple/MarcusTextDecoratorViewManager.h +4 -0
- package/apple/MarcusTextDecoratorViewManager.mm +11 -0
- package/apple/MarcusTextInputDecoratorComponentView.mm +1 -1
- package/apple/MarcusTextInputDecoratorShadowNode.mm +1 -1
- package/apple/MarcusTextLayoutManager.h +40 -0
- package/apple/MarcusTextLayoutManager.mm +173 -0
- package/apple/MarkdownAttributes.h +23 -2
- package/apple/MarkdownAttributes.m +6 -0
- package/apple/MarkdownCopy.swift +63 -0
- package/apple/MarkdownDecorator.swift +2 -2
- package/apple/MarkdownFormatter+React.swift +23 -0
- package/apple/MarkdownFormatter.swift +869 -148
- package/apple/MarkdownParagraphLayoutManager.swift +455 -0
- package/apple/MarkdownSwiftInterop.h +0 -1
- package/apple/MarkdownTextBackground.swift +59 -1
- package/apple/MarkdownTextFieldObserver.swift +2 -2
- package/apple/MarkdownTextLayoutFragment.swift +159 -33
- package/apple/MarkdownTextLayoutManagerDelegate.swift +67 -3
- package/apple/MarkdownTextStorageDelegate.swift +2 -2
- package/apple/MarkdownTextViewObserver.swift +2 -2
- package/apple/MarkdownUtils.swift +38 -0
- package/apple/MarkdownWritingDirection.swift +132 -0
- package/apple/RCTMarcusStyle+Codegen.h +115 -9
- package/apple/RCTMarcusStyle.h +128 -31
- package/apple/RCTMarcusStyle.m +48 -0
- package/apple/RCTParagraphComponentView+Marcus.h +17 -0
- package/apple/RCTParagraphComponentView+Marcus.mm +38 -0
- package/apple/RCTTextInputComponentView+Marcus.mm +1 -25
- package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorState.h +37 -0
- package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorViewComponentDescriptor.h +17 -0
- package/lib/commonjs/MarcusTextDecoratorViewNativeComponent.ts +199 -0
- package/lib/commonjs/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
- package/lib/commonjs/MarkdownText.js +330 -0
- package/lib/commonjs/MarkdownText.js.map +1 -0
- package/lib/commonjs/MarkdownText.web.js +529 -0
- package/lib/commonjs/MarkdownText.web.js.map +1 -0
- package/lib/commonjs/MarkdownTextInput.js +22 -27
- package/lib/commonjs/MarkdownTextInput.js.map +1 -1
- package/lib/commonjs/MarkdownTextInput.web.js +12 -7
- package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
- package/lib/commonjs/atomUtils.js +112 -0
- package/lib/commonjs/atomUtils.js.map +1 -0
- package/lib/commonjs/childrenUtils.js +36 -0
- package/lib/commonjs/childrenUtils.js.map +1 -0
- package/lib/commonjs/index.js +8 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/math/environment.js +69 -0
- package/lib/commonjs/math/environment.js.map +1 -0
- package/lib/commonjs/math/index.js +61 -0
- package/lib/commonjs/math/index.js.map +1 -0
- package/lib/commonjs/math/mathjax.js +548 -0
- package/lib/commonjs/math/mathjax.js.map +1 -0
- package/lib/commonjs/metro.js +172 -0
- package/lib/commonjs/metro.js.map +1 -0
- package/lib/commonjs/parser/index.d.ts +3 -0
- package/lib/commonjs/parser/index.js +450 -42
- package/lib/commonjs/parser/index.js.map +4 -4
- package/lib/commonjs/stripUtils.js +743 -0
- package/lib/commonjs/stripUtils.js.map +1 -0
- package/lib/commonjs/styleUtils.js +194 -23
- package/lib/commonjs/styleUtils.js.map +1 -1
- package/lib/commonjs/web/MarkdownElements.css +67 -0
- package/lib/commonjs/web/MarkdownTextInput.css +9 -7
- package/lib/commonjs/web/utils/blockLayout.js +95 -7
- package/lib/commonjs/web/utils/blockLayout.js.map +1 -1
- package/lib/commonjs/web/utils/blockUtils.js +327 -54
- package/lib/commonjs/web/utils/blockUtils.js.map +1 -1
- package/lib/commonjs/web/utils/elementUtils.js +80 -0
- package/lib/commonjs/web/utils/elementUtils.js.map +1 -0
- package/lib/commonjs/web/utils/parserUtils.js +84 -28
- package/lib/commonjs/web/utils/parserUtils.js.map +1 -1
- package/lib/commonjs/web/utils/treeUtils.js +6 -0
- package/lib/commonjs/web/utils/treeUtils.js.map +1 -1
- package/lib/commonjs/web/utils/webStyleUtils.js +25 -5
- package/lib/commonjs/web/utils/webStyleUtils.js.map +1 -1
- package/lib/module/MarcusTextDecoratorViewNativeComponent.ts +199 -0
- package/lib/module/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
- package/lib/module/MarkdownText.js +325 -0
- package/lib/module/MarkdownText.js.map +1 -0
- package/lib/module/MarkdownText.web.js +524 -0
- package/lib/module/MarkdownText.web.js.map +1 -0
- package/lib/module/MarkdownTextInput.js +24 -29
- package/lib/module/MarkdownTextInput.js.map +1 -1
- package/lib/module/MarkdownTextInput.web.js +12 -7
- package/lib/module/MarkdownTextInput.web.js.map +1 -1
- package/lib/module/atomUtils.js +106 -0
- package/lib/module/atomUtils.js.map +1 -0
- package/lib/module/childrenUtils.js +33 -0
- package/lib/module/childrenUtils.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/math/environment.js +67 -0
- package/lib/module/math/environment.js.map +1 -0
- package/lib/module/math/index.js +56 -0
- package/lib/module/math/index.js.map +1 -0
- package/lib/module/math/mathjax.js +541 -0
- package/lib/module/math/mathjax.js.map +1 -0
- package/lib/module/metro.js +169 -0
- package/lib/module/metro.js.map +1 -0
- package/lib/module/parser/index.d.ts +3 -0
- package/lib/module/parser/index.js +450 -42
- package/lib/module/parser/index.js.map +4 -4
- package/lib/module/stripUtils.js +739 -0
- package/lib/module/stripUtils.js.map +1 -0
- package/lib/module/styleUtils.js +196 -25
- package/lib/module/styleUtils.js.map +1 -1
- package/lib/module/web/MarkdownElements.css +67 -0
- package/lib/module/web/MarkdownTextInput.css +9 -7
- package/lib/module/web/utils/blockLayout.js +94 -8
- package/lib/module/web/utils/blockLayout.js.map +1 -1
- package/lib/module/web/utils/blockUtils.js +328 -56
- package/lib/module/web/utils/blockUtils.js.map +1 -1
- package/lib/module/web/utils/elementUtils.js +75 -0
- package/lib/module/web/utils/elementUtils.js.map +1 -0
- package/lib/module/web/utils/parserUtils.js +86 -30
- package/lib/module/web/utils/parserUtils.js.map +1 -1
- package/lib/module/web/utils/treeUtils.js +6 -0
- package/lib/module/web/utils/treeUtils.js.map +1 -1
- package/lib/module/web/utils/webStyleUtils.js +25 -5
- package/lib/module/web/utils/webStyleUtils.js.map +1 -1
- package/lib/typescript/commonjs/e2e/links.test.d.ts +2 -0
- package/lib/typescript/commonjs/e2e/links.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MarcusTextDecoratorViewNativeComponent.d.ts +93 -0
- package/lib/typescript/commonjs/src/MarcusTextDecoratorViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +64 -51
- package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/MarkdownText.d.ts +127 -0
- package/lib/typescript/commonjs/src/MarkdownText.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MarkdownText.web.d.ts +126 -0
- package/lib/typescript/commonjs/src/MarkdownText.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts +23 -1
- package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts +26 -4
- package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/atomUtils.d.ts +58 -0
- package/lib/typescript/commonjs/src/atomUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/childrenUtils.d.ts +12 -0
- package/lib/typescript/commonjs/src/childrenUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/commonTypes.d.ts +39 -3
- package/lib/typescript/commonjs/src/commonTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/math/environment.d.ts +7 -0
- package/lib/typescript/commonjs/src/math/environment.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/math/index.d.ts +64 -0
- package/lib/typescript/commonjs/src/math/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/math/mathjax.d.ts +63 -0
- package/lib/typescript/commonjs/src/math/mathjax.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/metro.d.ts +59 -0
- package/lib/typescript/commonjs/src/metro.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/parser/index.d.ts +3 -3
- package/lib/typescript/commonjs/src/parser/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/parser/micromark-extension-mentions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/rangeUtils.d.ts +1 -1
- package/lib/typescript/commonjs/src/stripUtils.d.ts +108 -0
- package/lib/typescript/commonjs/src/stripUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/styleUtils.d.ts +62 -4
- package/lib/typescript/commonjs/src/styleUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts +32 -4
- package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts +20 -8
- package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/web/utils/elementUtils.d.ts +37 -0
- package/lib/typescript/commonjs/src/web/utils/elementUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts +5 -5
- package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts +6 -1
- package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts +2 -2
- package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts.map +1 -1
- package/lib/typescript/module/e2e/links.test.d.ts +2 -0
- package/lib/typescript/module/e2e/links.test.d.ts.map +1 -0
- package/lib/typescript/module/src/MarcusTextDecoratorViewNativeComponent.d.ts +93 -0
- package/lib/typescript/module/src/MarcusTextDecoratorViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +64 -51
- package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/MarkdownText.d.ts +127 -0
- package/lib/typescript/module/src/MarkdownText.d.ts.map +1 -0
- package/lib/typescript/module/src/MarkdownText.web.d.ts +126 -0
- package/lib/typescript/module/src/MarkdownText.web.d.ts.map +1 -0
- package/lib/typescript/module/src/MarkdownTextInput.d.ts +23 -1
- package/lib/typescript/module/src/MarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/module/src/MarkdownTextInput.web.d.ts +26 -4
- package/lib/typescript/module/src/MarkdownTextInput.web.d.ts.map +1 -1
- package/lib/typescript/module/src/atomUtils.d.ts +58 -0
- package/lib/typescript/module/src/atomUtils.d.ts.map +1 -0
- package/lib/typescript/module/src/childrenUtils.d.ts +12 -0
- package/lib/typescript/module/src/childrenUtils.d.ts.map +1 -0
- package/lib/typescript/module/src/commonTypes.d.ts +39 -3
- package/lib/typescript/module/src/commonTypes.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/math/environment.d.ts +7 -0
- package/lib/typescript/module/src/math/environment.d.ts.map +1 -0
- package/lib/typescript/module/src/math/index.d.ts +64 -0
- package/lib/typescript/module/src/math/index.d.ts.map +1 -0
- package/lib/typescript/module/src/math/mathjax.d.ts +63 -0
- package/lib/typescript/module/src/math/mathjax.d.ts.map +1 -0
- package/lib/typescript/module/src/metro.d.ts +59 -0
- package/lib/typescript/module/src/metro.d.ts.map +1 -0
- package/lib/typescript/module/src/parser/index.d.ts +3 -3
- package/lib/typescript/module/src/parser/index.d.ts.map +1 -1
- package/lib/typescript/module/src/parser/micromark-extension-mentions.d.ts.map +1 -1
- package/lib/typescript/module/src/rangeUtils.d.ts +1 -1
- package/lib/typescript/module/src/stripUtils.d.ts +108 -0
- package/lib/typescript/module/src/stripUtils.d.ts.map +1 -0
- package/lib/typescript/module/src/styleUtils.d.ts +62 -4
- package/lib/typescript/module/src/styleUtils.d.ts.map +1 -1
- package/lib/typescript/module/src/web/utils/blockLayout.d.ts +32 -4
- package/lib/typescript/module/src/web/utils/blockLayout.d.ts.map +1 -1
- package/lib/typescript/module/src/web/utils/blockUtils.d.ts +20 -8
- package/lib/typescript/module/src/web/utils/blockUtils.d.ts.map +1 -1
- package/lib/typescript/module/src/web/utils/elementUtils.d.ts +37 -0
- package/lib/typescript/module/src/web/utils/elementUtils.d.ts.map +1 -0
- package/lib/typescript/module/src/web/utils/parserUtils.d.ts +5 -5
- package/lib/typescript/module/src/web/utils/parserUtils.d.ts.map +1 -1
- package/lib/typescript/module/src/web/utils/treeUtils.d.ts +6 -1
- package/lib/typescript/module/src/web/utils/treeUtils.d.ts.map +1 -1
- package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts +2 -2
- package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts.map +1 -1
- package/package.json +29 -2
- package/react-native.config.js +8 -1
- package/src/MarcusTextDecoratorViewNativeComponent.ts +199 -0
- package/src/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
- package/src/MarkdownText.tsx +472 -0
- package/src/MarkdownText.web.tsx +668 -0
- package/src/MarkdownTextInput.tsx +42 -38
- package/src/MarkdownTextInput.web.tsx +36 -13
- package/src/atomUtils.ts +112 -0
- package/src/childrenUtils.ts +39 -0
- package/src/commonTypes.ts +69 -9
- package/src/index.tsx +2 -1
- package/src/math/environment.ts +68 -0
- package/src/math/index.ts +78 -0
- package/src/math/mathjax.ts +604 -0
- package/src/metro.ts +238 -0
- package/src/parser/index.ts +175 -10
- package/src/parser/micromark-extension-mentions.ts +104 -11
- package/src/stripUtils.ts +919 -0
- package/src/styleUtils.ts +290 -26
- package/src/web/MarkdownElements.css +67 -0
- package/src/web/MarkdownTextInput.css +9 -7
- package/src/web/utils/blockLayout.ts +124 -14
- package/src/web/utils/blockUtils.ts +365 -59
- package/src/web/utils/elementUtils.ts +87 -0
- package/src/web/utils/parserUtils.ts +119 -31
- package/src/web/utils/treeUtils.ts +6 -1
- package/src/web/utils/webStyleUtils.ts +32 -8
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundColorSpan.kt +0 -6
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBoldSpan.kt +0 -6
- package/android/src/main/java/app/getbullet/marcus/spans/MarkdownItalicSpan.kt +0 -6
- package/apple/RCTMarcusStyle+Codegen.mm +0 -64
- package/apple/RCTMarcusUtils.h +0 -26
- package/apple/RCTMarcusUtils.mm +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleUtils.d.ts","sourceRoot":"","sources":["../../../../src/styleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"styleUtils.d.ts","sourceRoot":"","sources":["../../../../src/styleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,+CAA+C,CAAA;AAatD,KAAK,sBAAsB,GAAG,IAAI,CAChC,SAAS,EACP,OAAO,GACP,YAAY,GACZ,UAAU,GACV,WAAW,GACX,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,CACrB,CAAA;AAID,KAAK,qBAAqB,GAAG,sBAAsB,GACjD,IAAI,CACF,SAAS,EACP,iBAAiB,GACjB,aAAa,GACb,aAAa,GACb,cAAc,GACd,SAAS,GACT,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,GACR,kBAAkB,GAClB,gBAAgB,CACnB,GAAG;IAGF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAEH,KAAK,yBAAyB,GAAG,sBAAsB,GAAG;IACxD,KAAK,CAAC,EA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AAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,aAAa,CAmB7F;AAsCD,iBAAS,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,aAAa,CAEpF;AAED,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,GACvB,CAAA;AAED,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MarkdownRange } from "../../commonTypes.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResolvedMarkdownStyle } from "../../styleUtils.js";
|
|
3
3
|
import type { TextMeasurer } from "./measureUtils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Where one line's text sits, and what has to be drawn in the space to its left.
|
|
@@ -16,7 +16,35 @@ type LineLayout = {
|
|
|
16
16
|
/** Space to open after a marker, so the next container's gutter lands between the two. */
|
|
17
17
|
gaps: Map<number, number>;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* How a list's markers are drawn, which is the one thing a display does differently from an input.
|
|
21
|
+
*
|
|
22
|
+
* A display renders the marker rather than showing it: an unordered item's `-` becomes a bullet, an
|
|
23
|
+
* ordered item's `1.` stays the number it means but at its own scale, and both hold a little room
|
|
24
|
+
* either side. An input shows the marker you typed, in the base font, because there it is text
|
|
25
|
+
* being edited rather than a rendering of it. `MarkdownFormatter` draws the same distinction on
|
|
26
|
+
* both native platforms from the same style values.
|
|
27
|
+
*
|
|
28
|
+
* `fontSize` is what the wrapped element renders at, in pixels, which is what a marker is sized in
|
|
29
|
+
* proportion to.
|
|
30
|
+
*/
|
|
31
|
+
type MarkerRendering = {
|
|
32
|
+
display: boolean;
|
|
33
|
+
fontSize: number;
|
|
34
|
+
};
|
|
35
|
+
/** An input's markers, and the default everywhere the question does not arise. */
|
|
36
|
+
declare const SHOWN_MARKERS: MarkerRendering;
|
|
19
37
|
declare function toNumber(value: string | number | undefined | null): number;
|
|
38
|
+
/**
|
|
39
|
+
* The marker at the end of a prefix: the `-` of a bullet or the `1.` of a numbered item, without
|
|
40
|
+
* the indent in front of it or the space after it.
|
|
41
|
+
*
|
|
42
|
+
* Read off the text rather than taken from the `syntax` range covering it, because a prefix runs
|
|
43
|
+
* from wherever the previous container's marker ended and so can carry another container's marker
|
|
44
|
+
* with it -- the ordered list in `- > 1. ` is handed `> 1. `. The last run of non-blanks is this
|
|
45
|
+
* container's own. `MarkdownFormatter` reads it the same way on both native platforms.
|
|
46
|
+
*/
|
|
47
|
+
declare function markerRun(prefix: string): string;
|
|
20
48
|
/**
|
|
21
49
|
* Places the containers of every line, left to right -- the web half of `BlockLayout` in
|
|
22
50
|
* `apple/MarkdownFormatter.swift` and `android/.../MarkdownFormatter.kt`, and deliberately the same
|
|
@@ -35,7 +63,7 @@ declare function toNumber(value: string | number | undefined | null): number;
|
|
|
35
63
|
* to -- so it has to run before `sortRanges` rearranges them into the containment order the DOM
|
|
36
64
|
* builder needs.
|
|
37
65
|
*/
|
|
38
|
-
declare function layoutBlocks(text: string, ranges: MarkdownRange[], markdownStyle:
|
|
39
|
-
export { layoutBlocks, toNumber };
|
|
40
|
-
export type { LineLayout };
|
|
66
|
+
declare function layoutBlocks(text: string, ranges: MarkdownRange[], markdownStyle: ResolvedMarkdownStyle, measure: TextMeasurer, rendering?: MarkerRendering): Map<number, LineLayout>;
|
|
67
|
+
export { layoutBlocks, markerRun, SHOWN_MARKERS, toNumber };
|
|
68
|
+
export type { LineLayout, MarkerRendering };
|
|
41
69
|
//# sourceMappingURL=blockLayout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,sBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,
|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
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { LineLayout } from "./blockLayout.js";
|
|
1
|
+
import type { ResolvedMarkdownStyle } from "../../styleUtils.js";
|
|
2
|
+
import type { LineLayout, MarkerRendering } from "./blockLayout.js";
|
|
3
3
|
import type { NodeType } from "./treeUtils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Applies the layout the block walk computed for one line.
|
|
6
6
|
*
|
|
7
|
-
* Everything a container contributes lands here rather than on the container's own
|
|
7
|
+
* Everything a container contributes lands here rather than on the container's own element: its gutter
|
|
8
8
|
* is part of the paragraph's indent, and its ribbon is painted behind the whole paragraph. That is
|
|
9
9
|
* how the native formatters do it too, and on the web it is the only placement that works -- a
|
|
10
|
-
* container's
|
|
10
|
+
* container's element begins before the markers of the containers outside it, so a border drawn on it
|
|
11
11
|
* would sit in front of a bullet that is meant to precede it, and a gutter set on it would open
|
|
12
12
|
* before that bullet rather than after.
|
|
13
13
|
*
|
|
14
|
-
* `padding-
|
|
14
|
+
* `padding-inline-start` holds every line of the paragraph at the indent, and the negative `text-indent`
|
|
15
15
|
* pulls the first one back to where its own marker starts -- `firstLineHeadIndent` and `headIndent`,
|
|
16
16
|
* spelled in CSS. A line that wraps, or a line continuing the block with no marker of its own, then
|
|
17
17
|
* lines up with the text above it instead of with the marker.
|
|
18
18
|
*/
|
|
19
|
-
declare function addLineLayout(node: HTMLElement, layout: LineLayout | undefined, markdownStyle:
|
|
19
|
+
declare function addLineLayout(node: HTMLElement, layout: LineLayout | undefined, markdownStyle: ResolvedMarkdownStyle): void;
|
|
20
|
+
/**
|
|
21
|
+
* Turns a line's ribbons round when the line reads right to left.
|
|
22
|
+
*
|
|
23
|
+
* Asked of the browser rather than worked out from the text, because the browser is what lays the
|
|
24
|
+
* line out: whatever it resolved `dir="auto"` to is where it put the gutter, and the bars belong on
|
|
25
|
+
* that side whether or not a bidi rule written here would have agreed. `:dir()` is unsupported in
|
|
26
|
+
* browsers older than Safari 16.4, where `matches` throws and the fallback edge stands.
|
|
27
|
+
*
|
|
28
|
+
* Called once the line holds its text, since that is what a line's own direction is read from, and
|
|
29
|
+
* only for a line that has ribbons: nothing else on a line is measured from an edge.
|
|
30
|
+
*/
|
|
31
|
+
declare function setRibbonEdge(node: HTMLElement, layout: LineLayout | undefined): void;
|
|
20
32
|
/**
|
|
21
33
|
* Opens the space a marker holds for the container that follows it.
|
|
22
34
|
*
|
|
@@ -24,10 +36,10 @@ declare function addLineLayout(node: HTMLElement, layout: LineLayout | undefined
|
|
|
24
36
|
* puts a nested list's indent between the quote's `>` and the bullet rather than in front of both.
|
|
25
37
|
*/
|
|
26
38
|
declare function addBlockPrefixGap(node: HTMLElement, gap: number | undefined): void;
|
|
27
|
-
declare function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownStyle:
|
|
39
|
+
declare function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownStyle: ResolvedMarkdownStyle, isMultiline?: boolean, rendering?: MarkerRendering): void;
|
|
28
40
|
declare const MULTILINE_MARKDOWN_TYPES: string[];
|
|
29
41
|
declare function isMultilineMarkdownType(type: NodeType): boolean;
|
|
30
42
|
declare function isChildOfMarkdownElement(node: HTMLElement, elementType: NodeType): boolean;
|
|
31
43
|
declare function isChildOfMultilineMarkdownElement(node: HTMLElement): boolean;
|
|
32
|
-
export { addStyleToBlock, addLineLayout, addBlockPrefixGap, isMultilineMarkdownType, isChildOfMarkdownElement, isChildOfMultilineMarkdownElement, MULTILINE_MARKDOWN_TYPES, };
|
|
44
|
+
export { addStyleToBlock, addLineLayout, setRibbonEdge, addBlockPrefixGap, isMultilineMarkdownType, isChildOfMarkdownElement, isChildOfMultilineMarkdownElement, MULTILINE_MARKDOWN_TYPES, };
|
|
33
45
|
//# sourceMappingURL=blockUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blockUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/blockUtils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAe,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAa,CAAA;AAiH3C;;;;;;;;;;;;;;GAcG;AACH,iBAAS,aAAa,CACpB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,aAAa,EAAE,qBAAqB,QA4CrC;AAiBD;;;;;;;;;;GAUG;AACH,iBAAS,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,QAYvE;AAwBD;;;;;GAKG;AACH,iBAAS,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,QAOpE;AAED,iBAAS,eAAe,CACtB,aAAa,EAAE,WAAW,EAC1B,IAAI,EAAE,QAAQ,EACd,aAAa,EAAE,qBAAqB,EACpC,WAAW,UAAO,EAClB,SAAS,GAAE,eAA+B,QA+F3C;AAsJD,QAAA,MAAM,wBAAwB,UAAgB,CAAA;AAE9C,iBAAS,uBAAuB,CAAC,IAAI,EAAE,QAAQ,WAE9C;AAiBD,iBAAS,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAEnF;AACD,iBAAS,iCAAiC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAIrE;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,wBAAwB,GACzB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HTMLMarkdownElement } from "../../MarkdownTextInput.web.js";
|
|
2
|
+
import type { NodeType } from "./treeUtils.js";
|
|
3
|
+
/**
|
|
4
|
+
* The tag each markdown type is built as.
|
|
5
|
+
*
|
|
6
|
+
* A range says what a run of text *is*; the element it becomes should say the same thing to
|
|
7
|
+
* everything that reads the document rather than looking at it. A screen reader announces a
|
|
8
|
+
* `<strong>` and a `<blockquote>` and says nothing about a span; text copied out of the input
|
|
9
|
+
* arrives in another editor still emphasised; and the page `expo export` prerenders carries the
|
|
10
|
+
* structure rather than a wall of undifferentiated spans.
|
|
11
|
+
*
|
|
12
|
+
* `data-type` stays on every one of them regardless -- it is what the styling, the CSS and the
|
|
13
|
+
* render-model baselines are keyed on, and it distinguishes the several types that share a tag.
|
|
14
|
+
*
|
|
15
|
+
* Two pairings are worth spelling out. A fenced or indented block is `<pre>` from `codeblock`, the
|
|
16
|
+
* range covering the whole thing including its fences, with `<code>` inside it from `pre`, the
|
|
17
|
+
* range covering only the code -- which is the nesting HTML asks for, in the opposite naming to
|
|
18
|
+
* ours. And `link` is an anchor even in the input, where it has no `href` yet: an anchor without
|
|
19
|
+
* one is exactly what HTML has for a link whose destination is not resolved.
|
|
20
|
+
*
|
|
21
|
+
* Everything absent from here is a span, because HTML has nothing that means it: markdown's own
|
|
22
|
+
* punctuation, the parts of a link's markup, a mention, an emoji run.
|
|
23
|
+
*/
|
|
24
|
+
/** Marks an element as one of ours, for the rules that undo the tag's browser defaults. */
|
|
25
|
+
declare const ELEMENT_CLASS = "react-native-marcus";
|
|
26
|
+
declare function isBlockLevelType(type: NodeType): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Builds the element for a range, tagged and typed.
|
|
29
|
+
*
|
|
30
|
+
* `level` applies to headings only, and is the ATX level: `1` through `6` produce that heading,
|
|
31
|
+
* and `0` produces a span. A level arrives as one nested range per level -- `ungroupRanges` is what
|
|
32
|
+
* turns `depth` into the nesting the size scaling compounds down -- so only the outermost of them
|
|
33
|
+
* can be the heading itself, and the copies inside it are spans. `<h2><h2>` is not a thing.
|
|
34
|
+
*/
|
|
35
|
+
declare function createMarkdownElement(type: NodeType, level?: number): HTMLMarkdownElement;
|
|
36
|
+
export { createMarkdownElement, isBlockLevelType, ELEMENT_CLASS };
|
|
37
|
+
//# sourceMappingURL=elementUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/elementUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAa,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,2FAA2F;AAC3F,QAAA,MAAM,aAAa,wBAAwB,CAAA;AAgC3C,iBAAS,gBAAgB,CAAC,IAAI,EAAE,QAAQ,WAEvC;AAED;;;;;;;GAOG;AACH,iBAAS,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,SAAI,GAAG,mBAAmB,CAe7E;AAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HTMLMarkdownElement, MarkdownTextInputElement } from "../../MarkdownTextInput.web.js";
|
|
2
2
|
import type { TreeNode } from "./treeUtils.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type { LineLayout } from "./blockLayout.js";
|
|
3
|
+
import type { ResolvedMarkdownStyle } from "../../styleUtils.js";
|
|
4
|
+
import type { LineLayout, MarkerRendering } from "./blockLayout.js";
|
|
5
5
|
import type { TextMeasurer } from "./measureUtils.js";
|
|
6
6
|
import type { MarkdownRange } from "../../commonTypes.js";
|
|
7
7
|
type Paragraph = {
|
|
@@ -18,7 +18,7 @@ type Paragraph = {
|
|
|
18
18
|
*/
|
|
19
19
|
declare function normalizeLines(lines: Paragraph[], ranges: MarkdownRange[]): Paragraph[];
|
|
20
20
|
/** Builds HTML DOM structure based on passed text and markdown ranges */
|
|
21
|
-
declare function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], isMultiline?: boolean, markdownStyle?:
|
|
21
|
+
declare function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], isMultiline?: boolean, markdownStyle?: ResolvedMarkdownStyle, disableInlineStyles?: boolean, measure?: TextMeasurer, rendering?: MarkerRendering): {
|
|
22
22
|
dom: HTMLMarkdownElement;
|
|
23
23
|
tree: TreeNode;
|
|
24
24
|
};
|
|
@@ -31,11 +31,11 @@ type CachedLine = {
|
|
|
31
31
|
node: TreeNode;
|
|
32
32
|
};
|
|
33
33
|
type LineCache = {
|
|
34
|
-
markdownStyle:
|
|
34
|
+
markdownStyle: ResolvedMarkdownStyle;
|
|
35
35
|
isMultiline: boolean;
|
|
36
36
|
lines: CachedLine[];
|
|
37
37
|
};
|
|
38
|
-
declare function updateInputStructure(parserFunction: (input: string) => MarkdownRange[], target: MarkdownTextInputElement, text: string, cursorPositionIndex: number | null, isMultiline?: boolean, markdownStyle?:
|
|
38
|
+
declare function updateInputStructure(parserFunction: (input: string) => MarkdownRange[], target: MarkdownTextInputElement, text: string, cursorPositionIndex: number | null, isMultiline?: boolean, markdownStyle?: ResolvedMarkdownStyle, alwaysMoveCursorToTheEnd?: boolean, shouldForceDOMUpdate?: boolean, shouldScrollIntoView?: boolean): {
|
|
39
39
|
text: string;
|
|
40
40
|
cursorPosition: number;
|
|
41
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parserUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/parserUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,gCAA6B,CAAA;AAEhG,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,gBAAa,CAAA;AACrD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"parserUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/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,CAC3B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,EAAE,EAClD,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,WAAW,UAAO,EAClB,aAAa,GAAE,qBAA0B,EACzC,wBAAwB,UAAQ,EAChC,oBAAoB,UAAQ,EAC5B,oBAAoB,UAAQ;;;EAiD7B;AAED,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAA;AACvE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { HTMLMarkdownElement } from "../../MarkdownTextInput.web.js";
|
|
2
2
|
import type { MarkdownRange, MarkdownType } from "../../commonTypes.js";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* `list-item` is the one node with no range behind it: `<ul>` and `<ol>` may hold nothing but
|
|
5
|
+
* `<li>`, so the builder puts one inside each list container and everything the container holds
|
|
6
|
+
* goes in there. It covers exactly what its container does.
|
|
7
|
+
*/
|
|
8
|
+
type NodeType = MarkdownType | "line" | "text" | "br" | "root" | "list-item";
|
|
4
9
|
type TreeNode = Omit<MarkdownRange, "type"> & {
|
|
5
10
|
element: HTMLMarkdownElement;
|
|
6
11
|
parentNode: TreeNode | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/treeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAmB,CAAA;AAEpE,KAAK,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","s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,6 @@
|
|
|
1
1
|
import type { TextStyle } from "react-native";
|
|
2
|
-
import type {
|
|
3
|
-
declare function processMarkdownStyle(input:
|
|
2
|
+
import type { PartialMarkdownStyle, ResolvedMarkdownStyle } from "../../styleUtils.js";
|
|
3
|
+
declare function processMarkdownStyle(input: PartialMarkdownStyle | undefined): ResolvedMarkdownStyle;
|
|
4
4
|
declare function parseToReactDOMStyle(style: TextStyle): any;
|
|
5
5
|
declare const idGenerator: Generator<string, void, unknown>;
|
|
6
6
|
export { parseToReactDOMStyle, processMarkdownStyle, idGenerator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStyleUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/webStyleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"webStyleUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/web/utils/webStyleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAkB,CAAA;AAwEnF,iBAAS,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,qBAAqB,CAE5F;AAED,iBAAS,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAEnD;AASD,QAAA,MAAM,WAAW,kCAAqB,CAAA;AAEtC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-marcus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tomas Ravinskas",
|
|
@@ -33,6 +33,16 @@
|
|
|
33
33
|
"default": "./lib/commonjs/index.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
"./metro": {
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./lib/typescript/module/src/metro.d.ts",
|
|
39
|
+
"default": "./lib/module/metro.js"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./lib/typescript/commonjs/src/metro.d.ts",
|
|
43
|
+
"default": "./lib/commonjs/metro.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
36
46
|
"./package.json": "./package.json"
|
|
37
47
|
},
|
|
38
48
|
"scripts": {
|
|
@@ -88,22 +98,36 @@
|
|
|
88
98
|
"markdown"
|
|
89
99
|
],
|
|
90
100
|
"peerDependencies": {
|
|
101
|
+
"@mathjax/src": "^4.1.0",
|
|
102
|
+
"speech-rule-engine": "^5.0.0-rc.4",
|
|
91
103
|
"react": "*",
|
|
104
|
+
"react-dom": "*",
|
|
92
105
|
"react-native": ">=0.81",
|
|
93
106
|
"react-native-web": "^0.21.0",
|
|
94
107
|
"react-native-worklets": ">=0.7.0"
|
|
95
108
|
},
|
|
96
109
|
"peerDependenciesMeta": {
|
|
110
|
+
"@mathjax/src": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"speech-rule-engine": {
|
|
114
|
+
"optional": true
|
|
115
|
+
},
|
|
116
|
+
"react-dom": {
|
|
117
|
+
"optional": true
|
|
118
|
+
},
|
|
97
119
|
"react-native-web": {
|
|
98
120
|
"optional": true
|
|
99
121
|
}
|
|
100
122
|
},
|
|
101
123
|
"devDependencies": {
|
|
124
|
+
"@mathjax/src": "^4.1.3",
|
|
102
125
|
"@playwright/test": "^1.62.1",
|
|
103
126
|
"@react-native/babel-preset": "^0.86.3",
|
|
104
127
|
"@react-native/jest-preset": "^0.86.3",
|
|
105
128
|
"@types/jest": "^29.5.14",
|
|
106
129
|
"@types/react": "^19.2.0",
|
|
130
|
+
"@types/react-dom": "^19.2.7",
|
|
107
131
|
"del-cli": "^7.0.0",
|
|
108
132
|
"detox": "^20.51.4",
|
|
109
133
|
"emoji-regex": "^10.6.0",
|
|
@@ -115,6 +139,7 @@
|
|
|
115
139
|
"mdast-util-from-markdown": "^2.0.3",
|
|
116
140
|
"micromark-extension-gfm-autolink-literal": "^2.1.0",
|
|
117
141
|
"micromark-extension-gfm-strikethrough": "^2.1.0",
|
|
142
|
+
"micromark-extension-math": "^3.1.0",
|
|
118
143
|
"nodemon": "^3.1.14",
|
|
119
144
|
"patch-package": "^8.0.0",
|
|
120
145
|
"prettier": "2.8.8",
|
|
@@ -124,6 +149,7 @@
|
|
|
124
149
|
"react-native-builder-bob": "^0.43.0",
|
|
125
150
|
"react-native-web": "^0.21.2",
|
|
126
151
|
"react-native-worklets": "0.10.1",
|
|
152
|
+
"speech-rule-engine": "5.0.0-rc.4",
|
|
127
153
|
"tsx": "^4.23.13",
|
|
128
154
|
"typescript": "~6.0.3"
|
|
129
155
|
},
|
|
@@ -160,7 +186,8 @@
|
|
|
160
186
|
},
|
|
161
187
|
"ios": {
|
|
162
188
|
"componentProvider": {
|
|
163
|
-
"MarcusTextInputDecoratorView": "MarcusTextInputDecoratorComponentView"
|
|
189
|
+
"MarcusTextInputDecoratorView": "MarcusTextInputDecoratorComponentView",
|
|
190
|
+
"MarcusTextDecoratorView": "MarcusTextDecoratorComponentView"
|
|
164
191
|
}
|
|
165
192
|
}
|
|
166
193
|
}
|
package/react-native.config.js
CHANGED
|
@@ -2,7 +2,14 @@ module.exports = {
|
|
|
2
2
|
dependency: {
|
|
3
3
|
platforms: {
|
|
4
4
|
android: {
|
|
5
|
-
|
|
5
|
+
// Listed by hand because autolinking skips any component declared
|
|
6
|
+
// `interfaceOnly`, and both of these are. Without this the descriptor is
|
|
7
|
+
// never registered, the decorator falls back to a plain view -- which
|
|
8
|
+
// `display: contents` then flattens away -- and no markdown is applied.
|
|
9
|
+
componentDescriptors: [
|
|
10
|
+
"MarcusTextInputDecoratorViewComponentDescriptor",
|
|
11
|
+
"MarcusTextDecoratorViewComponentDescriptor",
|
|
12
|
+
],
|
|
6
13
|
cmakeListsPath: "../android/src/main/new_arch/CMakeLists.txt",
|
|
7
14
|
},
|
|
8
15
|
},
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { codegenNativeComponent } from "react-native"
|
|
2
|
+
import type { ColorValue, ViewProps } from "react-native"
|
|
3
|
+
|
|
4
|
+
import type { Float, Int32 } from "react-native/Libraries/Types/CodegenTypes"
|
|
5
|
+
|
|
6
|
+
import type { MarkdownStyle as TextInputMarkdownStyle } from "./MarcusTextInputDecoratorViewNativeComponent"
|
|
7
|
+
|
|
8
|
+
// Codegen parses each `*NativeComponent` file on its own and does not follow
|
|
9
|
+
// imports, so the style has to be spelled out again rather than shared with
|
|
10
|
+
// `MarcusTextInputDecoratorViewNativeComponent`. The assertion further down is
|
|
11
|
+
// what keeps the copy honest: the two have to stay assignable in both
|
|
12
|
+
// directions or `tsc --noEmit` fails.
|
|
13
|
+
|
|
14
|
+
// The text attributes one styled run can carry: the subset of React Native's
|
|
15
|
+
// `TextStyle` that survives as an `NSAttributedString` attribute on iOS, as a
|
|
16
|
+
// span on Android, and as a declaration on an inline element on the web.
|
|
17
|
+
//
|
|
18
|
+
// Everything here is optional and everything unset is inherited, which is what a
|
|
19
|
+
// run of markdown wants -- a mention that only names a colour keeps the face,
|
|
20
|
+
// the size and the weight of the prose it sits in. Native reads "unset" off the
|
|
21
|
+
// zero value: an empty string, a null colour, a zero length. That costs nothing,
|
|
22
|
+
// because a zero-length `letterSpacing`, `lineHeight` or `fontSize` means the
|
|
23
|
+
// same as leaving it out.
|
|
24
|
+
//
|
|
25
|
+
// `fontWeight`, `fontStyle`, `textDecorationLine` and `textDecorationStyle`
|
|
26
|
+
// arrive as plain strings rather than as unions. Codegen turns a union of string
|
|
27
|
+
// literals into an enum named after the prop it was found on, so the same
|
|
28
|
+
// spelling on twelve entries would become twelve unrelated C++ types and the one
|
|
29
|
+
// conversion template in `RCTMarcusStyle+Codegen.h` could not read any of them.
|
|
30
|
+
// The public type in `styleUtils` is the narrow one; this is the wire.
|
|
31
|
+
interface MarkdownTextStyle {
|
|
32
|
+
color?: ColorValue
|
|
33
|
+
fontFamily?: string
|
|
34
|
+
fontSize?: Float
|
|
35
|
+
fontStyle?: string
|
|
36
|
+
fontWeight?: string
|
|
37
|
+
letterSpacing?: Float
|
|
38
|
+
// Applies to whole lines: the platforms set it on the paragraph, so a range
|
|
39
|
+
// covering part of a line raises the height of all of it.
|
|
40
|
+
lineHeight?: Float
|
|
41
|
+
textDecorationLine?: string
|
|
42
|
+
// iOS and web only. Android draws an underline and a strikethrough in the text
|
|
43
|
+
// colour and offers no way to say otherwise.
|
|
44
|
+
textDecorationColor?: ColorValue
|
|
45
|
+
textDecorationStyle?: string
|
|
46
|
+
textShadowColor?: ColorValue
|
|
47
|
+
textShadowOffset?: { width: Float; height: Float }
|
|
48
|
+
textShadowRadius?: Float
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A run drawn as a box rather than as a background behind the glyphs: an inline
|
|
52
|
+
// or fenced run of code, or a mention's pill. Rounded, optionally bordered, with
|
|
53
|
+
// room inside it and around it, on top of whatever text attributes it carries.
|
|
54
|
+
//
|
|
55
|
+
// What the room holds open differs, because a block owns its lines and a run
|
|
56
|
+
// shares one. A block's padding and margin are held open on the leading edge and
|
|
57
|
+
// vertically, and a line long enough to wrap reaches the padding on the trailing
|
|
58
|
+
// edge rather than stopping in front of it: neither platform can reserve a
|
|
59
|
+
// trailing indent per paragraph. An inline run holds its padding and margin open
|
|
60
|
+
// on both sides, by widening the characters it starts and ends with, and grows
|
|
61
|
+
// into the line's own spacing above and below rather than pushing the lines
|
|
62
|
+
// apart.
|
|
63
|
+
//
|
|
64
|
+
// `padding` is the fallback for both axes; `paddingHorizontal` and
|
|
65
|
+
// `paddingVertical` win over it where they are set, and `margin` the same. A
|
|
66
|
+
// fenced block usually wants more room above and below than beside it, and one
|
|
67
|
+
// number cannot say that.
|
|
68
|
+
interface MarkdownBoxStyle extends MarkdownTextStyle {
|
|
69
|
+
backgroundColor?: ColorValue
|
|
70
|
+
borderColor?: ColorValue
|
|
71
|
+
borderWidth?: Float
|
|
72
|
+
borderRadius?: Float
|
|
73
|
+
padding?: Float
|
|
74
|
+
paddingHorizontal?: Float
|
|
75
|
+
paddingVertical?: Float
|
|
76
|
+
margin?: Float
|
|
77
|
+
marginHorizontal?: Float
|
|
78
|
+
marginVertical?: Float
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface MarkdownHeadingStyle extends MarkdownTextStyle {
|
|
82
|
+
// Each level down multiplies the one above, so level N is
|
|
83
|
+
// fontSize * scale^(N - 1). Six levels, matching HTML.
|
|
84
|
+
scale?: Float
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The bar beside a quoted block, the indent it opens, and the text inside it.
|
|
88
|
+
//
|
|
89
|
+
// `marginStart` and `paddingStart` rather than `marginLeft`/`paddingLeft`
|
|
90
|
+
// because the gutter opens on the line's leading edge, which is the right-hand
|
|
91
|
+
// side of a right-to-left paragraph. Both platforms already indent from the
|
|
92
|
+
// leading edge -- `NSParagraphStyle`'s head indent and Android's leading margin
|
|
93
|
+
// are both writing-direction relative -- so the names now say what was always
|
|
94
|
+
// drawn, and the web builder resolves them to `padding-inline-start`.
|
|
95
|
+
interface MarkdownBlockquoteStyle extends MarkdownTextStyle {
|
|
96
|
+
borderColor?: ColorValue
|
|
97
|
+
borderWidth?: Float
|
|
98
|
+
// Rounds the bar's ends. A bar whose radius is half its width comes out a
|
|
99
|
+
// capsule.
|
|
100
|
+
borderRadius?: Float
|
|
101
|
+
marginStart?: Float
|
|
102
|
+
paddingStart?: Float
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Indent, and the marker that sits in the gutter it opens. Kept as two separate
|
|
106
|
+
// entries so a renderer can style ordered and unordered lists differently, which
|
|
107
|
+
// is exactly what `markerScale` ends up meaning: an ordered item's number is
|
|
108
|
+
// text, an unordered item's bullet is a shape.
|
|
109
|
+
//
|
|
110
|
+
// Both markers are sized from the base font -- the size the wrapped `Text`
|
|
111
|
+
// renders at -- rather than from a size of their own, so a list marks itself in
|
|
112
|
+
// proportion to the prose it marks however that prose is sized. `marker` styles
|
|
113
|
+
// the marker itself, and what it leaves unset falls back to `syntax`, which is
|
|
114
|
+
// where a marker's colour came from before this entry existed.
|
|
115
|
+
//
|
|
116
|
+
// Only `MarkdownText` draws them. An input shows the marker you typed, in the
|
|
117
|
+
// base font, because it is text you are editing rather than a rendering of it.
|
|
118
|
+
interface MarkdownListStyle {
|
|
119
|
+
marginStart?: Float
|
|
120
|
+
paddingStart?: Float
|
|
121
|
+
// An ordered item's number is drawn at this fraction of the base font size; an
|
|
122
|
+
// unordered item's bullet takes it as a diameter, as a fraction of the same.
|
|
123
|
+
markerScale?: Float
|
|
124
|
+
// Room held open either side of the marker, between the gutter and the text.
|
|
125
|
+
markerPadding?: Float
|
|
126
|
+
marker?: MarkdownTextStyle
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Left as the two values it always was rather than folded into
|
|
130
|
+
// `MarkdownTextStyle`: an emoji run is swapped onto a font that has the glyph
|
|
131
|
+
// and sized to sit with the prose, and nothing else about it is worth saying.
|
|
132
|
+
interface MarkdownEmojiStyle {
|
|
133
|
+
fontSize?: Float
|
|
134
|
+
fontFamily?: string
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface MarkdownStyle {
|
|
138
|
+
syntax: MarkdownTextStyle
|
|
139
|
+
emoji: MarkdownEmojiStyle
|
|
140
|
+
link: MarkdownTextStyle
|
|
141
|
+
strong: MarkdownTextStyle
|
|
142
|
+
emphasis: MarkdownTextStyle
|
|
143
|
+
strikethrough: MarkdownTextStyle
|
|
144
|
+
heading: MarkdownHeadingStyle
|
|
145
|
+
blockquote: MarkdownBlockquoteStyle
|
|
146
|
+
orderedList: MarkdownListStyle
|
|
147
|
+
unorderedList: MarkdownListStyle
|
|
148
|
+
code: MarkdownBoxStyle
|
|
149
|
+
pre: MarkdownBoxStyle
|
|
150
|
+
// A name with an `@` in front of it, drawn as a pill: the same inline box an
|
|
151
|
+
// inline run of code sits in, and so the same lengths.
|
|
152
|
+
mention: MarkdownBoxStyle
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// `MarkdownRange` with `depth` filled in: codegen has no optional numbers, and
|
|
156
|
+
// the formatters read a missing depth as zero anyway.
|
|
157
|
+
interface MarkdownRangeStruct {
|
|
158
|
+
type: string
|
|
159
|
+
start: Int32
|
|
160
|
+
length: Int32
|
|
161
|
+
depth: Int32
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// What one placeholder character copies as. `index` is its offset in the
|
|
165
|
+
// stripped text -- the same string the ranges are measured against -- and
|
|
166
|
+
// `text` is the markdown it was written as, which is what the platform puts on
|
|
167
|
+
// the clipboard in its place.
|
|
168
|
+
interface MarkdownSubstitutionStruct {
|
|
169
|
+
index: Int32
|
|
170
|
+
text: string
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface NativeProps extends ViewProps {
|
|
174
|
+
markdownStyle: MarkdownStyle
|
|
175
|
+
// The parse result, already stripped of syntax and remapped onto the text the
|
|
176
|
+
// child `Text` is rendering. Unlike the input decorator there is no parser to
|
|
177
|
+
// register: a `Text`'s content only ever changes by a re-render, so JS always
|
|
178
|
+
// knows the string and can hand over finished ranges.
|
|
179
|
+
ranges: ReadonlyArray<MarkdownRangeStruct>
|
|
180
|
+
// Every drawing in the text, and the source it copies as. A view mounted in a
|
|
181
|
+
// `Text` is one U+FFFC in the string the platform lays out, and that is what
|
|
182
|
+
// both platforms would otherwise hand to the clipboard: an equation copies as
|
|
183
|
+
// an empty box. Only the display needs this -- an input has the source on the
|
|
184
|
+
// screen already, and copies it by doing nothing.
|
|
185
|
+
substitutions: ReadonlyArray<MarkdownSubstitutionStruct>
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type Assignable<A extends B, B> = A
|
|
189
|
+
|
|
190
|
+
type StyleMatchesTextInput = [
|
|
191
|
+
Assignable<MarkdownStyle, TextInputMarkdownStyle>,
|
|
192
|
+
Assignable<TextInputMarkdownStyle, MarkdownStyle>,
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
export default codegenNativeComponent<NativeProps>("MarcusTextDecoratorView", {
|
|
196
|
+
interfaceOnly: true,
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
export type { MarkdownRangeStruct, MarkdownSubstitutionStruct, StyleMatchesTextInput }
|