2.5.88 • Published 10 months ago

@erboladaiorg/dolorum-repellendus-ducimus v2.5.88

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

React Native Code Editor

npm-version gh-actions-status license

A code editor with syntax highlighting built for React Native applications. The component is built on top of React Syntax Highlighter. You can use it as a code editor or to display code snippets.

Installation

npm install @rivascva/react-native-code-editor

Contributing

Any contribution to make this component more extensible and efficient is welcome! Please give as much detail as possible about your bug fix or new feature in the pull request.

Simple Usage

import CodeEditor, { CodeEditorSyntaxStyles } from '@rivascva/react-native-code-editor';

const Example = (): JSX.Element => {
    return (
        <CodeEditor
            style={{
                fontSize: 20,
                inputLineHeight: 26,
                highlighterLineHeight: 26,
            }}
            language="javascript"
            syntaxStyle={CodeEditorSyntaxStyles.atomOneDark}
            showLineNumbers
        />
    );
};

export default Example;

Keyboard Alignment

Use the marginBottom style to accommodate the keyboard.

Note: See useKeyboard and useSafeAreaInsets for details on the hooks.

import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useKeyboard } from '@react-native-community/hooks';
import CodeEditor, { CodeEditorSyntaxStyles } from '@rivascva/react-native-code-editor';

const Example = (): JSX.Element => {
    const keyboard = useKeyboard();
    const insets = useSafeAreaInsets();

    return (
        <SafeAreaView>
            <CodeEditor
                style={{
                    ...{
                        fontSize: 20,
                        inputLineHeight: 26,
                        highlighterLineHeight: 26,
                    },
                    ...(keyboard.keyboardShown
                        ? { marginBottom: keyboard.keyboardHeight - insets.bottom }
                        : {}),
                }}
                language="javascript"
                syntaxStyle={CodeEditorSyntaxStyles.github}
                showLineNumbers
            />
        </SafeAreaView>
    );
};

export default Example;

Using React Navigator?

Checkout useBottomTabBarHeight for details on how to get the height of the bottom tab bar.

Props

PropDescription
style?Editor styles. More details below.
languageProgramming language to support. View all here.
syntaxStyle?Syntax highlighting style. View all here.
initialValue?Initial value on render.
onChange?On value change.
onKeyPress?On key press.
showLineNumbers?Whether to show line numbers next to each line.
readOnly?Make the editor read only.
autoFocus?Focus the code editor on component mount.

Note: You must import CodeEditorSyntaxStyles to set a syntaxStyle.

Styles

The style? prop has many custom styles to make the code editor as customizable as possible.

StyleDescription
height?Editor height.
width?Editor width.
marginTop?Editor top margin.
marginBottom?Editor bottom margin.
fontFamily?Default is Menlo-Regular (iOS) and Monospace (Android).
fontSize?Default is 16.
backgroundColor?Override the syntax style background.
padding?Default is 16.
lineNumbersColor?Text color of the line numbers.
lineNumbersBackgroundColor?Background color of the line numbers.
inputLineHeight?Use this property to align the text input with the syntax highlighter text.
inputColor?Use this property to help you align the text input with the syntax highlighter text. Do not use in production.
highlighterLineHeight?Use this property to align the syntax highlighter text with the text input.
highlighterColor?Use this property to help you align the syntax highlighter text with the text input. Do not use in production.

Note: You can import CodeEditorStyleType to type-check the styles.

Important Issue

There is a small ongoing issue involving the cursor misaligning from the text. It is very likely you will encounter this issue, but it is fixable. Please view issue #1 for the current fix.

Credits

regular-expressionquoteprogresslockfileflatapidescriptors256eslintstatelessvalidatorwhichvalidfetchuuides-shim APIfindLastIndexcolorsisa11ysetterprotobufmkdirpAsyncIteratormixinsgraphqleslintpluginlistenersMicrosofthelpers$.extendkoreaninvariantutilitiesserializationcomputed-typeses2018moveless compilercall-bindworkerpyyamljwthandlers_.extendoperating-systemESrgbArrayBuffer.prototype.slicearraybufferfindLastdotenvlintpush.gitignorefunctionprotocol-bufferstextgradients cssrangeerrorArray.prototype.findLastIndexsyntaxerrorapollojoimodulesbuffershttpbrowserfast-cloneflattenpreserve-symlinkspasswordcopyvarinternal slotencryptioncolorArrayBuffer#sliceString.prototype.trimcolumnsvestbyteOffsetreactECMAScript 2022arraysjson-schema-validatorbeanstalkpropconfigurablepathi18nvaluegroupsqssubprocesswarningmatchexitpatchiamdeep-copyECMAScript 2015bannerreduxhashfullSystem.globalglobal this valueasynceslint-pluginfpparsingcryptoworkspace:*ES2016serializerfsshelles7Setcallflux.envtypedECMAScript 6objidentifierses6deepcloneassertionHyBiECMAScript 30elbredactselfresolvemergesharedString.prototype.matchAllmetadatatypedarrayhasOwnECMAScript 2018Object.assignpackage.jsondescriptioncompile lesschaidefinedataViewebs@@toStringTagdatatouchchrometoolsES7callbackminimalsnsformatRFC-6455Float32ArrayastglaciertypanionworkflowstatelibphonenumberlastglobalThisless mixinscssgenericserrorutilgroupByreact-hookssameValueZerothreecircularjapanesecloudtrailmatchesObjectajvconsolefindjson-schema-validationrapidpipesignalargvnested cssUint8Arrayimmerstyleguidecolumnfast-deep-cloneUint32ArrayprunepostcssexpresssymlinkgetOwnPropertyDescriptorsymlinksSymbol.toStringTagslotWebSocket3djsxreplaytoArrayECMAScriptelectronregexES2015zodnodeoutputfilefastcloneFunction.prototype.namegetterECMAScript 2016cloudformationObservablesinterruptsBigInt64ArraytrimLeftInt32Arrayreadableeverymake dirfpsphoneincludesvaluesglobalmanagersetImmediatemkdirshttpsquerystringairbnbtestmakeregular expressionsetswfnamesfastifyTypeScripttranspilexhrsigintreact-testing-librarysequencees-shimskinesisassertacornexit-codeomitURLSearchParamscommanderdeep-clonesigned__proto__typeerrorECMAScript 2019utilswindowESnextUint8ClampedArrayrequestrecursivekeyfunctionalasterisksfull-widthec2busyignoretrimStarttypes-0autoprefixernpmdeterministicwgetkeysindicatorbinarycommand-lineietrimEndArraydateextendexecassertsargumentinbundlerformattingchromiumprocesses8StyleSheettrimutil.inspectprefixdirrfc4122ascii[[Prototype]]curlfnmatchenumerablerobustajaxlruvarscloudwatchhasOwnPropertyrdspoint-freechildsliceIteratorformpackagesyuplettaketraversehas-owndrageventEmitterramdasimpledbFloat64ArraysettingsRegExp#flagsqsinspectisConcatSpreadablesymbolsawesomesaucesafebrowserslistexpressionprivatepinobinarieses5fastreact animationextrababelbundlingendpointcollection.es6redux-toolkitstringifymobileecmascriptperformantsuperagentinstallcreateuser-streamsReflect.getPrototypeOfes2016momentfilternegativejavascriptvariablesrulescontainsgetoptmapreducevalidationfigletpropertyintrinsicbindaccessorparseiterateconstemitprototypehasscheme-validationviewjestsignalshardlinksspinnersArray.prototype.includesObject.keysoffsetcommandpureconfigpnpm9shimmonorepoescapeflagurlcoerciblecryptmaps3spinnerforkreuseliveTypeBoxES2019stringownemrsidebddsetPrototypeOfeslintconfigflatMapWeakSetqueryglobal objectstarterfastcopygdprstyleslogchinesematchAllvariables in cssclassesexecfilebufferObject.entriesio-tstelephonewafimportexportlazyjsdompolyfillReactiveXelmentriesiterationregexpArray.prototype.containscollectionInt16Arraymulti-packagetransportMapnativeroute53east-asian-widthdom-testing-libraryestreecompareconsumehooksinstallercjkshamshebangECMAScript 2021jQuerylinkelasticacheterminalhotequallessauthenticationcharacterzeroartdirectoryinputdeepcopydefinePropertycompilercallbind6to5Rxweaksetrfc9562WeakMapES2018ansiwalkArrayBufferttyeffect-tsclassnameObject.getPrototypeOfoptimistnumberInt8Arraycss nestingobjectroutingtoReversedschemeless cssenvironmentstesterwindowsSymbolreact-hook-formtypedarraysjson-schemaimportObject.definePropertyJSONdropfullwidthfunctionsstyledayjsreadablestreamesPushfantasy-landmodulelanguagesortedeventsWebSocketsES6unicodearktypepopmotiondatastructuretypeless.jsnpmignoresyntaxwaapihelperspecinternalsomerouteguidsuperstructwidthchannelStreamvisualfunction.lengthbcryptefficientpositivestyled-componentses-abstractsesloggingpredictableglobrandombrowserlistjsdiffpropertiestyped arraywhatwgwritablereact poseyamlcss variablees2015nodejstoobjectJSON-Schemacore-jstranspilerirqdomconcatMapparserawstoSortedBigUint64ArrayloadinggetintrinsicbinlinuxES2021classnamescolourcodesprotoObject.valuesArray.prototype.findLastanimationl10nbootstrap lesscss lessdescriptorloadbalancingstylingpackage managerjsonschematimeposeframerponyfillmrucurriedreduceStreamsspeedmacostypeofclass-validatortestingreadperformancetslibcliECMAScript 5storagegatewayboundPromisetermgetlengthpersistentdeepgradients css3reducerbootstrap cssaccessibilitypostcss-pluginpluginbabel-corextermiteratornameUnderscorefile systemfast-deep-copyamazonECMAScript 2017censorqueueflagspicomatchspawnstatusstructuredClonegetPrototypeOfclientRegExp.prototype.flagsObject.fromEntrieststrimRighteventDispatchersymboldependency managerremovezxarraycloneschematc39URLbyteLengtherror-handlinggitignoretoolkitutilitytypesafetacitimmutabledependenciesTypedArrayES8ES2023es2017cloudfrontES5waituploadcacheinferencedeleteform-validationES2020tostringtagspringCSSStyleDeclarationenvironmentfromdiffstringifierCSSserializeoptionjsregularuninstallloggerECMAScript 7RxJSglobalsagentObservableharmonydynamodbES2022negative zeroreal-timevpcYAMLcall-boundrequirestylesheetautoscalingshrinkwrapruntimehigher-ordertoStringTagvalidateforEachconcatsigtermcertificatesArray.prototype.filterstableprivate dataweakmaplocalfast-copyfixed-widthopensslenvsortoncestreamsbytepreprocessorqueueMicrotaskECMAScript 2020Array.prototype.flatnopereversedprettywrite
2.5.88

10 months ago

2.5.87

10 months ago

2.5.86

10 months ago

2.5.85

10 months ago

2.5.84

11 months ago

2.5.83

11 months ago

2.5.82

11 months ago

2.5.81

11 months ago

2.5.80

11 months ago

1.5.80

11 months ago

1.5.79

11 months ago

1.5.78

11 months ago

1.5.77

11 months ago

1.5.76

11 months ago

1.5.75

11 months ago

1.5.74

11 months ago

1.5.73

11 months ago

1.5.72

11 months ago

1.5.71

11 months ago

1.5.70

11 months ago

1.5.69

11 months ago

1.5.68

11 months ago

1.5.67

11 months ago

1.5.66

11 months ago

1.5.65

11 months ago

1.4.65

11 months ago

1.4.64

11 months ago

1.4.63

11 months ago

1.4.62

11 months ago

1.4.61

11 months ago

1.3.61

11 months ago

1.3.60

11 months ago

1.3.59

11 months ago

1.3.58

11 months ago

1.3.57

12 months ago

1.3.56

12 months ago

1.3.55

12 months ago

1.3.54

12 months ago

1.3.53

12 months ago

1.3.52

12 months ago

1.3.51

12 months ago

1.3.50

12 months ago

1.3.49

12 months ago

1.3.48

12 months ago

1.3.47

12 months ago

1.3.46

12 months ago

1.3.45

12 months ago

1.3.44

12 months ago

1.2.44

12 months ago

1.2.43

12 months ago

1.2.42

12 months ago

1.2.41

12 months ago

1.2.40

12 months ago

1.2.39

12 months ago

1.2.38

1 year ago

1.2.37

1 year ago

1.2.36

1 year ago

1.2.35

1 year ago

1.1.35

1 year ago

1.1.34

1 year ago

1.1.33

1 year ago

1.1.32

1 year ago

1.1.31

1 year ago

1.1.30

1 year ago

1.1.29

1 year ago

1.1.28

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

1 year ago

1.1.24

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago