-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into multiple-blockquotes-android
- Loading branch information
Showing
32 changed files
with
1,402 additions
and
1,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/node_modules/* | ||
parser/out.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: true, | ||
tsconfigRootDir: __dirname, | ||
}, | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier', | ||
'plugin:import/typescript', | ||
'plugin:prettier/recommended', | ||
], | ||
plugins: [ | ||
'react', | ||
'react-native', | ||
'import', | ||
'@typescript-eslint', | ||
'eslint-plugin-tsdoc', | ||
], | ||
settings: { | ||
'import/resolver': { | ||
alias: [['react-native-markdown-text-input', './src/index.tsx']], | ||
}, | ||
}, | ||
root: true, | ||
rules: { | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
quoteProps: 'consistent', | ||
singleQuote: true, | ||
tabWidth: 2, | ||
trailingComma: 'es5', | ||
useTabs: false, | ||
}, | ||
], | ||
'curly': 'error', | ||
'import/no-unresolved': 'error', | ||
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], | ||
'react/jsx-uses-vars': 'error', | ||
'react/jsx-uses-react': 'error', | ||
'no-use-before-define': 'off', | ||
'@typescript-eslint/no-use-before-define': 'off', // TODO consider enabling this (currently it reports styles defined at the bottom of the file) | ||
'@typescript-eslint/ban-ts-comment': [ | ||
'error', | ||
{ | ||
'ts-ignore': 'allow-with-description', | ||
'ts-expect-error': 'allow-with-description', | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
'@typescript-eslint/no-var-requires': 'warn', | ||
'eqeqeq': 'error', | ||
'no-unreachable': 'error', | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ prefer: 'type-imports' }, | ||
], | ||
'@typescript-eslint/consistent-type-exports': [ | ||
'error', | ||
{ fixMixedExportsWithInlineTypeSpecifier: false }, | ||
], | ||
'tsdoc/syntax': 'error', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"extends": "expo/tsconfig.base", | ||
"extends": ["../tsconfig.json", "expo/tsconfig.base"], | ||
"compilerOptions": { | ||
"strict": true | ||
} | ||
}, | ||
"include": ["App.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
117 changes: 117 additions & 0 deletions
117
android/src/main/java/com/markdowntextinput/MarkdownStyle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.markdowntextinput; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.facebook.react.bridge.ColorPropConverter; | ||
import com.facebook.react.bridge.Dynamic; | ||
import com.facebook.react.bridge.JSApplicationCausedNativeException; | ||
import com.facebook.react.bridge.ReadableMap; | ||
|
||
import java.util.Objects; | ||
|
||
public class MarkdownStyle { | ||
private final int mSyntaxColor; | ||
private final int mLinkColor; | ||
private final float mH1FontSize; | ||
private final int mQuoteBorderColor; | ||
private final float mQuoteBorderWidth; | ||
private final float mQuoteMarginLeft; | ||
private final float mQuotePaddingLeft; | ||
private final int mCodeColor; | ||
private final int mCodeBackgroundColor; | ||
private final int mPreColor; | ||
private final int mPreBackgroundColor; | ||
private final int mMentionHereBackgroundColor; | ||
private final int mMentionUserBackgroundColor; | ||
|
||
public MarkdownStyle(@NonNull ReadableMap map, @NonNull Context context) { | ||
mSyntaxColor = parseColor(map, "syntax", "color", context); | ||
mLinkColor = parseColor(map, "link", "color", context); | ||
mH1FontSize = parseFloat(map, "h1", "fontSize"); | ||
mQuoteBorderColor = parseColor(map, "quote", "borderColor", context); | ||
mQuoteBorderWidth = parseFloat(map, "quote", "borderWidth"); | ||
mQuoteMarginLeft = parseFloat(map, "quote", "marginLeft"); | ||
mQuotePaddingLeft = parseFloat(map, "quote", "paddingLeft"); | ||
mCodeColor = parseColor(map, "code", "color", context); | ||
mCodeBackgroundColor = parseColor(map, "code", "backgroundColor", context); | ||
mPreColor = parseColor(map, "pre", "color", context); | ||
mPreBackgroundColor = parseColor(map, "pre", "backgroundColor", context); | ||
mMentionHereBackgroundColor = parseColor(map, "mentionHere", "backgroundColor", context); | ||
mMentionUserBackgroundColor = parseColor(map, "mentionUser", "backgroundColor", context); | ||
} | ||
|
||
private static int parseColor(@NonNull ReadableMap map, @NonNull String key, @NonNull String prop, @NonNull Context context) { | ||
ReadableMap style = map.getMap(key); | ||
Objects.requireNonNull(style); | ||
Dynamic value = style.getDynamic(prop); | ||
switch (value.getType()) { | ||
case Number: | ||
return ColorPropConverter.getColor(value.asDouble(), context); | ||
case Map: | ||
return ColorPropConverter.getColor(value.asMap(), context); | ||
default: | ||
throw new JSApplicationCausedNativeException("ColorValue: the value must be a number or Object."); | ||
} | ||
} | ||
|
||
private static float parseFloat(@NonNull ReadableMap map, @NonNull String key, @NonNull String prop) { | ||
ReadableMap style = map.getMap(key); | ||
Objects.requireNonNull(style); | ||
double value = style.getDouble(prop); | ||
return (float) value; | ||
} | ||
|
||
public int getSyntaxColor() { | ||
return mSyntaxColor; | ||
} | ||
|
||
public int getLinkColor() { | ||
return mLinkColor; | ||
} | ||
|
||
public float getH1FontSize() { | ||
return mH1FontSize; | ||
} | ||
|
||
public int getQuoteBorderColor() { | ||
return mQuoteBorderColor; | ||
} | ||
|
||
public float getQuoteBorderWidth() { | ||
return mQuoteBorderWidth; | ||
} | ||
|
||
public float getQuoteMarginLeft() { | ||
return mQuoteMarginLeft; | ||
} | ||
|
||
public float getQuotePaddingLeft() { | ||
return mQuotePaddingLeft; | ||
} | ||
|
||
public int getCodeColor() { | ||
return mCodeColor; | ||
} | ||
|
||
public int getCodeBackgroundColor() { | ||
return mCodeBackgroundColor; | ||
} | ||
|
||
public int getPreColor() { | ||
return mPreColor; | ||
} | ||
|
||
public int getPreBackgroundColor() { | ||
return mPreBackgroundColor; | ||
} | ||
|
||
public int getMentionHereBackgroundColor() { | ||
return mMentionHereBackgroundColor; | ||
} | ||
|
||
public int getMentionUserBackgroundColor() { | ||
return mMentionUserBackgroundColor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.