@sanity/code-input 2.24.1-pte.113 → 2.24.2

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 CHANGED
@@ -52,12 +52,40 @@ Note that the above only works if you import and use the `all:part:@sanity/base/
52
52
  {title: 'Javascript', value: 'js'},
53
53
  {title: 'HTML', value: 'html'},
54
54
  {title: 'CSS', value: 'css'},
55
+ {title: 'Rust', value: 'rust', mode:'rust'},
55
56
  {title: 'SASS', value: 'sass'},
56
57
  ]
57
58
  }
58
59
  }
59
60
  ```
60
61
 
62
+ ## Add support for more languages
63
+
64
+ Only a subset of languages are supported by default (see full list [here](https://github.com/sanity-io/sanity/blob/current/packages/@sanity/code-input/src/config.ts#L4)). You can add support for other languages by importing the ace mode yourself, and specifying `mode` for the `languageAlternatives` schema config.
65
+
66
+ Example: Add support for the Rust Programming Language
67
+
68
+ ```js
69
+ // import rust support for ace, see https://github.com/securingsincity/react-ace for more details
70
+ import 'ace-builds/src-noconflict/mode-rust'
71
+
72
+ {
73
+ name: 'exampleUsage',
74
+ title: 'Example usage',
75
+ type: 'code',
76
+ options: {
77
+ languageAlternatives: [
78
+ {title: 'Javascript', value: 'js'},
79
+ {
80
+ title: 'Rust',
81
+ value: 'rust',
82
+ mode:'rust' // <- specify the mode to use here. Make sure this mode is also imported from ace-builds (see above)
83
+ },
84
+ ]
85
+ }
86
+ }
87
+ ```
88
+
61
89
  ## Data model
62
90
 
63
91
  ```js
@@ -1 +1 @@
1
- {"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../src/CodeInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAChF,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AAU1C,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAErD,OAAO,iBAAiB,CAAA;AAsCxB,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,cAAc,CAAA;IAC7B,SAAS,EAAE,IAAI,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC7B,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAkBD,QAAA,MAAM,SAAS;WAC2C,MAAM,IAAI;GAyUnE,CAAA;AAID,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../src/CodeInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAChF,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AAS1C,OAAO,EAAoB,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAExE,OAAO,iBAAiB,CAAA;AAsCxB,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,cAAc,CAAA;IAC7B,SAAS,EAAE,IAAI,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC7B,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAkBD,QAAA,MAAM,SAAS;WAC2C,MAAM,IAAI;GAmVnE,CAAA;AAID,eAAe,SAAS,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewCode.d.ts","sourceRoot":"","sources":["../../src/PreviewCode.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAErD,OAAO,iBAAiB,CAAA;AAqBxB,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAgBD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAqD1D"}
1
+ {"version":3,"file":"PreviewCode.d.ts","sourceRoot":"","sources":["../../src/PreviewCode.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAErD,OAAO,iBAAiB,CAAA;AAqBxB,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAsD1D"}
@@ -1,4 +1,4 @@
1
- import { Marker } from 'react-ace';
1
+ import { IMarker } from 'react-ace';
2
2
  export declare const highlightMarkersCSS: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
3
- export default function createHighlightMarkers(rows: number[]): Marker[];
3
+ export default function createHighlightMarkers(rows: number[]): IMarker[];
4
4
  //# sourceMappingURL=createHighlightMarkers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createHighlightMarkers.d.ts","sourceRoot":"","sources":["../../src/createHighlightMarkers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAGhC,eAAO,MAAM,mBAAmB,+FAQ/B,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAUvE"}
1
+ {"version":3,"file":"createHighlightMarkers.d.ts","sourceRoot":"","sources":["../../src/createHighlightMarkers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAGjC,eAAO,MAAM,mBAAmB,+FAQ/B,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAUxE"}
@@ -1,28 +1,28 @@
1
1
  import './groq';
2
- import 'brace/mode/batchfile';
3
- import 'brace/mode/csharp';
4
- import 'brace/mode/css';
5
- import 'brace/mode/golang';
6
- import 'brace/mode/html';
7
- import 'brace/mode/java';
8
- import 'brace/mode/javascript';
9
- import 'brace/mode/json';
10
- import 'brace/mode/jsx';
11
- import 'brace/mode/markdown';
12
- import 'brace/mode/mysql';
13
- import 'brace/mode/php';
14
- import 'brace/mode/python';
15
- import 'brace/mode/ruby';
16
- import 'brace/mode/sass';
17
- import 'brace/mode/scss';
18
- import 'brace/mode/sh';
19
- import 'brace/mode/text';
20
- import 'brace/mode/tsx';
21
- import 'brace/mode/typescript';
22
- import 'brace/mode/xml';
23
- import 'brace/mode/yaml';
24
- import 'brace/theme/github';
25
- import 'brace/theme/monokai';
26
- import 'brace/theme/terminal';
27
- import 'brace/theme/tomorrow';
2
+ import 'ace-builds/src-noconflict/mode-batchfile';
3
+ import 'ace-builds/src-noconflict/mode-csharp';
4
+ import 'ace-builds/src-noconflict/mode-css';
5
+ import 'ace-builds/src-noconflict/mode-golang';
6
+ import 'ace-builds/src-noconflict/mode-html';
7
+ import 'ace-builds/src-noconflict/mode-java';
8
+ import 'ace-builds/src-noconflict/mode-javascript';
9
+ import 'ace-builds/src-noconflict/mode-json';
10
+ import 'ace-builds/src-noconflict/mode-jsx';
11
+ import 'ace-builds/src-noconflict/mode-markdown';
12
+ import 'ace-builds/src-noconflict/mode-mysql';
13
+ import 'ace-builds/src-noconflict/mode-php';
14
+ import 'ace-builds/src-noconflict/mode-python';
15
+ import 'ace-builds/src-noconflict/mode-ruby';
16
+ import 'ace-builds/src-noconflict/mode-sass';
17
+ import 'ace-builds/src-noconflict/mode-scss';
18
+ import 'ace-builds/src-noconflict/mode-sh';
19
+ import 'ace-builds/src-noconflict/mode-text';
20
+ import 'ace-builds/src-noconflict/mode-tsx';
21
+ import 'ace-builds/src-noconflict/mode-typescript';
22
+ import 'ace-builds/src-noconflict/mode-xml';
23
+ import 'ace-builds/src-noconflict/mode-yaml';
24
+ import 'ace-builds/src-noconflict/theme-github';
25
+ import 'ace-builds/src-noconflict/theme-monokai';
26
+ import 'ace-builds/src-noconflict/theme-terminal';
27
+ import 'ace-builds/src-noconflict/theme-tomorrow';
28
28
  //# sourceMappingURL=editorSupport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editorSupport.d.ts","sourceRoot":"","sources":["../../src/editorSupport.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,CAAA;AACf,OAAO,sBAAsB,CAAA;AAC7B,OAAO,mBAAmB,CAAA;AAC1B,OAAO,gBAAgB,CAAA;AACvB,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,CAAA;AACxB,OAAO,uBAAuB,CAAA;AAC9B,OAAO,iBAAiB,CAAA;AACxB,OAAO,gBAAgB,CAAA;AACvB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,kBAAkB,CAAA;AACzB,OAAO,gBAAgB,CAAA;AACvB,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,CAAA;AACxB,OAAO,eAAe,CAAA;AACtB,OAAO,iBAAiB,CAAA;AACxB,OAAO,gBAAgB,CAAA;AACvB,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gBAAgB,CAAA;AACvB,OAAO,iBAAiB,CAAA;AAGxB,OAAO,oBAAoB,CAAA;AAC3B,OAAO,qBAAqB,CAAA;AAC5B,OAAO,sBAAsB,CAAA;AAC7B,OAAO,sBAAsB,CAAA"}
1
+ {"version":3,"file":"editorSupport.d.ts","sourceRoot":"","sources":["../../src/editorSupport.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,CAAA;AAEf,OAAO,0CAA0C,CAAA;AACjD,OAAO,uCAAuC,CAAA;AAC9C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,uCAAuC,CAAA;AAC9C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,2CAA2C,CAAA;AAClD,OAAO,qCAAqC,CAAA;AAC5C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,yCAAyC,CAAA;AAChD,OAAO,sCAAsC,CAAA;AAC7C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,uCAAuC,CAAA;AAC9C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,mCAAmC,CAAA;AAC1C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,2CAA2C,CAAA;AAClD,OAAO,oCAAoC,CAAA;AAC3C,OAAO,qCAAqC,CAAA;AAG5C,OAAO,wCAAwC,CAAA;AAC/C,OAAO,yCAAyC,CAAA;AAChD,OAAO,0CAA0C,CAAA;AACjD,OAAO,0CAA0C,CAAA"}
@@ -6,7 +6,7 @@ declare const _default: {
6
6
  inputComponent: React.ForwardRefExoticComponent<import("./CodeInput").CodeInputProps & React.RefAttributes<{
7
7
  focus: () => void;
8
8
  }>>;
9
- icon: React.ForwardRefExoticComponent<Pick<React.SVGProps<SVGSVGElement>, "string" | "style" | "clipPath" | "filter" | "mask" | "path" | "height" | "crossOrigin" | "href" | "max" | "media" | "method" | "min" | "name" | "target" | "type" | "width" | "className" | "id" | "lang" | "tabIndex" | "role" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "display" | "overflow" | "radius" | "fill" | "values" | "mode" | "fontSize" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "accentHeight" | "accumulate" | "additive" | "alignmentBaseline" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "azimuth" | "baseFrequency" | "baselineShift" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clip" | "clipPathUnits" | "clipRule" | "colorInterpolation" | "colorInterpolationFilters" | "colorProfile" | "colorRendering" | "contentScriptType" | "contentStyleType" | "cursor" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "direction" | "divisor" | "dominantBaseline" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "fillOpacity" | "fillRule" | "filterRes" | "filterUnits" | "floodColor" | "floodOpacity" | "focusable" | "fontFamily" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphOrientationVertical" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "imageRendering" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "letterSpacing" | "lightingColor" | "limitingConeAngle" | "local" | "markerEnd" | "markerHeight" | "markerMid" | "markerStart" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "numOctaves" | "offset" | "opacity" | "operator" | "order" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "paintOrder" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "pointerEvents" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rotate" | "rx" | "ry" | "scale" | "seed" | "shapeRendering" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "stopColor" | "stopOpacity" | "strikethroughPosition" | "strikethroughThickness" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textAnchor" | "textDecoration" | "textLength" | "textRendering" | "to" | "transform" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeBidi" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "vectorEffect" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "visibility" | "vMathematical" | "widths" | "wordSpacing" | "writingMode" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan"> & React.RefAttributes<SVGSVGElement>>;
9
+ icon: React.ForwardRefExoticComponent<Pick<React.SVGProps<SVGSVGElement>, "string" | "style" | "clipPath" | "filter" | "mask" | "path" | "height" | "crossOrigin" | "href" | "max" | "media" | "method" | "min" | "name" | "target" | "type" | "width" | "className" | "id" | "lang" | "tabIndex" | "role" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "display" | "overflow" | "radius" | "mode" | "fontSize" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "accentHeight" | "accumulate" | "additive" | "alignmentBaseline" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "azimuth" | "baseFrequency" | "baselineShift" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clip" | "clipPathUnits" | "clipRule" | "colorInterpolation" | "colorInterpolationFilters" | "colorProfile" | "colorRendering" | "contentScriptType" | "contentStyleType" | "cursor" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "direction" | "divisor" | "dominantBaseline" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "fill" | "fillOpacity" | "fillRule" | "filterRes" | "filterUnits" | "floodColor" | "floodOpacity" | "focusable" | "fontFamily" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphOrientationVertical" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "imageRendering" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "letterSpacing" | "lightingColor" | "limitingConeAngle" | "local" | "markerEnd" | "markerHeight" | "markerMid" | "markerStart" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "numOctaves" | "offset" | "opacity" | "operator" | "order" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "paintOrder" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "pointerEvents" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rotate" | "rx" | "ry" | "scale" | "seed" | "shapeRendering" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "stopColor" | "stopOpacity" | "strikethroughPosition" | "strikethroughThickness" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textAnchor" | "textDecoration" | "textLength" | "textRendering" | "to" | "transform" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeBidi" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "values" | "vectorEffect" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "visibility" | "vMathematical" | "widths" | "wordSpacing" | "writingMode" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan"> & React.RefAttributes<SVGSVGElement>>;
10
10
  fields: ({
11
11
  name: string;
12
12
  title: string;
@@ -1,6 +1,7 @@
1
1
  export interface CodeInputLanguage {
2
2
  title: string;
3
3
  value: string;
4
+ mode?: string;
4
5
  }
5
6
  export interface CodeInputType {
6
7
  name?: string;
@@ -11,6 +12,12 @@ export interface CodeInputType {
11
12
  title?: string;
12
13
  placeholder?: string;
13
14
  }[];
15
+ options?: {
16
+ theme?: string;
17
+ languageAlternatives: CodeInputLanguage[];
18
+ language: string;
19
+ withFilename?: boolean;
20
+ };
14
21
  }
15
22
  export interface CodeInputValue {
16
23
  _type?: 'code';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAC,EAAE,CAAA;CAC/D;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAC,EAAE,CAAA;IAC9D,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,oBAAoB,EAAE,iBAAiB,EAAE,CAAA;QACzC,QAAQ,EAAE,MAAM,CAAA;QAChB,YAAY,CAAC,EAAE,OAAO,CAAA;KACvB,CAAA;CACF;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B"}
package/lib/CodeInput.js CHANGED
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _has2 = _interopRequireDefault(require("lodash/has"));
9
-
10
- var _get2 = _interopRequireDefault(require("lodash/get"));
11
-
12
8
  var _react = _interopRequireWildcard(require("react"));
13
9
 
14
10
  var _components = require("@sanity/base/components");
@@ -35,12 +31,12 @@ var _config = require("./config");
35
31
 
36
32
  var _templateObject;
37
33
 
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
+
38
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
37
 
40
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
39
 
42
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
-
44
40
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
45
41
 
46
42
  var EditorContainer = (0, _styledComponents.default)(_ui.Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n box-sizing: border-box;\n overflow: hidden;\n z-index: 0;\n\n .ace_editor {\n font-family: ", ";\n font-size: ", ";\n line-height: inherit;\n }\n\n ", "\n\n &:not([disabled]):not([readonly]) {\n &:focus,\n &:focus-within {\n box-shadow: 0 0 0 2px ", ";\n background-color: ", ";\n border-color: ", ";\n }\n }\n"])), _ref => {
@@ -78,7 +74,7 @@ function isSupportedLanguage(mode) {
78
74
  }
79
75
 
80
76
  var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
81
- var _props$value;
77
+ var _props$value, _type$options5, _type$options6;
82
78
 
83
79
  var aceEditorRef = (0, _react.useRef)();
84
80
  var aceEditorId = (0, _autoId.useId)();
@@ -116,7 +112,9 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
116
112
  }), val ? (0, _patchEvent.set)(val, path) : (0, _patchEvent.unset)(path)]));
117
113
  }, [onChange, type.name]);
118
114
  var getTheme = (0, _react.useCallback)(() => {
119
- var preferredTheme = (0, _get2.default)(type, 'options.theme');
115
+ var _type$options;
116
+
117
+ var preferredTheme = (_type$options = type.options) === null || _type$options === void 0 ? void 0 : _type$options.theme;
120
118
  return preferredTheme && _config.SUPPORTED_THEMES.find(theme => theme === preferredTheme) ? preferredTheme : _config.DEFAULT_THEME;
121
119
  }, [type]);
122
120
  var handleToggleSelectLine = (0, _react.useCallback)(lineNumber => {
@@ -124,7 +122,7 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
124
122
 
125
123
  var editorSession = (_aceEditorRef$current3 = aceEditorRef.current) === null || _aceEditorRef$current3 === void 0 ? void 0 : (_aceEditorRef$current4 = _aceEditorRef$current3.editor) === null || _aceEditorRef$current4 === void 0 ? void 0 : _aceEditorRef$current4.getSession();
126
124
  var backgroundMarkers = editorSession === null || editorSession === void 0 ? void 0 : editorSession.getMarkers(true);
127
- var currentHighlightedLines = Object.keys(backgroundMarkers).filter(key => backgroundMarkers[key].type === 'highlight').map(key => backgroundMarkers[key].range.start.row);
125
+ var currentHighlightedLines = Object.keys(backgroundMarkers).filter(key => backgroundMarkers[key].type === 'screenLine').map(key => backgroundMarkers[key].range.start.row);
128
126
  var currentIndex = currentHighlightedLines.indexOf(lineNumber);
129
127
 
130
128
  if (currentIndex > -1) {
@@ -161,7 +159,9 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
161
159
  editor === null || editor === void 0 ? void 0 : editor.on('guttermousedown', handleGutterMouseDown);
162
160
  }, [handleGutterMouseDown]);
163
161
  var getLanguageAlternatives = (0, _react.useCallback)(() => {
164
- var languageAlternatives = (0, _get2.default)(type, 'options.languageAlternatives');
162
+ var _type$options2;
163
+
164
+ var languageAlternatives = (_type$options2 = type.options) === null || _type$options2 === void 0 ? void 0 : _type$options2.languageAlternatives;
165
165
 
166
166
  if (!languageAlternatives) {
167
167
  return _config.SUPPORTED_LANGUAGES;
@@ -173,7 +173,8 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
173
173
 
174
174
  return languageAlternatives.reduce((acc, _ref6) => {
175
175
  var title = _ref6.title,
176
- val = _ref6.value;
176
+ val = _ref6.value,
177
+ mode = _ref6.mode;
177
178
  var alias = _config.LANGUAGE_ALIASES[val];
178
179
 
179
180
  if (alias) {
@@ -181,24 +182,28 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
181
182
  console.warn("'options.languageAlternatives' lists a language with value \"%s\", which is an alias of \"%s\" - please replace the value to read \"%s\"", val, alias, alias);
182
183
  return acc.concat({
183
184
  title,
184
- value: alias
185
+ value: alias,
186
+ mode: mode
185
187
  });
186
188
  }
187
189
 
188
- if (!_config.SUPPORTED_LANGUAGES.find(lang => lang.value === val)) {
190
+ if (!mode && !_config.SUPPORTED_LANGUAGES.find(lang => lang.value === val)) {
189
191
  // eslint-disable-next-line no-console
190
192
  console.warn("'options.languageAlternatives' lists a language which is not supported: \"%s\", syntax highlighting will be disabled.", val);
191
193
  }
192
194
 
193
195
  return acc.concat({
194
196
  title,
195
- value: val
197
+ value: val,
198
+ mode
196
199
  });
197
200
  }, []);
198
201
  }, [type]);
199
202
  var handleCodeChange = (0, _react.useCallback)(code => {
203
+ var _type$options3;
204
+
200
205
  var path = _config.PATH_CODE;
201
- var fixedLanguage = (0, _get2.default)(type, 'options.language');
206
+ var fixedLanguage = (_type$options3 = type.options) === null || _type$options3 === void 0 ? void 0 : _type$options3.language;
202
207
  onChange(_patchEvent.PatchEvent.from([(0, _patchEvent.setIfMissing)({
203
208
  _type: type.name,
204
209
  language: fixedLanguage
@@ -226,8 +231,15 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
226
231
  var codePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_CODE, presenceItem.path));
227
232
  var filenamePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_FILENAME, presenceItem.path));
228
233
  var renderEditor = (0, _react.useCallback)(() => {
229
- var fixedLanguage = (0, _get2.default)(type, 'options.language');
230
- var mode = isSupportedLanguage(value && value.language || fixedLanguage) || 'text';
234
+ var _type$options4;
235
+
236
+ var fixedLanguage = (_type$options4 = type.options) === null || _type$options4 === void 0 ? void 0 : _type$options4.language;
237
+ var language = (value === null || value === void 0 ? void 0 : value.language) || fixedLanguage; // the language config from the schema
238
+
239
+ var configured = languages.find(entry => entry.value === language); // is the language officially supported (e.g. we import the mode by default)
240
+
241
+ var supported = language && isSupportedLanguage(language);
242
+ var mode = configured !== null && configured !== void 0 && configured.mode || supported ? language : 'text';
231
243
  return /*#__PURE__*/_react.default.createElement(EditorContainer, {
232
244
  radius: 1,
233
245
  shadow: 1,
@@ -252,7 +264,7 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
252
264
  }));
253
265
  }, [type, value, readOnly, getTheme, handleCodeChange, aceEditorId, handleEditorLoad, handleCodeFocus, onBlur]);
254
266
 
255
- if ((0, _has2.default)(type, 'options.language')) {
267
+ if ((_type$options5 = type.options) !== null && _type$options5 !== void 0 && _type$options5.language) {
256
268
  return /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
257
269
  path: _config.PATH_CODE,
258
270
  focusPath: focusPath,
@@ -288,7 +300,7 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
288
300
  }, languages.map(lang => /*#__PURE__*/_react.default.createElement("option", {
289
301
  key: lang.value,
290
302
  value: lang.value
291
- }, lang.title))))), (0, _get2.default)(type, 'options.withFilename', false) && /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
303
+ }, lang.title))))), ((_type$options6 = type.options) === null || _type$options6 === void 0 ? void 0 : _type$options6.withFilename) && /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
292
304
  path: _config.PATH_FILENAME,
293
305
  focusPath: focusPath,
294
306
  value: value === null || value === void 0 ? void 0 : value.filename,
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = PreviewCode;
7
7
 
8
- var _get2 = _interopRequireDefault(require("lodash/get"));
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
9
 
12
10
  var _reactAce = _interopRequireDefault(require("react-ace"));
@@ -23,34 +21,20 @@ require("./editorSupport");
23
21
 
24
22
  var _templateObject, _templateObject2;
25
23
 
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
27
 
28
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
29
 
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
30
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
33
31
 
34
32
  var PreviewContainer = (0, _styledComponents.default)(_ui.Box)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
35
33
  var PreviewInner = (0, _styledComponents.default)(_ui.Box)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background-color: #272822;\n\n .ace_editor {\n box-sizing: border-box;\n cursor: default;\n pointer-events: none;\n }\n\n .ace_content {\n box-sizing: border-box;\n overflow: hidden;\n }\n"])));
36
34
 
37
- function isSupportedLanguage(mode) {
38
- var alias = _config.LANGUAGE_ALIASES[mode];
39
-
40
- if (alias) {
41
- return alias;
42
- }
43
-
44
- var isSupported = _config.SUPPORTED_LANGUAGES.find(lang => lang.value === mode);
45
-
46
- if (isSupported) {
47
- return mode;
48
- }
49
-
50
- return false;
51
- }
52
-
53
35
  function PreviewCode(props) {
36
+ var _type$options;
37
+
54
38
  var aceEditorRef = (0, _react.useRef)();
55
39
  (0, _react.useEffect)(() => {
56
40
  var _aceEditorRef$current;
@@ -68,8 +52,8 @@ function PreviewCode(props) {
68
52
  }, []);
69
53
  var value = props.value,
70
54
  type = props.type;
71
- var fixedLanguage = (0, _get2.default)(type, 'options.language');
72
- var mode = isSupportedLanguage(value && value.language || fixedLanguage) || 'text';
55
+ var fixedLanguage = type === null || type === void 0 ? void 0 : (_type$options = type.options) === null || _type$options === void 0 ? void 0 : _type$options.language;
56
+ var mode = (value === null || value === void 0 ? void 0 : value.language) || fixedLanguage;
73
57
  return /*#__PURE__*/_react.default.createElement(PreviewContainer, null, /*#__PURE__*/_react.default.createElement(PreviewInner, {
74
58
  padding: 4
75
59
  }, /*#__PURE__*/_react.default.createElement(_reactAce.default, {
@@ -25,7 +25,7 @@ function createHighlightMarkers(rows) {
25
25
  endRow: Number(row) - 1,
26
26
  endCol: +Infinity,
27
27
  className: 'ace_editor_markers_highlight',
28
- type: 'highlight',
28
+ type: 'screenLine',
29
29
  inFront: true
30
30
  }));
31
31
  }
@@ -2,54 +2,54 @@
2
2
 
3
3
  require("./groq");
4
4
 
5
- require("brace/mode/batchfile");
5
+ require("ace-builds/src-noconflict/mode-batchfile");
6
6
 
7
- require("brace/mode/csharp");
7
+ require("ace-builds/src-noconflict/mode-csharp");
8
8
 
9
- require("brace/mode/css");
9
+ require("ace-builds/src-noconflict/mode-css");
10
10
 
11
- require("brace/mode/golang");
11
+ require("ace-builds/src-noconflict/mode-golang");
12
12
 
13
- require("brace/mode/html");
13
+ require("ace-builds/src-noconflict/mode-html");
14
14
 
15
- require("brace/mode/java");
15
+ require("ace-builds/src-noconflict/mode-java");
16
16
 
17
- require("brace/mode/javascript");
17
+ require("ace-builds/src-noconflict/mode-javascript");
18
18
 
19
- require("brace/mode/json");
19
+ require("ace-builds/src-noconflict/mode-json");
20
20
 
21
- require("brace/mode/jsx");
21
+ require("ace-builds/src-noconflict/mode-jsx");
22
22
 
23
- require("brace/mode/markdown");
23
+ require("ace-builds/src-noconflict/mode-markdown");
24
24
 
25
- require("brace/mode/mysql");
25
+ require("ace-builds/src-noconflict/mode-mysql");
26
26
 
27
- require("brace/mode/php");
27
+ require("ace-builds/src-noconflict/mode-php");
28
28
 
29
- require("brace/mode/python");
29
+ require("ace-builds/src-noconflict/mode-python");
30
30
 
31
- require("brace/mode/ruby");
31
+ require("ace-builds/src-noconflict/mode-ruby");
32
32
 
33
- require("brace/mode/sass");
33
+ require("ace-builds/src-noconflict/mode-sass");
34
34
 
35
- require("brace/mode/scss");
35
+ require("ace-builds/src-noconflict/mode-scss");
36
36
 
37
- require("brace/mode/sh");
37
+ require("ace-builds/src-noconflict/mode-sh");
38
38
 
39
- require("brace/mode/text");
39
+ require("ace-builds/src-noconflict/mode-text");
40
40
 
41
- require("brace/mode/tsx");
41
+ require("ace-builds/src-noconflict/mode-tsx");
42
42
 
43
- require("brace/mode/typescript");
43
+ require("ace-builds/src-noconflict/mode-typescript");
44
44
 
45
- require("brace/mode/xml");
45
+ require("ace-builds/src-noconflict/mode-xml");
46
46
 
47
- require("brace/mode/yaml");
47
+ require("ace-builds/src-noconflict/mode-yaml");
48
48
 
49
- require("brace/theme/github");
49
+ require("ace-builds/src-noconflict/theme-github");
50
50
 
51
- require("brace/theme/monokai");
51
+ require("ace-builds/src-noconflict/theme-monokai");
52
52
 
53
- require("brace/theme/terminal");
53
+ require("ace-builds/src-noconflict/theme-terminal");
54
54
 
55
- require("brace/theme/tomorrow");
55
+ require("ace-builds/src-noconflict/theme-tomorrow");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/code-input",
3
- "version": "2.24.1-pte.113+13cc82d2e0",
3
+ "version": "2.24.2",
4
4
  "description": "Ace editor for editing code",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./dist/dts",
@@ -21,14 +21,13 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@reach/auto-id": "^0.13.2",
24
- "@sanity/base": "2.24.1-pte.113+13cc82d2e0",
24
+ "@sanity/base": "2.24.1",
25
25
  "@sanity/icons": "^1.2.1",
26
- "@sanity/types": "2.24.1-pte.113+13cc82d2e0",
27
- "@sanity/ui": "^0.37.1",
28
- "@sanity/util": "2.24.1-pte.113+13cc82d2e0",
29
- "brace": "^0.11.1",
30
- "lodash": "^4.17.15",
31
- "react-ace": "^5.0.1"
26
+ "@sanity/types": "2.24.0",
27
+ "@sanity/ui": "^0.37.2",
28
+ "@sanity/util": "2.24.0",
29
+ "ace-builds": "^1.4.13",
30
+ "react-ace": "^9.5.0"
32
31
  },
33
32
  "devDependencies": {
34
33
  "rimraf": "^2.7.1"
@@ -47,5 +46,5 @@
47
46
  "url": "git+https://github.com/sanity-io/sanity.git",
48
47
  "directory": "packages/@sanity/code-input"
49
48
  },
50
- "gitHead": "13cc82d2e0dfdba52123ce6d8284c50be40961f4"
49
+ "gitHead": "405ea4469df477b7b9612d98ba5e3277be23ee54"
51
50
  }
@@ -1 +0,0 @@
1
- "use strict";