react-native-marcus 0.1.0 → 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
|
@@ -3,12 +3,34 @@ import React from "react";
|
|
|
3
3
|
import type { MouseEvent } from "react";
|
|
4
4
|
import type { LineCache } from "./web/utils/parserUtils.js";
|
|
5
5
|
import type { TreeNode } from "./web/utils/treeUtils.js";
|
|
6
|
+
import "./web/MarkdownElements.css";
|
|
6
7
|
import "./web/MarkdownTextInput.css";
|
|
7
|
-
import type {
|
|
8
|
-
import type { MarkdownRange } from "./commonTypes.js";
|
|
8
|
+
import type { PartialMarkdownStyle } from "./styleUtils.js";
|
|
9
9
|
interface MarkdownTextInputProps extends TextInputProps {
|
|
10
|
-
markdownStyle?:
|
|
11
|
-
|
|
10
|
+
markdownStyle?: PartialMarkdownStyle;
|
|
11
|
+
/**
|
|
12
|
+
* GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
|
|
13
|
+
*
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
gfm?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* `@name` mentions, which no flavour of markdown has a notion of.
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
mention?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
|
|
25
|
+
* of its own for a block.
|
|
26
|
+
*
|
|
27
|
+
* An input shows what was typed, so the maths stays as written -- what this
|
|
28
|
+
* turns on is recognising it, which greys the dollars as the markup they are
|
|
29
|
+
* and leaves the TeX between them alone.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
math?: boolean;
|
|
12
34
|
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
13
35
|
dir?: string;
|
|
14
36
|
disabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownTextInput.web.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownTextInput.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EAKT,cAAc,EAKf,MAAM,cAAc,CAAA;AACrB,OAAO,KAAmE,MAAM,OAAO,CAAA;AACvF,OAAO,KAAK,EAKV,UAAU,EAKX,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAAyB,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAAuB,CAAA;AAMrD,OAAO,
|
|
1
|
+
{"version":3,"file":"MarkdownTextInput.web.d.ts","sourceRoot":"","sources":["../../../../src/MarkdownTextInput.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EAKT,cAAc,EAKf,MAAM,cAAc,CAAA;AACrB,OAAO,KAAmE,MAAM,OAAO,CAAA;AACvF,OAAO,KAAK,EAKV,UAAU,EAKX,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAAyB,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAAuB,CAAA;AAMrD,OAAO,4BAA4B,CAAA;AACnC,OAAO,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,iBAAc,CAAA;AAkB/E,UAAU,sBAAuB,SAAQ,cAAc;IACrD,aAAa,CAAC,EAAE,oBAAoB,CAAA;IACpC;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IACjD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,UAAU,mBAAoB,SAAQ,KAAK;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,KAAK,iBAAiB,GAAG,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;AAE5E,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAcD,KAAK,wBAAwB,GAAG,cAAc,GAC5C,gBAAgB,GAAG;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,kGAAkG;IAClG,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,CAAA;AAEH,KAAK,mBAAmB,GAAG,WAAW,GAAG;IACvC,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,QAAA,MAAM,iBAAiB,kGAkzBtB,CAAA;AAwBD,eAAe,iBAAiB,CAAA;AAEhC,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,GACpB,CAAA;AAED,iBAAS,iBAAiB,SAIzB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { MarkdownEmbed, MarkdownMath, StrippedMarkdown } from "./stripUtils.js";
|
|
2
|
+
type Atom = ({
|
|
3
|
+
kind: "embed";
|
|
4
|
+
} & MarkdownEmbed) | ({
|
|
5
|
+
kind: "math";
|
|
6
|
+
} & MarkdownMath);
|
|
7
|
+
/**
|
|
8
|
+
* How a maths span is said out loud, or nothing for one that cannot be said.
|
|
9
|
+
*
|
|
10
|
+
* Passed in rather than imported so that this module knows nothing about
|
|
11
|
+
* typesetting: it is `./math`'s `speakMath` at both call sites, and a display
|
|
12
|
+
* with no maths backend passes one that always declines.
|
|
13
|
+
*/
|
|
14
|
+
type SpeakMath = (tex: string, display: boolean, locale?: string) => string | null;
|
|
15
|
+
declare const NO_ATOMS: Atom[];
|
|
16
|
+
/**
|
|
17
|
+
* Every placeholder in the stripped text, in the order it stands there.
|
|
18
|
+
*
|
|
19
|
+
* Sorting is enough to interleave the two kinds correctly: each index is a
|
|
20
|
+
* distinct character in the same string, so no two atoms can share one.
|
|
21
|
+
*/
|
|
22
|
+
declare function atomsOf(markdown: StrippedMarkdown): Atom[];
|
|
23
|
+
/**
|
|
24
|
+
* The text as it should be read out, with every placeholder written back out
|
|
25
|
+
* as what it stands for.
|
|
26
|
+
*
|
|
27
|
+
* A drawing costs exactly one character in the string the platform lays out --
|
|
28
|
+
* U+FFFC, the object replacement character -- and there is nothing in that
|
|
29
|
+
* character for a screen reader to say. An image's `alt` is its accessible name
|
|
30
|
+
* by every spec there is, and left empty it declares the image decorative, so
|
|
31
|
+
* it is used as written. A maths span is read as what was drawn, which is what
|
|
32
|
+
* `speak` answers; the TeX behind it is the fallback, because an expression
|
|
33
|
+
* read out as its source is still better than a sentence with a hole in it.
|
|
34
|
+
*
|
|
35
|
+
* `locale` is the language the maths is said in, and is passed straight
|
|
36
|
+
* through: the prose around it is in whatever language it was written in, and
|
|
37
|
+
* nothing here can or should change that.
|
|
38
|
+
*/
|
|
39
|
+
declare function describeAtoms(markdown: StrippedMarkdown, speak: SpeakMath, locale?: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* What a placeholder puts on the clipboard, which is the markdown it was
|
|
42
|
+
* written as.
|
|
43
|
+
*
|
|
44
|
+
* A copy of rendered text is plain text: `**bold**` comes off the screen as
|
|
45
|
+
* "bold", because that is what a copy of styled text has always been. A drawing
|
|
46
|
+
* has no plain text at all -- it is one U+FFFC, which pastes as a box -- and
|
|
47
|
+
* the source is the only honest thing to put there. Written back out with its
|
|
48
|
+
* dollar signs, a copied paragraph is markdown again and goes back into an
|
|
49
|
+
* editor as the document it came from.
|
|
50
|
+
*
|
|
51
|
+
* An image copies as nothing, the way an `<img>` does on the web: its alt text
|
|
52
|
+
* describes the picture for someone who cannot see it, and pasting a
|
|
53
|
+
* description where a picture was is not what anyone asked for.
|
|
54
|
+
*/
|
|
55
|
+
declare function sourceOf(atom: Atom): string;
|
|
56
|
+
export type { Atom, SpeakMath };
|
|
57
|
+
export { NO_ATOMS, atomsOf, describeAtoms, sourceOf };
|
|
58
|
+
//# sourceMappingURL=atomUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomUtils.d.ts","sourceRoot":"","sources":["../../../../src/atomUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAc,CAAA;AASjF,KAAK,IAAI,GAAG,CAAC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAAC,GAAG,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAAC,CAAA;AAEnF;;;;;;GAMG;AACH,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;AAElF,QAAA,MAAM,QAAQ,EAAE,IAAI,EAAO,CAAA;AAE3B;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EAAE,CAkBnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,aAAa,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB5F;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQpC;AAED,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Flattens children into the string they render as, or null if they are not
|
|
4
|
+
* text.
|
|
5
|
+
*
|
|
6
|
+
* Only strings and numbers are markdown. An element child is content there are
|
|
7
|
+
* no parser offsets for and no way to strip syntax out of, so a subtree
|
|
8
|
+
* containing one renders unformatted rather than half formatted.
|
|
9
|
+
*/
|
|
10
|
+
declare function flattenText(children: React.ReactNode): string | null;
|
|
11
|
+
export { flattenText };
|
|
12
|
+
//# sourceMappingURL=childrenUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childrenUtils.d.ts","sourceRoot":"","sources":["../../../../src/childrenUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;;GAOG;AACH,iBAAS,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,CAI7D;AAwBD,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,10 +1,46 @@
|
|
|
1
|
-
type MarkdownType = "
|
|
1
|
+
type MarkdownType = "strong" | "emphasis" | "strikethrough" | "emoji" | "mention" | "link" | "label" | "alt" | "title" | "code" | "pre" | "blockquote" | "list-ordered" | "list-unordered" | "block-prefix" | "heading" | "syntax" | "image" | "codeblock" | "math" | "math-block" | "language";
|
|
2
2
|
interface MarkdownRange {
|
|
3
3
|
type: MarkdownType;
|
|
4
4
|
start: number;
|
|
5
5
|
length: number;
|
|
6
6
|
depth?: number;
|
|
7
|
-
syntaxType?: "opening" | "closing";
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* What the parser recognises beyond CommonMark.
|
|
10
|
+
*
|
|
11
|
+
* Every one of them is off unless it is asked for. Each changes what an
|
|
12
|
+
* ordinary character means -- a tilde, an `@`, a dollar sign -- and a document
|
|
13
|
+
* written somewhere else, by someone who never heard of this library, is the
|
|
14
|
+
* one place where guessing at that is least recoverable. They are the whole of
|
|
15
|
+
* the parser's configuration: a caller chooses a flavour, not a parser, and the
|
|
16
|
+
* components take these as props of their own.
|
|
17
|
+
*/
|
|
18
|
+
interface ParserOptions {
|
|
19
|
+
/**
|
|
20
|
+
* GFM's strikethrough (`~~a~~`) and bare autolinks (`www.example.com`).
|
|
21
|
+
*
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
gfm?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* `@name` mentions, which no flavour of markdown has a notion of.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
mention?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* LaTeX between double dollar signs: `$$x^2$$` inline, and the same on lines
|
|
33
|
+
* of its own for a block.
|
|
34
|
+
*
|
|
35
|
+
* Two dollars, never one: `$5 and $6` is a price list in every document that
|
|
36
|
+
* has ever been written, and single-dollar maths would quietly turn it into a
|
|
37
|
+
* picture of the word "and".
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
math?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** A parser, as the components hold one: text in, ranges out. */
|
|
44
|
+
type MarkdownParser = (markdown: string) => MarkdownRange[];
|
|
45
|
+
export type { MarkdownType, MarkdownRange, ParserOptions, MarkdownParser };
|
|
10
46
|
//# sourceMappingURL=commonTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commonTypes.d.ts","sourceRoot":"","sources":["../../../../src/commonTypes.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GACb,
|
|
1
|
+
{"version":3,"file":"commonTypes.d.ts","sourceRoot":"","sources":["../../../../src/commonTypes.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GACb,QAAQ,GACR,UAAU,GACV,eAAe,GACf,OAAO,GAIP,SAAS,GACT,MAAM,GAIN,OAAO,GAKP,KAAK,GAIL,OAAO,GACP,MAAM,GACN,KAAK,GACL,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,SAAS,GACT,QAAQ,GACR,OAAO,GACP,WAAW,GAIX,MAAM,GAEN,YAAY,GAGZ,UAAU,CAAA;AAEd,UAAU,aAAa;IACrB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;GASG;AACH,UAAU,aAAa;IACrB;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,iEAAiE;AACjE,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,aAAa,EAAE,CAAA;AAE3D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as MarkdownTextInput, getWorkletRuntime } from "./MarkdownTextInput";
|
|
2
2
|
export type { MarkdownTextInputProps, MarkdownStyle } from "./MarkdownTextInput";
|
|
3
|
+
export { default as MarkdownText } from "./MarkdownText";
|
|
4
|
+
export type { MarkdownTextProps, OnLinkPress, RenderEmbed, RenderSVG } from "./MarkdownText";
|
|
3
5
|
export type { MarkdownType, MarkdownRange } from "./commonTypes.js";
|
|
4
|
-
export { parse as parser } from "./parser/index.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrF,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAChF,YAAY,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrF,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC5F,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAe,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What MathJax and SRE assume about their host that React Native does not
|
|
3
|
+
* provide. Imported before either of them, and first, because `import`
|
|
4
|
+
* statements are hoisted and run in the order they are written.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../src/math/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+DH,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The maths backend, in its "there isn't one" form.
|
|
3
|
+
*
|
|
4
|
+
* Typesetting TeX takes a library an order of magnitude larger than this one,
|
|
5
|
+
* and most applications will never draw an equation. So the real backend --
|
|
6
|
+
* `./mathjax.ts`, right beside this -- is never imported by anything: a
|
|
7
|
+
* bundler would follow the import and pull MathJax into every app that has
|
|
8
|
+
* ever installed this package, whether or not it renders maths.
|
|
9
|
+
*
|
|
10
|
+
* Instead the two are swapped at build time. `react-native-marcus/metro`'s
|
|
11
|
+
* `withMath()` resolves this module to that one, so an application opts in by
|
|
12
|
+
* editing its `metro.config.js` and the default bundle carries nothing.
|
|
13
|
+
*
|
|
14
|
+
* What the swap has to preserve is this shape and nothing else.
|
|
15
|
+
*/
|
|
16
|
+
/** One expression, drawn, with the box it needs. */
|
|
17
|
+
interface RenderedMath {
|
|
18
|
+
/**
|
|
19
|
+
* A standalone SVG document: glyph outlines inline, no `<use>`, no `<defs>`,
|
|
20
|
+
* and the colour already substituted in.
|
|
21
|
+
*/
|
|
22
|
+
svg: string;
|
|
23
|
+
/** Points, at the font size that was asked for. */
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
/**
|
|
27
|
+
* How far below the baseline the drawing hangs -- zero for `x^2`, real for
|
|
28
|
+
* `\frac{a}{b}`. Part of the picture rather than of the size: `height`
|
|
29
|
+
* already covers it.
|
|
30
|
+
*/
|
|
31
|
+
depth: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Whether maths can be drawn at all.
|
|
35
|
+
*
|
|
36
|
+
* Read by the display components, which leave a maths span exactly as it was
|
|
37
|
+
* written when this is false. Showing `$$x^2$$` is a good deal better than
|
|
38
|
+
* showing an empty box where an equation should be, and it is the one hint an
|
|
39
|
+
* application will get that its Metro config is missing a line.
|
|
40
|
+
*/
|
|
41
|
+
declare const available = false;
|
|
42
|
+
declare function renderMath(_tex: string, _display: boolean, _fontSize: number, _color: string | undefined): RenderedMath | null;
|
|
43
|
+
/**
|
|
44
|
+
* The expression as it should be read out, or nothing.
|
|
45
|
+
*
|
|
46
|
+
* A drawn equation is a picture, and the TeX behind it is source code: an
|
|
47
|
+
* author reading `\frac{a}{b}` knows what it means, and a reader who asked
|
|
48
|
+
* for a document rather than for its markup hears three words of punctuation.
|
|
49
|
+
* So a display says what it drew -- "StartFraction a Over b EndFraction" --
|
|
50
|
+
* while an input, where the TeX is what is on the screen and what the caret
|
|
51
|
+
* moves through, keeps the TeX.
|
|
52
|
+
*
|
|
53
|
+
* `locale` is the language it should be said in, as a name the backend knows;
|
|
54
|
+
* nothing means the backend's own default. What a document is written in and
|
|
55
|
+
* what its reader speaks are two different questions, and only the application
|
|
56
|
+
* knows the answer to the second.
|
|
57
|
+
*
|
|
58
|
+
* Returning nothing means the caller falls back to the TeX, which is what the
|
|
59
|
+
* stub does and what a backend does for an expression it cannot say.
|
|
60
|
+
*/
|
|
61
|
+
declare function speakMath(_tex: string, _display: boolean, _locale?: string): string | null;
|
|
62
|
+
export type { RenderedMath };
|
|
63
|
+
export { available, renderMath, speakMath };
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/math/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oDAAoD;AACpD,UAAU,YAAY;IACpB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS,QAAQ,CAAA;AAEvB,iBAAS,UAAU,CACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,YAAY,GAAG,IAAI,CAErB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEnF;AAED,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TeX -> SVG with MathJax 4, wired up the way React Native needs.
|
|
3
|
+
*
|
|
4
|
+
* Nothing imports this module. `react-native-marcus/metro`'s `withMath()`
|
|
5
|
+
* resolves `./index.ts` -- the stub beside it -- to this file, which is how an
|
|
6
|
+
* application opts into a dependency this size. See `./index.ts`.
|
|
7
|
+
*
|
|
8
|
+
* Three things here are not the defaults:
|
|
9
|
+
*
|
|
10
|
+
* - **`liteAdaptor`**, so nothing wants a DOM. It runs the same in Hermes, in a
|
|
11
|
+
* browser and in Node, which is what makes one renderer serve all three
|
|
12
|
+
* platforms and draw the same glyphs on each.
|
|
13
|
+
* - **`fontCache: "none"`**, so each expression is a standalone SVG with its
|
|
14
|
+
* glyph outlines inline. `"local"`, the default, emits `<use>` against a
|
|
15
|
+
* `<defs>` block, which is smaller on a page full of maths and useless when
|
|
16
|
+
* every expression is a separate attachment in someone else's view tree.
|
|
17
|
+
* - **`linebreaks: { inline: false }`**. v4 breaks long inline maths into
|
|
18
|
+
* several `<svg>` fragments separated by `<mjx-break>`; one attachment is one
|
|
19
|
+
* SVG, and left on, the metrics read off the first fragment are silently
|
|
20
|
+
* wrong.
|
|
21
|
+
*
|
|
22
|
+
* Every specifier below names `mjs/` outright rather than going through
|
|
23
|
+
* MathJax's `js/*` export, and that is not cosmetic. That export maps to `mjs`
|
|
24
|
+
* for `import` and to `cjs` for `require`, so a module reached both ways --
|
|
25
|
+
* which is exactly what this file does, importing the machinery and requiring
|
|
26
|
+
* the font ranges -- is loaded twice, and the two copies each hold half of what
|
|
27
|
+
* is needed. The symptom is every `\mathbb`, `\mathcal`, `\mathfrak`,
|
|
28
|
+
* `\mathsf` and `\mathtt` coming out blank while everything else draws
|
|
29
|
+
* perfectly. `mjs/` goes through the package's `"./*": "./*"` fallback, which
|
|
30
|
+
* has no conditions to disagree about.
|
|
31
|
+
*/
|
|
32
|
+
import "./environment.js";
|
|
33
|
+
import "@mathjax/src/mjs/input/tex/base/BaseConfiguration.js";
|
|
34
|
+
import "@mathjax/src/mjs/input/tex/ams/AmsConfiguration.js";
|
|
35
|
+
import "@mathjax/src/mjs/input/tex/newcommand/NewcommandConfiguration.js";
|
|
36
|
+
import "@mathjax/src/mjs/input/tex/boldsymbol/BoldsymbolConfiguration.js";
|
|
37
|
+
import type { RenderedMath } from "./index.js";
|
|
38
|
+
declare const available = true;
|
|
39
|
+
/**
|
|
40
|
+
* TeX in, one standalone SVG and its box out.
|
|
41
|
+
*
|
|
42
|
+
* The box is read off the root element rather than measured: MathJax reports
|
|
43
|
+
* width, height and the depth below the baseline in `ex`, and an `ex` is half
|
|
44
|
+
* the font size by its own `exFactor`. So nothing has to be laid out to find
|
|
45
|
+
* out how much room to ask for -- which is exactly what a text layout needs to
|
|
46
|
+
* know before it can lay the line out.
|
|
47
|
+
*
|
|
48
|
+
* Returns nothing for an expression it cannot draw, rather than throwing. TeX
|
|
49
|
+
* that reaches for something the bundled fonts do not carry ends in a
|
|
50
|
+
* `RangeError`, and one bad equation should cost the equation rather than the
|
|
51
|
+
* message it is in.
|
|
52
|
+
*/
|
|
53
|
+
declare function renderMath(tex: string, display: boolean, fontSize: number, color: string | undefined): RenderedMath | null;
|
|
54
|
+
/**
|
|
55
|
+
* TeX in, the expression as a sentence out.
|
|
56
|
+
*
|
|
57
|
+
* Returns nothing for anything it cannot say, which includes TeX that does not
|
|
58
|
+
* parse and a document where the rules never loaded.
|
|
59
|
+
*/
|
|
60
|
+
declare function speakMath(tex: string, display: boolean, locale?: string): string | null;
|
|
61
|
+
export type { RenderedMath };
|
|
62
|
+
export { available, renderMath, speakMath };
|
|
63
|
+
//# sourceMappingURL=mathjax.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mathjax.d.ts","sourceRoot":"","sources":["../../../../../src/math/mathjax.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,kBAAe,CAAA;AAqBtB,OAAO,sDAAsD,CAAA;AAC7D,OAAO,oDAAoD,CAAA;AAC3D,OAAO,kEAAkE,CAAA;AACzE,OAAO,kEAAkE,CAAA;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAS,CAAA;AAyJ3C,QAAA,MAAM,SAAS,OAAO,CAAA;AAqBtB;;;;;;;;;;;;;GAaG;AACH,iBAAS,UAAU,CACjB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,YAAY,GAAG,IAAI,CAqBrB;AAyRD;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyChF;AAED,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** As much of a Metro config as this touches. */
|
|
2
|
+
interface MetroConfig {
|
|
3
|
+
resolver?: {
|
|
4
|
+
resolveRequest?: ResolveRequest;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
type Resolution = {
|
|
10
|
+
type?: string;
|
|
11
|
+
filePath?: string;
|
|
12
|
+
} | null | undefined;
|
|
13
|
+
type ResolveRequest = (context: unknown, moduleName: string, platform: string | null) => Resolution;
|
|
14
|
+
interface WithMathOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The package whose `imports` field is read, in case a fork or a pinned copy
|
|
17
|
+
* is installed under another name.
|
|
18
|
+
*
|
|
19
|
+
* @default "@mathjax/src"
|
|
20
|
+
*/
|
|
21
|
+
packageName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* This library, in case it is installed under another name. Its own directory
|
|
24
|
+
* is what bounds the backend swap below.
|
|
25
|
+
*
|
|
26
|
+
* @default "react-native-marcus"
|
|
27
|
+
*/
|
|
28
|
+
libraryName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The languages maths can be read out in, as the speech engine names them:
|
|
31
|
+
* `af`, `ca`, `da`, `de`, `en`, `es`, `fr`, `hi`, `it`, `ko`, `nb`, `nn` and
|
|
32
|
+
* `sv`. Everything else is left out of the bundle.
|
|
33
|
+
*
|
|
34
|
+
* This is what `MarkdownText`'s `mathAccessibilityLocale` can choose between.
|
|
35
|
+
* It is a build-time list rather than a runtime one for the same reason
|
|
36
|
+
* MathJax itself is: the rules for one language are around 300KB, and an
|
|
37
|
+
* application that reads its maths in English has no business carrying the
|
|
38
|
+
* four megabytes of rules for the twelve languages it does not. Naming the
|
|
39
|
+
* ones you support is the same thing you already do for your own
|
|
40
|
+
* translations.
|
|
41
|
+
*
|
|
42
|
+
* A locale asked for and not bundled is read in English instead, with a
|
|
43
|
+
* warning in the console saying so.
|
|
44
|
+
*
|
|
45
|
+
* @default ["en"]
|
|
46
|
+
*/
|
|
47
|
+
locales?: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Teaches Metro to resolve MathJax, and points the library's maths backend at
|
|
51
|
+
* it.
|
|
52
|
+
*
|
|
53
|
+
* Any `resolveRequest` already on the config is kept and called for everything
|
|
54
|
+
* else, so this composes with whatever else the application is doing.
|
|
55
|
+
*/
|
|
56
|
+
declare function withMath(config: MetroConfig, options?: WithMathOptions): MetroConfig;
|
|
57
|
+
export type { MetroConfig, WithMathOptions };
|
|
58
|
+
export { withMath };
|
|
59
|
+
//# sourceMappingURL=metro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metro.d.ts","sourceRoot":"","sources":["../../../../src/metro.ts"],"names":[],"mappings":"AAiCA,iDAAiD;AACjD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE;QACT,cAAc,CAAC,EAAE,cAAc,CAAA;QAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;IACD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,KAAK,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzE,KAAK,cAAc,GAAG,CACpB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,KACpB,UAAU,CAAA;AAMf,UAAU,eAAe;IACvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAoFD;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,WAAW,CAkDjF;AAMD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { MarkdownRange } from "../commonTypes.js";
|
|
1
|
+
import type { MarkdownParser, MarkdownRange, ParserOptions } from "../commonTypes.js";
|
|
2
2
|
declare module "./index" {
|
|
3
|
-
function
|
|
3
|
+
function createParser(options?: ParserOptions): MarkdownParser;
|
|
4
4
|
}
|
|
5
5
|
declare global {
|
|
6
|
-
function __parse__micromark(markdown: string): MarkdownRange[];
|
|
6
|
+
function __parse__micromark(markdown: string, options?: ParserOptions): MarkdownRange[];
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/parser/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/parser/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAgB,aAAa,EAAE,MAAM,mBAAgB,CAAA;AA2MhG,OAAO,QAAQ,SAAS,CAAC;IACvB,SAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,cAAc,CAAA;CACtE;AAED,OAAO,CAAC,MAAM,CAAC;IACb,SAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,CAAA;CACxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micromark-extension-mentions.d.ts","sourceRoot":"","sources":["../../../../../src/parser/micromark-extension-mentions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"micromark-extension-mentions.d.ts","sourceRoot":"","sources":["../../../../../src/parser/micromark-extension-mentions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EAGV,MAAM,sBAAsB,CAAA;AAU7B,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,YAAY;QACpB,OAAO,EAAE,SAAS,CAAA;KACnB;CACF;AAmBD,wBAAgB,QAAQ,IAAI,SAAS,CAMpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MarkdownRange } from "./commonTypes.js";
|
|
2
|
-
declare function getTagPriority(tag: string): 0 | 1 | -1 | 3
|
|
2
|
+
declare function getTagPriority(tag: string): 0 | 2 | 1 | -1 | 3;
|
|
3
3
|
declare function sortRanges(ranges: MarkdownRange[]): MarkdownRange[];
|
|
4
4
|
declare function ungroupRanges(ranges: MarkdownRange[]): MarkdownRange[];
|
|
5
5
|
export { getTagPriority, sortRanges, ungroupRanges };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { MarkdownRange } from "./commonTypes.js";
|
|
2
|
+
/** What an image stood for, for a caller that has something to show instead. */
|
|
3
|
+
interface MarkdownEmbed {
|
|
4
|
+
/** Where the placeholder character stands in the stripped text. */
|
|
5
|
+
index: number;
|
|
6
|
+
uri: string;
|
|
7
|
+
alt: string;
|
|
8
|
+
/** Empty when the image was written without one, never absent. */
|
|
9
|
+
title: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the image shares its line with anything else.
|
|
12
|
+
*
|
|
13
|
+
* An image is written inline and is laid out inline either way, but what it
|
|
14
|
+
* is for depends on what is around it: alone on a line it is a figure, and
|
|
15
|
+
* in the middle of a sentence it is a badge or an emoji. Only the caller can
|
|
16
|
+
* pick a size, and this is what that decision is usually made on.
|
|
17
|
+
*
|
|
18
|
+
* A block marker does not count as company -- an image alone in a list item
|
|
19
|
+
* or a quote is still alone -- and another image does.
|
|
20
|
+
*/
|
|
21
|
+
inline: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** A maths span, for a caller that has something to draw it with. */
|
|
24
|
+
interface MarkdownMath {
|
|
25
|
+
/** Where the placeholder character stands in the stripped text. */
|
|
26
|
+
index: number;
|
|
27
|
+
/**
|
|
28
|
+
* The TeX between the dollars, with the dollars and the padding of `$ x $`
|
|
29
|
+
* taken off and the surrounding whitespace of a `$$` block trimmed. Never
|
|
30
|
+
* empty: a span with nothing in it is dropped rather than reported.
|
|
31
|
+
*/
|
|
32
|
+
tex: string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether it was written as a `$$` block on lines of its own, which is what
|
|
35
|
+
* decides whether TeX sets it in display style: bigger operators, limits
|
|
36
|
+
* above and below a sum rather than beside it. Where it sits on the page is
|
|
37
|
+
* the block layout's business, not the typesetter's.
|
|
38
|
+
*/
|
|
39
|
+
display: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** A link the display can hand to whatever is going to act on a press. */
|
|
42
|
+
interface MarkdownLink {
|
|
43
|
+
/** Where the link's text stands in the stripped text. */
|
|
44
|
+
start: number;
|
|
45
|
+
length: number;
|
|
46
|
+
uri: string;
|
|
47
|
+
/** The text between the brackets, which is all that is left of the link. */
|
|
48
|
+
label: string;
|
|
49
|
+
/** Empty when the link was written without one, never absent. */
|
|
50
|
+
title: string;
|
|
51
|
+
}
|
|
52
|
+
interface StrippedMarkdown {
|
|
53
|
+
text: string;
|
|
54
|
+
ranges: MarkdownRange[];
|
|
55
|
+
embeds: MarkdownEmbed[];
|
|
56
|
+
maths: MarkdownMath[];
|
|
57
|
+
links: MarkdownLink[];
|
|
58
|
+
}
|
|
59
|
+
interface StripOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Replace each image with a single placeholder character and report what it
|
|
62
|
+
* stood for, instead of leaving its alt text behind as prose.
|
|
63
|
+
*
|
|
64
|
+
* One character because that is exactly what a view mounted inside text costs
|
|
65
|
+
* the platform: both iOS and Android splice a single U+FFFC into the string
|
|
66
|
+
* the formatters index, in place of the attachment. So the ranges this
|
|
67
|
+
* returns are already right for a `Text` whose children have the embed
|
|
68
|
+
* spliced in where the placeholder is.
|
|
69
|
+
*/
|
|
70
|
+
embeds?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Replace each maths span with a single placeholder character and report the
|
|
73
|
+
* TeX it stood for, instead of leaving `$x^2$` behind as prose.
|
|
74
|
+
*
|
|
75
|
+
* The same one character an embed costs, for the same reason: what draws the
|
|
76
|
+
* maths is a view mounted in the text, and a view in a text is one character
|
|
77
|
+
* to both platforms.
|
|
78
|
+
*/
|
|
79
|
+
math?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Report where each link ended up and where it points.
|
|
82
|
+
*
|
|
83
|
+
* The destination is removed along with the rest of the markup, so a display
|
|
84
|
+
* that means to do something when a link is pressed has to be told here or
|
|
85
|
+
* not at all.
|
|
86
|
+
*/
|
|
87
|
+
links?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The character standing in for an embed, matching what the platforms use for
|
|
91
|
+
* an attachment so that the stripped text and the string that reaches the
|
|
92
|
+
* formatters are the same length.
|
|
93
|
+
*/
|
|
94
|
+
declare const OBJECT_REPLACEMENT = "\uFFFC";
|
|
95
|
+
/**
|
|
96
|
+
* Removes the markdown syntax from `text` and rewrites `ranges` to index what
|
|
97
|
+
* is left.
|
|
98
|
+
*
|
|
99
|
+
* Ranges are only ever dropped or shortened, never reordered, so the emission
|
|
100
|
+
* order the native formatters depend on survives -- a `block-prefix` still
|
|
101
|
+
* arrives immediately before its container, and a container that lost its
|
|
102
|
+
* marker entirely arrives with none, which is exactly the gutter-without-marker
|
|
103
|
+
* case the block layout already handles.
|
|
104
|
+
*/
|
|
105
|
+
declare function stripSyntax(text: string, ranges: MarkdownRange[], options?: StripOptions): StrippedMarkdown;
|
|
106
|
+
export type { MarkdownEmbed, MarkdownMath, MarkdownLink, StrippedMarkdown, StripOptions };
|
|
107
|
+
export { OBJECT_REPLACEMENT, stripSyntax };
|
|
108
|
+
//# sourceMappingURL=stripUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripUtils.d.ts","sourceRoot":"","sources":["../../../../src/stripUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAe,CAAA;AAalD,gFAAgF;AAChF,UAAU,aAAa;IACrB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;;;OAUG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,qEAAqE;AACrE,UAAU,YAAY;IACpB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,0EAA0E;AAC1E,UAAU,YAAY;IACpB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB;AAED,UAAU,YAAY;IACpB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,WAAW,CAAA;AAglBnC;;;;;;;;;GASG;AACH,iBAAS,WAAW,CAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,GAAE,YAAiB,GACzB,gBAAgB,CAsMlB;AAED,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA;AAEzF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,8 +1,66 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type
|
|
1
|
+
import type { TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import type { MarkdownEmojiStyle, MarkdownStyle } from "./MarcusTextInputDecoratorViewNativeComponent";
|
|
3
|
+
type MarkdownTextStyleProps = Pick<TextStyle, "color" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textDecorationLine" | "textDecorationColor" | "textDecorationStyle" | "textShadowColor" | "textShadowOffset" | "textShadowRadius">;
|
|
4
|
+
type MarkdownBoxStyleProps = MarkdownTextStyleProps & Pick<ViewStyle, "backgroundColor" | "borderColor" | "borderWidth" | "borderRadius" | "padding" | "paddingHorizontal" | "paddingVertical" | "margin" | "marginHorizontal" | "marginVertical"> & {
|
|
5
|
+
padding?: number;
|
|
6
|
+
paddingHorizontal?: number;
|
|
7
|
+
paddingVertical?: number;
|
|
8
|
+
margin?: number;
|
|
9
|
+
marginHorizontal?: number;
|
|
10
|
+
marginVertical?: number;
|
|
11
|
+
borderWidth?: number;
|
|
12
|
+
borderRadius?: number;
|
|
13
|
+
};
|
|
14
|
+
type MarkdownHeadingStyleProps = MarkdownTextStyleProps & {
|
|
15
|
+
scale?: number;
|
|
16
|
+
};
|
|
17
|
+
type MarkdownBlockquoteStyleProps = MarkdownTextStyleProps & Pick<ViewStyle, "borderColor"> & {
|
|
18
|
+
borderWidth?: number;
|
|
19
|
+
borderRadius?: number;
|
|
20
|
+
marginStart?: number;
|
|
21
|
+
paddingStart?: number;
|
|
22
|
+
};
|
|
23
|
+
type MarkdownListStyleProps = {
|
|
24
|
+
marginStart?: number;
|
|
25
|
+
paddingStart?: number;
|
|
26
|
+
markerScale?: number;
|
|
27
|
+
markerPadding?: number;
|
|
28
|
+
marker?: MarkdownTextStyleProps;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A markdown style as it is written: every entry optional, every property
|
|
32
|
+
* optional, and anything left out taken from the defaults below.
|
|
33
|
+
*/
|
|
34
|
+
type PartialMarkdownStyle = {
|
|
35
|
+
syntax?: MarkdownTextStyleProps;
|
|
36
|
+
emoji?: MarkdownEmojiStyle;
|
|
37
|
+
link?: MarkdownTextStyleProps;
|
|
38
|
+
strong?: MarkdownTextStyleProps;
|
|
39
|
+
emphasis?: MarkdownTextStyleProps;
|
|
40
|
+
strikethrough?: MarkdownTextStyleProps;
|
|
41
|
+
heading?: MarkdownHeadingStyleProps;
|
|
42
|
+
blockquote?: MarkdownBlockquoteStyleProps;
|
|
43
|
+
orderedList?: MarkdownListStyleProps;
|
|
44
|
+
unorderedList?: MarkdownListStyleProps;
|
|
45
|
+
code?: MarkdownBoxStyleProps;
|
|
46
|
+
pre?: MarkdownBoxStyleProps;
|
|
47
|
+
mention?: MarkdownBoxStyleProps;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The style once the defaults have been merged in: every entry present, every
|
|
51
|
+
* property still optional.
|
|
52
|
+
*
|
|
53
|
+
* Distinct from `PartialMarkdownStyle`, which is what a caller writes. This is
|
|
54
|
+
* what a renderer reads, and on the web its lengths have been through React
|
|
55
|
+
* Native Web's compiler by the time they get there -- a `fontSize` of `16` is
|
|
56
|
+
* the string `"16px"` -- which is why everything downstream of it either casts
|
|
57
|
+
* or runs the value back through `toNumber`.
|
|
58
|
+
*/
|
|
59
|
+
type ResolvedMarkdownStyle = Partial<{
|
|
3
60
|
[K in keyof MarkdownStyle]: Partial<MarkdownStyle[K]>;
|
|
4
61
|
}>;
|
|
5
62
|
declare function mergeMarkdownStyleWithDefault(input: PartialMarkdownStyle | undefined): MarkdownStyle;
|
|
6
|
-
|
|
7
|
-
export {
|
|
63
|
+
declare function processMarkdownStyle(input: PartialMarkdownStyle | undefined): MarkdownStyle;
|
|
64
|
+
export type { PartialMarkdownStyle, ResolvedMarkdownStyle, MarkdownTextStyleProps, MarkdownBoxStyleProps, MarkdownHeadingStyleProps, MarkdownBlockquoteStyleProps, MarkdownListStyleProps, };
|
|
65
|
+
export { mergeMarkdownStyleWithDefault, processMarkdownStyle };
|
|
8
66
|
//# sourceMappingURL=styleUtils.d.ts.map
|