@sanity/code-input 2.29.5-get-started-template.14 → 2.29.5-purple-unicorn.806
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/CodeInput.js +7 -0
- package/deprecatedSchema.js +7 -0
- package/lib/CodeInput.cjs +39 -0
- package/lib/CodeInput.cjs.map +1 -0
- package/lib/CodeInput.js +33 -333
- package/lib/CodeInput.js.map +1 -0
- package/lib/_CodeInput-d6f5810b.js +846 -0
- package/lib/_CodeInput-d6f5810b.js.map +1 -0
- package/lib/_CodeInput-f70e9606.cjs +857 -0
- package/lib/_CodeInput-f70e9606.cjs.map +1 -0
- package/lib/_reExport.js +19 -0
- package/lib/deprecatedSchema.cjs +23 -0
- package/lib/deprecatedSchema.cjs.map +1 -0
- package/lib/deprecatedSchema.js +19 -24
- package/lib/deprecatedSchema.js.map +1 -0
- package/lib/dts/src/CodeInput.d.ts +17 -0
- package/lib/dts/src/CodeInput.d.ts.map +1 -0
- package/lib/dts/src/CodeInput.js +155 -0
- package/lib/dts/src/CodeInput.js.map +1 -0
- package/{dist/dts → lib/dts/src}/PreviewCode.d.ts +8 -8
- package/lib/dts/src/PreviewCode.d.ts.map +1 -0
- package/lib/dts/src/PreviewCode.js +50 -0
- package/lib/dts/src/PreviewCode.js.map +1 -0
- package/lib/dts/src/__workshop__/dev.d.ts +3 -0
- package/lib/dts/src/__workshop__/dev.d.ts.map +1 -0
- package/lib/dts/src/__workshop__/dev.js +18 -0
- package/lib/dts/src/__workshop__/dev.js.map +1 -0
- package/lib/dts/src/__workshop__/index.d.ts +3 -0
- package/lib/dts/src/__workshop__/index.d.ts.map +1 -0
- package/lib/dts/src/__workshop__/index.js +10 -0
- package/lib/dts/src/__workshop__/index.js.map +1 -0
- package/{dist/dts → lib/dts/src}/config.d.ts +15 -15
- package/lib/dts/src/config.d.ts.map +1 -0
- package/lib/dts/src/config.js +38 -0
- package/lib/dts/src/config.js.map +1 -0
- package/{dist/dts → lib/dts/src}/createHighlightMarkers.d.ts +3 -3
- package/lib/dts/src/createHighlightMarkers.d.ts.map +1 -0
- package/lib/dts/src/createHighlightMarkers.js +22 -0
- package/lib/dts/src/createHighlightMarkers.js.map +1 -0
- package/{dist/dts → lib/dts/src}/deprecatedSchema.d.ts +11 -11
- package/lib/dts/src/deprecatedSchema.d.ts.map +1 -0
- package/lib/dts/src/deprecatedSchema.js +19 -0
- package/lib/dts/src/deprecatedSchema.js.map +1 -0
- package/{dist/dts → lib/dts/src}/editorSupport.d.ts +27 -27
- package/lib/dts/src/editorSupport.d.ts.map +1 -0
- package/lib/dts/src/editorSupport.js +32 -0
- package/lib/dts/src/editorSupport.js.map +1 -0
- package/{dist/dts → lib/dts/src}/getMedia.d.ts +2 -2
- package/lib/dts/src/getMedia.d.ts.map +1 -0
- package/lib/dts/src/getMedia.js +35 -0
- package/lib/dts/src/getMedia.js.map +1 -0
- package/lib/dts/src/groq.d.ts +2 -0
- package/lib/dts/src/groq.d.ts.map +1 -0
- package/lib/dts/src/groq.js +612 -0
- package/lib/dts/src/groq.js.map +1 -0
- package/lib/dts/src/index.d.ts +4 -0
- package/lib/dts/src/index.d.ts.map +1 -0
- package/lib/dts/src/index.js +7 -0
- package/lib/dts/src/index.js.map +1 -0
- package/lib/dts/src/schema.d.ts +47 -0
- package/lib/dts/src/schema.d.ts.map +1 -0
- package/lib/dts/src/schema.js +59 -0
- package/lib/dts/src/schema.js.map +1 -0
- package/{dist/dts → lib/dts/src}/types.d.ts +28 -28
- package/lib/dts/src/types.d.ts.map +1 -0
- package/lib/dts/src/types.js +2 -0
- package/lib/dts/src/types.js.map +1 -0
- package/lib/dts/tsconfig.tsbuildinfo +1 -0
- package/lib/index.cjs +45 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.js +43 -0
- package/lib/index.js.map +1 -0
- package/lib/schema.cjs +174 -0
- package/lib/schema.cjs.map +1 -0
- package/lib/schema.js +159 -62
- package/lib/schema.js.map +1 -0
- package/package.json +63 -12
- package/schema.js +7 -0
- package/src/CodeInput.tsx +327 -0
- package/src/PreviewCode.tsx +89 -0
- package/src/__workshop__/dev.tsx +35 -0
- package/src/__workshop__/index.ts +10 -0
- package/src/config.ts +45 -0
- package/src/createHighlightMarkers.ts +24 -0
- package/src/deprecatedSchema.ts +19 -0
- package/src/editorSupport.ts +33 -0
- package/src/getMedia.tsx +95 -0
- package/src/groq.ts +630 -0
- package/src/index.ts +11 -0
- package/src/schema.tsx +69 -0
- package/src/types.ts +26 -0
- package/dist/dts/CodeInput.d.ts +0 -23
- package/dist/dts/CodeInput.d.ts.map +0 -1
- package/dist/dts/PreviewCode.d.ts.map +0 -1
- package/dist/dts/config.d.ts.map +0 -1
- package/dist/dts/createHighlightMarkers.d.ts.map +0 -1
- package/dist/dts/deprecatedSchema.d.ts.map +0 -1
- package/dist/dts/editorSupport.d.ts.map +0 -1
- package/dist/dts/getMedia.d.ts.map +0 -1
- package/dist/dts/groq.d.ts +0 -376
- package/dist/dts/groq.d.ts.map +0 -1
- package/dist/dts/schema.d.ts +0 -44
- package/dist/dts/schema.d.ts.map +0 -1
- package/dist/dts/types.d.ts.map +0 -1
- package/lib/@types/css.d.js +0 -1
- package/lib/PreviewCode.js +0 -79
- package/lib/config.js +0 -103
- package/lib/createHighlightMarkers.js +0 -31
- package/lib/editorSupport.js +0 -55
- package/lib/getMedia.js +0 -110
- package/lib/groq.js +0 -414
- package/lib/types.js +0 -5
- package/tsconfig.json +0 -26
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_CodeInput-f70e9606.cjs","sources":["../src/createHighlightMarkers.ts","../src/groq.ts","../src/config.ts","../src/CodeInput.tsx"],"sourcesContent":["import {IMarker} from 'react-ace'\nimport {css} from 'styled-components'\n\nexport const highlightMarkersCSS = css`\n .ace_editor_markers_highlight {\n position: absolute;\n background-color: ${({theme}) => theme.sanity.color.solid.primary.enabled.bg};\n opacity: 0.2;\n width: 100% !important;\n border-radius: 0 !important;\n }\n`\n\nexport default function createHighlightMarkers(rows: number[]): IMarker[] {\n return rows.map((row) => ({\n startRow: Number(row) - 1,\n startCol: 0,\n endRow: Number(row) - 1,\n endCol: +Infinity,\n className: 'ace_editor_markers_highlight',\n type: 'screenLine',\n inFront: true,\n }))\n}\n","/* eslint-disable no-undef */\n\nexport {}\n\n// Grammar from https://github.com/sanity-io/vscode-sanity\nconst rules = {\n start: [\n {\n include: '#query',\n },\n {\n include: '#value',\n },\n {\n include: '#pair',\n },\n ],\n '#query': [\n {\n include: '#nullary-access-operator',\n },\n {\n include: '#arraylike',\n },\n {\n include: '#pipe',\n },\n {\n include: '#sort-order',\n },\n {\n include: '#filter',\n },\n ],\n '#variable': [\n {\n token: 'variable.other.groq',\n regex: /\\$[_A-Za-z][_0-9A-Za-z]*/,\n },\n ],\n '#keyword': [\n {\n token: 'keyword.other.groq',\n regex: /\\b(?:asc|desc|in|match)\\b/,\n },\n ],\n '#comparison': [\n {\n token: 'keyword.operator.comparison.groq',\n // eslint-disable-next-line no-div-regex\n regex: /==|!=|>=|<=|<!=>|<|>/,\n },\n ],\n '#operator': [\n {\n token: 'keyword.operator.arithmetic.groq',\n regex: /\\+|-|\\*{1,2}|\\/|%/,\n },\n ],\n '#pipe': [\n {\n token: 'keyword.operator.pipe.groq',\n regex: /\\|/,\n },\n ],\n '#logical': [\n {\n token: 'keyword.operator.logical.groq',\n regex: /!|&&|\\|\\|/,\n },\n ],\n '#reference': [\n {\n token: 'keyword.operator.reference.groq',\n regex: /->/,\n },\n ],\n '#pair': [\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#filter',\n },\n {\n token: 'keyword.operator.pair.groq',\n regex: /[=]>/,\n },\n ],\n '#arraylike': [\n {\n token: 'punctuation.definition.bracket.begin.groq',\n regex: /\\[/,\n push: [\n {\n token: ['text', 'keyword.operator.descendant.groq'],\n regex: /(\\])((?:\\s*\\.)?)/,\n next: 'pop',\n },\n {\n include: '#range',\n },\n {\n include: '#filter',\n },\n {\n include: '#array-values',\n },\n ],\n },\n ],\n '#array': [\n {\n token: 'punctuation.definition.bracket.begin.groq',\n regex: /\\[/,\n push: [\n {\n token: 'punctuation.definition.bracket.end.groq',\n regex: /\\]/,\n next: 'pop',\n },\n {\n include: '#array-values',\n },\n {\n defaultToken: 'meta.structure.array.groq',\n },\n ],\n },\n ],\n '#range': [\n {\n token: [\n 'meta.structure.range.groq',\n 'constant.numeric.groq',\n 'meta.structure.range.groq',\n 'keyword.operator.range.groq',\n 'meta.structure.range.groq',\n 'constant.numeric.groq',\n 'meta.structure.range.groq',\n ],\n regex: /(\\s*)(\\d+)(\\s*)(\\.{2,3})(\\s*)(\\d+)(\\s*)/,\n },\n ],\n '#spread': [\n {\n token: 'punctuation.definition.spread.begin.groq',\n regex: /\\.\\.\\./,\n push: [\n {\n include: '#array',\n },\n {\n include: '#function-call',\n },\n {\n include: '#projection',\n },\n {\n token: 'punctuation.definition.spread.end.groq',\n regex: /(?=.)/,\n next: 'pop',\n },\n {\n defaultToken: 'meta.structure.spread.groq',\n },\n ],\n },\n ],\n '#array-values': [\n {\n include: '#value',\n },\n {\n include: '#spread',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n token: 'invalid.illegal.expected-array-separator.groq',\n regex: /[^\\s\\]]/,\n },\n ],\n '#filter': [\n {\n include: '#function-call',\n },\n {\n include: '#keyword',\n },\n {\n include: '#constant',\n },\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#comparison',\n },\n {\n include: '#operator',\n },\n {\n include: '#logical',\n },\n ],\n '#comments': [\n {\n token: ['punctuation.definition.comment.groq', 'comment.line.double-slash.js'],\n regex: /(\\/\\/)(.*$)/,\n },\n ],\n '#nullary-access-operator': [\n {\n token: 'constant.language.groq',\n regex: /[*@^]/,\n },\n ],\n '#constant': [\n {\n token: 'constant.language.groq',\n regex: /\\b(?:true|false|null)\\b/,\n },\n ],\n '#number': [\n {\n token: 'constant.numeric.groq',\n regex: /-?(?:0|[1-9]\\d*)(?:(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)?/,\n },\n ],\n '#named-projection': [\n {\n include: '#identifier',\n },\n {\n include: '#objectkey',\n },\n {\n include: '#projection',\n },\n ],\n '#projection': [\n {\n token: 'punctuation.definition.projection.begin.groq',\n regex: /\\{/,\n push: [\n {\n token: 'punctuation.definition.projection.end.groq',\n regex: /\\}/,\n next: 'pop',\n },\n {\n include: '#identifier',\n },\n {\n include: '#objectkey',\n },\n {\n include: '#named-projection',\n },\n {\n include: '#comments',\n },\n {\n include: '#spread',\n },\n {\n include: '#pair',\n },\n {\n token: 'punctuation.separator.projection.key-value.groq',\n regex: /:/,\n push: [\n {\n token: 'punctuation.separator.projection.pair.groq',\n regex: /,|(?=\\})/,\n next: 'pop',\n },\n {\n include: '#nullary-access-operator',\n },\n {\n include: '#arraylike',\n },\n {\n include: '#value',\n },\n {\n include: '#spread',\n },\n {\n include: '#identifier',\n },\n {\n include: '#operator',\n },\n {\n include: '#comparison',\n },\n {\n include: '#pair',\n },\n {\n token: 'invalid.illegal.expected-projection-separator.groq',\n regex: /[^\\s,]/,\n },\n {\n defaultToken: 'meta.structure.projection.value.groq',\n },\n ],\n },\n {\n token: 'invalid.illegal.expected-projection-separator.groq',\n regex: /[^\\s},]/,\n },\n {\n defaultToken: 'meta.structure.projection.groq',\n },\n ],\n },\n ],\n '#string': [\n {\n include: '#single-string',\n },\n {\n include: '#double-string',\n },\n ],\n '#double-string': [\n {\n token: 'punctuation.definition.string.begin.groq',\n regex: /\"/,\n push: [\n {\n token: 'punctuation.definition.string.end.groq',\n regex: /\"/,\n next: 'pop',\n },\n {\n include: '#stringcontent',\n },\n {\n defaultToken: 'string.quoted.double.groq',\n },\n ],\n },\n ],\n '#single-string': [\n {\n token: 'punctuation.definition.string.single.begin.groq',\n regex: /'/,\n push: [\n {\n token: 'punctuation.definition.string.single.end.groq',\n regex: /'/,\n next: 'pop',\n },\n {\n include: '#stringcontent',\n },\n {\n defaultToken: 'string.quoted.single.groq',\n },\n ],\n },\n ],\n '#objectkey': [\n {\n include: '#string',\n },\n ],\n '#stringcontent': [\n {\n token: 'constant.character.escape.groq',\n regex: /\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})/,\n },\n {\n token: 'invalid.illegal.unrecognized-string-escape.groq',\n regex: /\\\\./,\n },\n ],\n '#sort-pair': [\n {\n token: ['variable.other.readwrite.groq', 'text', 'keyword.other.groq'],\n regex: /([_A-Za-z][_0-9A-Za-z]*)(?:(\\s*)(asc|desc))?/,\n },\n {\n token: ['constant.language.groq', 'punctuation.definition.bracket.begin.groq'],\n regex: /(@)(\\[)/,\n push: [\n {\n token: ['punctuation.definition.bracket.begin.groq', 'text', 'keyword.other.groq'],\n regex: /(\\])(?:(\\s*)(asc|desc))?/,\n next: 'pop',\n },\n {\n include: '#string',\n },\n ],\n },\n ],\n '#sort-order': [\n {\n token: 'support.function.sortorder.begin.groq',\n regex: /\\border\\s*\\(/,\n push: [\n {\n token: 'support.function.sortorder.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#sort-pair',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n token: 'invalid.illegal.expected-sort-separator.groq',\n regex: /[^\\s\\]]/,\n },\n {\n defaultToken: 'support.function.sortorder.groq',\n },\n ],\n },\n ],\n '#function-call': [\n {\n include: '#function-var-arg',\n },\n {\n include: '#function-single-arg',\n },\n {\n include: '#function-round',\n },\n ],\n '#function-var-arg': [\n {\n token: 'support.function.vararg.begin.groq',\n regex: /\\b(?:coalesce|select)\\s*\\(/,\n push: [\n {\n token: 'support.function.vararg.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#value',\n },\n {\n include: '#identifier',\n },\n {\n include: '#filter',\n },\n {\n include: '#pair',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n defaultToken: 'support.function.vararg.groq',\n },\n ],\n },\n ],\n '#function-single-arg': [\n {\n token: 'support.function.singlearg.begin.groq',\n regex: /\\b(?:count|defined|length|path|references)\\s*\\(/,\n push: [\n {\n token: 'support.function.singlearg.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#query',\n },\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#pair',\n },\n {\n defaultToken: 'support.function.singlearg.groq',\n },\n ],\n },\n ],\n '#identifier': [\n {\n token: [\n 'variable.other.readwrite.groq',\n 'text',\n 'punctuation.definition.block.js',\n 'text',\n 'keyword.operator.reference.groq',\n ],\n regex: /([_A-Za-z][_0-9A-Za-z]*)(\\s*)((?:\\[\\s*\\])?)(\\s*)(->)/,\n },\n {\n token: [\n 'variable.other.readwrite.groq',\n 'constant.language.groq',\n 'text',\n 'punctuation.definition.block.js',\n 'text',\n 'keyword.operator.descendant.groq',\n ],\n regex: /(?:([_A-Za-z][_0-9A-Za-z]*)|([@^]))(\\s*)((?:\\[\\s*\\])?)(\\s*)(\\.)/,\n },\n {\n token: 'variable.other.readwrite.groq',\n regex: /[_A-Za-z][_0-9A-Za-z]*/,\n },\n ],\n '#value': [\n {\n include: '#constant',\n },\n {\n include: '#number',\n },\n {\n include: '#string',\n },\n {\n include: '#array',\n },\n {\n include: '#variable',\n },\n {\n include: '#projection',\n },\n {\n include: '#comments',\n },\n {\n include: '#function-call',\n },\n ],\n}\n\ndeclare let ace: any\n\nace.define(\n 'ace/mode/groq_highlight_rules',\n ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules'],\n (acequire: (id: string) => any, exports: Record<string, unknown>, _module: any) => {\n const oop = acequire('../lib/oop')\n const TextHighlightRules = acequire('./text_highlight_rules').TextHighlightRules\n\n const GroqHighlightRules = function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore\n this.$rules = rules\n // @ts-ignore\n this.normalizeRules()\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }\n\n oop.inherits(GroqHighlightRules, TextHighlightRules)\n\n exports.GroqHighlightRules = GroqHighlightRules\n }\n)\n\nace.define(\n 'ace/mode/groq',\n [\n 'require',\n 'exports',\n 'module',\n 'ace/lib/oop',\n 'ace/mode/text',\n 'ace/tokenizer',\n 'ace/mode/groq_highlight_rules',\n 'ace/mode/folding/cstyle',\n ],\n (acequire: (id: string) => any, exports: Record<string, unknown>, _module: any) => {\n // eslint-disable-next-line strict\n 'use strict'\n const oop = acequire('../lib/oop')\n const TextMode = acequire('./text').Mode\n const Tokenizer = acequire('../tokenizer').Tokenizer\n const GroqHighlightRules = acequire('./groq_highlight_rules').GroqHighlightRules\n const FoldMode = acequire('./folding/cstyle').FoldMode\n\n const Mode = function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n const highlighter = new GroqHighlightRules()\n // @ts-ignore\n this.foldingRules = new FoldMode()\n // @ts-ignore\n this.$tokenizer = new Tokenizer(highlighter.getRules())\n // @ts-ignore\n this.$keywordList = highlighter.$keywordList\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }\n oop.inherits(Mode, TextMode)\n ;(function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore\n this.lineCommentStart = \"'\"\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }.call(Mode.prototype))\n\n exports.Mode = Mode\n }\n)\n","import {CodeInputLanguage} from './types'\n\n// NOTE: MAKE SURE THESE ALIGN WITH IMPORTS IN ./editorSupport\nexport const SUPPORTED_LANGUAGES: CodeInputLanguage[] = [\n {title: 'Batch file', value: 'batchfile'},\n {title: 'C#', value: 'csharp'},\n {title: 'CSS', value: 'css'},\n {title: 'Go', value: 'golang'},\n {title: 'GROQ', value: 'groq'},\n {title: 'HTML', value: 'html'},\n {title: 'Java', value: 'java'},\n {title: 'JavaScript', value: 'javascript'},\n {title: 'JSON', value: 'json'},\n {title: 'JSX', value: 'jsx'},\n {title: 'Markdown', value: 'markdown'},\n {title: 'MySQL', value: 'mysql'},\n {title: 'PHP', value: 'php'},\n {title: 'Plain text', value: 'text'},\n {title: 'Python', value: 'python'},\n {title: 'Ruby', value: 'ruby'},\n {title: 'SASS', value: 'sass'},\n {title: 'SCSS', value: 'scss'},\n {title: 'sh', value: 'sh'},\n {title: 'TSX', value: 'tsx'},\n {title: 'TypeScript', value: 'typescript'},\n {title: 'XML', value: 'xml'},\n {title: 'YAML', value: 'yaml'},\n]\n\nexport const LANGUAGE_ALIASES: Record<string, string | undefined> = {js: 'javascript'}\n\nexport const SUPPORTED_THEMES = ['github', 'monokai', 'terminal', 'tomorrow']\n\nexport const DEFAULT_THEME = 'tomorrow'\n\nexport const ACE_SET_OPTIONS = {\n useSoftTabs: true,\n navigateWithinSoftTabs: true /* note only supported by ace v1.2.7 or higher */,\n}\n\nexport const ACE_EDITOR_PROPS = {$blockScrolling: true}\n\nexport const PATH_LANGUAGE = ['language']\nexport const PATH_CODE = ['code']\nexport const PATH_FILENAME = ['filename']\n","/* eslint-disable react/jsx-handler-names */\nimport React, {useCallback, useEffect, useImperativeHandle, useMemo, useRef} from 'react'\nimport {\n FieldMember,\n MemberField,\n ObjectInputProps,\n set,\n setIfMissing,\n unset,\n} from '@sanity/base/form'\nimport {ObjectSchemaType} from '@sanity/types'\nimport {Card, Select, Stack} from '@sanity/ui'\nimport AceEditor from 'react-ace'\nimport styled from 'styled-components'\nimport createHighlightMarkers, {highlightMarkersCSS} from './createHighlightMarkers'\nimport {CodeInputLanguage, CodeInputValue} from './types'\n/* eslint-disable-next-line import/no-unassigned-import */\nimport './editorSupport'\n\nimport {\n ACE_EDITOR_PROPS,\n ACE_SET_OPTIONS,\n DEFAULT_THEME,\n LANGUAGE_ALIASES,\n PATH_CODE,\n SUPPORTED_LANGUAGES,\n SUPPORTED_THEMES,\n} from './config'\n\nexport type {CodeInputLanguage, CodeInputValue} from './types'\n\nconst EditorContainer = styled(Card)`\n position: relative;\n box-sizing: border-box;\n overflow: hidden;\n z-index: 0;\n\n .ace_editor {\n font-family: ${({theme}) => theme.sanity.fonts.code.family};\n font-size: ${({theme}) => theme.sanity.fonts.code.sizes[1]};\n line-height: inherit;\n }\n\n ${highlightMarkersCSS}\n\n &:not([disabled]):not([readonly]) {\n &:focus,\n &:focus-within {\n box-shadow: 0 0 0 2px ${({theme}) => theme.sanity.color.base.focusRing};\n background-color: ${({theme}) => theme.sanity.color.base.bg};\n border-color: ${({theme}) => theme.sanity.color.base.focusRing};\n }\n }\n`\n\nexport type CodeSchemaType = Omit<ObjectSchemaType, 'options'> & {\n options: {\n theme?: string\n languageAlternatives: CodeInputLanguage[]\n language: string\n withFilename?: boolean\n }\n}\n\nexport type CodeInputProps = ObjectInputProps<CodeInputValue, CodeSchemaType>\n\n// Returns a string with the mode name if supported (because aliases), otherwise false\nfunction isSupportedLanguage(mode: string) {\n const alias = LANGUAGE_ALIASES[mode]\n\n if (alias) {\n return alias\n }\n\n const isSupported = SUPPORTED_LANGUAGES.find((lang) => lang.value === mode)\n if (isSupported) {\n return mode\n }\n\n return false\n}\n\nexport function CodeInput(props: CodeInputProps) {\n const {\n focusRef,\n members,\n onBlur,\n onChange,\n onFocusPath,\n readOnly,\n renderField,\n renderInput,\n renderItem,\n schemaType: type,\n value,\n } = props\n\n const aceEditorRef = useRef<any>()\n\n const fieldMembers = useMemo(\n () => members.filter((member) => member.kind === 'field') as FieldMember[],\n [members]\n )\n\n const languageFieldMember = fieldMembers.find((member) => member.name === 'language')\n const filenameMember = fieldMembers.find((member) => member.name === 'filename')\n const codeFieldMember = fieldMembers.find((member) => member.name === 'code')\n\n useImperativeHandle(focusRef, () => ({\n focus: () => {\n aceEditorRef?.current?.editor?.focus()\n },\n }))\n\n const handleCodeFocus = useCallback(() => {\n onFocusPath(PATH_CODE)\n }, [onFocusPath])\n\n const getTheme = useCallback(() => {\n const preferredTheme = type.options?.theme\n return preferredTheme && SUPPORTED_THEMES.find((theme) => theme === preferredTheme)\n ? preferredTheme\n : DEFAULT_THEME\n }, [type])\n\n const handleToggleSelectLine = useCallback(\n (lineNumber: number) => {\n const editorSession = aceEditorRef.current?.editor?.getSession()\n const backgroundMarkers = editorSession?.getMarkers(true)\n const currentHighlightedLines = Object.keys(backgroundMarkers)\n .filter((key) => backgroundMarkers[key].type === 'screenLine')\n .map((key) => backgroundMarkers[key].range.start.row)\n const currentIndex = currentHighlightedLines.indexOf(lineNumber)\n if (currentIndex > -1) {\n // toggle remove\n currentHighlightedLines.splice(currentIndex, 1)\n } else {\n // toggle add\n currentHighlightedLines.push(lineNumber)\n currentHighlightedLines.sort()\n }\n onChange(\n set(\n currentHighlightedLines.map(\n (line) =>\n // ace starts at line (row) 0, but we store it starting at line 1\n line + 1\n ),\n ['highlightedLines']\n )\n )\n },\n [aceEditorRef, onChange]\n )\n\n const handleGutterMouseDown = useCallback(\n (event: any) => {\n const target = event.domEvent.target\n if (target.classList.contains('ace_gutter-cell')) {\n const row = event.getDocumentPosition().row\n handleToggleSelectLine(row)\n }\n },\n [handleToggleSelectLine]\n )\n\n useEffect(() => {\n const editor = aceEditorRef?.current?.editor\n return () => {\n editor?.session?.removeListener('guttermousedown', handleGutterMouseDown)\n }\n }, [aceEditorRef, handleGutterMouseDown])\n\n const handleEditorLoad = useCallback(\n (editor: any) => {\n editor?.on('guttermousedown', handleGutterMouseDown)\n },\n [handleGutterMouseDown]\n )\n\n const getLanguageAlternatives = useCallback((): {\n title: string\n value: string\n mode?: string\n }[] => {\n const languageAlternatives = type.options?.languageAlternatives\n if (!languageAlternatives) {\n return SUPPORTED_LANGUAGES\n }\n\n if (!Array.isArray(languageAlternatives)) {\n throw new Error(\n `'options.languageAlternatives' should be an array, got ${typeof languageAlternatives}`\n )\n }\n\n return languageAlternatives.reduce((acc: CodeInputLanguage[], {title, value: val, mode}) => {\n const alias = LANGUAGE_ALIASES[val]\n if (alias) {\n // eslint-disable-next-line no-console\n console.warn(\n `'options.languageAlternatives' lists a language with value \"%s\", which is an alias of \"%s\" - please replace the value to read \"%s\"`,\n val,\n alias,\n alias\n )\n\n return acc.concat({title, value: alias, mode: mode})\n }\n\n if (!mode && !SUPPORTED_LANGUAGES.find((lang) => lang.value === val)) {\n // eslint-disable-next-line no-console\n console.warn(\n `'options.languageAlternatives' lists a language which is not supported: \"%s\", syntax highlighting will be disabled.`,\n val\n )\n }\n\n return acc.concat({title, value: val, mode})\n }, [])\n }, [type])\n\n const handleCodeChange = useCallback(\n (code: string) => {\n const path = PATH_CODE\n const fixedLanguage = type.options?.language\n\n onChange([\n setIfMissing({_type: type.name, language: fixedLanguage}),\n code ? set(code, path) : unset(path),\n ])\n },\n [onChange, type]\n )\n\n const languages = getLanguageAlternatives().slice()\n\n const fixedLanguage = type.options?.language\n\n const language = value?.language || fixedLanguage\n\n // the language config from the schema\n const configured = languages.find((entry) => entry.value === language)\n\n // is the language officially supported (e.g. we import the mode by default)\n const supported = language && isSupportedLanguage(language)\n\n const mode = configured?.mode || (supported ? language : 'text')\n\n const renderLanguageInput = useCallback(\n (inputProps) => {\n return (\n <Select {...inputProps}>\n {languages.map((lang: {title: string; value: string}) => (\n <option key={lang.value} value={lang.value}>\n {lang.title}\n </option>\n ))}\n </Select>\n )\n },\n [languages]\n )\n\n const renderCodeInput = useCallback(\n (inputProps) => {\n return (\n <EditorContainer radius={1} shadow={1} readOnly={readOnly}>\n <AceEditor\n ref={aceEditorRef}\n mode={mode}\n theme={getTheme()}\n width=\"100%\"\n onChange={handleCodeChange}\n name={inputProps.id}\n value={inputProps.value}\n markers={\n value && value.highlightedLines\n ? createHighlightMarkers(value.highlightedLines)\n : undefined\n }\n onLoad={handleEditorLoad}\n readOnly={readOnly}\n tabSize={2}\n wrapEnabled\n setOptions={ACE_SET_OPTIONS}\n editorProps={ACE_EDITOR_PROPS}\n onFocus={handleCodeFocus}\n onBlur={onBlur}\n />\n </EditorContainer>\n )\n },\n [getTheme, handleCodeChange, handleCodeFocus, handleEditorLoad, mode, onBlur, readOnly, value]\n )\n\n return (\n <Stack space={4}>\n {languageFieldMember && (\n <MemberField\n member={languageFieldMember}\n renderItem={renderItem}\n renderField={renderField}\n renderInput={renderLanguageInput}\n />\n )}\n\n {type.options?.withFilename && filenameMember && (\n <MemberField\n member={filenameMember}\n renderItem={renderItem}\n renderField={renderField}\n renderInput={renderInput}\n />\n )}\n\n {codeFieldMember && (\n <MemberField\n member={codeFieldMember}\n renderInput={renderCodeInput}\n renderItem={renderItem}\n renderField={renderField}\n />\n )}\n </Stack>\n )\n}\n"],"names":["css","styled","Card","useRef","useMemo","useImperativeHandle","useCallback","set","useEffect","setIfMissing","unset","React","Select","AceEditor","Stack","MemberField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,mBAAmB,GAAGA,UAAG,CAAA,CAAA;;;AAGd,sBAAA,EAAA,CAAC,EAAC,KAAK,EAAC,KAAK,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAA;;;;;CAK/E,CAAA;AAEuB,SAAA,sBAAsB,CAAC,IAAc,EAAA;IAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACxB,QAAA,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;AACzB,QAAA,QAAQ,EAAE,CAAC;AACX,QAAA,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QACvB,MAAM,EAAE,CAAC,QAAQ;AACjB,QAAA,SAAS,EAAE,8BAA8B;AACzC,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,OAAO,EAAE,IAAI;AACd,KAAA,CAAC,CAAC,CAAA;AACL;;ACvBA;AAIA;AACA,MAAM,KAAK,GAAG;AACZ,IAAA,KAAK,EAAE;AACL,QAAA;AACE,YAAA,OAAO,EAAE,QAAQ;AAClB,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,QAAQ;AAClB,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,OAAO;AACjB,SAAA;AACF,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QA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,EAAE,KAAK,CAAC,CAC/F,CAAA;AAED,IAAA,QACEF,yBAAC,CAAA,aAAA,CAAAG,QAAK,EAAC,EAAA,KAAK,EAAE,CAAC,EAAA;QACZ,mBAAmB,KAClBH,yBAAC,CAAA,aAAA,CAAAI,gBAAW,IACV,MAAM,EAAE,mBAAmB,EAC3B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,mBAAmB,EAAA,CAChC,CACH;QAEA,IAAI,CAAC,OAAO,EAAE,YAAY,IAAI,cAAc,KAC3CJ,yBAAA,CAAA,aAAA,CAACI,gBAAW,EAAA,EACV,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAAA,CACxB,CACH;QAEA,eAAe,KACdJ,yBAAA,CAAA,aAAA,CAACI,gBAAW,EAAA,EACV,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,eAAe,EAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,CAAA,CACH,CACK,EACT;AACH;;;;;;;"}
|
package/lib/_reExport.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = function _reExport(_exports, _sourceModule) {
|
|
4
|
+
Object.defineProperty(_exports, '__esModule', {
|
|
5
|
+
value: true,
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
Object.keys(_sourceModule).forEach(function (key) {
|
|
9
|
+
if (key === '__esModule') return
|
|
10
|
+
if (key in _exports && _exports[key] === _sourceModule[key]) return
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(_exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _sourceModule[key]
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var deprecatedSchema = (() => {
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
console.warn('@sanity/code-input has been upgraded to automatically register its schema type.');
|
|
6
|
+
console.warn('Please remove the explicit import of `part:@sanity/base/schema-type`');
|
|
7
|
+
/* eslint-enable no-console */
|
|
8
|
+
return {
|
|
9
|
+
name: 'oldDeprecatedCodeTypeWhichYouShouldRemove',
|
|
10
|
+
type: 'object',
|
|
11
|
+
title: 'Deprecated code type',
|
|
12
|
+
fields: [
|
|
13
|
+
{
|
|
14
|
+
title: 'Code',
|
|
15
|
+
name: 'code',
|
|
16
|
+
type: 'text',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
module.exports = deprecatedSchema;
|
|
23
|
+
//# sourceMappingURL=deprecatedSchema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecatedSchema.cjs","sources":["../src/deprecatedSchema.ts"],"sourcesContent":["export default (() => {\n /* eslint-disable no-console */\n console.warn('@sanity/code-input has been upgraded to automatically register its schema type.')\n console.warn('Please remove the explicit import of `part:@sanity/base/schema-type`')\n /* eslint-enable no-console */\n\n return {\n name: 'oldDeprecatedCodeTypeWhichYouShouldRemove',\n type: 'object',\n title: 'Deprecated code type',\n fields: [\n {\n title: 'Code',\n name: 'code',\n type: 'text',\n },\n ],\n }\n})()\n"],"names":[],"mappings":";;AAAA,uBAAe,CAAC,MAAK;;AAEnB,IAAA,OAAO,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAA;AAC/F,IAAA,OAAO,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAA;;IAGpF,OAAO;AACL,QAAA,IAAI,EAAE,2CAA2C;AACjD,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,KAAK,EAAE,sBAAsB;AAC7B,QAAA,MAAM,EAAE;AACN,YAAA;AACE,gBAAA,KAAK,EAAE,MAAM;AACb,gBAAA,IAAI,EAAE,MAAM;AACZ,gBAAA,IAAI,EAAE,MAAM;AACb,aAAA;AACF,SAAA;KACF,CAAA;AACH,CAAC,GAAG;;;;"}
|
package/lib/deprecatedSchema.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fields: [{
|
|
19
|
-
title: 'Code',
|
|
20
|
-
name: 'code',
|
|
21
|
-
type: 'text'
|
|
22
|
-
}]
|
|
23
|
-
};
|
|
1
|
+
var deprecatedSchema = (() => {
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
console.warn('@sanity/code-input has been upgraded to automatically register its schema type.');
|
|
4
|
+
console.warn('Please remove the explicit import of `part:@sanity/base/schema-type`');
|
|
5
|
+
/* eslint-enable no-console */
|
|
6
|
+
return {
|
|
7
|
+
name: 'oldDeprecatedCodeTypeWhichYouShouldRemove',
|
|
8
|
+
type: 'object',
|
|
9
|
+
title: 'Deprecated code type',
|
|
10
|
+
fields: [
|
|
11
|
+
{
|
|
12
|
+
title: 'Code',
|
|
13
|
+
name: 'code',
|
|
14
|
+
type: 'text',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
24
18
|
})();
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
export { deprecatedSchema as default };
|
|
21
|
+
//# sourceMappingURL=deprecatedSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecatedSchema.js","sources":["../src/deprecatedSchema.ts"],"sourcesContent":["export default (() => {\n /* eslint-disable no-console */\n console.warn('@sanity/code-input has been upgraded to automatically register its schema type.')\n console.warn('Please remove the explicit import of `part:@sanity/base/schema-type`')\n /* eslint-enable no-console */\n\n return {\n name: 'oldDeprecatedCodeTypeWhichYouShouldRemove',\n type: 'object',\n title: 'Deprecated code type',\n fields: [\n {\n title: 'Code',\n name: 'code',\n type: 'text',\n },\n ],\n }\n})()\n"],"names":[],"mappings":"AAAA,uBAAe,CAAC,MAAK;;AAEnB,IAAA,OAAO,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAA;AAC/F,IAAA,OAAO,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAA;;IAGpF,OAAO;AACL,QAAA,IAAI,EAAE,2CAA2C;AACjD,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,KAAK,EAAE,sBAAsB;AAC7B,QAAA,MAAM,EAAE;AACN,YAAA;AACE,gBAAA,KAAK,EAAE,MAAM;AACb,gBAAA,IAAI,EAAE,MAAM;AACZ,gBAAA,IAAI,EAAE,MAAM;AACb,aAAA;AACF,SAAA;KACF,CAAA;AACH,CAAC,GAAG;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ObjectInputProps } from '@sanity/base/form';
|
|
3
|
+
import { ObjectSchemaType } from '@sanity/types';
|
|
4
|
+
import { CodeInputLanguage, CodeInputValue } from './types';
|
|
5
|
+
import './editorSupport';
|
|
6
|
+
export type { CodeInputLanguage, CodeInputValue } from './types';
|
|
7
|
+
export declare type CodeSchemaType = Omit<ObjectSchemaType, 'options'> & {
|
|
8
|
+
options: {
|
|
9
|
+
theme?: string;
|
|
10
|
+
languageAlternatives: CodeInputLanguage[];
|
|
11
|
+
language: string;
|
|
12
|
+
withFilename?: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare type CodeInputProps = ObjectInputProps<CodeInputValue, CodeSchemaType>;
|
|
16
|
+
export declare function CodeInput(props: CodeInputProps): JSX.Element;
|
|
17
|
+
//# sourceMappingURL=CodeInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../../src/CodeInput.tsx"],"names":[],"mappings":";AAEA,OAAO,EAGL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA;AAK9C,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAEzD,OAAO,iBAAiB,CAAA;AAYxB,YAAY,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AA0B9D,oBAAY,cAAc,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;IAC/D,OAAO,EAAE;QACP,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,CAAA;AAED,oBAAY,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;AAkB7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAoP9C"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-handler-names */
|
|
2
|
+
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
3
|
+
import { MemberField, set, setIfMissing, unset, } from '@sanity/base/form';
|
|
4
|
+
import { Card, Select, Stack } from '@sanity/ui';
|
|
5
|
+
import AceEditor from 'react-ace';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import createHighlightMarkers, { highlightMarkersCSS } from './createHighlightMarkers';
|
|
8
|
+
/* eslint-disable-next-line import/no-unassigned-import */
|
|
9
|
+
import './editorSupport';
|
|
10
|
+
import { ACE_EDITOR_PROPS, ACE_SET_OPTIONS, DEFAULT_THEME, LANGUAGE_ALIASES, PATH_CODE, SUPPORTED_LANGUAGES, SUPPORTED_THEMES, } from './config';
|
|
11
|
+
const EditorContainer = styled(Card) `
|
|
12
|
+
position: relative;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
z-index: 0;
|
|
16
|
+
|
|
17
|
+
.ace_editor {
|
|
18
|
+
font-family: ${({ theme }) => theme.sanity.fonts.code.family};
|
|
19
|
+
font-size: ${({ theme }) => theme.sanity.fonts.code.sizes[1]};
|
|
20
|
+
line-height: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
${highlightMarkersCSS}
|
|
24
|
+
|
|
25
|
+
&:not([disabled]):not([readonly]) {
|
|
26
|
+
&:focus,
|
|
27
|
+
&:focus-within {
|
|
28
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.sanity.color.base.focusRing};
|
|
29
|
+
background-color: ${({ theme }) => theme.sanity.color.base.bg};
|
|
30
|
+
border-color: ${({ theme }) => theme.sanity.color.base.focusRing};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
// Returns a string with the mode name if supported (because aliases), otherwise false
|
|
35
|
+
function isSupportedLanguage(mode) {
|
|
36
|
+
const alias = LANGUAGE_ALIASES[mode];
|
|
37
|
+
if (alias) {
|
|
38
|
+
return alias;
|
|
39
|
+
}
|
|
40
|
+
const isSupported = SUPPORTED_LANGUAGES.find((lang) => lang.value === mode);
|
|
41
|
+
if (isSupported) {
|
|
42
|
+
return mode;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
export function CodeInput(props) {
|
|
47
|
+
const { focusRef, members, onBlur, onChange, onFocusPath, readOnly, renderField, renderInput, renderItem, schemaType: type, value, } = props;
|
|
48
|
+
const aceEditorRef = useRef();
|
|
49
|
+
const fieldMembers = useMemo(() => members.filter((member) => member.kind === 'field'), [members]);
|
|
50
|
+
const languageFieldMember = fieldMembers.find((member) => member.name === 'language');
|
|
51
|
+
const filenameMember = fieldMembers.find((member) => member.name === 'filename');
|
|
52
|
+
const codeFieldMember = fieldMembers.find((member) => member.name === 'code');
|
|
53
|
+
useImperativeHandle(focusRef, () => ({
|
|
54
|
+
focus: () => {
|
|
55
|
+
aceEditorRef?.current?.editor?.focus();
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
const handleCodeFocus = useCallback(() => {
|
|
59
|
+
onFocusPath(PATH_CODE);
|
|
60
|
+
}, [onFocusPath]);
|
|
61
|
+
const getTheme = useCallback(() => {
|
|
62
|
+
const preferredTheme = type.options?.theme;
|
|
63
|
+
return preferredTheme && SUPPORTED_THEMES.find((theme) => theme === preferredTheme)
|
|
64
|
+
? preferredTheme
|
|
65
|
+
: DEFAULT_THEME;
|
|
66
|
+
}, [type]);
|
|
67
|
+
const handleToggleSelectLine = useCallback((lineNumber) => {
|
|
68
|
+
const editorSession = aceEditorRef.current?.editor?.getSession();
|
|
69
|
+
const backgroundMarkers = editorSession?.getMarkers(true);
|
|
70
|
+
const currentHighlightedLines = Object.keys(backgroundMarkers)
|
|
71
|
+
.filter((key) => backgroundMarkers[key].type === 'screenLine')
|
|
72
|
+
.map((key) => backgroundMarkers[key].range.start.row);
|
|
73
|
+
const currentIndex = currentHighlightedLines.indexOf(lineNumber);
|
|
74
|
+
if (currentIndex > -1) {
|
|
75
|
+
// toggle remove
|
|
76
|
+
currentHighlightedLines.splice(currentIndex, 1);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// toggle add
|
|
80
|
+
currentHighlightedLines.push(lineNumber);
|
|
81
|
+
currentHighlightedLines.sort();
|
|
82
|
+
}
|
|
83
|
+
onChange(set(currentHighlightedLines.map((line) =>
|
|
84
|
+
// ace starts at line (row) 0, but we store it starting at line 1
|
|
85
|
+
line + 1), ['highlightedLines']));
|
|
86
|
+
}, [aceEditorRef, onChange]);
|
|
87
|
+
const handleGutterMouseDown = useCallback((event) => {
|
|
88
|
+
const target = event.domEvent.target;
|
|
89
|
+
if (target.classList.contains('ace_gutter-cell')) {
|
|
90
|
+
const row = event.getDocumentPosition().row;
|
|
91
|
+
handleToggleSelectLine(row);
|
|
92
|
+
}
|
|
93
|
+
}, [handleToggleSelectLine]);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const editor = aceEditorRef?.current?.editor;
|
|
96
|
+
return () => {
|
|
97
|
+
editor?.session?.removeListener('guttermousedown', handleGutterMouseDown);
|
|
98
|
+
};
|
|
99
|
+
}, [aceEditorRef, handleGutterMouseDown]);
|
|
100
|
+
const handleEditorLoad = useCallback((editor) => {
|
|
101
|
+
editor?.on('guttermousedown', handleGutterMouseDown);
|
|
102
|
+
}, [handleGutterMouseDown]);
|
|
103
|
+
const getLanguageAlternatives = useCallback(() => {
|
|
104
|
+
const languageAlternatives = type.options?.languageAlternatives;
|
|
105
|
+
if (!languageAlternatives) {
|
|
106
|
+
return SUPPORTED_LANGUAGES;
|
|
107
|
+
}
|
|
108
|
+
if (!Array.isArray(languageAlternatives)) {
|
|
109
|
+
throw new Error(`'options.languageAlternatives' should be an array, got ${typeof languageAlternatives}`);
|
|
110
|
+
}
|
|
111
|
+
return languageAlternatives.reduce((acc, { title, value: val, mode }) => {
|
|
112
|
+
const alias = LANGUAGE_ALIASES[val];
|
|
113
|
+
if (alias) {
|
|
114
|
+
// eslint-disable-next-line no-console
|
|
115
|
+
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);
|
|
116
|
+
return acc.concat({ title, value: alias, mode: mode });
|
|
117
|
+
}
|
|
118
|
+
if (!mode && !SUPPORTED_LANGUAGES.find((lang) => lang.value === val)) {
|
|
119
|
+
// eslint-disable-next-line no-console
|
|
120
|
+
console.warn(`'options.languageAlternatives' lists a language which is not supported: "%s", syntax highlighting will be disabled.`, val);
|
|
121
|
+
}
|
|
122
|
+
return acc.concat({ title, value: val, mode });
|
|
123
|
+
}, []);
|
|
124
|
+
}, [type]);
|
|
125
|
+
const handleCodeChange = useCallback((code) => {
|
|
126
|
+
const path = PATH_CODE;
|
|
127
|
+
const fixedLanguage = type.options?.language;
|
|
128
|
+
onChange([
|
|
129
|
+
setIfMissing({ _type: type.name, language: fixedLanguage }),
|
|
130
|
+
code ? set(code, path) : unset(path),
|
|
131
|
+
]);
|
|
132
|
+
}, [onChange, type]);
|
|
133
|
+
const languages = getLanguageAlternatives().slice();
|
|
134
|
+
const fixedLanguage = type.options?.language;
|
|
135
|
+
const language = value?.language || fixedLanguage;
|
|
136
|
+
// the language config from the schema
|
|
137
|
+
const configured = languages.find((entry) => entry.value === language);
|
|
138
|
+
// is the language officially supported (e.g. we import the mode by default)
|
|
139
|
+
const supported = language && isSupportedLanguage(language);
|
|
140
|
+
const mode = configured?.mode || (supported ? language : 'text');
|
|
141
|
+
const renderLanguageInput = useCallback((inputProps) => {
|
|
142
|
+
return (React.createElement(Select, { ...inputProps }, languages.map((lang) => (React.createElement("option", { key: lang.value, value: lang.value }, lang.title)))));
|
|
143
|
+
}, [languages]);
|
|
144
|
+
const renderCodeInput = useCallback((inputProps) => {
|
|
145
|
+
return (React.createElement(EditorContainer, { radius: 1, shadow: 1, readOnly: readOnly },
|
|
146
|
+
React.createElement(AceEditor, { ref: aceEditorRef, mode: mode, theme: getTheme(), width: "100%", onChange: handleCodeChange, name: inputProps.id, value: inputProps.value, markers: value && value.highlightedLines
|
|
147
|
+
? createHighlightMarkers(value.highlightedLines)
|
|
148
|
+
: undefined, onLoad: handleEditorLoad, readOnly: readOnly, tabSize: 2, wrapEnabled: true, setOptions: ACE_SET_OPTIONS, editorProps: ACE_EDITOR_PROPS, onFocus: handleCodeFocus, onBlur: onBlur })));
|
|
149
|
+
}, [getTheme, handleCodeChange, handleCodeFocus, handleEditorLoad, mode, onBlur, readOnly, value]);
|
|
150
|
+
return (React.createElement(Stack, { space: 4 },
|
|
151
|
+
languageFieldMember && (React.createElement(MemberField, { member: languageFieldMember, renderItem: renderItem, renderField: renderField, renderInput: renderLanguageInput })),
|
|
152
|
+
type.options?.withFilename && filenameMember && (React.createElement(MemberField, { member: filenameMember, renderItem: renderItem, renderField: renderField, renderInput: renderInput })),
|
|
153
|
+
codeFieldMember && (React.createElement(MemberField, { member: codeFieldMember, renderInput: renderCodeInput, renderItem: renderItem, renderField: renderField }))));
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=CodeInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeInput.js","sourceRoot":"","sources":["../../../src/CodeInput.tsx"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AACzF,OAAO,EAEL,WAAW,EAEX,GAAG,EACH,YAAY,EACZ,KAAK,GACN,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAC,MAAM,YAAY,CAAA;AAC9C,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,sBAAsB,EAAE,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAA;AAEpF,0DAA0D;AAC1D,OAAO,iBAAiB,CAAA;AAExB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,UAAU,CAAA;AAIjB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;;;mBAOjB,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;iBAC7C,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;;;IAI1D,mBAAmB;;;;;8BAKO,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,KAA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AU,EACtB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,mBAAmB,GAChC,CACH;QAEA,IAAI,CAAC,OAAO,EAAE,YAAY,IAAI,cAAc,IAAI,CAC/C,oBAAC,WAAW,IACV,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,GACxB,CACH;QAEA,eAAe,IAAI,CAClB,oBAAC,WAAW,IACV,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,eAAe,EAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,GACxB,CACH,CACK,CACT,CAAA;AACH,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CodeInputType, CodeInputValue } from './types';
|
|
3
|
-
import './editorSupport';
|
|
4
|
-
export interface PreviewCodeProps {
|
|
5
|
-
type?: CodeInputType;
|
|
6
|
-
value?: CodeInputValue;
|
|
7
|
-
}
|
|
8
|
-
export default function PreviewCode(props: PreviewCodeProps): JSX.Element;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CodeInputType, CodeInputValue } from './types';
|
|
3
|
+
import './editorSupport';
|
|
4
|
+
export interface PreviewCodeProps {
|
|
5
|
+
type?: CodeInputType;
|
|
6
|
+
value?: CodeInputValue;
|
|
7
|
+
}
|
|
8
|
+
export default function PreviewCode(props: PreviewCodeProps): JSX.Element;
|
|
9
9
|
//# sourceMappingURL=PreviewCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import AceEditor from 'react-ace';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Box } from '@sanity/ui';
|
|
5
|
+
import { ACE_EDITOR_PROPS, ACE_SET_OPTIONS } from './config';
|
|
6
|
+
import createHighlightMarkers from './createHighlightMarkers';
|
|
7
|
+
/* eslint-disable-next-line import/no-unassigned-import */
|
|
8
|
+
import './editorSupport';
|
|
9
|
+
const PreviewContainer = styled(Box) `
|
|
10
|
+
position: relative;
|
|
11
|
+
`;
|
|
12
|
+
const PreviewInner = styled(Box) `
|
|
13
|
+
background-color: #272822;
|
|
14
|
+
|
|
15
|
+
.ace_editor {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
cursor: default;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ace_content {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
export default function PreviewCode(props) {
|
|
27
|
+
const aceEditorRef = useRef();
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!aceEditorRef?.current)
|
|
30
|
+
return;
|
|
31
|
+
const editor = aceEditorRef.current?.editor;
|
|
32
|
+
if (editor) {
|
|
33
|
+
// Avoid cursor and focus tracking by Ace
|
|
34
|
+
editor.renderer.$cursorLayer.element.style.opacity = 0;
|
|
35
|
+
editor.textInput.getElement().disabled = true;
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
const handleEditorChange = useCallback(() => {
|
|
39
|
+
// do nothing when the editor changes
|
|
40
|
+
}, []);
|
|
41
|
+
const { value, type } = props;
|
|
42
|
+
const fixedLanguage = type?.options?.language;
|
|
43
|
+
const mode = value?.language || fixedLanguage || 'text';
|
|
44
|
+
return (React.createElement(PreviewContainer, null,
|
|
45
|
+
React.createElement(PreviewInner, { padding: 4 },
|
|
46
|
+
React.createElement(AceEditor, { ref: aceEditorRef, focus: false, mode: mode, theme: "monokai", width: "100%", onChange: handleEditorChange, maxLines: 200, readOnly: true, wrapEnabled: true, showPrintMargin: false, highlightActiveLine: false, cursorStart: -1, value: (value && value.code) || '', markers: value && value.highlightedLines
|
|
47
|
+
? createHighlightMarkers(value.highlightedLines)
|
|
48
|
+
: undefined, tabSize: 2, showGutter: false, setOptions: ACE_SET_OPTIONS, editorProps: ACE_EDITOR_PROPS }))));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=PreviewCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewCode.js","sourceRoot":"","sources":["../../../src/PreviewCode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AAC3D,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAC,MAAM,UAAU,CAAA;AAC1D,OAAO,sBAAsB,MAAM,0BAA0B,CAAA;AAE7D,0DAA0D;AAC1D,OAAO,iBAAiB,CAAA;AAExB,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;CAEnC,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;;;;;;;;;;CAa/B,CAAA;AAOD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAuB;IACzD,MAAM,YAAY,GAAG,MAAM,EAAO,CAAA;IAElC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,EAAE,OAAO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AE,KAAK,EACjB,UAAU,EAAE,eAAe,EAC3B,WAAW,EAAE,gBAAgB,GAC7B,CACW,CACE,CACpB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../../src/__workshop__/dev.tsx"],"names":[],"mappings":";AAWA,MAAM,CAAC,OAAO,UAAU,QAAQ,gBAuB/B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createSchema } from '@sanity/base/_unstable';
|
|
2
|
+
import { Box } from '@sanity/ui';
|
|
3
|
+
import { useAction } from '@sanity/ui-workshop';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import typeDef from '../schema';
|
|
6
|
+
const schema = createSchema({ name: 'dev', types: [typeDef] });
|
|
7
|
+
const schemaType = schema.get('code');
|
|
8
|
+
export default function DevStory() {
|
|
9
|
+
const [focusPath] = useState([]);
|
|
10
|
+
const [validation] = useState([]);
|
|
11
|
+
const onBlur = useAction('onBlur');
|
|
12
|
+
const onChange = useAction('onChange');
|
|
13
|
+
const onFocus = useAction('onFocus');
|
|
14
|
+
const [presence] = useState([]);
|
|
15
|
+
return (React.createElement(Box, { padding: 4 },
|
|
16
|
+
React.createElement(React.Fragment, null, "TODO")));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../../src/__workshop__/dev.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAA;AAC7C,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAA;AAErC,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;AAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAmB,CAAA;AAEvD,MAAM,CAAC,OAAO,UAAU,QAAQ;IAC9B,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAO,EAAE,CAAC,CAAA;IACtC,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;IAClC,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;IACtC,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,CAAA;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAQ,EAAE,CAAC,CAAA;IAEtC,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;QACb,iDAAS,CAWL,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/__workshop__/index.ts"],"names":[],"mappings":";AAGA,wBAME"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineScope } from '@sanity/ui-workshop';
|
|
2
|
+
import { lazy } from 'react';
|
|
3
|
+
export default defineScope('code-input', '@sanity/code-input', [
|
|
4
|
+
{
|
|
5
|
+
name: 'dev',
|
|
6
|
+
title: 'Dev',
|
|
7
|
+
component: lazy(() => import('./dev')),
|
|
8
|
+
},
|
|
9
|
+
]);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/__workshop__/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAA;AAE1B,eAAe,WAAW,CAAC,YAAY,EAAE,oBAAoB,EAAE;IAC7D;QACE,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KACvC;CACF,CAAC,CAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { CodeInputLanguage } from './types';
|
|
2
|
-
export declare const SUPPORTED_LANGUAGES: CodeInputLanguage[];
|
|
3
|
-
export declare const LANGUAGE_ALIASES: Record<string, string | undefined>;
|
|
4
|
-
export declare const SUPPORTED_THEMES: string[];
|
|
5
|
-
export declare const DEFAULT_THEME = "tomorrow";
|
|
6
|
-
export declare const ACE_SET_OPTIONS: {
|
|
7
|
-
useSoftTabs: boolean;
|
|
8
|
-
navigateWithinSoftTabs: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare const ACE_EDITOR_PROPS: {
|
|
11
|
-
$blockScrolling: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare const PATH_LANGUAGE: string[];
|
|
14
|
-
export declare const PATH_CODE: string[];
|
|
15
|
-
export declare const PATH_FILENAME: string[];
|
|
1
|
+
import { CodeInputLanguage } from './types';
|
|
2
|
+
export declare const SUPPORTED_LANGUAGES: CodeInputLanguage[];
|
|
3
|
+
export declare const LANGUAGE_ALIASES: Record<string, string | undefined>;
|
|
4
|
+
export declare const SUPPORTED_THEMES: string[];
|
|
5
|
+
export declare const DEFAULT_THEME = "tomorrow";
|
|
6
|
+
export declare const ACE_SET_OPTIONS: {
|
|
7
|
+
useSoftTabs: boolean;
|
|
8
|
+
navigateWithinSoftTabs: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const ACE_EDITOR_PROPS: {
|
|
11
|
+
$blockScrolling: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const PATH_LANGUAGE: string[];
|
|
14
|
+
export declare const PATH_CODE: string[];
|
|
15
|
+
export declare const PATH_FILENAME: string[];
|
|
16
16
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAA;AAGzC,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,EAwBlD,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAsB,CAAA;AAEtF,eAAO,MAAM,gBAAgB,UAAgD,CAAA;AAE7E,eAAO,MAAM,aAAa,aAAa,CAAA;AAEvC,eAAO,MAAM,eAAe;;;CAG3B,CAAA;AAED,eAAO,MAAM,gBAAgB;;CAA0B,CAAA;AAEvD,eAAO,MAAM,aAAa,UAAe,CAAA;AACzC,eAAO,MAAM,SAAS,UAAW,CAAA;AACjC,eAAO,MAAM,aAAa,UAAe,CAAA"}
|