├── docs ├── .gitignore ├── .textlint.terms.json ├── docs │ ├── resources │ │ ├── img │ │ │ └── plugin-logo.png │ │ └── screenshots │ │ │ ├── code-field-languages.png │ │ │ ├── code-field-markdown.png │ │ │ ├── code-field-settings.png │ │ │ ├── code-field-css-picker.png │ │ │ ├── code-field-options-override.png │ │ │ ├── code-field-frontend-read-only.png │ │ │ └── code-field-javascript-autocomplete.png │ ├── @types │ │ └── shims.d.ts │ ├── .vitepress │ │ ├── theme │ │ │ ├── custom.css │ │ │ ├── NYSLogo.vue │ │ │ └── index.ts │ │ └── config.ts │ ├── vite.config.ts │ ├── public │ │ └── img │ │ │ ├── nys-logo.svg │ │ │ └── plugin-logo.svg │ └── index.md ├── Dockerfile ├── tsconfig.json ├── .textlintrc.js ├── package.json ├── Makefile └── README.md ├── phpstan.neon ├── ecs.php ├── CHANGELOG.md ├── Makefile ├── src ├── gql │ └── types │ │ ├── CodeDataType.php │ │ └── generators │ │ └── CodeDataGenerator.php ├── validators │ └── JsonValidator.php ├── models │ └── CodeData.php ├── icon.svg ├── CodeField.php ├── translations │ └── en │ │ └── codefield.php ├── templates │ └── _components │ │ └── fields │ │ ├── Code_input.twig │ │ └── Code_settings.twig ├── fields │ ├── MonacoLanguages.php │ └── Code.php └── resources │ └── IEditorOptionsSchema.json ├── LICENSE.md ├── README.md └── composer.json /docs/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /node_modules 3 | /docs/.vitepress/dist 4 | /docs/.vitepress/cache 5 | -------------------------------------------------------------------------------- /docs/.textlint.terms.json: -------------------------------------------------------------------------------- 1 | [ 2 | "Stylus", 3 | "VuePress", 4 | [ 5 | "front[- ]matter", 6 | "frontmatter" 7 | ] 8 | ] 9 | -------------------------------------------------------------------------------- /docs/docs/resources/img/plugin-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/img/plugin-logo.png -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-languages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-languages.png -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-markdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-markdown.png -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-settings.png -------------------------------------------------------------------------------- /docs/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG=20-alpine 2 | FROM node:$TAG 3 | 4 | RUN npm install -g npm@^10.0.0 5 | 6 | WORKDIR /app/ 7 | 8 | CMD ["run build"] 9 | 10 | ENTRYPOINT ["npm"] 11 | -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-css-picker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-css-picker.png -------------------------------------------------------------------------------- /docs/docs/@types/shims.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.vue" { 2 | import Vue from 'vue'; 3 | export default Vue; 4 | } 5 | 6 | declare module 'rollup-plugin-sitemap'; 7 | declare module 'NYSLogo'; 8 | -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-options-override.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-options-override.png -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-frontend-read-only.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-frontend-read-only.png -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | includes: 2 | - %currentWorkingDirectory%/vendor/craftcms/phpstan/phpstan.neon 3 | 4 | parameters: 5 | level: 5 6 | phpVersion: 80200 # PHP 8.2 7 | paths: 8 | - src 9 | -------------------------------------------------------------------------------- /docs/docs/resources/screenshots/code-field-javascript-autocomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/craft-code-field/develop-v5/docs/docs/resources/screenshots/code-field-javascript-autocomplete.png -------------------------------------------------------------------------------- /docs/docs/.vitepress/theme/custom.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --c-brand: #48a391; 3 | --c-brand-light: #5db7a5; 4 | } 5 | 6 | .custom-block.tip { 7 | border-color: var(--c-brand-light); 8 | } 9 | 10 | .DocSearch { 11 | --docsearch-primary-color: var(--c-brand) !important; 12 | } 13 | 14 | a > img { 15 | display: inline-block; 16 | } 17 | -------------------------------------------------------------------------------- /ecs.php: -------------------------------------------------------------------------------- 1 | paths([ 8 | __DIR__ . '/src', 9 | __FILE__, 10 | ]); 11 | $ecsConfig->parallel(); 12 | $ecsConfig->sets([SetList::CRAFT_CMS_4]); 13 | }; 14 | -------------------------------------------------------------------------------- /docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "esnext", 4 | "target": "esnext", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "strict": true, 8 | "skipLibCheck": true, 9 | "noUnusedLocals": true, 10 | "resolveJsonModule": true, 11 | "jsx": "preserve", 12 | "lib": ["ESNext", "DOM"], 13 | "types": ["vite/client"] 14 | }, 15 | "exclude": ["**/node_modules/**", "**/dist/**"] 16 | } 17 | -------------------------------------------------------------------------------- /docs/.textlintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | '@textlint-rule/no-unmatched-pair': true, 4 | apostrophe: true, 5 | 'common-misspellings': true, 6 | diacritics: true, 7 | 'en-capitalization': { 8 | allowHeading: false 9 | }, 10 | 'stop-words': { 11 | severity: 'warning' 12 | }, 13 | terminology: { 14 | terms: `${__dirname}/.textlint.terms.json` 15 | }, 16 | 'write-good': { 17 | severity: 'warning' 18 | } 19 | }, 20 | filters: { 21 | comments: true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docs/docs/.vitepress/theme/NYSLogo.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 19 | 20 | 35 | -------------------------------------------------------------------------------- /docs/docs/vite.config.ts: -------------------------------------------------------------------------------- 1 | import {defineConfig} from 'vite' 2 | import { sitemap, Url as SitemapUrl } from '@aminnairi/rollup-plugin-sitemap' 3 | import VitePressConfig from './.vitepress/config' 4 | import {DefaultTheme} from "vitepress/types/default-theme"; 5 | 6 | const docsSiteBaseUrl = 'https://nystudio107.com' 7 | const docsBaseUrl = new URL(VitePressConfig.base!, docsSiteBaseUrl).href.replace(/\/$/, '') + '/'; 8 | let siteMapUrls: SitemapUrl[] = [{ 9 | location: '', 10 | lastModified: new Date(), 11 | }]; 12 | 13 | // https://vitejs.dev/config/ 14 | export default defineConfig({ 15 | plugins: [ 16 | sitemap({ 17 | baseUrl: docsBaseUrl, 18 | urls: siteMapUrls, 19 | }) 20 | ], 21 | server: { 22 | host: '0.0.0.0', 23 | port: parseInt(process.env.DOCS_DEV_PORT ?? '4000'), 24 | strictPort: true, 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Code Field Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## 5.0.1 - 2025.05.17 6 | ### Fixed 7 | * Field editor form no longer breaks when changing entry type with same named code field ([#16](https://github.com/nystudio107/craft-code-field/issues/16)) 8 | 9 | ## 5.0.0 - 2024.04.15 10 | ### Added 11 | * Stable release for Craft CMS 5 12 | 13 | ## 5.0.0-beta.3 - 2024.02.09 14 | ### Added 15 | * Added a custom Field icon 16 | 17 | ## 5.0.0-beta.2 - 2024.01.28 18 | ### Added 19 | * Add `phpstan` and `ecs` code linting 20 | * Add `code-analysis.yaml` GitHub action 21 | 22 | ### Changed 23 | * Remove `columnType` setting that is no longer applicable in Craft 5 24 | * Refactor `getContentColumnType()` -> `static dbType()` 25 | 26 | ## 5.0.0-beta.1 - 2024.01.15 27 | ### Added 28 | * Initial beta release 29 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "docs:build": "npm run docs:fix && npm run docs:lint && vitepress build docs", 5 | "docs:dev": "vitepress dev docs", 6 | "docs:fix": "textlint --fix ./docs/**/*.md", 7 | "docs:lint": "textlint ./docs/**/*.md" 8 | }, 9 | "devDependencies": { 10 | "@textlint-rule/textlint-rule-no-unmatched-pair": "^1.0.8", 11 | "@types/node": "^20.0.0", 12 | "@aminnairi/rollup-plugin-sitemap": "^0.1.0", 13 | "textlint": "^13.0.0", 14 | "textlint-filter-rule-comments": "^1.2.2", 15 | "textlint-rule-apostrophe": "^1.0.0", 16 | "textlint-rule-common-misspellings": "^1.0.1", 17 | "textlint-rule-diacritics": "^1.0.0", 18 | "textlint-rule-en-capitalization": "^2.0.2", 19 | "textlint-rule-stop-words": "^2.0.8", 20 | "textlint-rule-terminology": "^2.1.4", 21 | "textlint-rule-write-good": "^1.6.2", 22 | "vitepress": "^1.0.0-alpha.29" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | MAJOR_VERSION?=5 2 | PLUGINDEV_PROJECT_DIR?=/Users/andrew/webdev/sites/plugindev/cms_v${MAJOR_VERSION}/ 3 | VENDOR?=nystudio107 4 | PROJECT_PATH?=${VENDOR}/$(shell basename $(CURDIR)) 5 | 6 | .PHONY: dev docs release 7 | 8 | # Start up the buildchain dev server 9 | dev: 10 | # Start up the docs dev server 11 | docs: 12 | ${MAKE} -C docs/ dev 13 | # Run code quality tools, tests, and build the buildchain & docs in preparation for a release 14 | release: --code-quality --code-tests --buildchain-clean-build --docs-clean-build 15 | # The internal targets used by the dev & release targets 16 | --buildchain-clean-build: 17 | --code-quality: 18 | ${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- ecs check vendor/${PROJECT_PATH}/src --fix 19 | ${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- phpstan analyze -c vendor/${PROJECT_PATH}/phpstan.neon 20 | --code-tests: 21 | --docs-clean-build: 22 | ${MAKE} -C docs/ clean 23 | ${MAKE} -C docs/ image-build 24 | ${MAKE} -C docs/ fix 25 | -------------------------------------------------------------------------------- /src/gql/types/CodeDataType.php: -------------------------------------------------------------------------------- 1 | fieldName; 31 | return $source->$fieldName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) nystudio107 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /docs/docs/.vitepress/theme/index.ts: -------------------------------------------------------------------------------- 1 | import Theme from 'vitepress/theme' 2 | import {h, watch} from 'vue' 3 | import './custom.css' 4 | 5 | import NYSLogo from './NYSLogo.vue'; 6 | 7 | // Could also come from .env 8 | const GA_ID = 'UA-69117511-1'; 9 | 10 | export default { 11 | ...Theme, 12 | Layout() { 13 | return h(Theme.Layout, null, { 14 | 'aside-bottom': () => h(NYSLogo) 15 | } 16 | ) 17 | }, 18 | enhanceApp: (ctx) => { 19 | // Google analytics integration 20 | if (import.meta.env.PROD && GA_ID && typeof window !== 'undefined') { 21 | (function (i, s, o, g, r, a, m) { 22 | i['GoogleAnalyticsObject'] = r 23 | i[r] = i[r] || function () { 24 | (i[r].q = i[r].q || []).push(arguments) 25 | } 26 | i[r].l = 1 * new Date() 27 | a = s.createElement(o) 28 | m = s.getElementsByTagName(o)[0] 29 | a.async = 1 30 | a.src = g 31 | m.parentNode.insertBefore(a, m) 32 | })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga') 33 | ga('create', GA_ID, 'auto') 34 | ga('set', 'anonymizeIp', true) 35 | // Send a page view any time the route changes 36 | watch(ctx.router.route, (newValue, oldValue) => { 37 | ga('set', 'page', newValue.path) 38 | ga('send', 'pageview') 39 | }) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/quality-score.png?b=v5)](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/?branch=v5) [![Code Coverage](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/coverage.png?b=v5)](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/?branch=v5) [![Build Status](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/build.png?b=v5)](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/build-status/v5) [![Code Intelligence Status](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/code-intelligence.svg?b=v5)](https://scrutinizer-ci.com/code-intelligence) 2 | 3 | # Code Field plugin for Craft CMS 4 | 5 | Provides a Code Field that has a full-featured code editor with syntax highlighting & autocomplete 6 | 7 | ## Requirements 8 | 9 | This plugin requires Craft CMS 5.0.0 or later 10 | 11 | ## Installation 12 | 13 | To install the plugin, follow these instructions. 14 | 15 | 1. Open your terminal and go to your Craft project: 16 | 17 | cd /path/to/project 18 | 19 | 2. Then tell Composer to load the plugin: 20 | 21 | composer require nystudio107/craft-code-field 22 | 23 | 3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Code Field. 24 | 25 | ## Documentation 26 | 27 | Click here -> [Code Field Documentation](https://nystudio107.com/plugins/code-field/documentation) 28 | 29 | Brought to you by [nystudio107](http://nystudio107.com) 30 | -------------------------------------------------------------------------------- /src/validators/JsonValidator.php: -------------------------------------------------------------------------------- 1 | $attribute; 34 | $error = null; 35 | if (!empty($value) && is_string($value)) { 36 | $json = Json::decodeIfJson($value); 37 | if (!is_array($json)) { 38 | $error = Craft::t( 39 | 'codefield', 40 | 'This is not valid JSON', 41 | ); 42 | } 43 | } else { 44 | $error = Craft::t('codefield', 'Is not a string.'); 45 | } 46 | // If there's an error, add it to the model, and log it 47 | if ($error) { 48 | $model->addError($attribute, $error); 49 | Craft::error($error, __METHOD__); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/models/CodeData.php: -------------------------------------------------------------------------------- 1 | value; 44 | } 45 | 46 | /** 47 | * @inheritdoc 48 | */ 49 | public function init(): void 50 | { 51 | parent::init(); 52 | } 53 | 54 | /** 55 | * @inheritdoc 56 | */ 57 | public function rules(): array 58 | { 59 | $rules = parent::rules(); 60 | $rules = array_merge($rules, [ 61 | ['value', 'string'], 62 | ['language', 'string'], 63 | ]); 64 | 65 | return $rules; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nystudio107/craft-code-field", 3 | "description": "Provides a Code Field that has a full-featured code editor with syntax highlighting & autocomplete", 4 | "type": "craft-plugin", 5 | "version": "5.0.1", 6 | "keywords": [ 7 | "craft", 8 | "cms", 9 | "craftcms", 10 | "craft-plugin", 11 | "code field" 12 | ], 13 | "support": { 14 | "docs": "https://github.com/nystudio107/craft-code-field/blob/v5/README.md", 15 | "issues": "https://github.com/nystudio107/craft-code-field/issues" 16 | }, 17 | "license": "MIT", 18 | "authors": [ 19 | { 20 | "name": "nystudio107", 21 | "homepage": "https://nystudio107.com" 22 | } 23 | ], 24 | "require": { 25 | "php": "^8.2", 26 | "craftcms/cms": "^5.0.0", 27 | "nystudio107/craft-code-editor": "^1.0.23" 28 | }, 29 | "require-dev": { 30 | "craftcms/ecs": "dev-main", 31 | "craftcms/phpstan": "dev-main", 32 | "craftcms/rector": "dev-main" 33 | }, 34 | "scripts": { 35 | "phpstan": "phpstan --ansi --memory-limit=1G", 36 | "check-cs": "ecs check --ansi", 37 | "fix-cs": "ecs check --fix --ansi" 38 | }, 39 | "config": { 40 | "allow-plugins": { 41 | "craftcms/plugin-installer": true, 42 | "yiisoft/yii2-composer": true 43 | }, 44 | "optimize-autoloader": true, 45 | "sort-packages": true 46 | }, 47 | "autoload": { 48 | "psr-4": { 49 | "nystudio107\\codefield\\": "src/" 50 | } 51 | }, 52 | "extra": { 53 | "name": "Code Field", 54 | "handle": "codefield", 55 | "changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft-code-field/v5/CHANGELOG.md", 56 | "class": "nystudio107\\codefield\\CodeField" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /docs/docs/public/img/nys-logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/docs/.vitepress/config.ts: -------------------------------------------------------------------------------- 1 | import {defineConfig} from 'vitepress' 2 | 3 | export default defineConfig({ 4 | title: 'Code Field Plugin', 5 | description: 'Documentation for the Code Field plugin', 6 | base: '/docs/code-field/', 7 | lang: 'en-US', 8 | head: [ 9 | ['meta', {content: 'https://github.com/nystudio107', property: 'og:see_also',}], 10 | ['meta', {content: 'https://twitter.com/nystudio107', property: 'og:see_also',}], 11 | ['meta', {content: 'https://youtube.com/nystudio107', property: 'og:see_also',}], 12 | ['meta', {content: 'https://www.facebook.com/newyorkstudio107', property: 'og:see_also',}], 13 | ], 14 | themeConfig: { 15 | socialLinks: [ 16 | {icon: 'github', link: 'https://github.com/nystudio107'}, 17 | {icon: 'twitter', link: 'https://twitter.com/nystudio107'}, 18 | ], 19 | logo: '/img/plugin-logo.svg', 20 | editLink: { 21 | pattern: 'https://github.com/nystudio107/craft-code-field/edit/develop-v5/docs/docs/:path', 22 | text: 'Edit this page on GitHub' 23 | }, 24 | algolia: { 25 | appId: '74MFI8NU6J', 26 | apiKey: 'ed2e079bdbaa44b6b82eaad5a09db0e1', 27 | indexName: 'nystudio107-code-field', 28 | searchParameters: { 29 | facetFilters: ["version:v5"], 30 | }, 31 | }, 32 | lastUpdatedText: 'Last Updated', 33 | sidebar: [], 34 | nav: [ 35 | {text: 'Home', link: 'https://nystudio107.com/plugins/code-field'}, 36 | {text: 'Store', link: 'https://plugins.craftcms.com/codefield'}, 37 | {text: 'Changelog', link: 'https://nystudio107.com/plugins/code-field/changelog'}, 38 | {text: 'Issues', link: 'https://github.com/nystudio107/craft-code-field/issues'}, 39 | { 40 | text: 'v5', items: [ 41 | {text: 'v5', link: '/'}, 42 | {text: 'v4', link: 'https://nystudio107.com/docs/code-field/v4/'}, 43 | {text: 'v3', link: 'https://nystudio107.com/docs/code-field/v3/'}, 44 | ], 45 | }, 46 | ] 47 | }, 48 | }); 49 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | MAJOR_VERSION?=5 2 | TAG?=20-alpine 3 | CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-docs 4 | DOCS_DEV_PORT?=400${MAJOR_VERSION} 5 | DOCS_DEST?=../../../sites/nystudio107/web/docs/code-field 6 | IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG)) 7 | IMAGE_NAME=${CONTAINER}:${TAG} 8 | DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app 9 | 10 | .PHONY: build clean dev fix image-build image-check lint npm ssh 11 | 12 | # Perform a dist build via npm run docs:build 13 | build: image-check 14 | ${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:build 15 | rm -rf ${DOCS_DEST} 16 | mv ./docs/.vitepress/dist ${DOCS_DEST} 17 | # Remove node_modules/ & package-lock.json 18 | clean: 19 | rm -rf node_modules/ 20 | rm -f package-lock.json 21 | # Run the development server via npm run docs:dev 22 | dev: image-check 23 | ${DOCKER_RUN} --name ${CONTAINER}-$@ -e DOCS_DEV_PORT="${DOCS_DEV_PORT}" -p ${DOCS_DEV_PORT}:${DOCS_DEV_PORT} ${IMAGE_NAME} run docs:dev 24 | # Fix the docs with textlint via npm run docs:fix 25 | fix: image-check 26 | ${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:fix 27 | # Build the Docker image & run npm install 28 | image-build: 29 | docker build . -t ${IMAGE_NAME} --build-arg TAG=${TAG} --no-cache 30 | ${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} install 31 | # Ensure the image has been created 32 | image-check: 33 | ifeq ($(IMAGE_INFO), []) 34 | image-check: image-build 35 | endif 36 | # Lint the docs with textlint via npm run docs:lint 37 | lint: image-check 38 | ${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:lint 39 | # Run the passed in npm command 40 | npm: image-check 41 | ${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} $(filter-out $@,$(MAKECMDGOALS)) $(MAKEFLAGS) 42 | # Open a shell inside of the container 43 | ssh: image-check 44 | ${DOCKER_RUN} --name ${CONTAINER}-$@ --entrypoint=/bin/sh ${IMAGE_NAME} 45 | %: 46 | @: 47 | # ref: https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line 48 | -------------------------------------------------------------------------------- /src/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 11 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/docs/public/img/plugin-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 11 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/CodeField.php: -------------------------------------------------------------------------------- 1 | types[] = Code::class; 74 | } 75 | ); 76 | 77 | Event::on( 78 | Plugins::class, 79 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, 80 | function(PluginEvent $event) { 81 | if ($event->plugin === $this) { 82 | } 83 | } 84 | ); 85 | 86 | Craft::info( 87 | Craft::t( 88 | 'codefield', 89 | '{name} plugin loaded', 90 | ['name' => $this->name] 91 | ), 92 | __METHOD__ 93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/gql/types/generators/CodeDataGenerator.php: -------------------------------------------------------------------------------- 1 | [ 41 | 'name' => 'language', 42 | 'description' => 'The language of the Code Field', 43 | 'type' => Type::string(), 44 | ], 45 | 'value' => [ 46 | 'name' => 'value', 47 | 'description' => 'The data entered into the Code Field', 48 | 'type' => Type::string(), 49 | ], 50 | ]; 51 | $codeDataType = GqlEntityRegistry::getEntity($typeName) 52 | ?: GqlEntityRegistry::createEntity($typeName, new CodeDataType([ 53 | 'name' => $typeName, 54 | 'description' => 'This entity has all the CodeData properties', 55 | 'fields' => function() use ($codeDataFields) { 56 | return $codeDataFields; 57 | }, 58 | ])); 59 | 60 | TypeLoader::registerType($typeName, function() use ($codeDataType) { 61 | return $codeDataType; 62 | }); 63 | 64 | return [$codeDataType]; 65 | } 66 | 67 | /** 68 | * @inheritdoc 69 | */ 70 | public static function getName($context = null): string 71 | { 72 | /** @var Code $context */ 73 | return $context->handle . '_CodeData'; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/translations/en/codefield.php: -------------------------------------------------------------------------------- 1 | 'The text that will be shown if the code field is empty.', 18 | 'Available Languages' => 'Available Languages', 19 | 'Visual Studio Dark' => 'Visual Studio Dark', 20 | '{name} plugin loaded' => '{name} plugin loaded', 21 | 'Code Field Theme' => 'Code Field Theme', 22 | 'High Contrast Dark' => 'High Contrast Dark', 23 | 'Code' => 'Code', 24 | 'This is not valid JSON' => 'This is not valid JSON', 25 | 'Code Field Default Language' => 'Code Field Default Language', 26 | 'Language' => 'Language', 27 | 'Is not a string.' => 'Is not a string.', 28 | 'Placeholder Text' => 'Placeholder Text', 29 | 'The languages that should be listed in the language selector dropdown menu.' => 'The languages that should be listed in the language selector dropdown menu.', 30 | 'Visual Studio Light' => 'Visual Studio Light', 31 | 'Single Line Code Field' => 'Single Line Code Field', 32 | 'Show Language Dropdown with Field' => 'Show Language Dropdown with Field', 33 | 'Font Size' => 'Font Size', 34 | 'Code Folding' => 'Code Folding', 35 | 'Monaco Editor Settings Override' => 'Monaco Editor Settings Override', 36 | 'Line Numbers' => 'Line Numbers', 37 | 'The font size to use for the Code Field editor.' => 'The font size to use for the Code Field editor.', 38 | 'The language to use for the Code Field editor.' => 'The language to use for the Code Field editor.', 39 | 'The theme to use for the Code Field editor.' => 'The theme to use for the Code Field editor.', 40 | 'Auto' => 'Auto', 41 | 'CodeData failed validation: ' => 'CodeData failed validation: ', 42 | 'Default Value' => 'Default Value', 43 | 'The default value of the Code Field.' => 'The default value of the Code Field.', 44 | 'JSON blob of Monaco [EditorOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html) that will override the default settings.' => 'JSON blob of Monaco [EditorOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html) that will override the default settings.', 45 | 'The default value the Code Field will be populated with.' => 'The default value the Code Field will be populated with.', 46 | ]; 47 | -------------------------------------------------------------------------------- /src/templates/_components/fields/Code_input.twig: -------------------------------------------------------------------------------- 1 | {# 2 | /** 3 | * Code Field plugin for Craft CMS 4 | * 5 | * Code Field Input 6 | * 7 | * @author nystudio107 8 | * @copyright Copyright (c) 2022 nystudio107 9 | * @link https://nystudio107.com 10 | * @package CodeField 11 | * @since 4.0.0 12 | */ 13 | #} 14 | 15 | {% import "_includes/forms" as forms %} 16 | {% import "codeeditor/codeEditor" as codeEditor %} 17 | 18 | {% set codeFieldId = id ?? field.getInputId() %} 19 | {% set config = { 20 | id: codeFieldId ~ "value", 21 | name: name ~ "[value]", 22 | describedBy: field.describedBy, 23 | placeholder: field.placeholder ?? "", 24 | required: field.required, 25 | first: true, 26 | orientation: orientation ?? null, 27 | value: value.value, 28 | } %} 29 | 30 | {# Monaco Editor options #} 31 | {% set monacoOptions = { 32 | theme: field.theme, 33 | language: value.language, 34 | fontSize: field.fontSize, 35 | } %} 36 | {% if not field.singleLineEditor %} 37 | {% if field.lineNumbers %} 38 | {% set monacoOptions = monacoOptions | merge({ 39 | lineNumbers: 'on', 40 | lineDecorationsWidth: 6, 41 | }) %} 42 | {% endif %} 43 | {% if field.codeFolding %} 44 | {% set monacoOptions = monacoOptions | merge({ 45 | folding: true, 46 | }) %} 47 | {% endif %} 48 | {% endif %} 49 | {% set monacoOptions = monacoOptions | merge(monacoOptionsOverride) %} 50 | {# Code Editor options #} 51 | {% set codeEditorOptions = { 52 | wrapperClass: "monaco-editor-background-frame", 53 | singleLineEditor: field.singleLineEditor, 54 | } %} 55 | {% if displayLanguages | length %} 56 |
57 | {% endif %} 58 | {% if field.singleLineEditor %} 59 | {{ codeEditor.textField(config, "CodeEditor", monacoOptions, codeEditorOptions) }} 60 | {% else %} 61 | {{ codeEditor.textareaField(config, "CodeEditor", monacoOptions, codeEditorOptions) }} 62 | {% endif %} 63 | 64 | {% if displayLanguages | length %} 65 | {% set languageSwitcherId = codeFieldId ~ "language" %} 66 | {{ forms.selectField({ 67 | id: languageSwitcherId, 68 | name: codeFieldId ~ "[language]", 69 | label: "Language"|t("codefield"), 70 | value: value.language, 71 | options: displayLanguages, 72 | }) }} 73 |
74 | {% js %} 75 | var elementId = '{{ config.id | namespaceInputId }}'; 76 | var switchId = '{{ languageSwitcherId | namespaceInputId }}'; 77 | $('#' + switchId).on('change', function () { 78 | var language = $(this).val(); 79 | var editor = monacoEditorInstances[elementId]; 80 | setMonacoEditorLanguage(editor, language, elementId); 81 | }); 82 | {% endjs %} 83 | {% endif %} 84 | -------------------------------------------------------------------------------- /src/fields/MonacoLanguages.php: -------------------------------------------------------------------------------- 1 | 'abap', 'label' => 'Abap'], 5 | ['value' => 'aes', 'label' => 'Aes'], 6 | ['value' => 'apex', 'label' => 'Apex'], 7 | ['value' => 'azcli', 'label' => 'Azure CLI'], 8 | ['value' => 'bat', 'label' => 'BAT'], 9 | ['value' => 'bicep', 'label' => 'Bicep'], 10 | ['value' => 'c', 'label' => 'C'], 11 | ['value' => 'cameligo', 'label' => 'Cameligo'], 12 | ['value' => 'clojure', 'label' => 'Clojure'], 13 | ['value' => 'coffeescript', 'label' => 'CoffeeScript'], 14 | ['value' => 'cpp', 'label' => 'C++'], 15 | ['value' => 'csharp', 'label' => 'C#'], 16 | ['value' => 'csp', 'label' => 'CSP'], 17 | ['value' => 'css', 'label' => 'CSS'], 18 | ['value' => 'cypher', 'label' => 'Cypher'], 19 | ['value' => 'dart', 'label' => 'Dart'], 20 | ['value' => 'dockerfile', 'label' => 'Dockerfile'], 21 | ['value' => 'ecl', 'label' => 'ECL'], 22 | ['value' => 'elixir', 'label' => 'Elixir'], 23 | ['value' => 'flow9', 'label' => 'Flow9'], 24 | ['value' => 'freemarker2', 'label' => 'Freemarker2'], 25 | ['value' => 'fsharp', 'label' => 'F#'], 26 | ['value' => 'go', 'label' => 'Go'], 27 | ['value' => 'graphql', 'label' => 'GraphQL'], 28 | ['value' => 'handlebars', 'label' => 'Handlebars'], 29 | ['value' => 'hcl', 'label' => 'HCL'], 30 | ['value' => 'html', 'label' => 'HTML'], 31 | ['value' => 'ini', 'label' => 'INI'], 32 | ['value' => 'java', 'label' => 'Java'], 33 | ['value' => 'javascript', 'label' => 'JavaScript'], 34 | ['value' => 'json', 'label' => 'JSON'], 35 | ['value' => 'julia', 'label' => 'Julia'], 36 | ['value' => 'kotlin', 'label' => 'Kotlin'], 37 | ['value' => 'less', 'label' => 'Less'], 38 | ['value' => 'lexon', 'label' => 'Lexon'], 39 | ['value' => 'liquid', 'label' => 'Liquid'], 40 | ['value' => 'lua', 'label' => 'Lua'], 41 | ['value' => 'm3', 'label' => 'M3'], 42 | ['value' => 'markdown', 'label' => 'Markdown'], 43 | ['value' => 'mips', 'label' => 'Mips'], 44 | ['value' => 'msdax', 'label' => 'MsDax'], 45 | ['value' => 'mysql', 'label' => 'MySQL'], 46 | ['value' => 'objective-c', 'label' => 'Objective-C'], 47 | ['value' => 'pascal', 'label' => 'Pascal'], 48 | ['value' => 'pascaligo', 'label' => 'Pascaligo'], 49 | ['value' => 'perl', 'label' => 'Perl'], 50 | ['value' => 'pgsql', 'label' => 'PgSQL'], 51 | ['value' => 'php', 'label' => 'PHP'], 52 | ['value' => 'pla', 'label' => 'PLA'], 53 | ['value' => 'plaintext', 'label' => 'Plain Text'], 54 | ['value' => 'postiats', 'label' => 'Pstiats'], 55 | ['value' => 'powerquery', 'label' => 'PowerQuery'], 56 | ['value' => 'powershell', 'label' => 'PowerShell'], 57 | ['value' => 'proto', 'label' => 'Proto'], 58 | ['value' => 'pug', 'label' => 'Pug'], 59 | ['value' => 'python', 'label' => 'Python'], 60 | ['value' => 'qsharp', 'label' => 'Q#'], 61 | ['value' => 'r', 'label' => 'R'], 62 | ['value' => 'razor', 'label' => 'Razor'], 63 | ['value' => 'redis', 'label' => 'Redis'], 64 | ['value' => 'redshift', 'label' => 'Redshift'], 65 | ['value' => 'restructuredtext', 'label' => 'Restructured Text'], 66 | ['value' => 'ruby', 'label' => 'Ruby'], 67 | ['value' => 'rust', 'label' => 'Rust'], 68 | ['value' => 'sb', 'label' => 'SB'], 69 | ['value' => 'scala', 'label' => 'Scala'], 70 | ['value' => 'scheme', 'label' => 'Scheme'], 71 | ['value' => 'scss', 'label' => 'SCSS'], 72 | ['value' => 'shell', 'label' => 'Shell'], 73 | ['value' => 'sol', 'label' => 'Sol'], 74 | ['value' => 'sparql', 'label' => 'SparQL'], 75 | ['value' => 'sql', 'label' => 'SQL'], 76 | ['value' => 'st', 'label' => 'ST'], 77 | ['value' => 'swift', 'label' => 'Swift'], 78 | ['value' => 'systemverilog', 'label' => 'System Verilog'], 79 | ['value' => 'tcl', 'label' => 'TCL'], 80 | ['value' => 'twig', 'label' => 'Twig'], 81 | ['value' => 'typescript', 'label' => 'TypeScript'], 82 | ['value' => 'vb', 'label' => 'Visual Basic'], 83 | ['value' => 'verilog', 'label' => 'Verilog'], 84 | ['value' => 'xml', 'label' => 'XML'], 85 | ['value' => 'yaml', 'label' => 'YAML'], 86 | ]; 87 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # `code-field` docs 2 | 3 | This buildchain is a self-contained build system for the `code-field` documentation. 4 | 5 | ## Overview 6 | 7 | The buildchain uses [VitePress](https://vitepress.dev/) via a Docker container to facilitate writing the docs as [markdown](https://vitepress.dev/guide/markdown), linting them via [textlint](https://textlint.github.io/), building them as HTML files with bundled assets, and publishing them automatically via a [GitHub action](https://docs.github.com/en/actions). 8 | 9 | It also uses a [Rollup](https://rollupjs.org/) [sitemap plugin](https://github.com/aminnairi/rollup-plugin-sitemap) to generate a `sitemap.xml` for the generated docs. 10 | 11 | The markdown sources for the docs and assets are in the `docs/docs/` directory. 12 | 13 | The built distribution docs are created via the `build-and-deploy-docs.yaml` 14 | 15 | ## Prerequisites 16 | 17 | To run the buildchain for development purposes: 18 | 19 | - You must have [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or the equivalent) installed 20 | 21 | ## Commands 22 | 23 | This buildchain uses `make` as an interface to the buildchain. The following commands are available from the `buildchain/` directory: 24 | 25 | - `make image-build` - Build the Docker image & run `npm install`. This command must be run once before using the Docker container. 26 | - `make dev` - Start Vite HMR dev server while writing/editing the docs. Click on the link displayed in the terminal to open the docs up 27 | - `make lint` - Run `textlint` on the docs, reporting on any errors and warnings 28 | - `make fix` - Run `textlint` on the docs, automatically fixing any errors, and reporting any warnings 29 | - `make clean` - Remove `node_modules/` and `package-lock.json` to start clean (need to run `make image-build` after doing this, see below) 30 | - `make npm XXX` - Run an `npm` command inside the container, e.g.: `make npm run lint` or `make npm install` 31 | - `make ssh` - Open up a shell session into the buildchain Docker container 32 | - `make build` - Do a local distribution build of the docs; normally not needed since they are built & deployed via GitHub action 33 | 34 | ## Docs versioning 35 | 36 | Each major version of the plugin corresponds to a major version of Craft. 37 | 38 | Each major version of the plugin has separate documentation that needs to be updated when changes span plugin versions. 39 | 40 | The latest version of the docs that correspond to the latest version of the plugin is always the root of the docs tree, with older versions appearing in sub-directories: 41 | 42 | ``` 43 | │ index.html 44 | ├── v4 45 | │ └── index.html 46 | ├── v3 47 | │ └── index.html 48 | ``` 49 | 50 | The docs are entirely separate, but linked to eachother via a version menu, configured in the `docs/docs/.vitepress/config.ts` file. 51 | 52 | ## Algolia Docsearch 53 | 54 | The docs uses [Algolia Docsearch](https://docsearch.algolia.com/) to index them, and allow for easy searching via a search field with auto-complete. 55 | 56 | Algolia Docsearch is configured in the `docs/docs/.vitepress/config.ts` file. 57 | 58 | ## textlint 59 | 60 | The buildchain uses [textlint](https://textlint.github.io/) to automatically fix errors on build, and also issue writing style warnings. 61 | 62 | `textlint` automatically uses any rules added to the `docs/package.json` file, which can be overridden or customized via the `docs/.textlintrc.js` file. 63 | 64 | See the [textlint docs](https://textlint.github.io/docs/getting-started.html) for details. 65 | 66 | ## Overriding environment variables 67 | 68 | The `Makefile` contains sane defaults for most things, but you can override them via environment variables if you need to. 69 | 70 | For instance, if you want to change the `DOCS_DEST` environment variable to change where `make build` builds the docs locally, you can set it before running any buildchain `make` commands: 71 | ```bash 72 | env DOCS_DEST=../path/to/some/dir make build 73 | ``` 74 | ...or use any other method for [setting environment variables](https://www.twilio.com/blog/how-to-set-environment-variables.html). This environment variable needs to be set in the shell where you run the buildchain's various `make` commands from, so setting it in your project's `.env` file won't work. 75 | -------------------------------------------------------------------------------- /src/templates/_components/fields/Code_settings.twig: -------------------------------------------------------------------------------- 1 | {# @var craft \craft\web\twig\variables\CraftVariable #} 2 | {# 3 | /** 4 | * Code Field plugin for Craft CMS 5 | * 6 | * Code Field Settings 7 | * 8 | * @author nystudio107 9 | * @copyright Copyright (c) 2022 nystudio107 10 | * @link https://nystudio107.com 11 | * @package CodeField 12 | * @since 4.0.0 13 | */ 14 | #} 15 | 16 | {% import "_includes/forms" as forms %} 17 | {% import "codeeditor/codeEditor" as codeEditor %} 18 | 19 | {{ forms.selectField({ 20 | label: "Code Field Theme"|t("codefield"), 21 | instructions: "The theme to use for the Code Field editor."|t("codefield"), 22 | id: "theme", 23 | name: "theme", 24 | value: field.theme, 25 | options: [ 26 | { value: "auto", label: "Auto"|t("codefield") }, 27 | { value: "vs", label: "Visual Studio Light"|t("codefield") }, 28 | { value: "vs-dark", label: "Visual Studio Dark"|t("codefield") }, 29 | { value: "hc-black", label: "High Contrast Dark"|t("codefield") }, 30 | ], 31 | errors: field.getErrors("theme") 32 | }) }} 33 | 34 | {{ forms.selectField({ 35 | label: "Code Field Default Language"|t("codefield"), 36 | instructions: "The language to use for the Code Field editor."|t("codefield"), 37 | id: "language", 38 | name: "language", 39 | value: field.language, 40 | options: monacoLanguages, 41 | errors: field.getErrors("language") 42 | }) }} 43 | 44 | {{ forms.selectField({ 45 | label: "Font Size"|t("codefield"), 46 | instructions: "The font size to use for the Code Field editor."|t("codefield"), 47 | id: "fontSize", 48 | name: "fontSize", 49 | value: field.fontSize, 50 | options: [ 51 | {value: 6, label: "6"}, 52 | {value: 7, label: "7"}, 53 | {value: 8, label: "8"}, 54 | {value: 9, label: "9"}, 55 | {value: 10, label: "10"}, 56 | {value: 11, label: "11"}, 57 | {value: 12, label: "12"}, 58 | {value: 13, label: "13"}, 59 | {value: 14, label: "14"}, 60 | {value: 15, label: "15"}, 61 | {value: 16, label: "16"}, 62 | {value: 17, label: "17"}, 63 | {value: 18, label: "18"}, 64 | {value: 19, label: "19"}, 65 | {value: 20, label: "20"}, 66 | {value: 21, label: "21"}, 67 | {value: 22, label: "22"}, 68 | {value: 23, label: "23"}, 69 | {value: 24, label: "24"}, 70 | ], 71 | errors: field.getErrors("fontSize") 72 | }) }} 73 | 74 | {{ forms.checkboxField({ 75 | label: "Single Line Code Field"|t("codefield"), 76 | id: "singleLineEditor", 77 | name: "singleLineEditor", 78 | checked: field.singleLineEditor, 79 | reverseToggle: "codeDisplayOptions", 80 | errors: field.getErrors("singleLineEditor") 81 | }) }} 82 | 83 |
84 | {{ forms.checkboxField({ 85 | label: "Line Numbers"|t("codefield"), 86 | id: "lineNumbers", 87 | name: "lineNumbers", 88 | checked: field.lineNumbers, 89 | errors: field.getErrors("lineNumbers") 90 | }) }} 91 | 92 | {{ forms.checkboxField({ 93 | label: "Code Folding"|t("codefield"), 94 | id: "codeFolding", 95 | name: "codeFolding", 96 | checked: field.codeFolding, 97 | errors: field.getErrors("codeFolding") 98 | }) }} 99 |
100 | 101 | {{ forms.textField({ 102 | label: "Placeholder Text"|t("codefield"), 103 | instructions: "The text that will be shown if the code field is empty."|t("codefield"), 104 | id: "placeholder", 105 | name: "placeholder", 106 | value: field.placeholder, 107 | errors: field.getErrors("placeholder") 108 | }) }} 109 | 110 | {{ forms.checkboxField({ 111 | label: "Show Language Dropdown with Field"|t("codefield"), 112 | id: "showLanguageDropdown", 113 | name: "showLanguageDropdown", 114 | checked: field.showLanguageDropdown, 115 | errors: field.getErrors("showLanguageDropdown") 116 | }) }} 117 | 118 | {{ codeEditor.textAreaField({ 119 | label: "Default Value"|t("codefield"), 120 | instructions: "The default value the Code Field will be populated with."|t("codefield"), 121 | id: "defaultValue", 122 | name: "defaultValue", 123 | value: field.defaultValue, 124 | errors: field.getErrors("defaultValue") 125 | }, "CodeField", {language: field.language}, {wrapperClass: "monaco-editor-background-frame"}) }} 126 | 127 |
128 | 129 | {{ "Available Languages"|t("codefield") }} 130 | 142 | 143 |
144 | {{ "Advanced"|t("app") }} 145 |
146 | {{ codeEditor.textAreaField({ 147 | label: "Monaco Editor Settings Override"|t("codefield"), 148 | instructions: "JSON blob of Monaco [EditorOptions](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html) that will override the default settings."|t("codefield"), 149 | id: "monacoEditorOptions", 150 | name: "monacoEditorOptions", 151 | value: field.monacoEditorOptions, 152 | errors: field.getErrors("monacoEditorOptions") 153 | }, "CodeField", {language: "json"}, {wrapperClass: "monaco-editor-background-frame"}) }} 154 |
155 | 156 | {% js %} 157 | // Add schema definitions for this JSON editor field 158 | var jsonSchemaUri = 'https://craft-code-editor.com/{{ "monacoEditorOptions"|namespaceInputId }}'; 159 | var jsonSchema = { 160 | uri: jsonSchemaUri, 161 | fileMatch: [jsonSchemaUri], 162 | schema: {{ optionsSchema | raw }} 163 | } 164 | // configure the JSON language support with schemas and schema associations 165 | monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ 166 | validate: true, 167 | schemas: [jsonSchema] 168 | }); 169 | {% endjs %} 170 | -------------------------------------------------------------------------------- /docs/docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Code Field plugin for Craft CMS 3 | sidebar: false 4 | 5 | description: Documentation for the Code Field plugin. The Code Field plugin provides a Code Field that has a full-featured code editor with syntax highlighting & autocomplete 6 | --- 7 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/quality-score.png?b=v5)](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/?branch=v5) [![Code Coverage](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/coverage.png?b=v5)](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/?branch=v5) [![Build Status](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/build.png?b=v5)](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/build-status/v5) [![Code Intelligence Status](https://scrutinizer-ci.com/g/nystudio107/craft-code-field/badges/code-intelligence.svg?b=v5)](https://scrutinizer-ci.com/code-intelligence) 8 | 9 | # Code Field plugin for Craft CMS 10 | 11 | Provides a Code Field that has a full-featured code editor with syntax highlighting & autocomplete 12 | 13 | ![Screenshot](./resources/img/plugin-logo.png) 14 | 15 | ## Requirements 16 | 17 | This plugin requires Craft CMS 5.0.0 or later 18 | 19 | ## Installation 20 | 21 | To install the plugin, follow these instructions. 22 | 23 | 1. Open your terminal and go to your Craft project: 24 | 25 | cd /path/to/project 26 | 27 | 2. Then tell Composer to load the plugin: 28 | 29 | composer require nystudio107/craft-code-field 30 | 31 | 3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Code Field. 32 | 33 | ## Code Field Overview 34 | 35 | Code Field is a Craft CMS field type that uses the [craft-code-editor](https://github.com/nystudio107/craft-code-editor) package to provide a modern code editor for content authors. 36 | 37 | Code Field uses the [Monaco editor](https://microsoft.github.io/monaco-editor/) that leverages the same core code that the popular [VS Code](https://code.visualstudio.com/) editor uses. 38 | 39 | That means it provides code highlighting, syntax checking, and autocompletion for over 80 languages. 40 | 41 | ![JavaScript](./resources/screenshots/code-field-javascript-autocomplete.png) 42 | 43 | It also has light, dark, and high contrast themes that can be chosen on a per-field basis. 44 | 45 | ![CSS](./resources/screenshots/code-field-css-picker.png) 46 | 47 | It also sports as a variety of editor options such as font size, line numbers, code folding, and more. 48 | 49 | ![Markdown](./resources/screenshots/code-field-markdown.png) 50 | 51 | ## Configuring Code Field 52 | 53 | Once the Code Editor plugin is installed, it provides a **Code** field type that you can create like any other Craft CMS field. 54 | 55 | You can configure each field with its own discrete settings: 56 | 57 | ![Code Field Settings](./resources/screenshots/code-field-settings.png) 58 | 59 | * **Code Field Theme** - The theme to use for the Code Field editor. It can be either Auto, Visual Studio Light, Visual Studio Dark, or High Contrast Dark. **Auto** will set the light/dark theme based on browser light/dark mode. **N.B.:** The Monaco editor [allows only one theme per page](https://github.com/microsoft/monaco-editor/issues/338) so you can’t have different editor instances using different themes. 60 | * **Code Field Default Language** - The language to use for the Code Field editor. This can optionally be changed by content authors while using the field (see below) 61 | * **Font Size** - The font size to use for the Code Field editor 62 | * **Single Line Code Field** - Whether the editor should behave like a Craft field that can be tabbed between, and displays as a single line, with no line breaks. 63 | * **Line Numbers** - Whether line numbers should be displayed in the Code Field editor. 64 | * **Code Folding** - Whether code folding controls should be displayed in the Code Field editor margins. 65 | * **Placeholder Text** - The text that will be shown if the Code Field is empty. 66 | * **Show Language Dropdown with Field** - Whether content authors should have a Language dropdown menu available to them under the Code Field editor when editing an entry. 67 | * **Default Value** - The default value the Code Field will be populated with. 68 | 69 | ### Available Languages 70 | 71 | Clicking on **Available Languages** discloses a list of over 80 languages: 72 | 73 | ![Markdown](./resources/screenshots/code-field-languages.png) 74 | 75 | Check the languages that you want to appear in the **Language** dropdown menu that is optionally displayed under the Code Field editor when editing an entry. 76 | 77 | This lets you limit the languages available to content authors to a subset of all of the available languages. 78 | 79 | ### Advanced 80 | 81 | Clicking on **Advanced** discloses a **Monaco Editor Settings Override** field: 82 | 83 | ![Markdown](./resources/screenshots/code-field-options-override.png) 84 | 85 | This allows you to override any of the Monaco [EditorOptions](https://microsoft.github.io/monaco-editor/typedoc/enums/editor.EditorOption.html) settings via a JSON blob configuration. 86 | 87 | Using this, you can control every aspect of the Code Field editor. 88 | 89 | This field uses a Code Editor field itself, with a JSON schema for the Monaco [`IEditorOptions`](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html), so you get autocomplete and hovers here, too! 90 | 91 | ## Converting Existing Fields 92 | 93 | You can convert existing Craft CMS [Plain Text](https://craftcms.com/docs/4.x/plain-text-fields.html) fields, [Code Mirror](https://plugins.craftcms.com/code-mirror) fields, [Simple Text](https://plugins.craftcms.com/simple-text) fields, or other text/code fields to Code Field fields just by changing the field type to **Code**. 94 | 95 | All of your existing content will be left intact after converting them over. 96 | 97 | ## Using Code Field 98 | 99 | Use the Code Field as you would any other Craft CMS field. 100 | 101 | To output the contents of the field on the frontend, simply do: 102 | 103 | ```twig 104 | {{ entry.someCode.value | raw }} 105 | ``` 106 | 107 | To know the language or other settings for the Code Field editor, you can get that as well: 108 | 109 | ```twig 110 | {# Do whatever you need to do for this language #} 111 | {% if entry.someCode.language == "javascript" %} 112 |

This is JavaScript!

113 | {% endif %} 114 | {# Output the code #} 115 |
{{ entry.someCode.value | raw }}
116 | ``` 117 | 118 | This will not result in any formatting of syntax highlighting of the code on the frontend; that’s up to you to do as you see fit (using [Shiki](https://shiki.matsu.io/), [highlight.js](https://highlightjs.org/), [Prism](https://prismjs.com/), etc.). 119 | 120 | ### Rendering with Syntax Highlighting 121 | 122 | However, you can also use the [craft-code-editor](https://github.com/nystudio107/craft-code-editor#in-frontend-templates) Twig macros directly to display the Code Field editor on the frontend. 123 | 124 | The following `monacoOptions` allow you to make the field read-only (though the user can still interact with the code): 125 | ```json 126 | { 127 | "domReadOnly": true, 128 | "readOnly": true 129 | } 130 | ``` 131 | 132 | So putting it together, if your Code Field field handle is `someCode`, this would allow you to display it on the frontend with full syntax highlighting, etc.: 133 | 134 | ```twig 135 | {% import "codeeditor/codeEditor" as codeEditor %} 136 | 137 |
138 | 139 |
140 | {{ codeEditor.includeJs("myCodeEditor", "Frontend Editor", { 141 | language: entry.someCode.language, 142 | theme: "auto", 143 | "domReadOnly": true, 144 | "readOnly": true 145 | }) }} 146 | ``` 147 | 148 | ...and it will look something like this: 149 | 150 | ![Frontend Read Only](./resources/screenshots/code-field-frontend-read-only.png) 151 | 152 | If you want Twig & Craft API autocompletes to work on the frontend, you’ll need to enable the [`allowFrontendAccess`](https://github.com/nystudio107/craft-code-editor#in-frontend-templates) setting in `craft-code-editor`, but this isn’t necessary if the code is just for display purposes. 153 | 154 | ### Rendering Twig Code Output 155 | 156 | If you are storing Twig code, you can actually render that on the frontend using [renderObjectTemplate](https://craftcms.com/docs/4.x/dev/functions.html#renderobjecttemplate) if you like: 157 | 158 | ```twig 159 | {{ renderObjectTemplate(entry.someCode.value, entry) }} 160 | ``` 161 | 162 | ## Advanced Usage 163 | 164 | ### GraphQL 165 | 166 | Code Field supports GraphQL, here’s an example query: 167 | 168 | ```GraphQL 169 | { 170 | entries(section: "blog", limit:1) { 171 | ...on blog_blog_Entry { 172 | title, 173 | someCode { 174 | language, 175 | value 176 | } 177 | } 178 | } 179 | } 180 | ``` 181 | 182 | In this example, `someCode` is the Code Field field handle. The schema supports the following parameters: 183 | 184 | * **`language`** - The language of the Code Field 185 | * **`value`** - The data entered into the Code Field 186 | 187 | Here’s an example of the data returned from the above query: 188 | 189 | ```json 190 | { 191 | "data": { 192 | "entries": [ 193 | { 194 | "title": "My first blog", 195 | "someCode": { 196 | "language": "typescript", 197 | "value": "function createQuote(quote, callback){ \r\n var myQuote = \"Like I always say, \" + quote;\r\n callback(myQuote); // 2\r\n}\r\n\r\nfunction logQuote(quote: string){\r\n console.log(quote);\r\n}\r\n\r\ncreateQuote(\"eat your vegetables!\", logQuote); // 1" 198 | } 199 | } 200 | ] 201 | } 202 | } 203 | ``` 204 | 205 | ## Code Field Roadmap 206 | 207 | Some things to do, and ideas for potential features: 208 | 209 | * Add a default value for the field in Field Settings 210 | * Provide support for additional third-party themes 211 | * Add a setting to turn off the display of the language icon 212 | 213 | Brought to you by [nystudio107](https://nystudio107.com) 214 | -------------------------------------------------------------------------------- /src/fields/Code.php: -------------------------------------------------------------------------------- 1 | $this->defaultValue, 170 | 'language' => $this->language, 171 | ]; 172 | // Handle incoming values potentially being JSON or an array 173 | if (!empty($value)) { 174 | // Handle JSON-encoded values coming in 175 | if (is_string($value)) { 176 | $jsonValue = Json::decodeIfJson($value); 177 | // If this is still a string (meaning it's not valid JSON), treat it as the value 178 | if (is_string($jsonValue)) { 179 | $config['value'] = $jsonValue; 180 | } 181 | if (is_array($jsonValue)) { 182 | // Check to make sure the array returned is an encoded `CodeData` config, with exactly 183 | // the same expected key/value pairs 184 | if (!array_diff_key($config, $jsonValue) && !array_diff_key($jsonValue, $config)) { 185 | $value = $jsonValue; 186 | } else { 187 | // Otherwise treat it as JSON data 188 | $value = [ 189 | 'value' => $value, 190 | 'language' => 'json', 191 | ]; 192 | } 193 | } 194 | } 195 | if (is_array($value)) { 196 | $config = array_merge($config, array_filter($value)); 197 | } 198 | } 199 | // Create and validate the model 200 | $codeData = new CodeData($config); 201 | if (!$codeData->validate()) { 202 | Craft::error( 203 | Craft::t('codefield', 'CodeData failed validation: ') 204 | . print_r($codeData->getErrors(), true), 205 | __METHOD__ 206 | ); 207 | } 208 | 209 | return $codeData; 210 | } 211 | 212 | /** 213 | * @inheritdoc 214 | */ 215 | public function getSettingsHtml(): ?string 216 | { 217 | $monacoLanguages = require(__DIR__ . '/MonacoLanguages.php'); 218 | $schemaFilePath = Craft::getAlias('@nystudio107/codefield/resources/IEditorOptionsSchema.json'); 219 | $optionsSchema = @file_get_contents($schemaFilePath) ?: ''; 220 | // Render the settings template 221 | return Craft::$app->getView()->renderTemplate( 222 | 'codefield/_components/fields/Code_settings', 223 | [ 224 | 'field' => $this, 225 | 'monacoLanguages' => $monacoLanguages, 226 | 'optionsSchema' => $optionsSchema, 227 | ] 228 | ); 229 | } 230 | 231 | /** 232 | * @inheritdoc 233 | */ 234 | public function getInputHtml($value, ElementInterface $element = null): string 235 | { 236 | $twigVariables = $this->getFieldRenderVariables($value, $element, true); 237 | // Render the input template 238 | return Craft::$app->getView()->renderTemplate( 239 | 'codefield/_components/fields/Code_input', 240 | $twigVariables 241 | ); 242 | } 243 | 244 | /** 245 | * @inheritdoc 246 | */ 247 | public function getStaticHtml(mixed $value, ElementInterface $element): string 248 | { 249 | $twigVariables = $this->getFieldRenderVariables($value, $element, false); 250 | // Render the input template 251 | return Craft::$app->getView()->renderTemplate( 252 | 'codefield/_components/fields/Code_input', 253 | $twigVariables 254 | ); 255 | } 256 | 257 | /** 258 | * @inheritdoc 259 | */ 260 | public function getContentGqlType(): Type|array 261 | { 262 | $typeArray = CodeDataGenerator::generateTypes($this); 263 | 264 | return [ 265 | 'name' => $this->handle, 266 | 'description' => 'Code Editor field', 267 | 'type' => array_shift($typeArray), 268 | ]; 269 | } 270 | 271 | /** 272 | * @inheritdoc 273 | */ 274 | public function rules(): array 275 | { 276 | $rules = parent::rules(); 277 | return array_merge($rules, [ 278 | ['theme', 'in', 'range' => ['auto', 'vs', 'vs-dark', 'hc-black']], 279 | ['theme', 'default', 'value' => 'auto'], 280 | ['language', 'string'], 281 | ['language', 'default', 'value' => 'javascript'], 282 | [['singleLineEditor', 'showLanguageDropdown', 'lineNumbers', 'codeFolding'], 'boolean'], 283 | ['placeholder', 'string'], 284 | ['placeholder', 'default', 'value' => ''], 285 | ['fontSize', 'integer'], 286 | ['fontSize', 'default', 'value' => 14], 287 | ['availableLanguages', ArrayValidator::class], 288 | ['monacoEditorOptions', JsonValidator::class], 289 | ]); 290 | } 291 | 292 | // Protected Methods 293 | // ========================================================================= 294 | 295 | /** 296 | * Return the Twig variables for rendering the field 297 | * 298 | * @param $value 299 | * @param ElementInterface $element 300 | * @param bool $enabled Whether the field is enabled or not 301 | * @return array[] 302 | */ 303 | protected function getFieldRenderVariables($value, ElementInterface $element, bool $enabled): array 304 | { 305 | // Get our id and namespace 306 | $id = Html::id($this->handle); 307 | $namespacedId = Craft::$app->getView()->namespaceInputId($id); 308 | 309 | // Extract just the languages that have been selected for display 310 | $displayLanguages = []; 311 | if ($this->showLanguageDropdown) { 312 | $monacoLanguages = require(__DIR__ . '/MonacoLanguages.php'); 313 | $decomposedLanguages = array_column($monacoLanguages, 'label', 'value'); 314 | $displayLanguages = array_intersect_key($decomposedLanguages, array_flip($this->availableLanguages)); 315 | // Handle "all" checkbox 316 | if ($this->availableLanguages[0] === '*') { 317 | $displayLanguages = $decomposedLanguages; 318 | } 319 | $displayLanguages = array_map(static function($k, $v) { 320 | return ['value' => $k, 'label' => $v]; 321 | }, array_keys($displayLanguages), array_values($displayLanguages)); 322 | } 323 | $monacoOptionsOverride = Json::decodeIfJson($this->monacoEditorOptions); 324 | if ($monacoOptionsOverride === null || is_string($monacoOptionsOverride)) { 325 | $monacoOptionsOverride = []; 326 | } 327 | // Disable the Monaco editor 328 | if (!$enabled) { 329 | $monacoOptionsOverride['domReadOnly'] = true; 330 | $monacoOptionsOverride['readOnly'] = true; 331 | } 332 | return [ 333 | 'name' => $this->handle, 334 | 'value' => $value, 335 | 'field' => $this, 336 | 'orientation' => $this->getOrientation($element), 337 | 'id' => $id, 338 | 'namespacedId' => $namespacedId, 339 | 'displayLanguages' => $displayLanguages, 340 | 'monacoOptionsOverride' => $monacoOptionsOverride, 341 | ]; 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /src/resources/IEditorOptionsSchema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "acceptSuggestionOnCommitCharacter": { 5 | "default": true, 6 | "description": "Accept suggestions on provider defined characters. Defaults to true.", 7 | "type": "boolean" 8 | }, 9 | "acceptSuggestionOnEnter": { 10 | "default": "on", 11 | "description": "Accept suggestions on ENTER. Defaults to 'on'.", 12 | "enum": [ 13 | "on", 14 | "off", 15 | "smart" 16 | ], 17 | "type": "string" 18 | }, 19 | "accessibilityPageSize": { 20 | "default": 3, 21 | "description": "Controls the number of lines in the editor that can be read out by a screen reader", 22 | "type": "number" 23 | }, 24 | "accessibilitySupport": { 25 | "default": "auto", 26 | "description": "Configure the editor's accessibility support. Defaults to 'auto'. It is best to leave this to 'auto'.", 27 | "type": "string" 28 | }, 29 | "ariaLabel": { 30 | "default": "", 31 | "description": "The aria label for the editor's textarea (when it is focused).", 32 | "type": "string" 33 | }, 34 | "autoClosingBrackets": { 35 | "$ref": "#/$defs/EditorAutoClosingStrategy" 36 | }, 37 | "autoClosingDelete": { 38 | "$ref": "#/$defs/EditorAutoClosingEditStrategy" 39 | }, 40 | "autoClosingOvertype": { 41 | "$ref": "#/$defs/EditorAutoClosingEditStrategy" 42 | }, 43 | "autoClosingQuotes": { 44 | "$ref": "#/$defs/EditorAutoClosingEditStrategy" 45 | }, 46 | "autoIndent": { 47 | "default": "advanced", 48 | "description": "Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines. Defaults to advanced.", 49 | "enum": [ 50 | "none", 51 | "advanced", 52 | "full", 53 | "brackets", 54 | "keep" 55 | ], 56 | "type": "string" 57 | }, 58 | "autoSurround": { 59 | "$ref": "#/$defs/EditorAutoSurroundStrategy" 60 | }, 61 | "automaticLayout": { 62 | "default": false, 63 | "description": "Enable that the editor will install a ResizeObserver to check if its container dom node size has changed. Defaults to false.", 64 | "type": "boolean" 65 | }, 66 | "bracketPairColorization": { 67 | "$ref": "#/$defs/IBracketPairColorizationOptions" 68 | }, 69 | "codeActionsOnSaveTimeout": { 70 | "default": 0, 71 | "description": "Timeout for running code actions on save.", 72 | "type": "number" 73 | }, 74 | "codeLens": { 75 | "default": true, 76 | "description": "Show code lens. Defaults to true.", 77 | "type": "boolean" 78 | }, 79 | "codeLensFontFamily": { 80 | "description": "Code lens font family. Defaults to editor font family.", 81 | "type": "string" 82 | }, 83 | "codeLensFontSize": { 84 | "description": "Code lens font size. Default to 90% of the editor font size", 85 | "type": "number" 86 | }, 87 | "colorDecorators": { 88 | "description": "Enable inline color decorators and color picker rendering.", 89 | "type": "boolean" 90 | }, 91 | "colorDecoratorsLimit": { 92 | "description": "Controls the max number of color decorators that can be rendered in an editor at once.", 93 | "type": "number" 94 | }, 95 | "columnSelection": { 96 | "default": false, 97 | "description": "Enable that the selection with the mouse and keys is doing column selection. Defaults to false.", 98 | "type": "boolean" 99 | }, 100 | "comments": { 101 | "$ref": "#/$defs/IEditorCommentsOptions" 102 | }, 103 | "contextmenu": { 104 | "default": true, 105 | "description": "Enable custom contextmenu. Defaults to true.", 106 | "type": "boolean" 107 | }, 108 | "copyWithSyntaxHighlighting": { 109 | "description": "Syntax highlighting is copied.", 110 | "type": "boolean" 111 | }, 112 | "cursorBlinking": { 113 | "default": "blink", 114 | "description": "Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'. Defaults to 'blink'.", 115 | "enum": [ 116 | "blink", 117 | "smooth", 118 | "phase", 119 | "expand", 120 | "solid" 121 | ], 122 | "type": "string" 123 | }, 124 | "cursorSmoothCaretAnimation": { 125 | "default": "off", 126 | "description": "Enable smooth caret animation. Defaults to 'off'.", 127 | "enum": [ 128 | "on", 129 | "off", 130 | "explicit" 131 | ], 132 | "type": "string" 133 | }, 134 | "cursorStyle": { 135 | "default": "line", 136 | "description": "Control the cursor style, either 'block' or 'line'. Defaults to 'line'.", 137 | "enum": [ 138 | "line", 139 | "block", 140 | "underline", 141 | "line-thin", 142 | "block-outline", 143 | "underline-thin" 144 | ], 145 | "type": "string" 146 | }, 147 | "cursorSurroundingLines": { 148 | "default": 0, 149 | "description": "Controls the minimal number of visible leading and trailing lines surrounding the cursor. Defaults to 0.", 150 | "type": "number" 151 | }, 152 | "cursorSurroundingLinesStyle": { 153 | "default": "default", 154 | "description": "Controls when cursorSurroundingLines should be enforced Defaults to default, cursorSurroundingLines is not enforced when cursor position is changed by mouse.", 155 | "enum": [ 156 | "default", 157 | "all" 158 | ], 159 | "type": "string" 160 | }, 161 | "cursorWidth": { 162 | "description": "Control the width of the cursor when cursorStyle is set to 'line'.", 163 | "type": "number" 164 | }, 165 | "definitionLinkOpensInPeek": { 166 | "default": false, 167 | "description": "Controls whether the definition link opens element in the peek widget. Defaults to false.", 168 | "type": "boolean" 169 | }, 170 | "disableLayerHinting": { 171 | "default": false, 172 | "description": "Disable the use of transform: translate3d(0px, 0px, 0px) for the editor margin and lines layers. The usage of transform: translate3d(0px, 0px, 0px) acts as a hint for browsers to create an extra layer. Defaults to false.", 173 | "type": "boolean" 174 | }, 175 | "disableMonospaceOptimizations": { 176 | "default": false, 177 | "description": "Disable the optimizations for monospace fonts. Defaults to false.", 178 | "type": "boolean" 179 | }, 180 | "domReadOnly": { 181 | "default": false, 182 | "description": "Should the textarea used for input use the DOM readonly attribute. Defaults to false.", 183 | "type": "boolean" 184 | }, 185 | "dragAndDrop": { 186 | "default": false, 187 | "description": "Controls if the editor should allow to move selections via drag and drop. Defaults to false.", 188 | "type": "boolean" 189 | }, 190 | "dropIntoEditor": { 191 | "$ref": "#/$defs/IDropIntoEditorOptions" 192 | }, 193 | "emptySelectionClipboard": { 194 | "description": "Copying without a selection copies the current line.", 195 | "type": "boolean" 196 | }, 197 | "experimentalWhitespaceRendering": { 198 | "default": "svg", 199 | "description": "Enable experimental whitespace rendering. Defaults to 'svg'.", 200 | "enum": [ 201 | "off", 202 | "svg", 203 | "font" 204 | ], 205 | "type": "string" 206 | }, 207 | "extraEditorClassName": { 208 | "description": "Class name to be added to the editor.", 209 | "type": "string" 210 | }, 211 | "fastScrollSensitivity": { 212 | "default": 5, 213 | "description": "FastScrolling mulitplier speed when pressing Alt Defaults to 5.", 214 | "type": "number" 215 | }, 216 | "find": { 217 | "$ref": "#/$defs/IEditorFindOptions" 218 | }, 219 | "fixedOverflowWidgets": { 220 | "default": false, 221 | "description": "Display overflow widgets as fixed. Defaults to false.", 222 | "type": "boolean" 223 | }, 224 | "folding": { 225 | "default": true, 226 | "description": "Enable code folding. Defaults to true.", 227 | "type": "boolean" 228 | }, 229 | "foldingHighlight": { 230 | "default": true, 231 | "description": "Enable highlight for folded regions. Defaults to true.", 232 | "type": "boolean" 233 | }, 234 | "foldingImportsByDefault": { 235 | "default": true, 236 | "description": "Auto fold imports folding regions. Defaults to true.", 237 | "type": "boolean" 238 | }, 239 | "foldingMaximumRegions": { 240 | "default": 5000, 241 | "description": "Maximum number of foldable regions. Defaults to 5000.", 242 | "type": "number" 243 | }, 244 | "foldingStrategy": { 245 | "default": "auto", 246 | "description": "Selects the folding strategy. 'auto' uses the strategies contributed for the current document, 'indentation' uses the indentation based folding strategy. Defaults to 'auto'.", 247 | "enum": [ 248 | "auto", 249 | "indentation" 250 | ], 251 | "type": "string" 252 | }, 253 | "fontFamily": { 254 | "description": "The font family", 255 | "type": "string" 256 | }, 257 | "fontLigatures": { 258 | "default": false, 259 | "description": "Enable font ligatures. Defaults to false.", 260 | "type": "boolean" 261 | }, 262 | "fontSize": { 263 | "description": "The font size", 264 | "type": "number" 265 | }, 266 | "fontVariations": { 267 | "default": false, 268 | "description": "Enable font variations. Defaults to false.", 269 | "type": [ 270 | "boolean", 271 | "string" 272 | ] 273 | }, 274 | "fontWeight": { 275 | "description": "The font weight", 276 | "type": "string" 277 | }, 278 | "formatOnPaste": { 279 | "default": false, 280 | "description": "Enable format on paste. Defaults to false.", 281 | "type": "boolean" 282 | }, 283 | "formatOnType": { 284 | "default": false, 285 | "description": "Enable format on type. Defaults to false.", 286 | "type": "boolean" 287 | }, 288 | "glyphMargin": { 289 | "default": false, 290 | "description": "Enable the rendering of the glyph margin. Defaults to true in vscode and to false in monaco-editor.", 291 | "type": "boolean" 292 | }, 293 | "gotoLocation": { 294 | "$ref": "#/$defs/IGotoLocationOptions" 295 | }, 296 | "guides": { 297 | "$ref": "#/$defs/IGuidesOptions" 298 | }, 299 | "hideCursorInOverviewRuler": { 300 | "default": false, 301 | "description": "Should the cursor be hidden in the overview ruler. Defaults to false.", 302 | "type": "boolean" 303 | }, 304 | "hover": { 305 | "$ref": "#/$defs/IEditorHoverOptions" 306 | }, 307 | "inDiffEditor": { 308 | "description": "This editor is used inside a diff editor.", 309 | "type": "boolean" 310 | }, 311 | "inlayHints": { 312 | "$ref": "#/$defs/IEditorInlayHintsOptions" 313 | }, 314 | "inlineSuggest": { 315 | "$ref": "#/$defs/IInlineSuggestOptions" 316 | }, 317 | "letterSpacing": { 318 | "description": "The letter spacing", 319 | "type": "number" 320 | }, 321 | "lightbulb": { 322 | "$ref": "#/$defs/IEditorLightbulbOptions" 323 | }, 324 | "lineDecorationsWidth": { 325 | "default": 10, 326 | "description": "The width reserved for line decorations (in px). Line decorations are placed between line numbers and the editor content. You can pass in a string in the format floating point followed by \"ch\". e.g. 1.3ch. Defaults to 10.", 327 | "type": [ 328 | "string", 329 | "number" 330 | ] 331 | }, 332 | "lineHeight": { 333 | "description": "The line height.", 334 | "type": "number" 335 | }, 336 | "lineNumbers": { 337 | "$ref": "#/$defs/LineNumbersType" 338 | }, 339 | "lineNumbersMinChars": { 340 | "default": 5, 341 | "description": "Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits. Defaults to 5.", 342 | "type": "number" 343 | }, 344 | "linkedEditing": { 345 | "default": false, 346 | "description": "Enable linked editing. Defaults to false.", 347 | "type": "boolean" 348 | }, 349 | "links": { 350 | "default": true, 351 | "description": "Enable detecting links and making them clickable. Defaults to true.", 352 | "type": "boolean" 353 | }, 354 | "matchBrackets": { 355 | "default": "always", 356 | "description": "Enable highlighting of matching brackets. Defaults to 'always'.", 357 | "enum": [ 358 | "always", 359 | "never", 360 | "near" 361 | ], 362 | "type": "string" 363 | }, 364 | "matchOnWordStartOnly": { 365 | "description": "Controls whether suggestions allow matches in the middle of the word instead of only at the beginning", 366 | "type": "boolean" 367 | }, 368 | "minimap": { 369 | "$ref": "#/$defs/IEditorMinimapOptions" 370 | }, 371 | "mouseStyle": { 372 | "default": "text", 373 | "description": "Control the mouse pointer style, either 'text' or 'default' or 'copy' Defaults to 'text'", 374 | "enum": [ 375 | "default", 376 | "text", 377 | "copy" 378 | ], 379 | "type": "string" 380 | }, 381 | "mouseWheelScrollSensitivity": { 382 | "default": 1, 383 | "description": "A multiplier to be used on the deltaX and deltaY of mouse wheel scroll events. Defaults to 1.", 384 | "type": "number" 385 | }, 386 | "mouseWheelZoom": { 387 | "default": false, 388 | "description": "Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. Defaults to false.", 389 | "type": "boolean" 390 | }, 391 | "multiCursorLimit": { 392 | "description": "Controls the max number of text cursors that can be in an active editor at once.", 393 | "type": "number" 394 | }, 395 | "multiCursorMergeOverlapping": { 396 | "default": true, 397 | "description": "Merge overlapping selections. Defaults to true", 398 | "type": "boolean" 399 | }, 400 | "multiCursorModifier": { 401 | "default": "all", 402 | "description": "The modifier to be used to add multiple cursors with the mouse. Defaults to 'alt'", 403 | "enum": [ 404 | "ctrlCmd", 405 | "alt" 406 | ], 407 | "type": "string" 408 | }, 409 | "multiCursorPaste": { 410 | "default": "spread", 411 | "description": "Configure the behaviour when pasting a text with the line count equal to the cursor count. Defaults to 'spread'.", 412 | "enum": [ 413 | "spread", 414 | "full" 415 | ], 416 | "type": "string" 417 | }, 418 | "occurrencesHighlight": { 419 | "default": true, 420 | "description": "Enable semantic occurrences highlight. Defaults to true.", 421 | "type": "boolean" 422 | }, 423 | "overviewRulerBorder": { 424 | "default": true, 425 | "description": "Controls if a border should be drawn around the overview ruler. Defaults to true.", 426 | "type": "boolean" 427 | }, 428 | "overviewRulerLanes": { 429 | "default": 3, 430 | "description": "The number of vertical lanes the overview ruler should render. Defaults to 3.", 431 | "type": "number" 432 | }, 433 | "padding": { 434 | "$ref": "#/$defs/IEditorPaddingOptions" 435 | }, 436 | "parameterHints": { 437 | "$ref": "#/$defs/IEditorParameterHintOptions" 438 | }, 439 | "peekWidgetDefaultFocus": { 440 | "default": false, 441 | "description": "Controls whether to focus the inline editor in the peek widget by default. Defaults to false.", 442 | "enum": [ 443 | false, 444 | "tree", 445 | "editor" 446 | ], 447 | "type": [ 448 | "boolean", 449 | "string" 450 | ] 451 | }, 452 | "quickSuggestions": { 453 | "$ref": "#/$defs/IQuickSuggestionsOptions" 454 | }, 455 | "quickSuggestionsDelay": { 456 | "default": 10, 457 | "description": "Quick suggestions show delay (in ms) Defaults to 10 (ms)", 458 | "type": "number" 459 | }, 460 | "readOnly": { 461 | "default": false, 462 | "description": "Should the editor be read only. See also domReadOnly. Defaults to false.", 463 | "type": "boolean" 464 | }, 465 | "renameOnType": { 466 | "description": "deprecated, use linkedEditing instead.", 467 | "type": "boolean" 468 | }, 469 | "renderControlCharacters": { 470 | "default": true, 471 | "description": "Enable rendering of control characters. Defaults to true.", 472 | "type": "boolean" 473 | }, 474 | "renderFinalNewline": { 475 | "default": "on", 476 | "description": "Render last line number when the file ends with a newline. Defaults to 'on' for Windows and macOS and 'dimmed' for Linux.", 477 | "enum": [ 478 | "on", 479 | "off", 480 | "dimmed" 481 | ], 482 | "type": "string" 483 | }, 484 | "renderLineHighlight": { 485 | "default": "all", 486 | "description": "Enable rendering of current line highlight. Defaults to all.", 487 | "enum": [ 488 | "all", 489 | "line", 490 | "none", 491 | "gutter" 492 | ], 493 | "type": "string" 494 | }, 495 | "renderLineHighlightOnlyWhenFocus": { 496 | "default": false, 497 | "description": "Control if the current line highlight should be rendered only the editor is focused. Defaults to false.", 498 | "type": "boolean" 499 | }, 500 | "renderValidationDecorations": { 501 | "default": "editable", 502 | "description": "Should the editor render validation decorations. Defaults to editable.", 503 | "enum": [ 504 | "on", 505 | "off", 506 | "editable" 507 | ], 508 | "type": "string" 509 | }, 510 | "renderWhitespace": { 511 | "default": "selection", 512 | "description": "Enable rendering of whitespace. Defaults to 'selection'.", 513 | "enum": [ 514 | "all", 515 | "none", 516 | "boundary", 517 | "selection", 518 | "trailing" 519 | ], 520 | "type": "string" 521 | }, 522 | "revealHorizontalRightPadding": { 523 | "default": 30, 524 | "description": "When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle. This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport. Defaults to 30 (px).", 525 | "type": "number" 526 | }, 527 | "roundedSelection": { 528 | "default": true, 529 | "description": "Render the editor selection with rounded borders. Defaults to true.", 530 | "type": "boolean" 531 | }, 532 | "rulers": { 533 | "default": [], 534 | "description": "Render vertical lines at the specified columns. Defaults to empty array.", 535 | "items": { 536 | "oneOf": [ 537 | { 538 | "type": "number" 539 | }, 540 | { 541 | "$ref": "#/$defs/IRulerOption" 542 | } 543 | ] 544 | }, 545 | "type": "array" 546 | }, 547 | "screenReaderAnnounceInlineSuggestion": { 548 | "description": "Control whether a screen reader announces inline suggestion content immediately.", 549 | "type": "boolean" 550 | }, 551 | "scrollBeyondLastColumn": { 552 | "default": 5, 553 | "description": "Enable that scrolling can go beyond the last column by a number of columns. Defaults to 5.", 554 | "type": "number" 555 | }, 556 | "scrollBeyondLastLine": { 557 | "default": true, 558 | "description": "Enable that scrolling can go one screen size after the last line. Defaults to true.", 559 | "type": "boolean" 560 | }, 561 | "scrollPredominantAxis": { 562 | "default": true, 563 | "description": "Enable that the editor scrolls only the predominant axis. Prevents horizontal drift when scrolling vertically on a trackpad. Defaults to true.", 564 | "type": "boolean" 565 | }, 566 | "scrollbar": { 567 | "$ref": "#/$defs/IEditorScrollbarOptions" 568 | }, 569 | "selectOnLineNumbers": { 570 | "default": true, 571 | "description": "Should the corresponding line be selected when clicking on the line number? Defaults to true.", 572 | "type": "boolean" 573 | }, 574 | "selectionClipboard": { 575 | "default": true, 576 | "description": "Enable Linux primary clipboard. Defaults to true.", 577 | "type": "boolean" 578 | }, 579 | "selectionHighlight": { 580 | "default": true, 581 | "description": "Enable selection highlight. Defaults to true.", 582 | "type": "boolean" 583 | }, 584 | "showDeprecated": { 585 | "description": "Controls strikethrough deprecated variables.", 586 | "type": "boolean" 587 | }, 588 | "showFoldingControls": { 589 | "default": "mouseover", 590 | "description": "Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter. Defaults to 'mouseover'.", 591 | "enum": [ 592 | "always", 593 | "never", 594 | "mouseover" 595 | ], 596 | "type": "string" 597 | }, 598 | "showUnused": { 599 | "description": "Controls fading out of unused variables.", 600 | "type": "boolean" 601 | }, 602 | "smartSelect": { 603 | "$ref": "#/$defs/ISmartSelectOptions" 604 | }, 605 | "smoothScrolling": { 606 | "default": false, 607 | "description": "Enable that the editor animates scrolling to a position. Defaults to false.", 608 | "type": "boolean" 609 | }, 610 | "snippetSuggestions": { 611 | "default": true, 612 | "description": "Enable snippet suggestions. Default to 'true'.", 613 | "enum": [ 614 | true, 615 | "none", 616 | "top", 617 | "bottom", 618 | "inline" 619 | ], 620 | "type": [ 621 | "boolean", 622 | "string" 623 | ] 624 | }, 625 | "stickyScroll": { 626 | "$ref": "#/$defs/IEditorStickyScrollOptions" 627 | }, 628 | "stickyTabStops": { 629 | "description": "Emulate selection behaviour of tab characters when using spaces for indentation. This means selection will stick to tab stops.", 630 | "type": "boolean" 631 | }, 632 | "stopRenderingLineAfter": { 633 | "default": 10000, 634 | "description": "Performance guard: Stop rendering a line after x characters. Defaults to 10000. Use -1 to never stop rendering", 635 | "type": "number" 636 | }, 637 | "suggest": { 638 | "$ref": "#/$defs/ISuggestOptions" 639 | }, 640 | "suggestFontSize": { 641 | "description": "The font size for the suggest widget. Defaults to the editor font size.", 642 | "type": "number" 643 | }, 644 | "suggestLineHeight": { 645 | "description": "The line height for the suggest widget. Defaults to the editor line height.", 646 | "type": "number" 647 | }, 648 | "suggestOnTriggerCharacters": { 649 | "default": true, 650 | "description": "Enable the suggestion box to pop-up on trigger characters. Defaults to true.", 651 | "type": "boolean" 652 | }, 653 | "suggestSelection": { 654 | "description": "The history mode for suggestions.", 655 | "enum": [ 656 | "first", 657 | "recentlyUsed", 658 | "recentlyUsedByPrefix" 659 | ], 660 | "type": "string" 661 | }, 662 | "tabCompletion": { 663 | "description": "Enable tab completion.", 664 | "enum": [ 665 | "on", 666 | "off", 667 | "onlySnippets" 668 | ], 669 | "type": "string" 670 | }, 671 | "tabFocusMode": { 672 | "description": "Controls whether the editor receives tabs or defers them to the workbench for navigation.", 673 | "type": "boolean" 674 | }, 675 | "tabIndex": { 676 | "description": "The tabindex property of the editor's textarea.", 677 | "type": "number" 678 | }, 679 | "unfoldOnClickAfterEndOfLine": { 680 | "default": false, 681 | "description": "Controls whether clicking on the empty content after a folded line will unfold the line. Defaults to false.", 682 | "type": "boolean" 683 | }, 684 | "unicodeHighlight": { 685 | "$ref": "#/$defs/IUnicodeHighlightOptions" 686 | }, 687 | "unusualLineTerminators": { 688 | "default": "prompt", 689 | "description": "Remove unusual line terminators like LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS). Defaults to 'prompt'.", 690 | "enum": [ 691 | "off", 692 | "auto", 693 | "prompt" 694 | ], 695 | "type": "string" 696 | }, 697 | "useShadowDOM": { 698 | "description": "Control if the editor should use shadow DOM.", 699 | "type": "boolean" 700 | }, 701 | "useTabStops": { 702 | "description": "Inserting and deleting whitespace follows tab stops.", 703 | "type": "boolean" 704 | }, 705 | "wordBreak": { 706 | "default": "normal", 707 | "description": "Sets whether line breaks appear wherever the text would otherwise overflow its content box. When wordBreak = 'normal', Use the default line break rule. When wordBreak = 'keepAll', Word breaks should not be used for Chinese/Japanese/Korean (CJK) text. Non-CJK text behavior is the same as for normal.", 708 | "enum": [ 709 | "normal", 710 | "keepAll" 711 | ], 712 | "type": "string" 713 | }, 714 | "wordSeparators": { 715 | "default": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?", 716 | "description": "A string containing the word separators used when doing word navigation. Defaults to `~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?", 717 | "type": "string" 718 | }, 719 | "wordWrap": { 720 | "default": "off", 721 | "description": "Control the wrapping of the editor. When wordWrap = \"off\", the lines will never wrap. When wordWrap = \"on\", the lines will wrap at the viewport width. When wordWrap = \"wordWrapColumn\", the lines will wrap at wordWrapColumn. When wordWrap = \"bounded\", the lines will wrap at min(viewport width, wordWrapColumn). Defaults to \"off\".", 722 | "enum": [ 723 | "on", 724 | "off", 725 | "wordWrapColumn", 726 | "bounded" 727 | ], 728 | "type": "string" 729 | }, 730 | "wordWrapBreakAfterCharacters": { 731 | "description": "Configure word wrapping characters. A break will be introduced before these characters.", 732 | "type": "string" 733 | }, 734 | "wordWrapBreakBeforeCharacters": { 735 | "description": "Configure word wrapping characters. A break will be introduced before these characters.", 736 | "type": "string" 737 | }, 738 | "wordWrapColumn": { 739 | "default": 80, 740 | "description": "Control the wrapping of the editor. When wordWrap = \"off\", the lines will never wrap. When wordWrap = \"on\", the lines will wrap at the viewport width. When wordWrap = \"wordWrapColumn\", the lines will wrap at wordWrapColumn. When wordWrap = \"bounded\", the lines will wrap at min(viewport width, wordWrapColumn). Defaults to 80.", 741 | "type": "number" 742 | }, 743 | "wordWrapOverride1": { 744 | "description": "Override the wordWrap setting.", 745 | "enum": [ 746 | "on", 747 | "off", 748 | "inherit" 749 | ], 750 | "type": "string" 751 | }, 752 | "wordWrapOverride2": { 753 | "description": "Override the wordWrapOverride1 setting.", 754 | "enum": [ 755 | "on", 756 | "off", 757 | "inherit" 758 | ], 759 | "type": "string" 760 | }, 761 | "wrappingIndent": { 762 | "default": "none", 763 | "description": "Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'. Defaults to 'same' in vscode and to 'none' in monaco-editor.", 764 | "enum": [ 765 | "none", 766 | "same", 767 | "indent", 768 | "deepIndent" 769 | ], 770 | "type": "string" 771 | }, 772 | "wrappingStrategy": { 773 | "default": "simple", 774 | "description": "Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'. Defaults to 'same' in vscode and to 'none' in monaco-editor.", 775 | "enum": [ 776 | "simple", 777 | "advanced" 778 | ], 779 | "type": "string" 780 | } 781 | }, 782 | "$defs": { 783 | "EditorAutoClosingStrategy": { 784 | "default": "languageDefined", 785 | "description": "Options for auto closing brackets. Defaults to language defined behavior.", 786 | "enum": [ 787 | "always", 788 | "languageDefined", 789 | "beforeWhitespace", 790 | "never" 791 | ], 792 | "type": "string" 793 | }, 794 | "EditorAutoClosingEditStrategy": { 795 | "default": "auto", 796 | "description": "Options for pressing backspace near quotes or bracket pairs.", 797 | "enum": [ 798 | "always", 799 | "auto", 800 | "never" 801 | ], 802 | "type": "string" 803 | }, 804 | "EditorAutoSurroundStrategy": { 805 | "default": "languageDefined", 806 | "description": "Configuration options for auto wrapping quotes and brackets.", 807 | "enum": [ 808 | "languageDefined", 809 | "quotes", 810 | "brackets", 811 | "never" 812 | ], 813 | "type": "string" 814 | }, 815 | "IBracketPairColorizationOptions": { 816 | "description": "Configures bracket pair colorization (disabled by default).", 817 | "properties": { 818 | "enabled": { 819 | "default": false, 820 | "description": "Enable or disable bracket pair colorization.", 821 | "type": "boolean" 822 | }, 823 | "independentColorPoolPerBracketType": { 824 | "default": false, 825 | "description": "Use independent color pool per bracket type.", 826 | "type": "boolean" 827 | } 828 | }, 829 | "type": "object" 830 | }, 831 | "IEditorCommentsOptions": { 832 | "description": "Control the behaviour of comments in the editor.", 833 | "properties": { 834 | "ignoreEmptyLines": { 835 | "default": true, 836 | "description": "Ignore empty lines when inserting line comments. Defaults to true.", 837 | "type": "boolean" 838 | }, 839 | "insertSpace": { 840 | "default": true, 841 | "description": "Insert a space after the line comment token and inside the block comments tokens. Defaults to true.", 842 | "type": "boolean" 843 | } 844 | }, 845 | "type": "object" 846 | }, 847 | "IDropIntoEditorOptions": { 848 | "description": "Controls dropping into the editor from an external source. When enabled, this shows a preview of the drop location and triggers an onDropIntoEditor event.", 849 | "properties": { 850 | "enabled": { 851 | "default": true, 852 | "description": "Enable the dropping into editor. Defaults to true.", 853 | "type": "boolean" 854 | } 855 | }, 856 | "type": "object" 857 | }, 858 | "IEditorFindOptions": { 859 | "description": "Control the behavior of the find widget.", 860 | "properties": { 861 | "addExtraSpaceOnTop": { 862 | "description": "", 863 | "type": "boolean" 864 | }, 865 | "autoFindInSelection": { 866 | "description": "Controls if Find in Selection flag is turned on in the editor.", 867 | "enum": [ 868 | "always", 869 | "never", 870 | "multiline" 871 | ], 872 | "type": "string" 873 | }, 874 | "cursorMoveOnType": { 875 | "description": "Controls whether the cursor should move to find matches while typing.", 876 | "type": "boolean" 877 | }, 878 | "loop": { 879 | "description": "Controls whether the search result and diff result automatically restarts from the beginning (or the end) when no further matches can be found.", 880 | "type": "boolean" 881 | }, 882 | "seedSearchStringFromSelection": { 883 | "description": "Controls if we seed search string in the Find Widget with editor selection.", 884 | "enum": [ 885 | "always", 886 | "never", 887 | "selection" 888 | ], 889 | "type": "string" 890 | } 891 | }, 892 | "type": "object" 893 | }, 894 | "IGotoLocationOptions": { 895 | "description": "Configuration options for go to location.", 896 | "properties": { 897 | "alternativeDeclarationCommand": { 898 | "type": "string" 899 | }, 900 | "alternativeDefinitionCommand": { 901 | "type": "string" 902 | }, 903 | "alternativeImplementationCommand": { 904 | "type": "string" 905 | }, 906 | "alternativeReferenceCommand": { 907 | "type": "string" 908 | }, 909 | "alternativeTypeDefinitionCommand": { 910 | "type": "string" 911 | }, 912 | "multiple": { 913 | "$ref": "#/$defs/GoToLocationValues" 914 | }, 915 | "multipleDeclarations": { 916 | "$ref": "#/$defs/GoToLocationValues" 917 | }, 918 | "multipleDefinitions": { 919 | "$ref": "#/$defs/GoToLocationValues" 920 | }, 921 | "multipleImplementations": { 922 | "$ref": "#/$defs/GoToLocationValues" 923 | }, 924 | "multipleReferences": { 925 | "$ref": "#/$defs/GoToLocationValues" 926 | }, 927 | "multipleTypeDefinitions": { 928 | "$ref": "#/$defs/GoToLocationValues" 929 | } 930 | }, 931 | "type": "object" 932 | }, 933 | "GoToLocationValues": { 934 | "enum": [ 935 | "peek", 936 | "gotoAndPeek", 937 | "goto" 938 | ], 939 | "type": "string" 940 | }, 941 | "IGuidesOptions": { 942 | "description": "Controls the behavior of editor guides.", 943 | "properties": { 944 | "bracketPairs": { 945 | "default": false, 946 | "description": "Enable rendering of bracket pair guides. Defaults to false.", 947 | "enum": [ 948 | true, 949 | false, 950 | "active" 951 | ], 952 | "type": [ 953 | "boolean", 954 | "string" 955 | ] 956 | }, 957 | "bracketPairsHorizontal": { 958 | "default": "active", 959 | "description": "Enable rendering of vertical bracket pair guides. Defaults to 'active'.", 960 | "enum": [ 961 | true, 962 | false, 963 | "active" 964 | ], 965 | "type": [ 966 | "boolean", 967 | "string" 968 | ] 969 | }, 970 | "highlightActiveBracketPair": { 971 | "default": true, 972 | "description": "Enable highlighting of the active bracket pair. Defaults to true.", 973 | "type": "boolean" 974 | }, 975 | "highlightActiveIndentation": { 976 | "default": true, 977 | "description": "Enable highlighting of the active indent guide. Defaults to true.", 978 | "enum": [ 979 | true, 980 | false, 981 | "always" 982 | ], 983 | "type": [ 984 | "boolean", 985 | "string" 986 | ] 987 | }, 988 | "indentation": { 989 | "default": true, 990 | "description": "Enable rendering of indent guides. Defaults to true.", 991 | "type": "boolean" 992 | } 993 | }, 994 | "type": "object" 995 | }, 996 | "IEditorHoverOptions": { 997 | "description": "Configure the editor's hover.", 998 | "properties": { 999 | "above": { 1000 | "default": false, 1001 | "description": "Should the hover be shown above the line if possible? Defaults to false.", 1002 | "type": "boolean" 1003 | }, 1004 | "delay": { 1005 | "default": 300, 1006 | "description": "Delay for showing the hover. Defaults to 300.", 1007 | "type": "number" 1008 | }, 1009 | "enabled": { 1010 | "default": true, 1011 | "description": "Enable the hover. Defaults to true.", 1012 | "type": "boolean" 1013 | }, 1014 | "sticky": { 1015 | "default": true, 1016 | "description": "Is the hover sticky such that it can be clicked and its contents selected? Defaults to true.", 1017 | "type": "boolean" 1018 | } 1019 | }, 1020 | "type": "object" 1021 | }, 1022 | "IEditorInlayHintsOptions": { 1023 | "description": "Control the behavior and rendering of the inline hints.", 1024 | "properties": { 1025 | "enabled": { 1026 | "default": true, 1027 | "description": "Enable the inline hints. Defaults to true.", 1028 | "enum": [ 1029 | true, 1030 | false, 1031 | "on", 1032 | "off", 1033 | "offUnlessPressed", 1034 | "onUnlessPressed" 1035 | ], 1036 | "type": [ 1037 | "boolean", 1038 | "string" 1039 | ] 1040 | }, 1041 | "fontFamily": { 1042 | "description": "Font family of inline hints. Defaults to editor font family.", 1043 | "type": "string" 1044 | }, 1045 | "fontSize": { 1046 | "description": "Font size of inline hints. Default to 90% of the editor font size.", 1047 | "type": "number" 1048 | }, 1049 | "padding": { 1050 | "description": "Font size of inline hints. Default to 90% of the editor font size.", 1051 | "type": "number" 1052 | } 1053 | }, 1054 | "type": "object" 1055 | }, 1056 | "IInlineSuggestOptions": { 1057 | "description": "Inline suggest options.", 1058 | "properties": { 1059 | "enabled": { 1060 | "description": "Enable or disable the rendering of automatic inline completions.", 1061 | "type": "boolean" 1062 | }, 1063 | "mode": { 1064 | "default": "prefix", 1065 | "description": "Configures the mode. Use prefix to only show ghost text if the text to replace is a prefix of the suggestion text. Use subword to only show ghost text if the replace text is a subword of the suggestion text. Use subwordSmart to only show ghost text if the replace text is a subword of the suggestion text, but the subword must start after the cursor position. Defaults to prefix.", 1066 | "enum": [ 1067 | "prefix", 1068 | "subword", 1069 | "subwordSmart" 1070 | ], 1071 | "type": "string" 1072 | }, 1073 | "showToolbar": { 1074 | "description": "Determines whether the toolbar is displayed.", 1075 | "enum": [ 1076 | "always", 1077 | "onHover" 1078 | ], 1079 | "type": "string" 1080 | }, 1081 | "suppressSuggestions": { 1082 | "description": "Whether suggestions should be supressed.", 1083 | "type": "boolean" 1084 | } 1085 | }, 1086 | "type": "object" 1087 | }, 1088 | "IEditorLightbulbOptions": { 1089 | "description": "Control the behavior and rendering of the code action lightbulb.", 1090 | "properties": { 1091 | "enabled": { 1092 | "description": "Enable the lightbulb code action. Defaults to true.", 1093 | "type": "boolean" 1094 | } 1095 | }, 1096 | "type": "object" 1097 | }, 1098 | "LineNumbersType": { 1099 | "default": "on", 1100 | "description": "Control the rendering of line numbers. If it is a function, it will be invoked when rendering a line number and the return value will be rendered. Otherwise, if it is a truthy, line numbers will be rendered normally (equivalent of using an identity function). Otherwise, line numbers will not be rendered. Defaults to on.", 1101 | "enum": [ 1102 | "on", 1103 | "off", 1104 | "relative", 1105 | "interval" 1106 | ], 1107 | "type": "string" 1108 | }, 1109 | "IEditorMinimapOptions": { 1110 | "description": "Controls dropping into the editor from an external source. When enabled, this shows a preview of the drop location and triggers an onDropIntoEditor event.", 1111 | "properties": { 1112 | "autohide": { 1113 | "description": "Control the rendering of minimap.", 1114 | "type": "boolean" 1115 | }, 1116 | "enabled": { 1117 | "default": true, 1118 | "description": "Enable the rendering of the minimap. Defaults to true.", 1119 | "type": "boolean" 1120 | }, 1121 | "maxColumn": { 1122 | "default": 120, 1123 | "description": "Limit the width of the minimap to render at most a certain number of columns. Defaults to 120.", 1124 | "type": "number" 1125 | }, 1126 | "renderCharacters": { 1127 | "default": true, 1128 | "description": "Render the actual text on a line (as opposed to color blocks). Defaults to true.", 1129 | "type": "boolean" 1130 | }, 1131 | "scale": { 1132 | "default": 1, 1133 | "description": "Relative size of the font in the minimap. Defaults to 1.", 1134 | "type": "number" 1135 | }, 1136 | "showSlider": { 1137 | "default": "mouseover", 1138 | "description": "Control the rendering of the minimap slider. Defaults to 'mouseover'.", 1139 | "enum": [ 1140 | "always", 1141 | "mouseover" 1142 | ], 1143 | "type": "string" 1144 | }, 1145 | "side": { 1146 | "default": "right", 1147 | "description": "Control the side of the minimap in editor. Defaults to 'right'.", 1148 | "enum": [ 1149 | "right", 1150 | "left" 1151 | ], 1152 | "type": "string" 1153 | }, 1154 | "size": { 1155 | "default": "actual", 1156 | "description": "Control the minimap rendering mode. Defaults to 'actual'.", 1157 | "enum": [ 1158 | "actual", 1159 | "proportional", 1160 | "fill", 1161 | "fit" 1162 | ], 1163 | "type": "string" 1164 | } 1165 | }, 1166 | "type": "object" 1167 | }, 1168 | "IEditorPaddingOptions": { 1169 | "description": "Controls the spacing around the editor.", 1170 | "properties": { 1171 | "bottom": { 1172 | "description": "Spacing between bottom edge of editor and last line.", 1173 | "type": "number" 1174 | }, 1175 | "top": { 1176 | "description": "Spacing between top edge of editor and first line.", 1177 | "type": "number" 1178 | } 1179 | }, 1180 | "type": "object" 1181 | }, 1182 | "IEditorParameterHintOptions": { 1183 | "description": "Parameter hint options.", 1184 | "properties": { 1185 | "cycle": { 1186 | "default": false, 1187 | "description": "Enable cycling of parameter hints. Defaults to false.", 1188 | "type": "boolean" 1189 | }, 1190 | "enabled": { 1191 | "default": true, 1192 | "description": "Enable parameter hints. Defaults to true.", 1193 | "type": "boolean" 1194 | } 1195 | }, 1196 | "type": "object" 1197 | }, 1198 | "IQuickSuggestionsOptions": { 1199 | "default": true, 1200 | "description": "Enable quick suggestions (shadow suggestions) Defaults to true.", 1201 | "properties": { 1202 | "comments": { 1203 | "$ref": "#/$defs/QuickSuggestionsValue" 1204 | }, 1205 | "other": { 1206 | "$ref": "#/$defs/QuickSuggestionsValue" 1207 | }, 1208 | "strings": { 1209 | "$ref": "#/$defs/QuickSuggestionsValue" 1210 | } 1211 | }, 1212 | "type": [ 1213 | "boolean", 1214 | "object" 1215 | ] 1216 | }, 1217 | "IRulerOption": { 1218 | "properties": { 1219 | "color": { 1220 | "type": "string" 1221 | }, 1222 | "column": { 1223 | "type": "number" 1224 | } 1225 | }, 1226 | "type": "object" 1227 | }, 1228 | "QuickSuggestionsValue": { 1229 | "enum": [ 1230 | true, 1231 | false, 1232 | "on", 1233 | "inline", 1234 | "off" 1235 | ], 1236 | "type": [ 1237 | "boolean", 1238 | "string" 1239 | ] 1240 | }, 1241 | "IEditorScrollbarOptions": { 1242 | "description": "Control the behavior and rendering of the scrollbars.", 1243 | "properties": { 1244 | "alwaysConsumeMouseWheel": { 1245 | "default": true, 1246 | "description": "Always consume mouse wheel events (always call preventDefault() and stopPropagation() on the browser events). Defaults to true. NOTE: This option cannot be updated using updateOptions()", 1247 | "type": "boolean" 1248 | }, 1249 | "arrowSize": { 1250 | "default": 11, 1251 | "description": "The size of arrows (if displayed). Defaults to 11. NOTE: This option cannot be updated using updateOptions()", 1252 | "type": "number" 1253 | }, 1254 | "handleMouseWheel": { 1255 | "default": true, 1256 | "description": "Listen to mouse wheel events and react to them by scrolling. Defaults to true.", 1257 | "type": "boolean" 1258 | }, 1259 | "horizontal": { 1260 | "default": "auto", 1261 | "description": "Render horizontal scrollbar. Defaults to 'auto'.", 1262 | "enum": [ 1263 | "auto", 1264 | "visible", 1265 | "hidden" 1266 | ], 1267 | "type": "string" 1268 | }, 1269 | "horizontalHasArrows": { 1270 | "default": false, 1271 | "description": "Render arrows at the left and right of the horizontal scrollbar. Defaults to false. NOTE: This option cannot be updated using updateOptions()", 1272 | "type": "boolean" 1273 | }, 1274 | "horizontalScrollbarSize": { 1275 | "default": 10, 1276 | "description": "Height in pixels for the horizontal scrollbar. Defaults to 10 (px).", 1277 | "type": "number" 1278 | }, 1279 | "horizontalSliderSize": { 1280 | "description": "Height in pixels for the horizontal slider. Defaults to horizontalScrollbarSize. NOTE: This option cannot be updated using updateOptions()", 1281 | "type": "number" 1282 | }, 1283 | "scrollByPage": { 1284 | "default": false, 1285 | "description": "Scroll gutter clicks move by page vs jump to position. Defaults to false.", 1286 | "type": "boolean" 1287 | }, 1288 | "useShadows": { 1289 | "default": true, 1290 | "description": "Cast horizontal and vertical shadows when the content is scrolled. Defaults to true. NOTE: This option cannot be updated using updateOptions()", 1291 | "type": "boolean" 1292 | }, 1293 | "vertical": { 1294 | "default": "auto", 1295 | "description": "Render vertical scrollbar. Defaults to 'auto'.", 1296 | "enum": [ 1297 | "auto", 1298 | "visible", 1299 | "hidden" 1300 | ], 1301 | "type": "string" 1302 | }, 1303 | "verticalHasArrows": { 1304 | "default": false, 1305 | "description": "Render arrows at the top and bottom of the vertical scrollbar. Defaults to false. NOTE: This option cannot be updated using updateOptions()", 1306 | "type": "boolean" 1307 | }, 1308 | "verticalScrollbarSize": { 1309 | "default": 10, 1310 | "description": "Width in pixels for the vertical scrollbar. Defaults to 10 (px).", 1311 | "type": "number" 1312 | }, 1313 | "verticalSliderSize": { 1314 | "description": "Width in pixels for the vertical slider. Defaults to verticalScrollbarSize. NOTE: This option cannot be updated using updateOptions()", 1315 | "type": "number" 1316 | } 1317 | }, 1318 | "type": "object" 1319 | }, 1320 | "ISmartSelectOptions": { 1321 | "description": "Smart select options.", 1322 | "properties": { 1323 | "selectLeadingAndTrailingWhitespace": { 1324 | "type": "boolean" 1325 | } 1326 | }, 1327 | "type": "object" 1328 | }, 1329 | "IEditorStickyScrollOptions": { 1330 | "description": "Control the behavior of sticky scroll options", 1331 | "properties": { 1332 | "defaultModel": { 1333 | "description": "Model to choose for sticky scroll by default", 1334 | "enum": [ 1335 | "outlineModel", 1336 | "foldingProviderModel", 1337 | "indentationModel" 1338 | ], 1339 | "type": "string" 1340 | }, 1341 | "enabled": { 1342 | "description": "Enable the sticky scroll", 1343 | "type": "boolean" 1344 | }, 1345 | "maxLineCount": { 1346 | "description": "Maximum number of sticky lines to show", 1347 | "type": "number" 1348 | } 1349 | }, 1350 | "type": "object" 1351 | }, 1352 | "ISuggestOptions": { 1353 | "description": "Suggest options", 1354 | "properties": { 1355 | "filterGraceful": { 1356 | "default": true, 1357 | "description": "Enable graceful matching. Defaults to true.", 1358 | "type": "boolean" 1359 | }, 1360 | "insertMode": { 1361 | "default": false, 1362 | "description": "Overwrite word ends on accept. Default to false.", 1363 | "enum": [ 1364 | true, 1365 | false, 1366 | "insert", 1367 | "replace" 1368 | ], 1369 | "type": [ 1370 | "boolean", 1371 | "string" 1372 | ] 1373 | }, 1374 | "localityBonus": { 1375 | "description": "Favors words that appear close to the cursor.", 1376 | "type": "boolean" 1377 | }, 1378 | "matchOnWordStartOnly": { 1379 | "description": "Controls whether suggestions allow matches in the middle of the word instead of only at the beginning.", 1380 | "type": "boolean" 1381 | }, 1382 | "preview": { 1383 | "description": "Enable or disable the rendering of the suggestion preview.", 1384 | "type": "boolean" 1385 | }, 1386 | "previewMode": { 1387 | "description": "Configures the mode of the preview.", 1388 | "enum": [ 1389 | "prefix", 1390 | "subword", 1391 | "subwordSmart" 1392 | ], 1393 | "type": "string" 1394 | }, 1395 | "selectionMode": { 1396 | "description": "Select suggestions when triggered via quick suggest or trigger characters.", 1397 | "enum": [ 1398 | "always", 1399 | "never", 1400 | "whenTriggerCharacter", 1401 | "whenQuickSuggestion" 1402 | ], 1403 | "type": "string" 1404 | }, 1405 | "shareSuggestSelections": { 1406 | "description": "Enable using global storage for remembering suggestions.", 1407 | "type": "boolean" 1408 | }, 1409 | "showClasses": { 1410 | "description": "Show class-suggestions.", 1411 | "type": "boolean" 1412 | }, 1413 | "showColors": { 1414 | "description": "Show color-suggestions.", 1415 | "type": "boolean" 1416 | }, 1417 | "showConstants": { 1418 | "description": "Show constant-suggestions.", 1419 | "type": "boolean" 1420 | }, 1421 | "showConstructors": { 1422 | "description": "Show constructor-suggestions.", 1423 | "type": "boolean" 1424 | }, 1425 | "showDeprecated": { 1426 | "description": "Show deprecated-suggestions.", 1427 | "type": "boolean" 1428 | }, 1429 | "showEnumMembers": { 1430 | "description": "Show enumMember-suggestions.", 1431 | "type": "boolean" 1432 | }, 1433 | "showEnums": { 1434 | "description": "Show enum-suggestions.", 1435 | "type": "boolean" 1436 | }, 1437 | "showEvents": { 1438 | "description": "Show event-suggestions.", 1439 | "type": "boolean" 1440 | }, 1441 | "showFields": { 1442 | "description": "Show field-suggestions.", 1443 | "type": "boolean" 1444 | }, 1445 | "showFiles": { 1446 | "description": "Show file-suggestions.", 1447 | "type": "boolean" 1448 | }, 1449 | "showFolders": { 1450 | "description": "Show folder-suggestions.", 1451 | "type": "boolean" 1452 | }, 1453 | "showFunctions": { 1454 | "description": "Show function-suggestions.", 1455 | "type": "boolean" 1456 | }, 1457 | "showIcons": { 1458 | "default": true, 1459 | "description": "Enable or disable icons in suggestions. Defaults to true.", 1460 | "type": "boolean" 1461 | }, 1462 | "showInlineDetails": { 1463 | "default": true, 1464 | "description": "Show details inline with the label. Defaults to true.", 1465 | "type": "boolean" 1466 | }, 1467 | "showInterfaces": { 1468 | "description": "Show interface-suggestions.", 1469 | "type": "boolean" 1470 | }, 1471 | "showIssues": { 1472 | "description": "Show issue-suggestions.", 1473 | "type": "boolean" 1474 | }, 1475 | "showKeywords": { 1476 | "description": "Show keyword-suggestions.", 1477 | "type": "boolean" 1478 | }, 1479 | "showMethods": { 1480 | "description": "Show method-suggestions.", 1481 | "type": "boolean" 1482 | }, 1483 | "showModules": { 1484 | "description": "Show module-suggestions.", 1485 | "type": "boolean" 1486 | }, 1487 | "showOperators": { 1488 | "description": "Show operator-suggestions.", 1489 | "type": "boolean" 1490 | }, 1491 | "showProperties": { 1492 | "description": "Show property-suggestions.", 1493 | "type": "boolean" 1494 | }, 1495 | "showReferences": { 1496 | "description": "Show reference-suggestions.", 1497 | "type": "boolean" 1498 | }, 1499 | "showSnippets": { 1500 | "description": "Show snippet-suggestions.", 1501 | "type": "boolean" 1502 | }, 1503 | "showStatusBar": { 1504 | "description": "Enable or disable the suggest status bar.", 1505 | "type": "boolean" 1506 | }, 1507 | "showStructs": { 1508 | "description": "Show struct-suggestions.", 1509 | "type": "boolean" 1510 | }, 1511 | "showTypeParameters": { 1512 | "description": "Show typeParameter-suggestions.", 1513 | "type": "boolean" 1514 | }, 1515 | "showUnits": { 1516 | "description": "Show unit-suggestions.", 1517 | "type": "boolean" 1518 | }, 1519 | "showUsers": { 1520 | "description": "Show user-suggestions.", 1521 | "type": "boolean" 1522 | }, 1523 | "showValues": { 1524 | "description": "Show value-suggestions.", 1525 | "type": "boolean" 1526 | }, 1527 | "showVariables": { 1528 | "description": "Show variable-suggestions.", 1529 | "type": "boolean" 1530 | }, 1531 | "showWords": { 1532 | "description": "Show text-suggestions.", 1533 | "type": "boolean" 1534 | }, 1535 | "snippetsPreventQuickSuggestions": { 1536 | "default": true, 1537 | "description": "Prevent quick suggestions when a snippet is active. Defaults to true.", 1538 | "type": "boolean" 1539 | } 1540 | }, 1541 | "type": "object" 1542 | }, 1543 | "IUnicodeHighlightOptions": { 1544 | "description": "Controls the behavior of the unicode highlight feature (by default, ambiguous and invisible characters are highlighted).", 1545 | "properties": { 1546 | "allowedCharacters": { 1547 | "additionalProperties": { 1548 | "type": "boolean", 1549 | "enum": [ 1550 | true 1551 | ] 1552 | }, 1553 | "description": "Defines allowed characters that are not being highlighted.", 1554 | "type": "object" 1555 | }, 1556 | "allowedLocales": { 1557 | "additionalProperties": { 1558 | "type": "boolean", 1559 | "enum": [ 1560 | true 1561 | ] 1562 | }, 1563 | "description": "Unicode characters that are common in allowed locales are not being highlighted.", 1564 | "type": "object" 1565 | }, 1566 | "ambiguousCharacters": { 1567 | "description": "Controls whether characters are highlighted that can be confused with basic ASCII characters, except those that are common in the current user locale.", 1568 | "type": "object" 1569 | }, 1570 | "includeComments": { 1571 | "description": "Controls whether characters in comments should also be subject to unicode highlighting.", 1572 | "enum": [ 1573 | true, 1574 | false, 1575 | "inUntrustedWorkspace" 1576 | ], 1577 | "type": [ 1578 | "boolean", 1579 | "string" 1580 | ] 1581 | }, 1582 | "includeStrings": { 1583 | "description": "Controls whether characters in strings should also be subject to unicode highlighting.", 1584 | "enum": [ 1585 | true, 1586 | false, 1587 | "inUntrustedWorkspace" 1588 | ], 1589 | "type": [ 1590 | "boolean", 1591 | "string" 1592 | ] 1593 | }, 1594 | "invisibleCharacters": { 1595 | "description": "Controls whether characters that just reserve space or have no width at all are highlighted.", 1596 | "type": "boolean" 1597 | }, 1598 | "nonBasicASCII": { 1599 | "description": "Controls whether all non-basic ASCII characters are highlighted. Only characters between U+0020 and U+007E, tab, line-feed and carriage-return are considered basic ASCII.", 1600 | "enum": [ 1601 | true, 1602 | false, 1603 | "inUntrustedWorkspace" 1604 | ], 1605 | "type": [ 1606 | "boolean", 1607 | "string" 1608 | ] 1609 | } 1610 | }, 1611 | "type": "object" 1612 | } 1613 | } 1614 | } 1615 | --------------------------------------------------------------------------------