@sanity/code-input 3.0.0-v3-studio.0 → 3.0.0-v3-studio.3
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 +8 -15
- package/lib/cjs/index.js +145 -79
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +145 -76
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +6 -2
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +24 -9
- package/src/CodeInput.tsx +50 -32
- package/src/PreviewCode.tsx +1 -1
- package/src/ace-editor/AceEditor-client.test.tsx +24 -0
- package/src/ace-editor/AceEditor-server.test.tsx +18 -0
- package/src/ace-editor/AceEditorLazy.tsx +19 -0
- package/src/{editorSupport.ts → ace-editor/editorSupport.ts} +3 -0
- package/src/{groq.ts → ace-editor/groq.ts} +0 -0
- package/src/schema.tsx +5 -9
package/README.md
CHANGED
|
@@ -173,22 +173,15 @@ MIT-licensed. See LICENSE.
|
|
|
173
173
|
|
|
174
174
|
## Develop & test
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
177
|
+
with default configuration for build & watch scripts.
|
|
177
178
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
In another shell, `cd` to your test studio and run:
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npx yalc add @sanity/code-input --link && yarn install
|
|
186
|
-
```
|
|
179
|
+
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
180
|
+
on how to run this plugin with hotreload in the studio.
|
|
187
181
|
|
|
188
|
-
|
|
189
|
-
triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
|
|
182
|
+
## Release new version
|
|
190
183
|
|
|
191
|
-
|
|
184
|
+
Run ["CI & Release" workflow](https://github.com/sanity-io/code-input/actions).
|
|
185
|
+
Make sure to select the main branch and check "Release new version".
|
|
192
186
|
|
|
193
|
-
|
|
194
|
-
with default configuration for build & watch scripts.
|
|
187
|
+
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
var $k7rGe$sanity = require("sanity");
|
|
2
|
-
var $k7rGe$reactjsxruntime = require("react/jsx-runtime");
|
|
3
|
-
var $k7rGe$react = require("react");
|
|
4
|
-
var $k7rGe$sanityicons = require("@sanity/icons");
|
|
5
|
-
var $k7rGe$sanityform = require("sanity/form");
|
|
6
|
-
var $k7rGe$sanityui = require("@sanity/ui");
|
|
7
1
|
var $k7rGe$reactace = require("react-ace");
|
|
8
|
-
var $k7rGe$styledcomponents = require("styled-components");
|
|
9
2
|
require("ace-builds/src-noconflict/mode-batchfile");
|
|
10
3
|
require("ace-builds/src-noconflict/mode-csharp");
|
|
11
4
|
require("ace-builds/src-noconflict/mode-css");
|
|
@@ -32,16 +25,68 @@ require("ace-builds/src-noconflict/theme-github");
|
|
|
32
25
|
require("ace-builds/src-noconflict/theme-monokai");
|
|
33
26
|
require("ace-builds/src-noconflict/theme-terminal");
|
|
34
27
|
require("ace-builds/src-noconflict/theme-tomorrow");
|
|
28
|
+
var $k7rGe$sanity = require("sanity");
|
|
29
|
+
var $k7rGe$sanityicons = require("@sanity/icons");
|
|
30
|
+
var $k7rGe$reactjsxruntime = require("react/jsx-runtime");
|
|
31
|
+
var $k7rGe$react = require("react");
|
|
32
|
+
var $k7rGe$sanityform = require("sanity/form");
|
|
33
|
+
var $k7rGe$sanityui = require("@sanity/ui");
|
|
34
|
+
var $k7rGe$styledcomponents = require("styled-components");
|
|
35
35
|
|
|
36
|
+
function $parcel$interopDefault(a) {
|
|
37
|
+
return a && a.__esModule ? a.default : a;
|
|
38
|
+
}
|
|
39
|
+
function $parcel$defineInteropFlag(a) {
|
|
40
|
+
Object.defineProperty(a, '__esModule', {value: true, configurable: true});
|
|
41
|
+
}
|
|
36
42
|
function $parcel$export(e, n, v, s) {
|
|
37
43
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
var $parcel$global =
|
|
46
|
+
typeof globalThis !== 'undefined'
|
|
47
|
+
? globalThis
|
|
48
|
+
: typeof self !== 'undefined'
|
|
49
|
+
? self
|
|
50
|
+
: typeof window !== 'undefined'
|
|
51
|
+
? window
|
|
52
|
+
: typeof global !== 'undefined'
|
|
53
|
+
? global
|
|
54
|
+
: {};
|
|
55
|
+
var $parcel$modules = {};
|
|
56
|
+
var $parcel$inits = {};
|
|
57
|
+
|
|
58
|
+
var parcelRequire = $parcel$global["parcelRequire07ce"];
|
|
59
|
+
if (parcelRequire == null) {
|
|
60
|
+
parcelRequire = function(id) {
|
|
61
|
+
if (id in $parcel$modules) {
|
|
62
|
+
return $parcel$modules[id].exports;
|
|
63
|
+
}
|
|
64
|
+
if (id in $parcel$inits) {
|
|
65
|
+
var init = $parcel$inits[id];
|
|
66
|
+
delete $parcel$inits[id];
|
|
67
|
+
var module = {id: id, exports: {}};
|
|
68
|
+
$parcel$modules[id] = module;
|
|
69
|
+
init.call(module.exports, module, module.exports);
|
|
70
|
+
return module.exports;
|
|
71
|
+
}
|
|
72
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
73
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
74
|
+
throw err;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
parcelRequire.register = function register(id, init) {
|
|
78
|
+
$parcel$inits[id] = init;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
$parcel$global["parcelRequire07ce"] = parcelRequire;
|
|
41
82
|
}
|
|
83
|
+
parcelRequire.register("lMYyH", function(module, exports) {
|
|
42
84
|
|
|
43
|
-
$parcel$
|
|
44
|
-
|
|
85
|
+
$parcel$defineInteropFlag(module.exports);
|
|
86
|
+
|
|
87
|
+
$parcel$export(module.exports, "default", () => $b9b128b60a9c7418$export$2e2bcd8739ae039);
|
|
88
|
+
|
|
89
|
+
parcelRequire("kmEYb");
|
|
45
90
|
|
|
46
91
|
|
|
47
92
|
|
|
@@ -53,30 +98,27 @@ $parcel$export(module.exports, "PreviewCode", () => $15530f24e7c40879$export$2e2
|
|
|
53
98
|
|
|
54
99
|
|
|
55
100
|
|
|
56
|
-
const $470a71f5fffbba1a$export$ac98e174937d3154 = (0, $k7rGe$styledcomponents.css)`
|
|
57
|
-
.ace_editor_markers_highlight {
|
|
58
|
-
position: absolute;
|
|
59
|
-
background-color: ${({ theme: theme })=>theme.sanity.color.solid.primary.enabled.bg};
|
|
60
|
-
opacity: 0.2;
|
|
61
|
-
width: 100% !important;
|
|
62
|
-
border-radius: 0 !important;
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
function $470a71f5fffbba1a$export$2e2bcd8739ae039(rows) {
|
|
66
|
-
return rows.map((row)=>({
|
|
67
|
-
startRow: Number(row) - 1,
|
|
68
|
-
startCol: 0,
|
|
69
|
-
endRow: Number(row) - 1,
|
|
70
|
-
endCol: Infinity,
|
|
71
|
-
className: "ace_editor_markers_highlight",
|
|
72
|
-
type: "screenLine",
|
|
73
|
-
inFront: true
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
101
|
|
|
77
102
|
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
var $b9b128b60a9c7418$export$2e2bcd8739ae039 = (0, ($parcel$interopDefault($k7rGe$reactace)));
|
|
117
|
+
|
|
118
|
+
});
|
|
119
|
+
parcelRequire.register("kmEYb", function(module, exports) {
|
|
78
120
|
// Grammar from https://github.com/sanity-io/vscode-sanity
|
|
79
|
-
const $
|
|
121
|
+
const $8261c675491bb30c$var$rules = {
|
|
80
122
|
start: [
|
|
81
123
|
{
|
|
82
124
|
include: "#query"
|
|
@@ -661,7 +703,7 @@ ace.define("ace/mode/groq_highlight_rules", [
|
|
|
661
703
|
const TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
|
|
662
704
|
const GroqHighlightRules = function() {
|
|
663
705
|
/* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-ignore
|
|
664
|
-
this.$rules = $
|
|
706
|
+
this.$rules = $8261c675491bb30c$var$rules;
|
|
665
707
|
// @ts-ignore
|
|
666
708
|
this.normalizeRules();
|
|
667
709
|
/* eslint-enable @typescript-eslint/ban-ts-comment */ };
|
|
@@ -702,9 +744,12 @@ ace.define("ace/mode/groq", [
|
|
|
702
744
|
exports.Mode = Mode;
|
|
703
745
|
});
|
|
704
746
|
|
|
747
|
+
});
|
|
705
748
|
|
|
706
749
|
|
|
707
750
|
|
|
751
|
+
$parcel$export(module.exports, "codeInput", () => $244e63ca53592e4d$export$d18430c17c97a000);
|
|
752
|
+
$parcel$export(module.exports, "PreviewCode", () => $15530f24e7c40879$export$2e2bcd8739ae039);
|
|
708
753
|
|
|
709
754
|
|
|
710
755
|
|
|
@@ -714,21 +759,26 @@ ace.define("ace/mode/groq", [
|
|
|
714
759
|
|
|
715
760
|
|
|
716
761
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
762
|
+
const $470a71f5fffbba1a$export$ac98e174937d3154 = (0, $k7rGe$styledcomponents.css)`
|
|
763
|
+
.ace_editor_markers_highlight {
|
|
764
|
+
position: absolute;
|
|
765
|
+
background-color: ${({ theme: theme })=>theme.sanity.color.solid.primary.enabled.bg};
|
|
766
|
+
opacity: 0.2;
|
|
767
|
+
width: 100% !important;
|
|
768
|
+
border-radius: 0 !important;
|
|
769
|
+
}
|
|
770
|
+
`;
|
|
771
|
+
function $470a71f5fffbba1a$export$2e2bcd8739ae039(rows) {
|
|
772
|
+
return rows.map((row)=>({
|
|
773
|
+
startRow: Number(row) - 1,
|
|
774
|
+
startCol: 0,
|
|
775
|
+
endRow: Number(row) - 1,
|
|
776
|
+
endCol: Infinity,
|
|
777
|
+
className: "ace_editor_markers_highlight",
|
|
778
|
+
type: "screenLine",
|
|
779
|
+
inFront: true
|
|
780
|
+
}));
|
|
781
|
+
}
|
|
732
782
|
|
|
733
783
|
|
|
734
784
|
const $8fdae771dbccc774$export$7c77c3a9bb93870d = [
|
|
@@ -855,6 +905,17 @@ const $8fdae771dbccc774$export$4f74600301fa25db = [
|
|
|
855
905
|
|
|
856
906
|
|
|
857
907
|
|
|
908
|
+
|
|
909
|
+
const $8b53187504760ea8$export$476686f2cdb5577f = /*#__PURE__*/ (0, ($parcel$interopDefault($k7rGe$react))).lazy(()=>Promise.resolve((parcelRequire("lMYyH"))));
|
|
910
|
+
function $8b53187504760ea8$export$99999bc9085b44fd() {
|
|
911
|
+
const [mounted, setMounted] = (0, $k7rGe$react.useState)(false);
|
|
912
|
+
(0, $k7rGe$react.useEffect)(()=>{
|
|
913
|
+
setMounted(true);
|
|
914
|
+
}, []);
|
|
915
|
+
return mounted ? $8b53187504760ea8$export$476686f2cdb5577f : null;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
|
|
858
919
|
const $293e4fb68be52bc5$var$EditorContainer = (0, ($parcel$interopDefault($k7rGe$styledcomponents)))((0, $k7rGe$sanityui.Card))`
|
|
859
920
|
position: relative;
|
|
860
921
|
box-sizing: border-box;
|
|
@@ -1021,31 +1082,42 @@ function $293e4fb68be52bc5$export$20d4ca75cb144ab0(props) {
|
|
|
1021
1082
|
}, [
|
|
1022
1083
|
languages
|
|
1023
1084
|
]);
|
|
1085
|
+
const AceEditor = (0, $8b53187504760ea8$export$99999bc9085b44fd)();
|
|
1024
1086
|
const renderCodeInput = (0, $k7rGe$react.useCallback)((inputProps)=>{
|
|
1025
1087
|
return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)($293e4fb68be52bc5$var$EditorContainer, {
|
|
1026
1088
|
radius: 1,
|
|
1027
1089
|
shadow: 1,
|
|
1028
1090
|
readOnly: readOnly,
|
|
1029
|
-
children: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1091
|
+
children: AceEditor && /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$react.Suspense), {
|
|
1092
|
+
fallback: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)("div", {
|
|
1093
|
+
children: "Loading code editor..."
|
|
1094
|
+
}),
|
|
1095
|
+
children: [
|
|
1096
|
+
"(",
|
|
1097
|
+
/*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)(AceEditor, {
|
|
1098
|
+
ref: aceEditorRef,
|
|
1099
|
+
mode: mode1,
|
|
1100
|
+
theme: theme,
|
|
1101
|
+
width: "100%",
|
|
1102
|
+
onChange: handleCodeChange,
|
|
1103
|
+
name: inputProps.id,
|
|
1104
|
+
value: inputProps.value,
|
|
1105
|
+
markers: value && value.highlightedLines ? (0, $470a71f5fffbba1a$export$2e2bcd8739ae039)(value.highlightedLines) : undefined,
|
|
1106
|
+
onLoad: handleEditorLoad,
|
|
1107
|
+
readOnly: readOnly,
|
|
1108
|
+
tabSize: 2,
|
|
1109
|
+
wrapEnabled: true,
|
|
1110
|
+
setOptions: (0, $8fdae771dbccc774$export$1d910bb34606e145),
|
|
1111
|
+
editorProps: (0, $8fdae771dbccc774$export$24aa1be5d8c3cd08),
|
|
1112
|
+
onFocus: handleCodeFocus,
|
|
1113
|
+
onBlur: onBlur
|
|
1114
|
+
}),
|
|
1115
|
+
")"
|
|
1116
|
+
]
|
|
1046
1117
|
})
|
|
1047
1118
|
});
|
|
1048
1119
|
}, [
|
|
1120
|
+
AceEditor,
|
|
1049
1121
|
theme,
|
|
1050
1122
|
handleCodeChange,
|
|
1051
1123
|
handleCodeFocus,
|
|
@@ -1053,7 +1125,7 @@ function $293e4fb68be52bc5$export$20d4ca75cb144ab0(props) {
|
|
|
1053
1125
|
mode1,
|
|
1054
1126
|
onBlur,
|
|
1055
1127
|
readOnly,
|
|
1056
|
-
value
|
|
1128
|
+
value,
|
|
1057
1129
|
]);
|
|
1058
1130
|
return /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsxs)((0, $k7rGe$sanityui.Stack), {
|
|
1059
1131
|
space: 4,
|
|
@@ -1091,7 +1163,7 @@ function $293e4fb68be52bc5$export$20d4ca75cb144ab0(props) {
|
|
|
1091
1163
|
|
|
1092
1164
|
|
|
1093
1165
|
|
|
1094
|
-
|
|
1166
|
+
parcelRequire("lMYyH");
|
|
1095
1167
|
const $15530f24e7c40879$var$PreviewContainer = (0, ($parcel$interopDefault($k7rGe$styledcomponents)))((0, $k7rGe$sanityui.Box))`
|
|
1096
1168
|
position: relative;
|
|
1097
1169
|
`;
|
|
@@ -1276,17 +1348,14 @@ function $c676b2e7a96a4665$export$a854ab43349813f2(language) {
|
|
|
1276
1348
|
}
|
|
1277
1349
|
|
|
1278
1350
|
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
...props
|
|
1282
|
-
});
|
|
1283
|
-
};
|
|
1284
|
-
var $fcd6ef024a3d4c8a$export$2e2bcd8739ae039 = {
|
|
1351
|
+
|
|
1352
|
+
var $fcd6ef024a3d4c8a$export$2e2bcd8739ae039 = (0, $k7rGe$sanity.defineType)({
|
|
1285
1353
|
name: "code",
|
|
1286
1354
|
type: "object",
|
|
1287
1355
|
title: "Code",
|
|
1288
1356
|
components: {
|
|
1289
|
-
input: (0, $293e4fb68be52bc5$export$20d4ca75cb144ab0)
|
|
1357
|
+
input: (0, $293e4fb68be52bc5$export$20d4ca75cb144ab0),
|
|
1358
|
+
preview: (0, $15530f24e7c40879$export$2e2bcd8739ae039)
|
|
1290
1359
|
},
|
|
1291
1360
|
icon: (0, $k7rGe$sanityicons.CodeBlockIcon),
|
|
1292
1361
|
fields: [
|
|
@@ -1327,14 +1396,11 @@ var $fcd6ef024a3d4c8a$export$2e2bcd8739ae039 = {
|
|
|
1327
1396
|
prepare: (value)=>{
|
|
1328
1397
|
return {
|
|
1329
1398
|
title: value.filename || (value.language || "unknown").toUpperCase(),
|
|
1330
|
-
media: (0, $c676b2e7a96a4665$export$a854ab43349813f2)(value?.language)
|
|
1331
|
-
extendedPreview: /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)($fcd6ef024a3d4c8a$var$Preview, {
|
|
1332
|
-
value: value
|
|
1333
|
-
})
|
|
1399
|
+
media: (0, $c676b2e7a96a4665$export$a854ab43349813f2)(value?.language)
|
|
1334
1400
|
};
|
|
1335
1401
|
}
|
|
1336
1402
|
}
|
|
1337
|
-
};
|
|
1403
|
+
});
|
|
1338
1404
|
|
|
1339
1405
|
|
|
1340
1406
|
|