@sanity/code-input 2.30.0 → 2.30.2-shopify.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/dist/dts/CodeInput.d.ts +1 -2
- package/dist/dts/CodeInput.d.ts.map +1 -1
- package/dist/dts/schema.d.ts +1 -1
- package/lib/CodeInput.js +63 -71
- package/package.json +6 -5
package/dist/dts/CodeInput.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormFieldPresence } from '@sanity/base/presence';
|
|
3
|
-
import { Path
|
|
3
|
+
import { Path } from '@sanity/types';
|
|
4
4
|
import { CodeInputType, CodeInputValue } from './types';
|
|
5
5
|
import './editorSupport';
|
|
6
6
|
export interface CodeInputProps {
|
|
7
7
|
compareValue?: CodeInputValue;
|
|
8
8
|
focusPath: Path;
|
|
9
9
|
level: number;
|
|
10
|
-
markers: Marker[];
|
|
11
10
|
onBlur: () => void;
|
|
12
11
|
onChange: (...args: any[]) => void;
|
|
13
12
|
onFocus: (path: Path) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../src/CodeInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../src/CodeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAChF,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAA;AASlC,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,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;GAyWnE,CAAA;AAID,eAAe,SAAS,CAAA"}
|
package/dist/dts/schema.d.ts
CHANGED
|
@@ -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" | "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" | "
|
|
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" | "local" | "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" | "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;
|
package/lib/CodeInput.js
CHANGED
|
@@ -15,7 +15,7 @@ var PathUtils = _interopRequireWildcard(require("@sanity/util/paths"));
|
|
|
15
15
|
|
|
16
16
|
var _changeIndicators = require("@sanity/base/change-indicators");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _PatchEvent = _interopRequireWildcard(require("@sanity/form-builder/PatchEvent"));
|
|
19
19
|
|
|
20
20
|
var _reactAce = _interopRequireDefault(require("react-ace"));
|
|
21
21
|
|
|
@@ -74,7 +74,7 @@ function isSupportedLanguage(mode) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
77
|
-
var _props$value, _type$options5, _type$options6;
|
|
77
|
+
var _props$value, _type$options5, _type$options6, _type$options7;
|
|
78
78
|
|
|
79
79
|
var aceEditorRef = (0, _react.useRef)();
|
|
80
80
|
var aceEditorId = (0, _autoId.useId)();
|
|
@@ -107,9 +107,9 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
107
107
|
var handleFilenameChange = (0, _react.useCallback)(event => {
|
|
108
108
|
var val = event.target.value;
|
|
109
109
|
var path = _config.PATH_FILENAME;
|
|
110
|
-
onChange(
|
|
110
|
+
onChange(_PatchEvent.default.from([(0, _PatchEvent.setIfMissing)({
|
|
111
111
|
_type: type.name
|
|
112
|
-
}), val ? (0,
|
|
112
|
+
}), val ? (0, _PatchEvent.set)(val, path) : (0, _PatchEvent.unset)(path)]));
|
|
113
113
|
}, [onChange, type.name]);
|
|
114
114
|
var getTheme = (0, _react.useCallback)(() => {
|
|
115
115
|
var _type$options;
|
|
@@ -134,7 +134,7 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
134
134
|
currentHighlightedLines.sort();
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
onChange(
|
|
137
|
+
onChange(_PatchEvent.default.from((0, _PatchEvent.set)(currentHighlightedLines.map(line => // ace starts at line (row) 0, but we store it starting at line 1
|
|
138
138
|
line + 1), ['highlightedLines'])));
|
|
139
139
|
}, [aceEditorRef, onChange]);
|
|
140
140
|
var handleGutterMouseDown = (0, _react.useCallback)(event => {
|
|
@@ -204,17 +204,17 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
204
204
|
|
|
205
205
|
var path = _config.PATH_CODE;
|
|
206
206
|
var fixedLanguage = (_type$options3 = type.options) === null || _type$options3 === void 0 ? void 0 : _type$options3.language;
|
|
207
|
-
onChange(
|
|
207
|
+
onChange(_PatchEvent.default.from([(0, _PatchEvent.setIfMissing)({
|
|
208
208
|
_type: type.name,
|
|
209
209
|
language: fixedLanguage
|
|
210
|
-
}), code ? (0,
|
|
210
|
+
}), code ? (0, _PatchEvent.set)(code, path) : (0, _PatchEvent.unset)(path)]));
|
|
211
211
|
}, [onChange, type]);
|
|
212
212
|
var handleLanguageChange = (0, _react.useCallback)(event => {
|
|
213
213
|
var val = event.currentTarget.value;
|
|
214
214
|
var path = _config.PATH_LANGUAGE;
|
|
215
|
-
onChange(
|
|
215
|
+
onChange(_PatchEvent.default.from([(0, _PatchEvent.setIfMissing)({
|
|
216
216
|
_type: type.name
|
|
217
|
-
}), val ? (0,
|
|
217
|
+
}), val ? (0, _PatchEvent.set)(val, path) : (0, _PatchEvent.unset)(path)]));
|
|
218
218
|
}, [onChange, type.name]);
|
|
219
219
|
var languages = getLanguageAlternatives().slice();
|
|
220
220
|
var selectedLanguage = props !== null && props !== void 0 && (_props$value = props.value) !== null && _props$value !== void 0 && _props$value.language ? languages.find(item => {
|
|
@@ -230,6 +230,46 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
230
230
|
var languagePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_LANGUAGE, presenceItem.path));
|
|
231
231
|
var codePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_CODE, presenceItem.path));
|
|
232
232
|
var filenamePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_FILENAME, presenceItem.path));
|
|
233
|
+
var renderLanguageAlternatives = (0, _react.useCallback)(() => {
|
|
234
|
+
return /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
|
|
235
|
+
path: _config.PATH_LANGUAGE,
|
|
236
|
+
focusPath: focusPath,
|
|
237
|
+
value: selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value,
|
|
238
|
+
compareValue: languageCompareValue
|
|
239
|
+
}, /*#__PURE__*/_react.default.createElement(_components.FormField, {
|
|
240
|
+
level: level + 1,
|
|
241
|
+
label: (languageField === null || languageField === void 0 ? void 0 : languageField.title) || 'Language',
|
|
242
|
+
__unstable_presence: languagePresence
|
|
243
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Select, {
|
|
244
|
+
onChange: handleLanguageChange,
|
|
245
|
+
readOnly: readOnly,
|
|
246
|
+
value: (selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value) || '',
|
|
247
|
+
onFocus: handleLanguageFocus,
|
|
248
|
+
onBlur: onBlur
|
|
249
|
+
}, languages.map(lang => /*#__PURE__*/_react.default.createElement("option", {
|
|
250
|
+
key: lang.value,
|
|
251
|
+
value: lang.value
|
|
252
|
+
}, lang.title)))));
|
|
253
|
+
}, [focusPath, handleLanguageChange, handleLanguageFocus, languageCompareValue, languageField === null || languageField === void 0 ? void 0 : languageField.title, languagePresence, languages, level, onBlur, readOnly, selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value]);
|
|
254
|
+
var renderFilenameInput = (0, _react.useCallback)(() => {
|
|
255
|
+
return /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
|
|
256
|
+
path: _config.PATH_FILENAME,
|
|
257
|
+
focusPath: focusPath,
|
|
258
|
+
value: value === null || value === void 0 ? void 0 : value.filename,
|
|
259
|
+
compareValue: filenameCompareValue
|
|
260
|
+
}, /*#__PURE__*/_react.default.createElement(_components.FormField, {
|
|
261
|
+
label: (filenameField === null || filenameField === void 0 ? void 0 : filenameField.title) || 'Filename',
|
|
262
|
+
level: level + 1,
|
|
263
|
+
__unstable_presence: filenamePresence
|
|
264
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.TextInput, {
|
|
265
|
+
name: "filename",
|
|
266
|
+
value: (value === null || value === void 0 ? void 0 : value.filename) || '',
|
|
267
|
+
placeholder: filenameField === null || filenameField === void 0 ? void 0 : filenameField.placeholder,
|
|
268
|
+
onChange: handleFilenameChange,
|
|
269
|
+
onFocus: handleFilenameFocus,
|
|
270
|
+
onBlur: onBlur
|
|
271
|
+
})));
|
|
272
|
+
}, [filenameCompareValue, filenameField === null || filenameField === void 0 ? void 0 : filenameField.placeholder, filenameField === null || filenameField === void 0 ? void 0 : filenameField.title, filenamePresence, focusPath, handleFilenameChange, handleFilenameFocus, level, onBlur, value === null || value === void 0 ? void 0 : value.filename]);
|
|
233
273
|
var renderEditor = (0, _react.useCallback)(() => {
|
|
234
274
|
var _type$options4;
|
|
235
275
|
|
|
@@ -239,8 +279,17 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
239
279
|
var configured = languages.find(entry => entry.value === language); // is the language officially supported (e.g. we import the mode by default)
|
|
240
280
|
|
|
241
281
|
var supported = language && isSupportedLanguage(language);
|
|
242
|
-
var mode = (configured === null || configured === void 0 ? void 0 : configured.mode) || (supported ?
|
|
243
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
282
|
+
var mode = (configured === null || configured === void 0 ? void 0 : configured.mode) || (supported ? supported : 'text');
|
|
283
|
+
return /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
|
|
284
|
+
path: _config.PATH_CODE,
|
|
285
|
+
focusPath: focusPath,
|
|
286
|
+
value: value === null || value === void 0 ? void 0 : value.code,
|
|
287
|
+
compareValue: codeCompareValue
|
|
288
|
+
}, /*#__PURE__*/_react.default.createElement(_components.FormField, {
|
|
289
|
+
label: "Code",
|
|
290
|
+
level: level + 1,
|
|
291
|
+
__unstable_presence: codePresence
|
|
292
|
+
}, /*#__PURE__*/_react.default.createElement(EditorContainer, {
|
|
244
293
|
radius: 1,
|
|
245
294
|
shadow: 1,
|
|
246
295
|
readOnly: readOnly
|
|
@@ -261,71 +310,14 @@ var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
261
310
|
editorProps: _config.ACE_EDITOR_PROPS,
|
|
262
311
|
onFocus: handleCodeFocus,
|
|
263
312
|
onBlur: onBlur
|
|
264
|
-
}));
|
|
265
|
-
}, [type, value, readOnly, getTheme, handleCodeChange, aceEditorId, handleEditorLoad, handleCodeFocus, onBlur]);
|
|
266
|
-
|
|
267
|
-
if ((_type$options5 = type.options) !== null && _type$options5 !== void 0 && _type$options5.language) {
|
|
268
|
-
return /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
|
|
269
|
-
path: _config.PATH_CODE,
|
|
270
|
-
focusPath: focusPath,
|
|
271
|
-
value: value === null || value === void 0 ? void 0 : value.code,
|
|
272
|
-
compareValue: codeCompareValue
|
|
273
|
-
}, /*#__PURE__*/_react.default.createElement(_components.FormFieldSet, {
|
|
274
|
-
title: type.title,
|
|
275
|
-
description: type.description,
|
|
276
|
-
level: level
|
|
277
|
-
}, renderEditor()));
|
|
278
|
-
}
|
|
279
|
-
|
|
313
|
+
}))));
|
|
314
|
+
}, [(_type$options5 = type.options) === null || _type$options5 === void 0 ? void 0 : _type$options5.language, value, languages, focusPath, codeCompareValue, level, codePresence, readOnly, getTheme, handleCodeChange, aceEditorId, handleEditorLoad, handleCodeFocus, onBlur]);
|
|
280
315
|
return /*#__PURE__*/_react.default.createElement(_components.FormFieldSet, {
|
|
281
316
|
title: type.title,
|
|
282
317
|
description: type.description,
|
|
283
318
|
level: level,
|
|
284
319
|
__unstable_changeIndicator: false
|
|
285
|
-
},
|
|
286
|
-
path: _config.PATH_LANGUAGE,
|
|
287
|
-
focusPath: focusPath,
|
|
288
|
-
value: selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value,
|
|
289
|
-
compareValue: languageCompareValue
|
|
290
|
-
}, /*#__PURE__*/_react.default.createElement(_components.FormField, {
|
|
291
|
-
level: level + 1,
|
|
292
|
-
label: (languageField === null || languageField === void 0 ? void 0 : languageField.title) || 'Language',
|
|
293
|
-
__unstable_presence: languagePresence
|
|
294
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Select, {
|
|
295
|
-
onChange: handleLanguageChange,
|
|
296
|
-
readOnly: readOnly,
|
|
297
|
-
value: (selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value) || '',
|
|
298
|
-
onFocus: handleLanguageFocus,
|
|
299
|
-
onBlur: onBlur
|
|
300
|
-
}, languages.map(lang => /*#__PURE__*/_react.default.createElement("option", {
|
|
301
|
-
key: lang.value,
|
|
302
|
-
value: lang.value
|
|
303
|
-
}, lang.title))))), ((_type$options6 = type.options) === null || _type$options6 === void 0 ? void 0 : _type$options6.withFilename) && /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
|
|
304
|
-
path: _config.PATH_FILENAME,
|
|
305
|
-
focusPath: focusPath,
|
|
306
|
-
value: value === null || value === void 0 ? void 0 : value.filename,
|
|
307
|
-
compareValue: filenameCompareValue
|
|
308
|
-
}, /*#__PURE__*/_react.default.createElement(_components.FormField, {
|
|
309
|
-
label: (filenameField === null || filenameField === void 0 ? void 0 : filenameField.title) || 'Filename',
|
|
310
|
-
level: level + 1,
|
|
311
|
-
__unstable_presence: filenamePresence
|
|
312
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.TextInput, {
|
|
313
|
-
name: "filename",
|
|
314
|
-
value: (value === null || value === void 0 ? void 0 : value.filename) || '',
|
|
315
|
-
placeholder: filenameField === null || filenameField === void 0 ? void 0 : filenameField.placeholder,
|
|
316
|
-
onChange: handleFilenameChange,
|
|
317
|
-
onFocus: handleFilenameFocus,
|
|
318
|
-
onBlur: onBlur
|
|
319
|
-
}))), /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
|
|
320
|
-
path: _config.PATH_CODE,
|
|
321
|
-
focusPath: focusPath,
|
|
322
|
-
value: value === null || value === void 0 ? void 0 : value.code,
|
|
323
|
-
compareValue: codeCompareValue
|
|
324
|
-
}, /*#__PURE__*/_react.default.createElement(_components.FormField, {
|
|
325
|
-
label: "Code",
|
|
326
|
-
level: level + 1,
|
|
327
|
-
__unstable_presence: codePresence
|
|
328
|
-
}, renderEditor())));
|
|
320
|
+
}, !((_type$options6 = type.options) !== null && _type$options6 !== void 0 && _type$options6.language) && renderLanguageAlternatives(), (type === null || type === void 0 ? void 0 : (_type$options7 = type.options) === null || _type$options7 === void 0 ? void 0 : _type$options7.withFilename) && renderFilenameInput(), renderEditor());
|
|
329
321
|
});
|
|
330
322
|
|
|
331
323
|
CodeInput.displayName = 'CodeInput';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/code-input",
|
|
3
|
-
"version": "2.30.0",
|
|
3
|
+
"version": "2.30.2-shopify.0+4e3235208",
|
|
4
4
|
"description": "Ace editor for editing code",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./dist/dts",
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@reach/auto-id": "^0.13.2",
|
|
24
|
-
"@sanity/base": "2.30.0",
|
|
24
|
+
"@sanity/base": "2.30.2-shopify.0+4e3235208",
|
|
25
|
+
"@sanity/form-builder": "2.30.2-shopify.0+4e3235208",
|
|
25
26
|
"@sanity/icons": "^1.2.6",
|
|
26
|
-
"@sanity/types": "2.
|
|
27
|
+
"@sanity/types": "2.30.2-shopify.0+4e3235208",
|
|
27
28
|
"@sanity/ui": "^0.37.9",
|
|
28
|
-
"@sanity/util": "2.
|
|
29
|
+
"@sanity/util": "2.30.2-shopify.0+4e3235208",
|
|
29
30
|
"ace-builds": "^1.4.13",
|
|
30
31
|
"react-ace": "^9.5.0"
|
|
31
32
|
},
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"url": "git+https://github.com/sanity-io/sanity.git",
|
|
47
48
|
"directory": "packages/@sanity/code-input"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4e3235208960dc8d16b04a649ddecdc4e7573837"
|
|
50
51
|
}
|