|
|
@@ -13,37 +13,49 @@ import {
|
|
|
|
|
|
const stylesheet = StyleSheet.create({
|
|
|
editorInput: {
|
|
|
- fontFamily: Platform.OS === "web" ? "monospace" : "System",
|
|
|
+ fontFamily: Platform.OS === "web" ? "Consolas, 'Courier New', monospace" : "monospace",
|
|
|
backgroundColor: "transparent",
|
|
|
textAlignVertical: "top",
|
|
|
position: "absolute",
|
|
|
color: "transparent",
|
|
|
+ fontWeight: "400",
|
|
|
+ letterSpacing: 0,
|
|
|
+ borderWidth: 0,
|
|
|
+ lineHeight: 24,
|
|
|
+ fontSize: 14,
|
|
|
+ padding: 0,
|
|
|
+ margin: 0,
|
|
|
bottom: 0,
|
|
|
right: 0,
|
|
|
left: 0,
|
|
|
top: 0,
|
|
|
...webStyle({
|
|
|
+ fontVariantLigatures: "none",
|
|
|
caretColor: "inherit",
|
|
|
outline: "none",
|
|
|
resize: "none"
|
|
|
})
|
|
|
},
|
|
|
- gutter: {
|
|
|
- justifyContent: "flex-end",
|
|
|
- alignItems: "flex-start",
|
|
|
- flexDirection: "row",
|
|
|
- borderRightWidth: 1,
|
|
|
+ content: {
|
|
|
+ fontFamily: Platform.OS === "web" ? "Consolas, 'Courier New', monospace" : "monospace",
|
|
|
+ fontWeight: "400",
|
|
|
+ letterSpacing: 0,
|
|
|
...webStyle({
|
|
|
- userSelect: "none"
|
|
|
+ fontVariantLigatures: "none",
|
|
|
+ whiteSpace: Platform.OS === "web" ? "pre" : "pre-wrap"
|
|
|
})
|
|
|
},
|
|
|
- content: {
|
|
|
- fontFamily: Platform.OS === "web" ? "monospace" : "System",
|
|
|
+ codeText: {
|
|
|
+ fontFamily: Platform.OS === "web" ? "Consolas, 'Courier New', monospace" : "monospace",
|
|
|
+ fontWeight: "400",
|
|
|
+ letterSpacing: 0,
|
|
|
+ fontSize: 14,
|
|
|
...webStyle({
|
|
|
- whiteSpace: Platform.OS === "web" ? "pre" : "pre-wrap"
|
|
|
+ fontVariantLigatures: "none"
|
|
|
})
|
|
|
},
|
|
|
lineNumber: {
|
|
|
+ fontFamily: Platform.OS === "web" ? "monospace" : "System",
|
|
|
textAlign: "right",
|
|
|
marginRight: 4,
|
|
|
lineHeight: 24,
|
|
|
@@ -52,12 +64,27 @@ const stylesheet = StyleSheet.create({
|
|
|
userSelect: "none"
|
|
|
})
|
|
|
},
|
|
|
- container: {
|
|
|
+ gutter: {
|
|
|
+ justifyContent: "flex-end",
|
|
|
alignItems: "flex-start",
|
|
|
flexDirection: "row",
|
|
|
+ borderRightWidth: 1,
|
|
|
+ ...webStyle({
|
|
|
+ userSelect: "none"
|
|
|
+ })
|
|
|
+ },
|
|
|
+ toolbarContainer: {
|
|
|
+ justifyContent: "flex-start",
|
|
|
+ borderBottomWidth: 0,
|
|
|
+ alignItems: "center",
|
|
|
+ flexDirection: "row",
|
|
|
+ paddingVertical: 4,
|
|
|
+ flexWrap: "wrap"
|
|
|
+ },
|
|
|
+ container: {
|
|
|
+ flexDirection: "column",
|
|
|
position: "relative",
|
|
|
- borderRadius: 10,
|
|
|
- borderWidth: 1
|
|
|
+ width: "100%"
|
|
|
},
|
|
|
lineRow: {
|
|
|
alignItems: "flex-start",
|
|
|
@@ -68,15 +95,22 @@ const stylesheet = StyleSheet.create({
|
|
|
minWidth: "100%",
|
|
|
flexGrow: 1
|
|
|
},
|
|
|
+ text: {
|
|
|
+ lineHeight: 24
|
|
|
+ },
|
|
|
scrollView: {
|
|
|
flex: 1
|
|
|
}
|
|
|
});
|
|
|
|
|
|
export const useStyles = ({
|
|
|
+ isToolbarVisible = false,
|
|
|
isLineNumberVisible = true,
|
|
|
hasLanguage = false,
|
|
|
+ spreadBehaviour,
|
|
|
typography,
|
|
|
+ radiuses,
|
|
|
+ borders,
|
|
|
colors,
|
|
|
spaces
|
|
|
}: ICodeEditorDynamicStyleProps) => {
|
|
|
@@ -91,44 +125,72 @@ export const useStyles = ({
|
|
|
}
|
|
|
|
|
|
const languageMarginLeft = spaces.spacingSm;
|
|
|
+ const lineHeight = (typography.bodyMediumSize?.lineHeight as number) || 24;
|
|
|
|
|
|
const styles = {
|
|
|
+ editorContainer: {
|
|
|
+ paddingTop: isToolbarVisible ? spaces.spacingXs : spaces.spacingMd,
|
|
|
+ borderTopRightRadius: isToolbarVisible ? 0 : radiuses.form,
|
|
|
+ borderTopLeftRadius: isToolbarVisible ? 0 : radiuses.form,
|
|
|
+ backgroundColor: colors.content.container.subtle,
|
|
|
+ borderColor: colors.content.border.subtle,
|
|
|
+ borderBottomRightRadius: radiuses.form,
|
|
|
+ borderBottomLeftRadius: radiuses.form,
|
|
|
+ paddingHorizontal: spaces.spacingMd,
|
|
|
+ paddingBottom: spaces.spacingMd,
|
|
|
+ borderWidth: borders.line,
|
|
|
+ borderTopWidth: isToolbarVisible ? 0 : borders.line
|
|
|
+ } as ViewStyle,
|
|
|
+ toolbarContainer: {
|
|
|
+ backgroundColor: colors.content.container.subtle,
|
|
|
+ borderColor: colors.content.border.subtle,
|
|
|
+ borderTopRightRadius: radiuses.form,
|
|
|
+ paddingHorizontal: spaces.spacingMd,
|
|
|
+ borderTopLeftRadius: radiuses.form,
|
|
|
+ paddingBottom: spaces.spacingXs,
|
|
|
+ borderRightWidth: borders.line,
|
|
|
+ borderLeftWidth: borders.line,
|
|
|
+ borderTopWidth: borders.line,
|
|
|
+ paddingTop: spaces.spacingMd,
|
|
|
+ gap: spaces.spacingXs
|
|
|
+ } as ViewStyle,
|
|
|
editorInput: {
|
|
|
...typography.bodyMediumSize,
|
|
|
- lineHeight: 24,
|
|
|
- padding: 0,
|
|
|
- paddingLeft: isLineNumberVisible ? (gutterWidth + gutterMarginRight) : spaces.spacingSm,
|
|
|
- paddingTop: hasLanguage ? 32 : 0,
|
|
|
+ paddingLeft: (isLineNumberVisible ? (gutterWidth + gutterMarginRight) : spaces.spacingSm),
|
|
|
+ fontFamily: Platform.OS === "web" ? "Consolas, 'Courier New', monospace" : "monospace",
|
|
|
+ paddingTop: hasLanguage ? (lineHeight + spaces.spacingSm) : 0,
|
|
|
+ paddingRight: spaces.spacingMd,
|
|
|
...webStyle({
|
|
|
caretColor: colors.content.text.high
|
|
|
})
|
|
|
} as TextStyle,
|
|
|
+ container: {
|
|
|
+ alignSelf: spreadBehaviour === "stretch" ? "stretch" : (spreadBehaviour === "baseline" ? "baseline" : "auto"),
|
|
|
+ width: spreadBehaviour === "baseline" ? "auto" : "100%",
|
|
|
+ marginVertical: spaces.spacingSm
|
|
|
+ } as ViewStyle,
|
|
|
languageText: {
|
|
|
- color: colors.content.text.low,
|
|
|
marginBottom: spaces.spacingSm,
|
|
|
+ color: colors.content.text.low,
|
|
|
marginLeft: languageMarginLeft,
|
|
|
...webStyle({
|
|
|
userSelect: "none"
|
|
|
})
|
|
|
} as TextStyle,
|
|
|
- container: {
|
|
|
- backgroundColor: colors.content.container.subtle,
|
|
|
- borderColor: colors.content.border.subtle,
|
|
|
- marginVertical: spaces.spacingSm,
|
|
|
- padding: spaces.spacingMd
|
|
|
+ text: {
|
|
|
+ ...typography.bodyMediumSize,
|
|
|
+ fontFamily: Platform.OS === "web" ? "Consolas, 'Courier New', monospace" : "monospace"
|
|
|
+ } as TextStyle,
|
|
|
+ lineRow: {
|
|
|
+ marginLeft: !isLineNumberVisible ? spaces.spacingSm : 0,
|
|
|
+ minHeight: lineHeight,
|
|
|
+ height: lineHeight
|
|
|
} as ViewStyle,
|
|
|
gutter: {
|
|
|
paddingRight: gutterPaddingRight,
|
|
|
marginRight: gutterMarginRight,
|
|
|
width: gutterWidth
|
|
|
- } as ViewStyle,
|
|
|
- lineRow: {
|
|
|
- marginLeft: !isLineNumberVisible ? spaces.spacingSm : 0
|
|
|
- } as ViewStyle,
|
|
|
- text: {
|
|
|
- ...typography.bodyMediumSize,
|
|
|
- lineHeight: 24
|
|
|
- } as TextStyle
|
|
|
+ } as ViewStyle
|
|
|
};
|
|
|
|
|
|
return styles;
|