5841 changed files with 649683 additions and 308 deletions
@ -0,0 +1,72 @@
@@ -0,0 +1,72 @@
|
||||
# In all environments, the following files are loaded if they exist, |
||||
# the latter taking precedence over the former: |
||||
# |
||||
# * .env contains default values for the environment variables needed by the app |
||||
# * .env.local uncommitted file with local overrides |
||||
# * .env.$APP_ENV committed environment-specific defaults |
||||
# * .env.$APP_ENV.local uncommitted environment-specific overrides |
||||
# |
||||
# Real environment variables win over .env files. |
||||
# |
||||
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. |
||||
# https://symfony.com/doc/current/configuration/secrets.html |
||||
# |
||||
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). |
||||
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration |
||||
|
||||
###> symfony/framework-bundle ### |
||||
APP_ENV=dev |
||||
APP_SECRET=9e287f1ad737386dde46d51e80487236 |
||||
###< symfony/framework-bundle ### |
||||
###> docker ### |
||||
SERVER_NAME=http://localhost |
||||
POSTGRES_DB=newsroom_db |
||||
POSTGRES_USER=dn_user |
||||
POSTGRES_PASSWORD=password92749278 |
||||
POSTGRES_VERSION=17 |
||||
POSTGRES_CHARSET=utf8 |
||||
###< docker ### |
||||
|
||||
###> doctrine/doctrine-bundle ### |
||||
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url |
||||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml |
||||
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}?serverVersion=${POSTGRES_VERSION}&charset=${POSTGRES_CHARSET}" |
||||
###< doctrine/doctrine-bundle ### |
||||
|
||||
###> mercure ### |
||||
MERCURE_URL=https://php/.well-known/mercure |
||||
MERCURE_PUBLIC_URL="http://localhost/.well-known/mercure" |
||||
MERCURE_JWT_SECRET="!NotSecretAtAll!" |
||||
MERCURE_PUBLISHER_JWT_KEY="!NotSoSecretMercureHubJWTSecretKey!" |
||||
MERCURE_SUBSCRIBER_JWT_KEY="!NotSoSecretMercureHubJWTSecretKey!" |
||||
###< mercure ### |
||||
|
||||
###> elastic ### |
||||
# Set to 'true' to enable Elasticsearch, 'false' to use database queries |
||||
ELASTICSEARCH_ENABLED=false |
||||
ELASTICSEARCH_HOST=localhost |
||||
ELASTICSEARCH_PORT=9200 |
||||
ELASTICSEARCH_USERNAME=elastic |
||||
ELASTICSEARCH_PASSWORD=your_password |
||||
ELASTICSEARCH_INDEX_NAME=articles |
||||
ELASTICSEARCH_USER_INDEX_NAME=users |
||||
###< elastic ### |
||||
###> redis ### |
||||
REDIS_HOST=redis |
||||
REDIS_PASSWORD=r_password |
||||
###< redis ### |
||||
###> symfony/messenger ### |
||||
MESSENGER_TRANSPORT_DSN="redis://:${REDIS_PASSWORD}@${REDIS_HOST}/1" |
||||
###< symfony/messenger ### |
||||
|
||||
###> nostr relay ### |
||||
# Domain for relay WebSocket endpoint (use relay.your-domain.com in production) |
||||
RELAY_DOMAIN=relay.localhost |
||||
# Internal relay URL used by the Symfony app (ws:// for internal, wss:// for external) |
||||
NOSTR_DEFAULT_RELAY=ws://strfry:7777 |
||||
# Upstream relays to sync from (space-separated list, must be quoted) |
||||
RELAY_UPSTREAMS="wss://relay.somewhere.com" |
||||
|
||||
###> trusted proxies ### |
||||
TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 |
||||
###< trusted proxies ### |
||||
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash |
||||
# Script to download npm packages for Symfony Asset Mapper importmap |
||||
# This works around network timeout issues in the Docker container |
||||
|
||||
cd "$(dirname "$0")" |
||||
|
||||
echo "Downloading npm packages for Asset Mapper..." |
||||
mkdir -p assets/vendor |
||||
|
||||
# Download critical packages first |
||||
packages=( |
||||
"lodash-es@4.17.21" |
||||
"parchment@3.0.0" |
||||
"eventemitter3@5.0.1" |
||||
"fast-diff@1.3.0" |
||||
"lodash.clonedeep@4.5.0" |
||||
"lodash.isequal@4.5.0" |
||||
"es-module-shims@2.0.10" |
||||
"nostr-tools@2.17.0" |
||||
) |
||||
|
||||
download_package() { |
||||
local name=$1 |
||||
local ver=$2 |
||||
local pkg_name=$name |
||||
|
||||
echo "Downloading $name@$ver..." |
||||
|
||||
# Handle scoped packages |
||||
local dir_name=$name |
||||
if [[ $name == @* ]]; then |
||||
# Scoped package like @noble/curves/secp256k1 |
||||
dir_name=$(echo "$name" | sed 's/@/\\@/g') |
||||
fi |
||||
|
||||
# Create package directory |
||||
mkdir -p "assets/vendor/$dir_name" |
||||
|
||||
# Download and extract to temp location |
||||
local temp_dir=$(mktemp -d) |
||||
if curl -sLf "https://registry.npmjs.org/$name/-/${pkg_name##*/}-${ver}.tgz" | tar -xz -C "$temp_dir" 2>/dev/null; then |
||||
# Find the main entry point |
||||
local entry_point="" |
||||
|
||||
# Check common locations for entry point |
||||
if [ -f "$temp_dir/package/dist/index.js" ]; then |
||||
entry_point="$temp_dir/package/dist/index.js" |
||||
elif [ -f "$temp_dir/package/index.js" ]; then |
||||
entry_point="$temp_dir/package/index.js" |
||||
elif [ -f "$temp_dir/package/esm/index.js" ]; then |
||||
entry_point="$temp_dir/package/esm/index.js" |
||||
elif [ -f "$temp_dir/package/main.js" ]; then |
||||
entry_point="$temp_dir/package/main.js" |
||||
else |
||||
# Try to find any .js file in the package |
||||
entry_point=$(find "$temp_dir/package" -name "*.js" -type f | grep -E "(index|main|dist.*index)" | head -1) |
||||
if [ -z "$entry_point" ]; then |
||||
entry_point=$(find "$temp_dir/package" -name "*.js" -type f | head -1) |
||||
fi |
||||
fi |
||||
|
||||
if [ -n "$entry_point" ] && [ -f "$entry_point" ]; then |
||||
cp "$entry_point" "assets/vendor/$dir_name/index.js" |
||||
echo " ✓ Downloaded $name@$ver" |
||||
else |
||||
echo " ✗ Failed to find entry point for $name@$ver" |
||||
fi |
||||
|
||||
rm -rf "$temp_dir" |
||||
else |
||||
echo " ✗ Failed to download $name@$ver" |
||||
rm -rf "$temp_dir" |
||||
return 1 |
||||
fi |
||||
} |
||||
|
||||
for pkg in "${packages[@]}"; do |
||||
name=$(echo "$pkg" | cut -d@ -f1) |
||||
ver=$(echo "$pkg" | cut -d@ -f2) |
||||
download_package "$name" "$ver" || true |
||||
done |
||||
|
||||
echo "Done downloading critical packages" |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../katex/cli.js |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../loose-envify/cli.js |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../ua-parser-js/script/cli.js |
||||
@ -0,0 +1,867 @@
@@ -0,0 +1,867 @@
|
||||
{ |
||||
"name": "newsroom", |
||||
"version": "1.0.0", |
||||
"lockfileVersion": 3, |
||||
"requires": true, |
||||
"packages": { |
||||
"node_modules/@codemirror/autocomplete": { |
||||
"version": "6.20.0", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.0.tgz", |
||||
"integrity": "sha512-bOwvTOIJcG5FVo5gUUupiwYh8MioPLQ4UcqbcRf7UQ98X90tCa9E1kZ3Z7tqwpZxYyOvh1YTYbmZE9RTfTp5hg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.17.0", |
||||
"@lezer/common": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/commands": { |
||||
"version": "6.10.1", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.1.tgz", |
||||
"integrity": "sha512-uWDWFypNdQmz2y1LaNJzK7fL7TYKLeUAU0npEC685OKTF3KcQ2Vu3klIM78D7I6wGhktme0lh3CuQLv0ZCrD9Q==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.4.0", |
||||
"@codemirror/view": "^6.27.0", |
||||
"@lezer/common": "^1.1.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/lang-css": { |
||||
"version": "6.3.1", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz", |
||||
"integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@lezer/common": "^1.0.2", |
||||
"@lezer/css": "^1.1.7" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/lang-html": { |
||||
"version": "6.4.11", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.11.tgz", |
||||
"integrity": "sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/lang-css": "^6.0.0", |
||||
"@codemirror/lang-javascript": "^6.0.0", |
||||
"@codemirror/language": "^6.4.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.17.0", |
||||
"@lezer/common": "^1.0.0", |
||||
"@lezer/css": "^1.1.0", |
||||
"@lezer/html": "^1.3.12" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/lang-javascript": { |
||||
"version": "6.2.4", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.4.tgz", |
||||
"integrity": "sha512-0WVmhp1QOqZ4Rt6GlVGwKJN3KW7Xh4H2q8ZZNGZaP6lRdxXJzmjm4FqvmOojVj6khWJHIb9sp7U/72W7xQgqAA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/language": "^6.6.0", |
||||
"@codemirror/lint": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.17.0", |
||||
"@lezer/common": "^1.0.0", |
||||
"@lezer/javascript": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/lang-json": { |
||||
"version": "6.0.2", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz", |
||||
"integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@lezer/json": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/lang-markdown": { |
||||
"version": "6.5.0", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.0.tgz", |
||||
"integrity": "sha512-0K40bZ35jpHya6FriukbgaleaqzBLZfOh7HuzqbMxBXkbYMJDxfF39c23xOgxFezR+3G+tR2/Mup+Xk865OMvw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.7.1", |
||||
"@codemirror/lang-html": "^6.0.0", |
||||
"@codemirror/language": "^6.3.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.0.0", |
||||
"@lezer/common": "^1.2.1", |
||||
"@lezer/markdown": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/language": { |
||||
"version": "6.12.1", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.1.tgz", |
||||
"integrity": "sha512-Fa6xkSiuGKc8XC8Cn96T+TQHYj4ZZ7RdFmXA3i9xe/3hLHfwPZdM+dqfX0Cp0zQklBKhVD8Yzc8LS45rkqcwpQ==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.23.0", |
||||
"@lezer/common": "^1.5.0", |
||||
"@lezer/highlight": "^1.0.0", |
||||
"@lezer/lr": "^1.0.0", |
||||
"style-mod": "^4.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/lint": { |
||||
"version": "6.9.2", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.2.tgz", |
||||
"integrity": "sha512-sv3DylBiIyi+xKwRCJAAsBZZZWo82shJ/RTMymLabAdtbkV5cSKwWDeCgtUq3v8flTaXS2y1kKkICuRYtUswyQ==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.35.0", |
||||
"crelt": "^1.0.5" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/search": { |
||||
"version": "6.5.11", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.11.tgz", |
||||
"integrity": "sha512-KmWepDE6jUdL6n8cAAqIpRmLPBZ5ZKnicE8oGU/s3QrAVID+0VhLFrzUucVKHG5035/BSykhExDL/Xm7dHthiA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.0.0", |
||||
"crelt": "^1.0.5" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/state": { |
||||
"version": "6.5.3", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.3.tgz", |
||||
"integrity": "sha512-MerMzJzlXogk2fxWFU1nKp36bY5orBG59HnPiz0G9nLRebWa0zXuv2siH6PLIHBvv5TH8CkQRqjBs0MlxCZu+A==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@marijn/find-cluster-break": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/theme-one-dark": { |
||||
"version": "6.1.3", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/theme-one-dark/-/theme-one-dark-6.1.3.tgz", |
||||
"integrity": "sha512-NzBdIvEJmx6fjeremiGp3t/okrLPYT0d9orIc7AFun8oZcRk58aejkqhv6spnz4MLAevrKNPMQYXEWMg4s+sKA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.0.0", |
||||
"@lezer/highlight": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@codemirror/view": { |
||||
"version": "6.39.9", |
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.39.9.tgz", |
||||
"integrity": "sha512-miGSIfBOKC1s2oHoa80dp+BjtsL8sXsrgGlQnQuOcfvaedcQUtqddTmKbJSDkLl4mkgPvZyXuKic2HDNYcJLYA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/state": "^6.5.0", |
||||
"crelt": "^1.0.6", |
||||
"style-mod": "^4.1.0", |
||||
"w3c-keyname": "^2.2.4" |
||||
} |
||||
}, |
||||
"node_modules/@kurkle/color": { |
||||
"version": "0.3.4", |
||||
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz", |
||||
"integrity": "sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/@lezer/common": { |
||||
"version": "1.5.0", |
||||
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.0.tgz", |
||||
"integrity": "sha512-PNGcolp9hr4PJdXR4ix7XtixDrClScvtSCYW3rQG106oVMOOI+jFb+0+J3mbeL/53g1Zd6s0kJzaw6Ri68GmAA==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/@lezer/css": { |
||||
"version": "1.3.0", |
||||
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.0.tgz", |
||||
"integrity": "sha512-pBL7hup88KbI7hXnZV3PQsn43DHy6TWyzuyk2AO9UyoXcDltvIdqWKE1dLL/45JVZ+YZkHe1WVHqO6wugZZWcw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.2.0", |
||||
"@lezer/highlight": "^1.0.0", |
||||
"@lezer/lr": "^1.3.0" |
||||
} |
||||
}, |
||||
"node_modules/@lezer/highlight": { |
||||
"version": "1.2.3", |
||||
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", |
||||
"integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.3.0" |
||||
} |
||||
}, |
||||
"node_modules/@lezer/html": { |
||||
"version": "1.3.13", |
||||
"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz", |
||||
"integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.2.0", |
||||
"@lezer/highlight": "^1.0.0", |
||||
"@lezer/lr": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@lezer/javascript": { |
||||
"version": "1.5.4", |
||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz", |
||||
"integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.2.0", |
||||
"@lezer/highlight": "^1.1.3", |
||||
"@lezer/lr": "^1.3.0" |
||||
} |
||||
}, |
||||
"node_modules/@lezer/json": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz", |
||||
"integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.2.0", |
||||
"@lezer/highlight": "^1.0.0", |
||||
"@lezer/lr": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@lezer/lr": { |
||||
"version": "1.4.7", |
||||
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.7.tgz", |
||||
"integrity": "sha512-wNIFWdSUfX9Jc6ePMzxSPVgTVB4EOfDIwLQLWASyiUdHKaMsiilj9bYiGkGQCKVodd0x6bgQCV207PILGFCF9Q==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@lezer/markdown": { |
||||
"version": "1.6.3", |
||||
"resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.6.3.tgz", |
||||
"integrity": "sha512-jpGm5Ps+XErS+xA4urw7ogEGkeZOahVQF21Z6oECF0sj+2liwZopd2+I8uH5I/vZsRuuze3OxBREIANLf6KKUw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@lezer/common": "^1.5.0", |
||||
"@lezer/highlight": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/@marijn/find-cluster-break": { |
||||
"version": "1.0.2", |
||||
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz", |
||||
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/@noble/ciphers": { |
||||
"version": "0.5.3", |
||||
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.5.3.tgz", |
||||
"integrity": "sha512-B0+6IIHiqEs3BPMT0hcRmHvEj2QHOLu+uwt+tqDDeVd0oyVzh7BPrDcPjRnV1PV/5LaknXJJQvOuRGR0zQJz+w==", |
||||
"license": "MIT", |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@noble/curves": { |
||||
"version": "1.9.7", |
||||
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", |
||||
"integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@noble/hashes": "1.8.0" |
||||
}, |
||||
"engines": { |
||||
"node": "^14.21.3 || >=16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@noble/hashes": { |
||||
"version": "1.8.0", |
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", |
||||
"integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": "^14.21.3 || >=16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/base": { |
||||
"version": "1.2.6", |
||||
"resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", |
||||
"integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", |
||||
"license": "MIT", |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip32": { |
||||
"version": "1.3.1", |
||||
"resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz", |
||||
"integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@noble/curves": "~1.1.0", |
||||
"@noble/hashes": "~1.3.1", |
||||
"@scure/base": "~1.1.0" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip32/node_modules/@noble/curves": { |
||||
"version": "1.1.0", |
||||
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", |
||||
"integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@noble/hashes": "1.3.1" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip32/node_modules/@noble/curves/node_modules/@noble/hashes": { |
||||
"version": "1.3.1", |
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", |
||||
"integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">= 16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip32/node_modules/@noble/hashes": { |
||||
"version": "1.3.3", |
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", |
||||
"integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">= 16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip32/node_modules/@scure/base": { |
||||
"version": "1.1.9", |
||||
"resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", |
||||
"integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", |
||||
"license": "MIT", |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip39": { |
||||
"version": "1.2.1", |
||||
"resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", |
||||
"integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@noble/hashes": "~1.3.0", |
||||
"@scure/base": "~1.1.0" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip39/node_modules/@noble/hashes": { |
||||
"version": "1.3.3", |
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", |
||||
"integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">= 16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/@scure/bip39/node_modules/@scure/base": { |
||||
"version": "1.1.9", |
||||
"resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", |
||||
"integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", |
||||
"license": "MIT", |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/asap": { |
||||
"version": "2.0.6", |
||||
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", |
||||
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/change-emitter": { |
||||
"version": "0.1.6", |
||||
"resolved": "https://registry.npmjs.org/change-emitter/-/change-emitter-0.1.6.tgz", |
||||
"integrity": "sha512-YXzt1cQ4a2jqazhcuSWEOc1K2q8g9H6eWNsyZgi640LDzRWVQ2eDe+Y/kVdftH+vYdPF2rgDb3dLdpxE1jvAxw==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/chart.js": { |
||||
"version": "4.5.1", |
||||
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.5.1.tgz", |
||||
"integrity": "sha512-GIjfiT9dbmHRiYi6Nl2yFCq7kkwdkp1W/lp2J99rX0yo9tgJGn3lKQATztIjb5tVtevcBtIdICNWqlq5+E8/Pw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@kurkle/color": "^0.3.0" |
||||
}, |
||||
"engines": { |
||||
"pnpm": ">=8" |
||||
} |
||||
}, |
||||
"node_modules/codemirror": { |
||||
"version": "6.0.2", |
||||
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz", |
||||
"integrity": "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/commands": "^6.0.0", |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/lint": "^6.0.0", |
||||
"@codemirror/search": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.0.0" |
||||
} |
||||
}, |
||||
"node_modules/commander": { |
||||
"version": "8.3.0", |
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", |
||||
"integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">= 12" |
||||
} |
||||
}, |
||||
"node_modules/core-js": { |
||||
"version": "1.2.7", |
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", |
||||
"integrity": "sha512-ZiPp9pZlgxpWRu0M+YWbm6+aQ84XEfH1JRXvfOc/fILWI0VKhLC2LX13X1NYq4fULzLMq7Hfh43CSo2/aIaUPA==", |
||||
"deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/create-react-class": { |
||||
"version": "15.7.0", |
||||
"resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.7.0.tgz", |
||||
"integrity": "sha512-QZv4sFWG9S5RUvkTYWbflxeZX+JG7Cz0Tn33rQBJ+WFQTqTfUTjMjiv9tnfXazjsO5r0KhPs+AqCjyrQX6h2ng==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"loose-envify": "^1.3.1", |
||||
"object-assign": "^4.1.1" |
||||
} |
||||
}, |
||||
"node_modules/crelt": { |
||||
"version": "1.0.6", |
||||
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", |
||||
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/encoding": { |
||||
"version": "0.1.13", |
||||
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", |
||||
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"iconv-lite": "^0.6.2" |
||||
} |
||||
}, |
||||
"node_modules/eventemitter3": { |
||||
"version": "5.0.1", |
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", |
||||
"integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" |
||||
}, |
||||
"node_modules/fast-diff": { |
||||
"version": "1.3.0", |
||||
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", |
||||
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==" |
||||
}, |
||||
"node_modules/fbjs": { |
||||
"version": "0.8.18", |
||||
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.18.tgz", |
||||
"integrity": "sha512-EQaWFK+fEPSoibjNy8IxUtaFOMXcWsY0JaVrQoZR9zC8N2Ygf9iDITPWjUTVIax95b6I742JFLqASHfsag/vKA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"core-js": "^1.0.0", |
||||
"isomorphic-fetch": "^2.1.1", |
||||
"loose-envify": "^1.0.0", |
||||
"object-assign": "^4.1.0", |
||||
"promise": "^7.1.1", |
||||
"setimmediate": "^1.0.5", |
||||
"ua-parser-js": "^0.7.30" |
||||
} |
||||
}, |
||||
"node_modules/hoist-non-react-statics": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz", |
||||
"integrity": "sha512-r8huvKK+m+VraiRipdZYc+U4XW43j6OFG/oIafe7GfDbRpCduRoX9JI/DRxqgtBSCeL+et6N6ibZoedHS2NyOQ==" |
||||
}, |
||||
"node_modules/iconv-lite": { |
||||
"version": "0.6.3", |
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", |
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"safer-buffer": ">= 2.1.2 < 3.0.0" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.10.0" |
||||
} |
||||
}, |
||||
"node_modules/is-stream": { |
||||
"version": "1.1.0", |
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", |
||||
"integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">=0.10.0" |
||||
} |
||||
}, |
||||
"node_modules/isomorphic-fetch": { |
||||
"version": "2.2.1", |
||||
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", |
||||
"integrity": "sha512-9c4TNAKYXM5PRyVcwUZrF3W09nQ+sO7+jydgs4ZGW9dhsLG2VOlISJABombdQqQRXCwuYG3sYV/puGf5rp0qmA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"node-fetch": "^1.0.1", |
||||
"whatwg-fetch": ">=0.10.0" |
||||
} |
||||
}, |
||||
"node_modules/js-tokens": { |
||||
"version": "4.0.0", |
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", |
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/katex": { |
||||
"version": "0.16.27", |
||||
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.27.tgz", |
||||
"integrity": "sha512-aeQoDkuRWSqQN6nSvVCEFvfXdqo1OQiCmmW1kc9xSdjutPv7BGO7pqY9sQRJpMOGrEdfDgF2TfRXe5eUAD2Waw==", |
||||
"funding": [ |
||||
"https://opencollective.com/katex", |
||||
"https://github.com/sponsors/katex" |
||||
], |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"commander": "^8.3.0" |
||||
}, |
||||
"bin": { |
||||
"katex": "cli.js" |
||||
} |
||||
}, |
||||
"node_modules/lodash-es": { |
||||
"version": "4.17.22", |
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.22.tgz", |
||||
"integrity": "sha512-XEawp1t0gxSi9x01glktRZ5HDy0HXqrM0x5pXQM98EaI0NxO6jVM7omDOxsuEo5UIASAnm2bRp1Jt/e0a2XU8Q==" |
||||
}, |
||||
"node_modules/lodash.clonedeep": { |
||||
"version": "4.5.0", |
||||
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", |
||||
"integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" |
||||
}, |
||||
"node_modules/lodash.isequal": { |
||||
"version": "4.5.0", |
||||
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", |
||||
"integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", |
||||
"deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead." |
||||
}, |
||||
"node_modules/loose-envify": { |
||||
"version": "1.4.0", |
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", |
||||
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"js-tokens": "^3.0.0 || ^4.0.0" |
||||
}, |
||||
"bin": { |
||||
"loose-envify": "cli.js" |
||||
} |
||||
}, |
||||
"node_modules/node-fetch": { |
||||
"version": "1.7.3", |
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", |
||||
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"encoding": "^0.1.11", |
||||
"is-stream": "^1.0.1" |
||||
} |
||||
}, |
||||
"node_modules/nostr-tools": { |
||||
"version": "2.19.4", |
||||
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-2.19.4.tgz", |
||||
"integrity": "sha512-qVLfoTpZegNYRJo5j+Oi6RPu0AwLP6jcvzcB3ySMnIT5DrAGNXfs5HNBspB/2HiGfH3GY+v6yXkTtcKSBQZwSg==", |
||||
"license": "Unlicense", |
||||
"dependencies": { |
||||
"@noble/ciphers": "^0.5.1", |
||||
"@noble/curves": "1.2.0", |
||||
"@noble/hashes": "1.3.1", |
||||
"@scure/base": "1.1.1", |
||||
"@scure/bip32": "1.3.1", |
||||
"@scure/bip39": "1.2.1", |
||||
"nostr-wasm": "0.1.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"typescript": ">=5.0.0" |
||||
}, |
||||
"peerDependenciesMeta": { |
||||
"typescript": { |
||||
"optional": true |
||||
} |
||||
} |
||||
}, |
||||
"node_modules/nostr-tools/node_modules/@noble/curves": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", |
||||
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@noble/hashes": "1.3.2" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes": { |
||||
"version": "1.3.2", |
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", |
||||
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">= 16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/nostr-tools/node_modules/@noble/hashes": { |
||||
"version": "1.3.1", |
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", |
||||
"integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">= 16" |
||||
}, |
||||
"funding": { |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
}, |
||||
"node_modules/nostr-tools/node_modules/@scure/base": { |
||||
"version": "1.1.1", |
||||
"resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.1.tgz", |
||||
"integrity": "sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==", |
||||
"funding": [ |
||||
{ |
||||
"type": "individual", |
||||
"url": "https://paulmillr.com/funding/" |
||||
} |
||||
], |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/nostr-wasm": { |
||||
"version": "0.1.0", |
||||
"resolved": "https://registry.npmjs.org/nostr-wasm/-/nostr-wasm-0.1.0.tgz", |
||||
"integrity": "sha512-78BTryCLcLYv96ONU8Ws3Q1JzjlAt+43pWQhIl86xZmWeegYCNLPml7yQ+gG3vR6V5h4XGj+TxO+SS5dsThQIA==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/object-assign": { |
||||
"version": "4.1.1", |
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", |
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">=0.10.0" |
||||
} |
||||
}, |
||||
"node_modules/parchment": { |
||||
"version": "3.0.0", |
||||
"resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0.tgz", |
||||
"integrity": "sha512-HUrJFQ/StvgmXRcQ1ftY6VEZUq3jA2t9ncFN4F84J/vN0/FPpQF+8FKXb3l6fLces6q0uOHj6NJn+2xvZnxO6A==" |
||||
}, |
||||
"node_modules/prism-react": { |
||||
"version": "1.0.2", |
||||
"resolved": "https://registry.npmjs.org/prism-react/-/prism-react-1.0.2.tgz", |
||||
"integrity": "sha512-OoBo0kX55Fi+M4oGuYQ+AkU4/xSvB357mLXbYGP3j4oi4RtsdY5Rn3ViJ6gGU8IkZKs5cnmF7IteWWwUFyVd7Q==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"recompose": "^0.22.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"react": "^15.0.2 || ^0.14.8" |
||||
} |
||||
}, |
||||
"node_modules/prism-redux": { |
||||
"version": "1.0.2", |
||||
"resolved": "https://registry.npmjs.org/prism-redux/-/prism-redux-1.0.2.tgz", |
||||
"integrity": "sha512-e1DGRK+V/dxL6n6M25Py1QrAQLHkeueXyNxDTURT1y+KAMwSJdnlNvGU3ZLY2RIaA+ZdFTc9oTvTSR+mS88VyQ==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/prismjs": { |
||||
"version": "1.30.0", |
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", |
||||
"integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">=6" |
||||
} |
||||
}, |
||||
"node_modules/promise": { |
||||
"version": "7.3.1", |
||||
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", |
||||
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"asap": "~2.0.3" |
||||
} |
||||
}, |
||||
"node_modules/prop-types": { |
||||
"version": "15.8.1", |
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", |
||||
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"loose-envify": "^1.4.0", |
||||
"object-assign": "^4.1.1", |
||||
"react-is": "^16.13.1" |
||||
} |
||||
}, |
||||
"node_modules/quill": { |
||||
"version": "2.0.3", |
||||
"resolved": "https://registry.npmjs.org/quill/-/quill-2.0.3.tgz", |
||||
"integrity": "sha512-xEYQBqfYx/sfb33VJiKnSJp8ehloavImQ2A6564GAbqG55PGw1dAWUn1MUbQB62t0azawUS2CZZhWCjO8gRvTw==", |
||||
"dependencies": { |
||||
"eventemitter3": "^5.0.1", |
||||
"lodash-es": "^4.17.21", |
||||
"parchment": "^3.0.0", |
||||
"quill-delta": "^5.1.0" |
||||
}, |
||||
"engines": { |
||||
"npm": ">=8.2.3" |
||||
} |
||||
}, |
||||
"node_modules/quill-delta": { |
||||
"version": "5.1.0", |
||||
"resolved": "https://registry.npmjs.org/quill-delta/-/quill-delta-5.1.0.tgz", |
||||
"integrity": "sha512-X74oCeRI4/p0ucjb5Ma8adTXd9Scumz367kkMK5V/IatcX6A0vlgLgKbzXWy5nZmCGeNJm2oQX0d2Eqj+ZIlCA==", |
||||
"dependencies": { |
||||
"fast-diff": "^1.3.0", |
||||
"lodash.clonedeep": "^4.5.0", |
||||
"lodash.isequal": "^4.5.0" |
||||
}, |
||||
"engines": { |
||||
"node": ">= 12.0.0" |
||||
} |
||||
}, |
||||
"node_modules/react": { |
||||
"version": "15.7.0", |
||||
"resolved": "https://registry.npmjs.org/react/-/react-15.7.0.tgz", |
||||
"integrity": "sha512-5/MMRYmpmM0sMTHGLossnJCrmXQIiJilD6y3YN3TzAwGFj6zdnMtFv6xmi65PHKRV+pehIHpT7oy67Sr6s9AHA==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"create-react-class": "^15.6.0", |
||||
"fbjs": "^0.8.9", |
||||
"loose-envify": "^1.1.0", |
||||
"object-assign": "^4.1.0", |
||||
"prop-types": "^15.5.10" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.10.0" |
||||
} |
||||
}, |
||||
"node_modules/react-is": { |
||||
"version": "16.13.1", |
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", |
||||
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/recompose": { |
||||
"version": "0.22.0", |
||||
"resolved": "https://registry.npmjs.org/recompose/-/recompose-0.22.0.tgz", |
||||
"integrity": "sha512-QjNK/CgNg6wa7sqaQelgkRdl7ktIYbOV4xp0m2n8TexmHI5h3gjOc5a6nNQhtH3Js63hGZ1HfvJ3DUErrvZ2yg==", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"change-emitter": "^0.1.2", |
||||
"fbjs": "^0.8.1", |
||||
"hoist-non-react-statics": "^1.0.0", |
||||
"symbol-observable": "^1.0.4" |
||||
}, |
||||
"peerDependencies": { |
||||
"react": "^0.14.0 || ^15.0.0" |
||||
} |
||||
}, |
||||
"node_modules/safer-buffer": { |
||||
"version": "2.1.2", |
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", |
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/setimmediate": { |
||||
"version": "1.0.5", |
||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", |
||||
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/style-mod": { |
||||
"version": "4.1.3", |
||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", |
||||
"integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/symbol-observable": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", |
||||
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", |
||||
"license": "MIT", |
||||
"engines": { |
||||
"node": ">=0.10.0" |
||||
} |
||||
}, |
||||
"node_modules/ua-parser-js": { |
||||
"version": "0.7.41", |
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.41.tgz", |
||||
"integrity": "sha512-O3oYyCMPYgNNHuO7Jjk3uacJWZF8loBgwrfd/5LE/HyZ3lUIOdniQ7DNXJcIgZbwioZxk0fLfI4EVnetdiX5jg==", |
||||
"funding": [ |
||||
{ |
||||
"type": "opencollective", |
||||
"url": "https://opencollective.com/ua-parser-js" |
||||
}, |
||||
{ |
||||
"type": "paypal", |
||||
"url": "https://paypal.me/faisalman" |
||||
}, |
||||
{ |
||||
"type": "github", |
||||
"url": "https://github.com/sponsors/faisalman" |
||||
} |
||||
], |
||||
"license": "MIT", |
||||
"bin": { |
||||
"ua-parser-js": "script/cli.js" |
||||
}, |
||||
"engines": { |
||||
"node": "*" |
||||
} |
||||
}, |
||||
"node_modules/w3c-keyname": { |
||||
"version": "2.2.8", |
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", |
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", |
||||
"license": "MIT" |
||||
}, |
||||
"node_modules/whatwg-fetch": { |
||||
"version": "3.6.20", |
||||
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz", |
||||
"integrity": "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==", |
||||
"license": "MIT" |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,634 @@
@@ -0,0 +1,634 @@
|
||||
## 6.20.0 (2025-11-20) |
||||
|
||||
### New features |
||||
|
||||
Completions now support a `sortText` property to influence sort order. |
||||
|
||||
## 6.19.1 (2025-10-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure a completion's info panel is associated with that completion in the accessibility tree. |
||||
|
||||
## 6.19.0 (2025-09-26) |
||||
|
||||
### New features |
||||
|
||||
Completion sections may now set their rank to `dynamic` to indicate their order should be determined by the matching score of their best-matching option. |
||||
|
||||
## 6.18.7 (2025-09-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add a binding for Alt-i to trigger `startCompletion`, following VS Code's current default bindings. |
||||
|
||||
Improve handling of nested fields in snippets. |
||||
|
||||
## 6.18.6 (2025-02-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where the closing character for double-angle quotation marks and full-width brackets was computed incorrectly. |
||||
|
||||
## 6.18.5 (2025-02-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where clicking on the scrollbar for the completion list could move focus out of the editor. |
||||
|
||||
## 6.18.4 (2024-12-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Align the behavior of snippet completions with text completions in that they overwrite the selected text. |
||||
|
||||
## 6.18.3 (2024-11-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Backspacing to the start of the completed range will no longer close the completion tooltip when it was triggered implicitly by typing the character before that range. |
||||
|
||||
## 6.18.2 (2024-10-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't immediately show synchronously updated completions when there are some sources that still need to return. |
||||
|
||||
## 6.18.1 (2024-09-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `insertCompletionText` would get confused about the length of the inserted text when it contained CRLF line breaks, and create an invalid selection. |
||||
|
||||
Add Alt-Backtick as additional binding on macOS, where IME can take over Ctrl-Space. |
||||
|
||||
## 6.18.0 (2024-08-05) |
||||
|
||||
### Bug fixes |
||||
|
||||
Style the info element so that newlines are preserved, to make it easier to display multi-line info from a string source. |
||||
|
||||
### New features |
||||
|
||||
When registering an `abort` handler for a completion query, you can now use the `onDocChange` option to indicate that your query should be aborted as soon as the document changes while it is running. |
||||
|
||||
## 6.17.0 (2024-07-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where completions weren't properly reset when starting a new completion through `activateOnCompletion`. |
||||
|
||||
### New features |
||||
|
||||
`CompletionContext` objects now have a `view` property that holds the editor view when the query context has a view available. |
||||
|
||||
## 6.16.3 (2024-06-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
Avoid adding an `aria-autocomplete` attribute to the editor when there are no active sources active. |
||||
|
||||
## 6.16.2 (2024-05-31) |
||||
|
||||
### Bug fixes |
||||
|
||||
Allow backslash-escaped closing braces inside snippet field names/content. |
||||
|
||||
## 6.16.1 (2024-05-29) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where multiple backslashes before a brace in a snippet were all removed. |
||||
|
||||
## 6.16.0 (2024-04-12) |
||||
|
||||
### New features |
||||
|
||||
The new `activateOnCompletion` option allows autocompletion to be configured to chain completion activation for some types of completions. |
||||
|
||||
## 6.15.0 (2024-03-13) |
||||
|
||||
### New features |
||||
|
||||
The new `filterStrict` option can be used to turn off fuzzy matching of completions. |
||||
|
||||
## 6.14.0 (2024-03-10) |
||||
|
||||
### New features |
||||
|
||||
Completion results can now define a `map` method that can be used to adjust position-dependent information for document changes. |
||||
|
||||
## 6.13.0 (2024-02-29) |
||||
|
||||
### New features |
||||
|
||||
Completions may now provide 'commit characters' that, when typed, commit the completion before inserting the character. |
||||
|
||||
## 6.12.0 (2024-01-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure snippet completions also set `userEvent` to `input.complete`. |
||||
|
||||
Fix a crash when the editor lost focus during an update and autocompletion was active. |
||||
|
||||
Fix a crash when using a snippet that has only one field, but multiple instances of that field. |
||||
|
||||
### New features |
||||
|
||||
The new `activateOnTypingDelay` option allows control over the debounce time before the completions are queried when the user types. |
||||
|
||||
## 6.11.1 (2023-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused typing over closed brackets after pressing enter to still not work in many situations. |
||||
|
||||
## 6.11.0 (2023-11-09) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue that would prevent typing over closed brackets after starting a new line with enter. |
||||
|
||||
### New features |
||||
|
||||
Additional elements rendered in completion options with `addToOptions` are now given access to the editor view. |
||||
|
||||
## 6.10.2 (2023-10-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused `updateSyncTime` to always delay the initial population of the tooltip. |
||||
|
||||
## 6.10.1 (2023-10-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where picking a selection with the mouse could use the wrong completion if the completion list was updated after being opened. |
||||
|
||||
## 6.10.0 (2023-10-11) |
||||
|
||||
### New features |
||||
|
||||
The new autocompletion configuration option `updateSyncTime` allows control over how long fast sources are held back waiting for slower completion sources. |
||||
|
||||
## 6.9.2 (2023-10-06) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug in `completeAnyWord` that could cause it to generate invalid regular expressions and crash. |
||||
|
||||
## 6.9.1 (2023-09-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure the cursor is scrolled into view after inserting completion text. |
||||
|
||||
Make sure scrolling completions into view doesn't get confused when the tooltip is scaled. |
||||
|
||||
## 6.9.0 (2023-07-18) |
||||
|
||||
### New features |
||||
|
||||
Completions may now provide a `displayLabel` property that overrides the way they are displayed in the completion list. |
||||
|
||||
## 6.8.1 (2023-06-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
`acceptCompletion` now returns false (allowing other handlers to take effect) when the completion popup is open but disabled. |
||||
|
||||
## 6.8.0 (2023-06-12) |
||||
|
||||
### New features |
||||
|
||||
The result of `Completion.info` may now include a `destroy` method that will be called when the tooltip is removed. |
||||
|
||||
## 6.7.1 (2023-05-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that cause incorrect ordering of completions when some results covered input text and others didn't. |
||||
|
||||
## 6.7.0 (2023-05-11) |
||||
|
||||
### New features |
||||
|
||||
The new `hasNextSnippetField` and `hasPrevSnippetField` functions can be used to figure out if the snippet-field-motion commands apply to a given state. |
||||
|
||||
## 6.6.1 (2023-05-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that made the editor use the completion's original position, rather than its current position, when changes happened in the document while a result was active. |
||||
|
||||
## 6.6.0 (2023-04-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug in `insertCompletionText` that caused it to replace the wrong range when a result set's `to` fell after the cursor. |
||||
|
||||
### New features |
||||
|
||||
Functions returned by `snippet` can now be called without a completion object. |
||||
|
||||
## 6.5.1 (2023-04-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Keep completions open when interaction with an info tooltip moves focus out of the editor. |
||||
|
||||
## 6.5.0 (2023-04-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
When `closeBrackets` skips a bracket, it now generates a change that overwrites the bracket. |
||||
|
||||
Replace the entire selected range when picking a completion with a non-cursor selection active. |
||||
|
||||
### New features |
||||
|
||||
Completions can now provide a `section` field that is used to group them into sections. |
||||
|
||||
The new `positionInfo` option can be used to provide custom logic for positioning the info tooltips. |
||||
|
||||
## 6.4.2 (2023-02-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where the apply method created by `snippet` didn't add a `pickedCompletion` annotation to the transactions it created. |
||||
|
||||
## 6.4.1 (2023-02-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't consider node names in trees that aren't the same language as the one at the completion position in `ifIn` and `ifNotIn`. |
||||
|
||||
Make sure completions that exactly match the input get a higher score than those that don't (so that even if the latter has a score boost, it ends up lower in the list). |
||||
|
||||
## 6.4.0 (2022-12-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where the extension would sometimes try to draw a disabled dialog at an outdated position, leading to plugin crashes. |
||||
|
||||
### New features |
||||
|
||||
A `tooltipClass` option to autocompletion can now be used to add additional CSS classes to the completion tooltip. |
||||
|
||||
## 6.3.4 (2022-11-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where completion lists could end up being higher than the tooltip they were in. |
||||
|
||||
## 6.3.3 (2022-11-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Set an explicit `box-sizing` style on completion icons so CSS resets don't mess them up. |
||||
|
||||
Allow closing braces in templates to be escaped with a backslash. |
||||
|
||||
## 6.3.2 (2022-11-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression that could cause the completion dialog to stick around when it should be hidden. |
||||
|
||||
## 6.3.1 (2022-11-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression where transactions for picking a completion (without custom `apply` method) no longer had the `pickedCompletion` annotation. |
||||
|
||||
Reduce flickering for completion sources without `validFor` info by temporarily showing a disabled tooltip while the completion updates. |
||||
|
||||
Make sure completion info tooltips are kept within the space provided by the `tooltipSpace` option. |
||||
|
||||
## 6.3.0 (2022-09-22) |
||||
|
||||
### New features |
||||
|
||||
Close bracket configuration now supports a `stringPrefixes` property that can be used to allow autoclosing of prefixed strings. |
||||
|
||||
## 6.2.0 (2022-09-13) |
||||
|
||||
### New features |
||||
|
||||
Autocompletion now takes an `interactionDelay` option that can be used to control the delay between the time where completion opens and the time where commands like `acceptCompletion` affect it. |
||||
|
||||
## 6.1.1 (2022-09-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that prevented transactions produced by `deleteBracketPair` from being marked as deletion user events. |
||||
|
||||
Improve positioning of completion info tooltips so they are less likely to stick out of the screen on small displays. |
||||
|
||||
## 6.1.0 (2022-07-19) |
||||
|
||||
### New features |
||||
|
||||
You can now provide a `compareCompletions` option to autocompletion to influence the way completions with the same match score are sorted. |
||||
|
||||
The `selectOnOpen` option to autocompletion can be used to require explicitly selecting a completion option before `acceptCompletion` does anything. |
||||
|
||||
## 6.0.4 (2022-07-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Remove a leftover `console.log` in bracket closing code. |
||||
|
||||
## 6.0.3 (2022-07-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused `closeBrackets` to not close quotes when at the end of a syntactic construct that starts with a similar quote. |
||||
|
||||
## 6.0.2 (2022-06-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Declare package dependencies as peer dependencies as an attempt to avoid duplicated package issues. |
||||
|
||||
## 6.0.1 (2022-06-09) |
||||
|
||||
### Bug fixes |
||||
|
||||
Support escaping `${` or `#{` in snippets. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Scroll the cursor into view when inserting a snippet. |
||||
|
||||
## 0.20.3 (2022-05-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add an aria-label to the completion listbox. |
||||
|
||||
Fix a regression that caused transactions generated for completion to not have a `userEvent` annotation. |
||||
|
||||
## 0.20.2 (2022-05-24) |
||||
|
||||
### New features |
||||
|
||||
The package now exports an `insertCompletionText` helper that implements the default behavior for applying a completion. |
||||
|
||||
## 0.20.1 (2022-05-16) |
||||
|
||||
### New features |
||||
|
||||
The new `closeOnBlur` option determines whether the completion tooltip is closed when the editor loses focus. |
||||
|
||||
`CompletionResult` objects with `filter: false` may now have a `getMatch` property that determines the matched range in the options. |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Breaking changes |
||||
|
||||
`CompletionResult.span` has been renamed to `validFor`, and may now hold a function as well as a regular expression. |
||||
|
||||
### Bug fixes |
||||
|
||||
Remove code that dropped any options beyond the 300th one when matching and sorting option lists. |
||||
|
||||
Completion will now apply to all cursors when there are multiple cursors. |
||||
|
||||
### New features |
||||
|
||||
`CompletionResult.update` can now be used to implement quick autocompletion updates in a synchronous way. |
||||
|
||||
The @codemirror/closebrackets package was merged into this one. |
||||
|
||||
## 0.19.15 (2022-03-23) |
||||
|
||||
### New features |
||||
|
||||
The `selectedCompletionIndex` function tells you the position of the currently selected completion. |
||||
|
||||
The new `setSelectionCompletion` function creates a state effect that moves the selected completion to a given index. |
||||
|
||||
A completion's `info` method may now return null to indicate that no further info is available. |
||||
|
||||
## 0.19.14 (2022-03-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make the ARIA attributes added to the editor during autocompletion spec-compliant. |
||||
|
||||
## 0.19.13 (2022-02-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where the completion tooltip stayed open if it was explicitly opened and the user backspaced past its start. |
||||
|
||||
Stop snippet filling when a change happens across one of the snippet fields' boundaries. |
||||
|
||||
## 0.19.12 (2022-01-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix completion navigation with PageUp/Down when the completion tooltip isn't part of the view DOM. |
||||
|
||||
## 0.19.11 (2022-01-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused page up/down to only move the selection by two options in the completion tooltip. |
||||
|
||||
## 0.19.10 (2022-01-05) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure the info tooltip is hidden when the selected option is scrolled out of view. |
||||
|
||||
Fix a bug in the completion ranking that would sometimes give options that match the input by word start chars higher scores than appropriate. |
||||
|
||||
Options are now sorted (ascending) by length when their match score is otherwise identical. |
||||
|
||||
## 0.19.9 (2021-11-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where info tooltips would be visible in an inappropriate position when there was no room to place them properly. |
||||
|
||||
## 0.19.8 (2021-11-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Give the completion tooltip a minimal width, and show ellipsis when completions overflow the tooltip width. |
||||
|
||||
### New features |
||||
|
||||
`autocompletion` now accepts an `aboveCursor` option to make the completion tooltip show up above the cursor. |
||||
|
||||
## 0.19.7 (2021-11-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make option deduplication less aggressive, so that options with different `type` or `apply` fields don't get merged. |
||||
|
||||
## 0.19.6 (2021-11-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where parsing a snippet with a field that was labeled only by a number crashed. |
||||
|
||||
## 0.19.5 (2021-11-09) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure info tooltips don't stick out of the bottom of the page. |
||||
|
||||
### New features |
||||
|
||||
The package exports a new function `selectedCompletion`, which can be used to find out which completion is currently selected. |
||||
|
||||
Transactions created by picking a completion now have an annotation (`pickedCompletion`) holding the original completion. |
||||
|
||||
## 0.19.4 (2021-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't rely on the platform's highlight colors for the active completion, since those are inconsistent and may not be appropriate for the theme. |
||||
|
||||
Fix incorrect match underline for some kinds of matched completions. |
||||
|
||||
## 0.19.3 (2021-08-31) |
||||
|
||||
### Bug fixes |
||||
|
||||
Improve the sorting of completions by using `localeCompare`. |
||||
|
||||
Fix reading of autocompletions in NVDA screen reader. |
||||
|
||||
### New features |
||||
|
||||
The new `icons` option can be used to turn off icons in the completion list. |
||||
|
||||
The `optionClass` option can now be used to add CSS classes to the options in the completion list. |
||||
|
||||
It is now possible to inject additional content into rendered completion options with the `addToOptions` configuration option. |
||||
|
||||
## 0.19.2 (2021-08-25) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `completeAnyWord` would return results when there was no query and `explicit` was false. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.19.0 |
||||
|
||||
## 0.18.8 (2021-06-30) |
||||
|
||||
### New features |
||||
|
||||
Add an `ifIn` helper function that constrains a completion source to only fire when in a given syntax node. Add support for unfiltered completions |
||||
|
||||
A completion result can now set a `filter: false` property to disable filtering and sorting of completions, when it already did so itself. |
||||
|
||||
## 0.18.7 (2021-06-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't treat continued completions when typing after an explicit completion as explicit. |
||||
|
||||
## 0.18.6 (2021-06-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Adding or reconfiguring completion sources will now cause them to be activated right away if a completion was active. |
||||
|
||||
### New features |
||||
|
||||
You can now specify multiple types in `Completion.type` by separating them by spaces. Small doc comment tweak for Completion.type |
||||
|
||||
## 0.18.5 (2021-04-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression where snippet field selection didn't work with @codemirror/state 0.18.6. |
||||
|
||||
Fix a bug where snippet fields with different position numbers were inappropriately merged. |
||||
|
||||
## 0.18.4 (2021-04-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a crash in Safari when moving the selection during composition. |
||||
|
||||
## 0.18.3 (2021-03-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Adjust to updated @codemirror/tooltip interface. |
||||
|
||||
## 0.18.2 (2021-03-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix unintended ES2020 output (the package contains ES6 code again). |
||||
|
||||
## 0.18.1 (2021-03-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Stop active completion when all sources resolve without producing any matches. |
||||
|
||||
### New features |
||||
|
||||
`Completion.info` may now return a promise. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Only preserve selected option across updates when it isn't the first option. |
||||
|
||||
## 0.17.4 (2021-01-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a styling issue where the selection had become invisible inside snippet fields (when using `drawSelection`). |
||||
|
||||
### New features |
||||
|
||||
Snippet fields can now be selected with the pointing device (so that they are usable on touch devices). |
||||
|
||||
## 0.17.3 (2021-01-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where uppercase completions would be incorrectly matched against the typed input. |
||||
|
||||
## 0.17.2 (2021-01-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't bind Cmd-Space on macOS, since that already has a system default binding. Use Ctrl-Space for autocompletion. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
# @codemirror/autocomplete [](https://www.npmjs.org/package/@codemirror/autocomplete) |
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#autocomplete) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/autocomplete/blob/main/CHANGELOG.md) ] |
||||
|
||||
This package implements autocompletion for the |
||||
[CodeMirror](https://codemirror.net/) code editor. |
||||
|
||||
The [project page](https://codemirror.net/) has more information, a |
||||
number of [examples](https://codemirror.net/examples/) and the |
||||
[documentation](https://codemirror.net/docs/). |
||||
|
||||
This code is released under an |
||||
[MIT license](https://github.com/codemirror/autocomplete/tree/main/LICENSE). |
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit, |
||||
we have a [code of |
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies |
||||
to communication around the project. |
||||
|
||||
## Usage |
||||
|
||||
```javascript |
||||
import {EditorView} from "@codemirror/view" |
||||
import {autocompletion} from "@codemirror/autocomplete" |
||||
import {jsonLanguage} from "@codemirror/lang-json" |
||||
|
||||
const view = new EditorView({ |
||||
parent: document.body, |
||||
extensions: [ |
||||
jsonLanguage, |
||||
autocompletion(), |
||||
jsonLanguage.data.of({ |
||||
autocomplete: ["id", "name", "address"] |
||||
}) |
||||
] |
||||
}) |
||||
``` |
||||
|
||||
This configuration will just complete the given words anywhere in JSON |
||||
context. Most language modules come with more refined autocompletion |
||||
built-in, but you can also write your own custom autocompletion |
||||
[sources](https://codemirror.net/docs/ref/#autocomplete.CompletionSource) |
||||
and associate them with your language this way. |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,648 @@
@@ -0,0 +1,648 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state'; |
||||
import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view'; |
||||
import * as _lezer_common from '@lezer/common'; |
||||
|
||||
/** |
||||
Objects type used to represent individual completions. |
||||
*/ |
||||
interface Completion { |
||||
/** |
||||
The label to show in the completion picker. This is what input |
||||
is matched against to determine whether a completion matches (and |
||||
how well it matches). |
||||
*/ |
||||
label: string; |
||||
/** |
||||
An optional override for the completion's visible label. When |
||||
using this, matched characters will only be highlighted if you |
||||
provide a [`getMatch`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.getMatch) |
||||
function. |
||||
*/ |
||||
displayLabel?: string; |
||||
/** |
||||
Overrides the text that is used to sort completions. Will |
||||
default to `label` if not given. |
||||
*/ |
||||
sortText?: string; |
||||
/** |
||||
An optional short piece of information to show (with a different |
||||
style) after the label. |
||||
*/ |
||||
detail?: string; |
||||
/** |
||||
Additional info to show when the completion is selected. Can be |
||||
a plain string or a function that'll render the DOM structure to |
||||
show when invoked. |
||||
*/ |
||||
info?: string | ((completion: Completion) => CompletionInfo | Promise<CompletionInfo>); |
||||
/** |
||||
How to apply the completion. The default is to replace it with |
||||
its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a |
||||
string, the completion range is replaced by that string. When it |
||||
is a function, that function is called to perform the |
||||
completion. If it fires a transaction, it is responsible for |
||||
adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion) |
||||
annotation to it. |
||||
*/ |
||||
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void); |
||||
/** |
||||
The type of the completion. This is used to pick an icon to show |
||||
for the completion. Icons are styled with a CSS class created by |
||||
appending the type name to `"cm-completionIcon-"`. You can |
||||
define or restyle icons by defining these selectors. The base |
||||
library defines simple icons for `class`, `constant`, `enum`, |
||||
`function`, `interface`, `keyword`, `method`, `namespace`, |
||||
`property`, `text`, `type`, and `variable`. |
||||
|
||||
Multiple types can be provided by separating them with spaces. |
||||
*/ |
||||
type?: string; |
||||
/** |
||||
When this option is selected, and one of these characters is |
||||
typed, insert the completion before typing the character. |
||||
*/ |
||||
commitCharacters?: readonly string[]; |
||||
/** |
||||
When given, should be a number from -99 to 99 that adjusts how |
||||
this completion is ranked compared to other completions that |
||||
match the input as well as this one. A negative number moves it |
||||
down the list, a positive number moves it up. |
||||
*/ |
||||
boost?: number; |
||||
/** |
||||
Can be used to divide the completion list into sections. |
||||
Completions in a given section (matched by name) will be grouped |
||||
together, with a heading above them. Options without section |
||||
will appear above all sections. A string value is equivalent to |
||||
a `{name}` object. |
||||
*/ |
||||
section?: string | CompletionSection; |
||||
} |
||||
/** |
||||
The type returned from |
||||
[`Completion.info`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info). May be a DOM |
||||
node, null to indicate there is no info, or an object with an |
||||
optional `destroy` method that cleans up the node. |
||||
*/ |
||||
type CompletionInfo = Node | null | { |
||||
dom: Node; |
||||
destroy?(): void; |
||||
}; |
||||
/** |
||||
Object used to describe a completion |
||||
[section](https://codemirror.net/6/docs/ref/#autocomplete.Completion.section). It is recommended to |
||||
create a shared object used by all the completions in a given |
||||
section. |
||||
*/ |
||||
interface CompletionSection { |
||||
/** |
||||
The name of the section. If no `render` method is present, this |
||||
will be displayed above the options. |
||||
*/ |
||||
name: string; |
||||
/** |
||||
An optional function that renders the section header. Since the |
||||
headers are shown inside a list, you should make sure the |
||||
resulting element has a `display: list-item` style. |
||||
*/ |
||||
header?: (section: CompletionSection) => HTMLElement; |
||||
/** |
||||
By default, sections are ordered alphabetically by name. To |
||||
specify an explicit order, `rank` can be used. Sections with a |
||||
lower rank will be shown above sections with a higher rank. |
||||
|
||||
When set to `"dynamic"`, the section's position compared to |
||||
other dynamic sections depends on the matching score of the |
||||
best-matching option in the sections. |
||||
*/ |
||||
rank?: number | "dynamic"; |
||||
} |
||||
/** |
||||
An instance of this is passed to completion source functions. |
||||
*/ |
||||
declare class CompletionContext { |
||||
/** |
||||
The editor state that the completion happens in. |
||||
*/ |
||||
readonly state: EditorState; |
||||
/** |
||||
The position at which the completion is happening. |
||||
*/ |
||||
readonly pos: number; |
||||
/** |
||||
Indicates whether completion was activated explicitly, or |
||||
implicitly by typing. The usual way to respond to this is to |
||||
only return completions when either there is part of a |
||||
completable entity before the cursor, or `explicit` is true. |
||||
*/ |
||||
readonly explicit: boolean; |
||||
/** |
||||
The editor view. May be undefined if the context was created |
||||
in a situation where there is no such view available, such as |
||||
in synchronous updates via |
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) |
||||
or when called by test code. |
||||
*/ |
||||
readonly view?: EditorView | undefined; |
||||
/** |
||||
Create a new completion context. (Mostly useful for testing |
||||
completion sources—in the editor, the extension will create |
||||
these for you.) |
||||
*/ |
||||
constructor( |
||||
/** |
||||
The editor state that the completion happens in. |
||||
*/ |
||||
state: EditorState, |
||||
/** |
||||
The position at which the completion is happening. |
||||
*/ |
||||
pos: number, |
||||
/** |
||||
Indicates whether completion was activated explicitly, or |
||||
implicitly by typing. The usual way to respond to this is to |
||||
only return completions when either there is part of a |
||||
completable entity before the cursor, or `explicit` is true. |
||||
*/ |
||||
explicit: boolean, |
||||
/** |
||||
The editor view. May be undefined if the context was created |
||||
in a situation where there is no such view available, such as |
||||
in synchronous updates via |
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update) |
||||
or when called by test code. |
||||
*/ |
||||
view?: EditorView | undefined); |
||||
/** |
||||
Get the extent, content, and (if there is a token) type of the |
||||
token before `this.pos`. |
||||
*/ |
||||
tokenBefore(types: readonly string[]): { |
||||
from: number; |
||||
to: number; |
||||
text: string; |
||||
type: _lezer_common.NodeType; |
||||
} | null; |
||||
/** |
||||
Get the match of the given expression directly before the |
||||
cursor. |
||||
*/ |
||||
matchBefore(expr: RegExp): { |
||||
from: number; |
||||
to: number; |
||||
text: string; |
||||
} | null; |
||||
/** |
||||
Yields true when the query has been aborted. Can be useful in |
||||
asynchronous queries to avoid doing work that will be ignored. |
||||
*/ |
||||
get aborted(): boolean; |
||||
/** |
||||
Allows you to register abort handlers, which will be called when |
||||
the query is |
||||
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted). |
||||
|
||||
By default, running queries will not be aborted for regular |
||||
typing or backspacing, on the assumption that they are likely to |
||||
return a result with a |
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that |
||||
allows the result to be used after all. Passing `onDocChange: |
||||
true` will cause this query to be aborted for any document |
||||
change. |
||||
*/ |
||||
addEventListener(type: "abort", listener: () => void, options?: { |
||||
onDocChange: boolean; |
||||
}): void; |
||||
} |
||||
/** |
||||
Given a a fixed array of options, return an autocompleter that |
||||
completes them. |
||||
*/ |
||||
declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource; |
||||
/** |
||||
Wrap the given completion source so that it will only fire when the |
||||
cursor is in a syntax node with one of the given names. |
||||
*/ |
||||
declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource; |
||||
/** |
||||
Wrap the given completion source so that it will not fire when the |
||||
cursor is in a syntax node with one of the given names. |
||||
*/ |
||||
declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource; |
||||
/** |
||||
The function signature for a completion source. Such a function |
||||
may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult) |
||||
synchronously or as a promise. Returning null indicates no |
||||
completions are available. |
||||
*/ |
||||
type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise<CompletionResult | null>; |
||||
/** |
||||
Interface for objects returned by completion sources. |
||||
*/ |
||||
interface CompletionResult { |
||||
/** |
||||
The start of the range that is being completed. |
||||
*/ |
||||
from: number; |
||||
/** |
||||
The end of the range that is being completed. Defaults to the |
||||
main cursor position. |
||||
*/ |
||||
to?: number; |
||||
/** |
||||
The completions returned. These don't have to be compared with |
||||
the input by the source—the autocompletion system will do its |
||||
own matching (against the text between `from` and `to`) and |
||||
sorting. |
||||
*/ |
||||
options: readonly Completion[]; |
||||
/** |
||||
When given, further typing or deletion that causes the part of |
||||
the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from` |
||||
and `to` to match this regular expression or predicate function |
||||
will not query the completion source again, but continue with |
||||
this list of options. This can help a lot with responsiveness, |
||||
since it allows the completion list to be updated synchronously. |
||||
*/ |
||||
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean); |
||||
/** |
||||
By default, the library filters and scores completions. Set |
||||
`filter` to `false` to disable this, and cause your completions |
||||
to all be included, in the order they were given. When there are |
||||
other sources, unfiltered completions appear at the top of the |
||||
list of completions. `validFor` must not be given when `filter` |
||||
is `false`, because it only works when filtering. |
||||
*/ |
||||
filter?: boolean; |
||||
/** |
||||
When [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) is set to |
||||
`false` or a completion has a |
||||
[`displayLabel`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.displayLabel), this |
||||
may be provided to compute the ranges on the label that match |
||||
the input. Should return an array of numbers where each pair of |
||||
adjacent numbers provide the start and end of a range. The |
||||
second argument, the match found by the library, is only passed |
||||
when `filter` isn't `false`. |
||||
*/ |
||||
getMatch?: (completion: Completion, matched?: readonly number[]) => readonly number[]; |
||||
/** |
||||
Synchronously update the completion result after typing or |
||||
deletion. If given, this should not do any expensive work, since |
||||
it will be called during editor state updates. The function |
||||
should make sure (similar to |
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the |
||||
completion still applies in the new state. |
||||
*/ |
||||
update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null; |
||||
/** |
||||
When results contain position-dependent information in, for |
||||
example, `apply` methods, you can provide this method to update |
||||
the result for transactions that happen after the query. It is |
||||
not necessary to update `from` and `to`—those are tracked |
||||
automatically. |
||||
*/ |
||||
map?: (current: CompletionResult, changes: ChangeDesc) => CompletionResult | null; |
||||
/** |
||||
Set a default set of [commit |
||||
characters](https://codemirror.net/6/docs/ref/#autocomplete.Completion.commitCharacters) for all |
||||
options in this result. |
||||
*/ |
||||
commitCharacters?: readonly string[]; |
||||
} |
||||
/** |
||||
This annotation is added to transactions that are produced by |
||||
picking a completion. |
||||
*/ |
||||
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>; |
||||
/** |
||||
Helper function that returns a transaction spec which inserts a |
||||
completion's text in the main selection range, and any other |
||||
selection range that has the same text in front of it. |
||||
*/ |
||||
declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec; |
||||
|
||||
interface CompletionConfig { |
||||
/** |
||||
When enabled (defaults to true), autocompletion will start |
||||
whenever the user types something that can be completed. |
||||
*/ |
||||
activateOnTyping?: boolean; |
||||
/** |
||||
When given, if a completion that matches the predicate is |
||||
picked, reactivate completion again as if it was typed normally. |
||||
*/ |
||||
activateOnCompletion?: (completion: Completion) => boolean; |
||||
/** |
||||
The amount of time to wait for further typing before querying |
||||
completion sources via |
||||
[`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping). |
||||
Defaults to 100, which should be fine unless your completion |
||||
source is very slow and/or doesn't use `validFor`. |
||||
*/ |
||||
activateOnTypingDelay?: number; |
||||
/** |
||||
By default, when completion opens, the first option is selected |
||||
and can be confirmed with |
||||
[`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion). When this |
||||
is set to false, the completion widget starts with no completion |
||||
selected, and the user has to explicitly move to a completion |
||||
before you can confirm one. |
||||
*/ |
||||
selectOnOpen?: boolean; |
||||
/** |
||||
Override the completion sources used. By default, they will be |
||||
taken from the `"autocomplete"` [language |
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold |
||||
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays |
||||
of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)). |
||||
*/ |
||||
override?: readonly CompletionSource[] | null; |
||||
/** |
||||
Determines whether the completion tooltip is closed when the |
||||
editor loses focus. Defaults to true. |
||||
*/ |
||||
closeOnBlur?: boolean; |
||||
/** |
||||
The maximum number of options to render to the DOM. |
||||
*/ |
||||
maxRenderedOptions?: number; |
||||
/** |
||||
Set this to false to disable the [default completion |
||||
keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to |
||||
add bindings to control completion yourself. The bindings should |
||||
probably have a higher precedence than other bindings for the |
||||
same keys.) |
||||
*/ |
||||
defaultKeymap?: boolean; |
||||
/** |
||||
By default, completions are shown below the cursor when there is |
||||
space. Setting this to true will make the extension put the |
||||
completions above the cursor when possible. |
||||
*/ |
||||
aboveCursor?: boolean; |
||||
/** |
||||
When given, this may return an additional CSS class to add to |
||||
the completion dialog element. |
||||
*/ |
||||
tooltipClass?: (state: EditorState) => string; |
||||
/** |
||||
This can be used to add additional CSS classes to completion |
||||
options. |
||||
*/ |
||||
optionClass?: (completion: Completion) => string; |
||||
/** |
||||
By default, the library will render icons based on the |
||||
completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of |
||||
each option. Set this to false to turn that off. |
||||
*/ |
||||
icons?: boolean; |
||||
/** |
||||
This option can be used to inject additional content into |
||||
options. The `render` function will be called for each visible |
||||
completion, and should produce a DOM node to show. `position` |
||||
determines where in the DOM the result appears, relative to |
||||
other added widgets and the standard content. The default icons |
||||
have position 20, the label position 50, and the detail position |
||||
80. |
||||
*/ |
||||
addToOptions?: { |
||||
render: (completion: Completion, state: EditorState, view: EditorView) => Node | null; |
||||
position: number; |
||||
}[]; |
||||
/** |
||||
By default, [info](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info) tooltips are |
||||
placed to the side of the selected completion. This option can |
||||
be used to override that. It will be given rectangles for the |
||||
list of completions, the selected option, the info element, and |
||||
the availble [tooltip |
||||
space](https://codemirror.net/6/docs/ref/#view.tooltips^config.tooltipSpace), and should return |
||||
style and/or class strings for the info element. |
||||
*/ |
||||
positionInfo?: (view: EditorView, list: Rect, option: Rect, info: Rect, space: Rect) => { |
||||
style?: string; |
||||
class?: string; |
||||
}; |
||||
/** |
||||
The comparison function to use when sorting completions with the same |
||||
match score. Defaults to using |
||||
[`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare). |
||||
*/ |
||||
compareCompletions?: (a: Completion, b: Completion) => number; |
||||
/** |
||||
When set to true (the default is false), turn off fuzzy matching |
||||
of completions and only show those that start with the text the |
||||
user typed. Only takes effect for results where |
||||
[`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) isn't false. |
||||
*/ |
||||
filterStrict?: boolean; |
||||
/** |
||||
By default, commands relating to an open completion only take |
||||
effect 75 milliseconds after the completion opened, so that key |
||||
presses made before the user is aware of the tooltip don't go to |
||||
the tooltip. This option can be used to configure that delay. |
||||
*/ |
||||
interactionDelay?: number; |
||||
/** |
||||
When there are multiple asynchronous completion sources, this |
||||
controls how long the extension waits for a slow source before |
||||
displaying results from faster sources. Defaults to 100 |
||||
milliseconds. |
||||
*/ |
||||
updateSyncTime?: number; |
||||
} |
||||
|
||||
/** |
||||
Convert a snippet template to a function that can |
||||
[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written |
||||
using syntax like this: |
||||
|
||||
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}" |
||||
|
||||
Each `${}` placeholder (you may also use `#{}`) indicates a field |
||||
that the user can fill in. Its name, if any, will be the default |
||||
content for the field. |
||||
|
||||
When the snippet is activated by calling the returned function, |
||||
the code is inserted at the given position. Newlines in the |
||||
template are indented by the indentation of the start line, plus |
||||
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after |
||||
the newline. |
||||
|
||||
On activation, (all instances of) the first field are selected. |
||||
The user can move between fields with Tab and Shift-Tab as long as |
||||
the fields are active. Moving to the last field or moving the |
||||
cursor out of the current field deactivates the fields. |
||||
|
||||
The order of fields defaults to textual order, but you can add |
||||
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide |
||||
a custom order. |
||||
|
||||
To include a literal `{` or `}` in your template, put a backslash |
||||
in front of it. This will be removed and the brace will not be |
||||
interpreted as indicating a placeholder. |
||||
*/ |
||||
declare function snippet(template: string): (editor: { |
||||
state: EditorState; |
||||
dispatch: (tr: Transaction) => void; |
||||
}, completion: Completion | null, from: number, to: number) => void; |
||||
/** |
||||
A command that clears the active snippet, if any. |
||||
*/ |
||||
declare const clearSnippet: StateCommand; |
||||
/** |
||||
Move to the next snippet field, if available. |
||||
*/ |
||||
declare const nextSnippetField: StateCommand; |
||||
/** |
||||
Move to the previous snippet field, if available. |
||||
*/ |
||||
declare const prevSnippetField: StateCommand; |
||||
/** |
||||
Check if there is an active snippet with a next field for |
||||
`nextSnippetField` to move to. |
||||
*/ |
||||
declare function hasNextSnippetField(state: EditorState): boolean; |
||||
/** |
||||
Returns true if there is an active snippet and a previous field |
||||
for `prevSnippetField` to move to. |
||||
*/ |
||||
declare function hasPrevSnippetField(state: EditorState): boolean; |
||||
/** |
||||
A facet that can be used to configure the key bindings used by |
||||
snippets. The default binds Tab to |
||||
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to |
||||
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape |
||||
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet). |
||||
*/ |
||||
declare const snippetKeymap: Facet<readonly KeyBinding[], readonly KeyBinding[]>; |
||||
/** |
||||
Create a completion from a snippet. Returns an object with the |
||||
properties from `completion`, plus an `apply` function that |
||||
applies the snippet. |
||||
*/ |
||||
declare function snippetCompletion(template: string, completion: Completion): Completion; |
||||
|
||||
/** |
||||
Returns a command that moves the completion selection forward or |
||||
backward by the given amount. |
||||
*/ |
||||
declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command; |
||||
/** |
||||
Accept the current completion. |
||||
*/ |
||||
declare const acceptCompletion: Command; |
||||
/** |
||||
Explicitly start autocompletion. |
||||
*/ |
||||
declare const startCompletion: Command; |
||||
/** |
||||
Close the currently active completion. |
||||
*/ |
||||
declare const closeCompletion: Command; |
||||
|
||||
/** |
||||
A completion source that will scan the document for words (using a |
||||
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and |
||||
return those as completions. |
||||
*/ |
||||
declare const completeAnyWord: CompletionSource; |
||||
|
||||
/** |
||||
Configures bracket closing behavior for a syntax (via |
||||
[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"` |
||||
identifier. |
||||
*/ |
||||
interface CloseBracketConfig { |
||||
/** |
||||
The opening brackets to close. Defaults to `["(", "[", "{", "'", |
||||
'"']`. Brackets may be single characters or a triple of quotes |
||||
(as in `"'''"`). |
||||
*/ |
||||
brackets?: string[]; |
||||
/** |
||||
Characters in front of which newly opened brackets are |
||||
automatically closed. Closing always happens in front of |
||||
whitespace. Defaults to `")]}:;>"`. |
||||
*/ |
||||
before?: string; |
||||
/** |
||||
When determining whether a given node may be a string, recognize |
||||
these prefixes before the opening quote. |
||||
*/ |
||||
stringPrefixes?: string[]; |
||||
} |
||||
/** |
||||
Extension to enable bracket-closing behavior. When a closeable |
||||
bracket is typed, its closing bracket is immediately inserted |
||||
after the cursor. When closing a bracket directly in front of a |
||||
closing bracket inserted by the extension, the cursor moves over |
||||
that bracket. |
||||
*/ |
||||
declare function closeBrackets(): Extension; |
||||
/** |
||||
Command that implements deleting a pair of matching brackets when |
||||
the cursor is between them. |
||||
*/ |
||||
declare const deleteBracketPair: StateCommand; |
||||
/** |
||||
Close-brackets related key bindings. Binds Backspace to |
||||
[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair). |
||||
*/ |
||||
declare const closeBracketsKeymap: readonly KeyBinding[]; |
||||
/** |
||||
Implements the extension's behavior on text insertion. If the |
||||
given string counts as a bracket in the language around the |
||||
selection, and replacing the selection with it requires custom |
||||
behavior (inserting a closing version or skipping past a |
||||
previously-closed bracket), this function returns a transaction |
||||
representing that custom behavior. (You only need this if you want |
||||
to programmatically insert brackets—the |
||||
[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will |
||||
take care of running this for user input.) |
||||
*/ |
||||
declare function insertBracket(state: EditorState, bracket: string): Transaction | null; |
||||
|
||||
/** |
||||
Returns an extension that enables autocompletion. |
||||
*/ |
||||
declare function autocompletion(config?: CompletionConfig): Extension; |
||||
/** |
||||
Basic keybindings for autocompletion. |
||||
|
||||
- Ctrl-Space (and Alt-\` or Alt-i on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion) |
||||
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion) |
||||
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)` |
||||
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)` |
||||
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")` |
||||
- PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")` |
||||
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion) |
||||
*/ |
||||
declare const completionKeymap: readonly KeyBinding[]; |
||||
/** |
||||
Get the current completion status. When completions are available, |
||||
this will return `"active"`. When completions are pending (in the |
||||
process of being queried), this returns `"pending"`. Otherwise, it |
||||
returns `null`. |
||||
*/ |
||||
declare function completionStatus(state: EditorState): null | "active" | "pending"; |
||||
/** |
||||
Returns the available completions as an array. |
||||
*/ |
||||
declare function currentCompletions(state: EditorState): readonly Completion[]; |
||||
/** |
||||
Return the currently selected completion, if any. |
||||
*/ |
||||
declare function selectedCompletion(state: EditorState): Completion | null; |
||||
/** |
||||
Returns the currently selected position in the active completion |
||||
list, or null if no completions are active. |
||||
*/ |
||||
declare function selectedCompletionIndex(state: EditorState): number | null; |
||||
/** |
||||
Create an effect that can be attached to a transaction to change |
||||
the currently selected completion. |
||||
*/ |
||||
declare function setSelectedCompletion(index: number): StateEffect<unknown>; |
||||
|
||||
export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion }; |
||||
@ -0,0 +1,648 @@
@@ -0,0 +1,648 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state'; |
||||
import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view'; |
||||
import * as _lezer_common from '@lezer/common'; |
||||
|
||||
/** |
||||
Objects type used to represent individual completions. |
||||
*/ |
||||
interface Completion { |
||||
/** |
||||
The label to show in the completion picker. This is what input |
||||
is matched against to determine whether a completion matches (and |
||||
how well it matches). |
||||
*/ |
||||
label: string; |
||||
/** |
||||
An optional override for the completion's visible label. When |
||||
using this, matched characters will only be highlighted if you |
||||
provide a [`getMatch`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.getMatch)
|
||||
function. |
||||
*/ |
||||
displayLabel?: string; |
||||
/** |
||||
Overrides the text that is used to sort completions. Will |
||||
default to `label` if not given. |
||||
*/ |
||||
sortText?: string; |
||||
/** |
||||
An optional short piece of information to show (with a different |
||||
style) after the label. |
||||
*/ |
||||
detail?: string; |
||||
/** |
||||
Additional info to show when the completion is selected. Can be |
||||
a plain string or a function that'll render the DOM structure to |
||||
show when invoked. |
||||
*/ |
||||
info?: string | ((completion: Completion) => CompletionInfo | Promise<CompletionInfo>); |
||||
/** |
||||
How to apply the completion. The default is to replace it with |
||||
its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a
|
||||
string, the completion range is replaced by that string. When it |
||||
is a function, that function is called to perform the |
||||
completion. If it fires a transaction, it is responsible for |
||||
adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion)
|
||||
annotation to it. |
||||
*/ |
||||
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void); |
||||
/** |
||||
The type of the completion. This is used to pick an icon to show |
||||
for the completion. Icons are styled with a CSS class created by |
||||
appending the type name to `"cm-completionIcon-"`. You can |
||||
define or restyle icons by defining these selectors. The base |
||||
library defines simple icons for `class`, `constant`, `enum`, |
||||
`function`, `interface`, `keyword`, `method`, `namespace`, |
||||
`property`, `text`, `type`, and `variable`. |
||||
|
||||
Multiple types can be provided by separating them with spaces. |
||||
*/ |
||||
type?: string; |
||||
/** |
||||
When this option is selected, and one of these characters is |
||||
typed, insert the completion before typing the character. |
||||
*/ |
||||
commitCharacters?: readonly string[]; |
||||
/** |
||||
When given, should be a number from -99 to 99 that adjusts how |
||||
this completion is ranked compared to other completions that |
||||
match the input as well as this one. A negative number moves it |
||||
down the list, a positive number moves it up. |
||||
*/ |
||||
boost?: number; |
||||
/** |
||||
Can be used to divide the completion list into sections. |
||||
Completions in a given section (matched by name) will be grouped |
||||
together, with a heading above them. Options without section |
||||
will appear above all sections. A string value is equivalent to |
||||
a `{name}` object. |
||||
*/ |
||||
section?: string | CompletionSection; |
||||
} |
||||
/** |
||||
The type returned from |
||||
[`Completion.info`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info). May be a DOM
|
||||
node, null to indicate there is no info, or an object with an |
||||
optional `destroy` method that cleans up the node. |
||||
*/ |
||||
type CompletionInfo = Node | null | { |
||||
dom: Node; |
||||
destroy?(): void; |
||||
}; |
||||
/** |
||||
Object used to describe a completion |
||||
[section](https://codemirror.net/6/docs/ref/#autocomplete.Completion.section). It is recommended to
|
||||
create a shared object used by all the completions in a given |
||||
section. |
||||
*/ |
||||
interface CompletionSection { |
||||
/** |
||||
The name of the section. If no `render` method is present, this |
||||
will be displayed above the options. |
||||
*/ |
||||
name: string; |
||||
/** |
||||
An optional function that renders the section header. Since the |
||||
headers are shown inside a list, you should make sure the |
||||
resulting element has a `display: list-item` style. |
||||
*/ |
||||
header?: (section: CompletionSection) => HTMLElement; |
||||
/** |
||||
By default, sections are ordered alphabetically by name. To |
||||
specify an explicit order, `rank` can be used. Sections with a |
||||
lower rank will be shown above sections with a higher rank. |
||||
|
||||
When set to `"dynamic"`, the section's position compared to |
||||
other dynamic sections depends on the matching score of the |
||||
best-matching option in the sections. |
||||
*/ |
||||
rank?: number | "dynamic"; |
||||
} |
||||
/** |
||||
An instance of this is passed to completion source functions. |
||||
*/ |
||||
declare class CompletionContext { |
||||
/** |
||||
The editor state that the completion happens in. |
||||
*/ |
||||
readonly state: EditorState; |
||||
/** |
||||
The position at which the completion is happening. |
||||
*/ |
||||
readonly pos: number; |
||||
/** |
||||
Indicates whether completion was activated explicitly, or |
||||
implicitly by typing. The usual way to respond to this is to |
||||
only return completions when either there is part of a |
||||
completable entity before the cursor, or `explicit` is true. |
||||
*/ |
||||
readonly explicit: boolean; |
||||
/** |
||||
The editor view. May be undefined if the context was created |
||||
in a situation where there is no such view available, such as |
||||
in synchronous updates via |
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
|
||||
or when called by test code. |
||||
*/ |
||||
readonly view?: EditorView | undefined; |
||||
/** |
||||
Create a new completion context. (Mostly useful for testing |
||||
completion sources—in the editor, the extension will create |
||||
these for you.) |
||||
*/ |
||||
constructor( |
||||
/** |
||||
The editor state that the completion happens in. |
||||
*/ |
||||
state: EditorState,
|
||||
/** |
||||
The position at which the completion is happening. |
||||
*/ |
||||
pos: number,
|
||||
/** |
||||
Indicates whether completion was activated explicitly, or |
||||
implicitly by typing. The usual way to respond to this is to |
||||
only return completions when either there is part of a |
||||
completable entity before the cursor, or `explicit` is true. |
||||
*/ |
||||
explicit: boolean,
|
||||
/** |
||||
The editor view. May be undefined if the context was created |
||||
in a situation where there is no such view available, such as |
||||
in synchronous updates via |
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
|
||||
or when called by test code. |
||||
*/ |
||||
view?: EditorView | undefined); |
||||
/** |
||||
Get the extent, content, and (if there is a token) type of the |
||||
token before `this.pos`. |
||||
*/ |
||||
tokenBefore(types: readonly string[]): { |
||||
from: number; |
||||
to: number; |
||||
text: string; |
||||
type: _lezer_common.NodeType; |
||||
} | null; |
||||
/** |
||||
Get the match of the given expression directly before the |
||||
cursor. |
||||
*/ |
||||
matchBefore(expr: RegExp): { |
||||
from: number; |
||||
to: number; |
||||
text: string; |
||||
} | null; |
||||
/** |
||||
Yields true when the query has been aborted. Can be useful in |
||||
asynchronous queries to avoid doing work that will be ignored. |
||||
*/ |
||||
get aborted(): boolean; |
||||
/** |
||||
Allows you to register abort handlers, which will be called when |
||||
the query is |
||||
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
|
||||
|
||||
By default, running queries will not be aborted for regular |
||||
typing or backspacing, on the assumption that they are likely to |
||||
return a result with a |
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
|
||||
allows the result to be used after all. Passing `onDocChange:
|
||||
true` will cause this query to be aborted for any document
|
||||
change. |
||||
*/ |
||||
addEventListener(type: "abort", listener: () => void, options?: { |
||||
onDocChange: boolean; |
||||
}): void; |
||||
} |
||||
/** |
||||
Given a a fixed array of options, return an autocompleter that |
||||
completes them. |
||||
*/ |
||||
declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource; |
||||
/** |
||||
Wrap the given completion source so that it will only fire when the |
||||
cursor is in a syntax node with one of the given names. |
||||
*/ |
||||
declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource; |
||||
/** |
||||
Wrap the given completion source so that it will not fire when the |
||||
cursor is in a syntax node with one of the given names. |
||||
*/ |
||||
declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource; |
||||
/** |
||||
The function signature for a completion source. Such a function |
||||
may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult)
|
||||
synchronously or as a promise. Returning null indicates no |
||||
completions are available. |
||||
*/ |
||||
type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise<CompletionResult | null>; |
||||
/** |
||||
Interface for objects returned by completion sources. |
||||
*/ |
||||
interface CompletionResult { |
||||
/** |
||||
The start of the range that is being completed. |
||||
*/ |
||||
from: number; |
||||
/** |
||||
The end of the range that is being completed. Defaults to the |
||||
main cursor position. |
||||
*/ |
||||
to?: number; |
||||
/** |
||||
The completions returned. These don't have to be compared with |
||||
the input by the source—the autocompletion system will do its |
||||
own matching (against the text between `from` and `to`) and |
||||
sorting. |
||||
*/ |
||||
options: readonly Completion[]; |
||||
/** |
||||
When given, further typing or deletion that causes the part of |
||||
the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from`
|
||||
and `to` to match this regular expression or predicate function |
||||
will not query the completion source again, but continue with |
||||
this list of options. This can help a lot with responsiveness, |
||||
since it allows the completion list to be updated synchronously. |
||||
*/ |
||||
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean); |
||||
/** |
||||
By default, the library filters and scores completions. Set |
||||
`filter` to `false` to disable this, and cause your completions |
||||
to all be included, in the order they were given. When there are |
||||
other sources, unfiltered completions appear at the top of the |
||||
list of completions. `validFor` must not be given when `filter` |
||||
is `false`, because it only works when filtering. |
||||
*/ |
||||
filter?: boolean; |
||||
/** |
||||
When [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) is set to
|
||||
`false` or a completion has a |
||||
[`displayLabel`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.displayLabel), this
|
||||
may be provided to compute the ranges on the label that match |
||||
the input. Should return an array of numbers where each pair of |
||||
adjacent numbers provide the start and end of a range. The |
||||
second argument, the match found by the library, is only passed |
||||
when `filter` isn't `false`. |
||||
*/ |
||||
getMatch?: (completion: Completion, matched?: readonly number[]) => readonly number[]; |
||||
/** |
||||
Synchronously update the completion result after typing or |
||||
deletion. If given, this should not do any expensive work, since |
||||
it will be called during editor state updates. The function |
||||
should make sure (similar to |
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the
|
||||
completion still applies in the new state. |
||||
*/ |
||||
update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null; |
||||
/** |
||||
When results contain position-dependent information in, for |
||||
example, `apply` methods, you can provide this method to update |
||||
the result for transactions that happen after the query. It is |
||||
not necessary to update `from` and `to`—those are tracked |
||||
automatically. |
||||
*/ |
||||
map?: (current: CompletionResult, changes: ChangeDesc) => CompletionResult | null; |
||||
/** |
||||
Set a default set of [commit |
||||
characters](https://codemirror.net/6/docs/ref/#autocomplete.Completion.commitCharacters) for all
|
||||
options in this result. |
||||
*/ |
||||
commitCharacters?: readonly string[]; |
||||
} |
||||
/** |
||||
This annotation is added to transactions that are produced by |
||||
picking a completion. |
||||
*/ |
||||
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>; |
||||
/** |
||||
Helper function that returns a transaction spec which inserts a |
||||
completion's text in the main selection range, and any other |
||||
selection range that has the same text in front of it. |
||||
*/ |
||||
declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec; |
||||
|
||||
interface CompletionConfig { |
||||
/** |
||||
When enabled (defaults to true), autocompletion will start |
||||
whenever the user types something that can be completed. |
||||
*/ |
||||
activateOnTyping?: boolean; |
||||
/** |
||||
When given, if a completion that matches the predicate is |
||||
picked, reactivate completion again as if it was typed normally. |
||||
*/ |
||||
activateOnCompletion?: (completion: Completion) => boolean; |
||||
/** |
||||
The amount of time to wait for further typing before querying |
||||
completion sources via |
||||
[`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping).
|
||||
Defaults to 100, which should be fine unless your completion |
||||
source is very slow and/or doesn't use `validFor`. |
||||
*/ |
||||
activateOnTypingDelay?: number; |
||||
/** |
||||
By default, when completion opens, the first option is selected |
||||
and can be confirmed with |
||||
[`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion). When this
|
||||
is set to false, the completion widget starts with no completion |
||||
selected, and the user has to explicitly move to a completion |
||||
before you can confirm one. |
||||
*/ |
||||
selectOnOpen?: boolean; |
||||
/** |
||||
Override the completion sources used. By default, they will be |
||||
taken from the `"autocomplete"` [language |
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold
|
||||
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays
|
||||
of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)).
|
||||
*/ |
||||
override?: readonly CompletionSource[] | null; |
||||
/** |
||||
Determines whether the completion tooltip is closed when the |
||||
editor loses focus. Defaults to true. |
||||
*/ |
||||
closeOnBlur?: boolean; |
||||
/** |
||||
The maximum number of options to render to the DOM. |
||||
*/ |
||||
maxRenderedOptions?: number; |
||||
/** |
||||
Set this to false to disable the [default completion |
||||
keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to
|
||||
add bindings to control completion yourself. The bindings should |
||||
probably have a higher precedence than other bindings for the |
||||
same keys.) |
||||
*/ |
||||
defaultKeymap?: boolean; |
||||
/** |
||||
By default, completions are shown below the cursor when there is |
||||
space. Setting this to true will make the extension put the |
||||
completions above the cursor when possible. |
||||
*/ |
||||
aboveCursor?: boolean; |
||||
/** |
||||
When given, this may return an additional CSS class to add to |
||||
the completion dialog element. |
||||
*/ |
||||
tooltipClass?: (state: EditorState) => string; |
||||
/** |
||||
This can be used to add additional CSS classes to completion |
||||
options. |
||||
*/ |
||||
optionClass?: (completion: Completion) => string; |
||||
/** |
||||
By default, the library will render icons based on the |
||||
completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of
|
||||
each option. Set this to false to turn that off. |
||||
*/ |
||||
icons?: boolean; |
||||
/** |
||||
This option can be used to inject additional content into |
||||
options. The `render` function will be called for each visible |
||||
completion, and should produce a DOM node to show. `position` |
||||
determines where in the DOM the result appears, relative to |
||||
other added widgets and the standard content. The default icons |
||||
have position 20, the label position 50, and the detail position |
||||
80. |
||||
*/ |
||||
addToOptions?: { |
||||
render: (completion: Completion, state: EditorState, view: EditorView) => Node | null; |
||||
position: number; |
||||
}[]; |
||||
/** |
||||
By default, [info](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info) tooltips are
|
||||
placed to the side of the selected completion. This option can |
||||
be used to override that. It will be given rectangles for the |
||||
list of completions, the selected option, the info element, and |
||||
the availble [tooltip |
||||
space](https://codemirror.net/6/docs/ref/#view.tooltips^config.tooltipSpace), and should return
|
||||
style and/or class strings for the info element. |
||||
*/ |
||||
positionInfo?: (view: EditorView, list: Rect, option: Rect, info: Rect, space: Rect) => { |
||||
style?: string; |
||||
class?: string; |
||||
}; |
||||
/** |
||||
The comparison function to use when sorting completions with the same |
||||
match score. Defaults to using |
||||
[`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
|
||||
*/ |
||||
compareCompletions?: (a: Completion, b: Completion) => number; |
||||
/** |
||||
When set to true (the default is false), turn off fuzzy matching |
||||
of completions and only show those that start with the text the |
||||
user typed. Only takes effect for results where |
||||
[`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) isn't false.
|
||||
*/ |
||||
filterStrict?: boolean; |
||||
/** |
||||
By default, commands relating to an open completion only take |
||||
effect 75 milliseconds after the completion opened, so that key |
||||
presses made before the user is aware of the tooltip don't go to |
||||
the tooltip. This option can be used to configure that delay. |
||||
*/ |
||||
interactionDelay?: number; |
||||
/** |
||||
When there are multiple asynchronous completion sources, this |
||||
controls how long the extension waits for a slow source before |
||||
displaying results from faster sources. Defaults to 100 |
||||
milliseconds. |
||||
*/ |
||||
updateSyncTime?: number; |
||||
} |
||||
|
||||
/** |
||||
Convert a snippet template to a function that can |
||||
[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
|
||||
using syntax like this: |
||||
|
||||
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}" |
||||
|
||||
Each `${}` placeholder (you may also use `#{}`) indicates a field |
||||
that the user can fill in. Its name, if any, will be the default |
||||
content for the field. |
||||
|
||||
When the snippet is activated by calling the returned function, |
||||
the code is inserted at the given position. Newlines in the |
||||
template are indented by the indentation of the start line, plus |
||||
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
|
||||
the newline. |
||||
|
||||
On activation, (all instances of) the first field are selected. |
||||
The user can move between fields with Tab and Shift-Tab as long as |
||||
the fields are active. Moving to the last field or moving the |
||||
cursor out of the current field deactivates the fields. |
||||
|
||||
The order of fields defaults to textual order, but you can add |
||||
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide |
||||
a custom order. |
||||
|
||||
To include a literal `{` or `}` in your template, put a backslash |
||||
in front of it. This will be removed and the brace will not be |
||||
interpreted as indicating a placeholder. |
||||
*/ |
||||
declare function snippet(template: string): (editor: { |
||||
state: EditorState; |
||||
dispatch: (tr: Transaction) => void; |
||||
}, completion: Completion | null, from: number, to: number) => void; |
||||
/** |
||||
A command that clears the active snippet, if any. |
||||
*/ |
||||
declare const clearSnippet: StateCommand; |
||||
/** |
||||
Move to the next snippet field, if available. |
||||
*/ |
||||
declare const nextSnippetField: StateCommand; |
||||
/** |
||||
Move to the previous snippet field, if available. |
||||
*/ |
||||
declare const prevSnippetField: StateCommand; |
||||
/** |
||||
Check if there is an active snippet with a next field for |
||||
`nextSnippetField` to move to. |
||||
*/ |
||||
declare function hasNextSnippetField(state: EditorState): boolean; |
||||
/** |
||||
Returns true if there is an active snippet and a previous field |
||||
for `prevSnippetField` to move to. |
||||
*/ |
||||
declare function hasPrevSnippetField(state: EditorState): boolean; |
||||
/** |
||||
A facet that can be used to configure the key bindings used by |
||||
snippets. The default binds Tab to |
||||
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
|
||||
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
|
||||
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
|
||||
*/ |
||||
declare const snippetKeymap: Facet<readonly KeyBinding[], readonly KeyBinding[]>; |
||||
/** |
||||
Create a completion from a snippet. Returns an object with the |
||||
properties from `completion`, plus an `apply` function that |
||||
applies the snippet. |
||||
*/ |
||||
declare function snippetCompletion(template: string, completion: Completion): Completion; |
||||
|
||||
/** |
||||
Returns a command that moves the completion selection forward or |
||||
backward by the given amount. |
||||
*/ |
||||
declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command; |
||||
/** |
||||
Accept the current completion. |
||||
*/ |
||||
declare const acceptCompletion: Command; |
||||
/** |
||||
Explicitly start autocompletion. |
||||
*/ |
||||
declare const startCompletion: Command; |
||||
/** |
||||
Close the currently active completion. |
||||
*/ |
||||
declare const closeCompletion: Command; |
||||
|
||||
/** |
||||
A completion source that will scan the document for words (using a |
||||
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
|
||||
return those as completions. |
||||
*/ |
||||
declare const completeAnyWord: CompletionSource; |
||||
|
||||
/** |
||||
Configures bracket closing behavior for a syntax (via |
||||
[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"`
|
||||
identifier. |
||||
*/ |
||||
interface CloseBracketConfig { |
||||
/** |
||||
The opening brackets to close. Defaults to `["(", "[", "{", "'",
|
||||
'"']`. Brackets may be single characters or a triple of quotes
|
||||
(as in `"'''"`). |
||||
*/ |
||||
brackets?: string[]; |
||||
/** |
||||
Characters in front of which newly opened brackets are |
||||
automatically closed. Closing always happens in front of |
||||
whitespace. Defaults to `")]}:;>"`. |
||||
*/ |
||||
before?: string; |
||||
/** |
||||
When determining whether a given node may be a string, recognize |
||||
these prefixes before the opening quote. |
||||
*/ |
||||
stringPrefixes?: string[]; |
||||
} |
||||
/** |
||||
Extension to enable bracket-closing behavior. When a closeable |
||||
bracket is typed, its closing bracket is immediately inserted |
||||
after the cursor. When closing a bracket directly in front of a |
||||
closing bracket inserted by the extension, the cursor moves over |
||||
that bracket. |
||||
*/ |
||||
declare function closeBrackets(): Extension; |
||||
/** |
||||
Command that implements deleting a pair of matching brackets when |
||||
the cursor is between them. |
||||
*/ |
||||
declare const deleteBracketPair: StateCommand; |
||||
/** |
||||
Close-brackets related key bindings. Binds Backspace to |
||||
[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
|
||||
*/ |
||||
declare const closeBracketsKeymap: readonly KeyBinding[]; |
||||
/** |
||||
Implements the extension's behavior on text insertion. If the |
||||
given string counts as a bracket in the language around the |
||||
selection, and replacing the selection with it requires custom |
||||
behavior (inserting a closing version or skipping past a |
||||
previously-closed bracket), this function returns a transaction |
||||
representing that custom behavior. (You only need this if you want |
||||
to programmatically insert brackets—the |
||||
[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
|
||||
take care of running this for user input.) |
||||
*/ |
||||
declare function insertBracket(state: EditorState, bracket: string): Transaction | null; |
||||
|
||||
/** |
||||
Returns an extension that enables autocompletion. |
||||
*/ |
||||
declare function autocompletion(config?: CompletionConfig): Extension; |
||||
/** |
||||
Basic keybindings for autocompletion. |
||||
|
||||
- Ctrl-Space (and Alt-\` or Alt-i on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
|
||||
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
|
||||
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
|
||||
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
|
||||
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
||||
- PageUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false, "page")`
|
||||
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
|
||||
*/ |
||||
declare const completionKeymap: readonly KeyBinding[]; |
||||
/** |
||||
Get the current completion status. When completions are available, |
||||
this will return `"active"`. When completions are pending (in the |
||||
process of being queried), this returns `"pending"`. Otherwise, it |
||||
returns `null`. |
||||
*/ |
||||
declare function completionStatus(state: EditorState): null | "active" | "pending"; |
||||
/** |
||||
Returns the available completions as an array. |
||||
*/ |
||||
declare function currentCompletions(state: EditorState): readonly Completion[]; |
||||
/** |
||||
Return the currently selected completion, if any. |
||||
*/ |
||||
declare function selectedCompletion(state: EditorState): Completion | null; |
||||
/** |
||||
Returns the currently selected position in the active completion |
||||
list, or null if no completions are active. |
||||
*/ |
||||
declare function selectedCompletionIndex(state: EditorState): number | null; |
||||
/** |
||||
Create an effect that can be attached to a transaction to change |
||||
the currently selected completion. |
||||
*/ |
||||
declare function setSelectedCompletion(index: number): StateEffect<unknown>; |
||||
|
||||
export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion }; |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
{ |
||||
"name": "@codemirror/autocomplete", |
||||
"version": "6.20.0", |
||||
"description": "Autocompletion for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/index.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.17.0", |
||||
"@lezer/common": "^1.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/autocomplete.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,374 @@
@@ -0,0 +1,374 @@
|
||||
## 6.10.1 (2025-12-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where `copyLineDown` would leave the cursor on the wrong line when it was at the start of the line. |
||||
|
||||
## 6.10.0 (2025-10-23) |
||||
|
||||
### New features |
||||
|
||||
The new `deleteGroupForwardWin` command provides by-group forward deletion using the Windows convention. |
||||
|
||||
## 6.9.0 (2025-10-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Prevent the default behavior of backspace and delete keys, to prevent the browser from doing anything creative when there's nothing to delete. |
||||
|
||||
### New features |
||||
|
||||
Implement new `addCursorAbove` and `addCursorBelow` commands. Bind them to Mod-Alt-ArrowUp/Down in the default keymap. |
||||
|
||||
## 6.8.1 (2025-03-31) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where creating a comment for a line that starts an inner language would use the comment style from the outer language. |
||||
|
||||
## 6.8.0 (2025-01-08) |
||||
|
||||
### New features |
||||
|
||||
The new `cursorGroupForwardWin` and `selectGroupForwardWin` commands implement Windows-style forward motion by group. |
||||
|
||||
## 6.7.1 (2024-10-21) |
||||
|
||||
### Bug fixes |
||||
|
||||
Change `toggleBlockCommentByLine` to not affect lines with the selection end right at their start. |
||||
|
||||
## 6.7.0 (2024-10-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Bind Shift-Enter to the same command as Enter in the default keymap, so that it doesn't do nothing when on an EditContext-supporting browser. |
||||
|
||||
### New features |
||||
|
||||
Add commands for by-string-index cursor motion that ignores text direction. |
||||
|
||||
## 6.6.2 (2024-09-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue causing `selectParentSyntax` to not select syntax that is a direct child of the top node. |
||||
|
||||
Make `selectParentSyntax` return false when it doesn't change the selection. |
||||
|
||||
## 6.6.1 (2024-08-31) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug in the undo history that would cause it to incorrectly track inverted effects when adding multiple edits to a single history event. |
||||
|
||||
## 6.6.0 (2024-06-04) |
||||
|
||||
### New features |
||||
|
||||
The new `toggleTabFocusMode` and `temporarilySetTabFocusMode` commands provide control over the view's tab-focus mode. |
||||
|
||||
The default keymap now binds Ctrl-m (Shift-Alt-m on macOS) to `toggleTabFocusMode`. |
||||
|
||||
## 6.5.0 (2024-04-19) |
||||
|
||||
### New features |
||||
|
||||
The `insertNewlineKeepIndent` command inserts a newline along with the same indentation as the line before. |
||||
|
||||
## 6.4.0 (2024-04-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `deleteLine` sometimes leaves the cursor on the wrong line. |
||||
|
||||
### New features |
||||
|
||||
The new `deleteCharBackwardStrict` command just deletes a character, without further smart behavior around indentation. |
||||
|
||||
## 6.3.3 (2023-12-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue causing cursor motion commands to not dispatch a transaction when the change only affects cursor associativity. |
||||
|
||||
## 6.3.2 (2023-11-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression that caused `deleteCharBackward` to sometimes delete a large chunk of text. |
||||
|
||||
## 6.3.1 (2023-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
When undoing, store the selection after the undone change with the redo event, so that redoing restores it. |
||||
|
||||
`deleteCharBackward` will no longer delete variant selector characters as separate characters. |
||||
|
||||
## 6.3.0 (2023-09-29) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make it possible for `selectParentSyntax` to jump out of or into a syntax tree overlay. |
||||
|
||||
Make Cmd-Backspace and Cmd-Delete on macOS delete to the next line wrap point, not the start/end of the line. |
||||
|
||||
### New features |
||||
|
||||
The new `deleteLineBoundaryForward` and `deleteLineBoundaryBackward` commands delete to the start/end of the line or the next line wrapping point. |
||||
|
||||
## 6.2.5 (2023-08-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `insertNewlineAndIndent` properly count indentation for tabs when copying over the previous line's indentation. |
||||
|
||||
The various sub-word motion commands will now use `Intl.Segmenter`, when available, to stop at CJK language word boundaries. |
||||
|
||||
Fix a bug in `insertNewlineAndIndent` that would delete text between brackets if it had no corresponding AST node. |
||||
|
||||
## 6.2.4 (2023-05-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
The by-subword motion commands now properly treat dashes, underscores, and similar as subword separators. |
||||
|
||||
## 6.2.3 (2023-04-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
Block commenting the selection no longer includes indentation on the first line. |
||||
|
||||
## 6.2.2 (2023-03-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where line commenting got confused when commenting a range that crossed language boundaries. |
||||
|
||||
## 6.2.1 (2023-02-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Keep cursor position stable in `cursorPageUp`/`cursorPageDown` when there are panels or other scroll margins active. |
||||
|
||||
Make sure `toggleComment` doesn't get thrown off by local language nesting, by fetching the language data for the start of the selection line. |
||||
|
||||
## 6.2.0 (2023-01-18) |
||||
|
||||
### New features |
||||
|
||||
The new `joinToEvent` history configuration option allows you to provide custom logic that determines whether a new transaction is added to an existing history event. |
||||
|
||||
## 6.1.3 (2022-12-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Preserve selection bidi level when extending the selection, to prevent shift-selection from getting stuck in some kinds of bidirectional text. |
||||
|
||||
## 6.1.2 (2022-10-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused deletion commands on non-empty ranges to incorrectly return false and do nothing, causing the editor to fall back to native behavior. |
||||
|
||||
## 6.1.1 (2022-09-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure the selection endpoints are moved out of atomic ranges when applying a deletion command to a non-empty selection. |
||||
|
||||
## 6.1.0 (2022-08-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Prevent native behavior on Ctrl/Cmd-ArrowLeft/ArrowRight bindings, so that browsers with odd bidi behavior won't do the wrong thing at start/end of line. |
||||
|
||||
Cmd-ArrowLeft/Right on macOS now moves the cursor in the direction of the arrow even in right-to-left content. |
||||
|
||||
### New features |
||||
|
||||
The new `cursorLineBoundaryLeft`/`Right` and `selectLineBoundaryLeft`/`Right` commands allow directional motion to line boundaries. |
||||
|
||||
## 6.0.1 (2022-06-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Announce to the screen reader when the selection is deleted. |
||||
|
||||
Also bind Ctrl-Shift-z to redo on Linux. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where by-page selection commands sometimes moved one line too far. |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Breaking changes |
||||
|
||||
There is no longer a separate `commentKeymap`. Those bindings are now part of `defaultKeymap`. |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `cursorPageUp` and `cursorPageDown` move by window height when the editor is higher than the window. |
||||
|
||||
Make sure the default behavior of Home/End is prevented, since it could produce unexpected results on macOS. |
||||
|
||||
### New features |
||||
|
||||
The exports from @codemirror/comment are now available in this package. |
||||
|
||||
The exports from the @codemirror/history package are now available from this package. |
||||
|
||||
## 0.19.8 (2022-01-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
`deleteCharBackward` now removes extending characters one at a time, rather than deleting the entire glyph at once. |
||||
|
||||
Alt-v is no longer bound in `emacsStyleKeymap` and macOS's `standardKeymap`, because macOS doesn't bind it by default and it conflicts with some keyboard layouts. |
||||
|
||||
## 0.19.7 (2022-01-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't bind Alt-\< and Alt-> on macOS by default, since those interfere with some keyboard layouts. Make cursorPageUp/Down scroll the view to keep the cursor in place |
||||
|
||||
`cursorPageUp` and `cursorPageDown` now scroll the view by the amount that the cursor moved. |
||||
|
||||
## 0.19.6 (2021-12-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
The standard keymap no longer overrides Shift-Delete, in order to allow the native behavior of that key to happen on platforms that support it. |
||||
|
||||
## 0.19.5 (2021-09-21) |
||||
|
||||
### New features |
||||
|
||||
Adds an `insertBlankLine` command which creates an empty line below the selection, and binds it to Mod-Enter in the default keymap. |
||||
|
||||
## 0.19.4 (2021-09-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make commands that affect the editor's content check `state.readOnly` and return false when that is true. |
||||
|
||||
## 0.19.3 (2021-09-09) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make by-line cursor motion commands move the cursor to the start/end of the document when they hit the first/last line. |
||||
|
||||
Fix a bug where `deleteCharForward`/`Backward` behaved incorrectly when deleting directly before or after an atomic range. |
||||
|
||||
## 0.19.2 (2021-08-24) |
||||
|
||||
### New features |
||||
|
||||
New commands `cursorSubwordForward`, `cursorSubwordBackward`, `selectSubwordForward`, and `selectSubwordBackward` which implement motion by camel case subword. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Change default binding for backspace to `deleteCharBackward`, drop `deleteCodePointBackward`/`Forward` from the library. |
||||
|
||||
`defaultTabBinding` was removed. |
||||
|
||||
### Bug fixes |
||||
|
||||
Drop Alt-d, Alt-f, and Alt-b bindings from `emacsStyleKeymap` (and thus from the default macOS bindings). |
||||
|
||||
`deleteCharBackward` and `deleteCharForward` now take atomic ranges into account. |
||||
|
||||
### New features |
||||
|
||||
Attach more granular user event strings to transactions. |
||||
|
||||
The module exports a new binding `indentWithTab` that binds tab and shift-tab to `indentMore` and `indentLess`. |
||||
|
||||
## 0.18.3 (2021-06-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
`moveLineDown` will no longer incorrectly grow the selection. |
||||
|
||||
Line-based commands will no longer include lines where a range selection ends right at the start of the line. |
||||
|
||||
## 0.18.2 (2021-05-06) |
||||
|
||||
### Bug fixes |
||||
|
||||
Use Ctrl-l, not Alt-l, to bind `selectLine` on macOS, to avoid conflicting with special-character-insertion bindings. |
||||
|
||||
Make the macOS Command-ArrowLeft/Right commands behave more like their native versions. |
||||
|
||||
## 0.18.1 (2021-04-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Also bind Shift-Backspace and Shift-Delete in the default keymap (to do the same thing as the Shift-less binding). |
||||
|
||||
### New features |
||||
|
||||
Adds a `deleteToLineStart` command. |
||||
|
||||
Adds bindings for Cmd-Delete and Cmd-Backspace on macOS. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.18. |
||||
|
||||
## 0.17.5 (2021-02-25) |
||||
|
||||
### Bug fixes |
||||
|
||||
Use Alt-l for the default `selectLine` binding, because Mod-l already has an important meaning in the browser. |
||||
|
||||
Make `deleteGroupBackward`/`deleteGroupForward` delete groups of whitespace when bigger than a single space. |
||||
|
||||
Don't change lines that have the end of a range selection directly at their start in `indentLess`, `indentMore`, and `indentSelection`. |
||||
|
||||
## 0.17.4 (2021-02-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where `deleteToLineEnd` would delete the rest of the document when at the end of a line. |
||||
|
||||
## 0.17.3 (2021-02-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `insertNewlineAndIndent` behaved strangely with the cursor between brackets that sat on different lines. |
||||
|
||||
## 0.17.2 (2021-01-22) |
||||
|
||||
### New features |
||||
|
||||
The new `insertTab` command inserts a tab when nothing is selected, and defers to `indentMore` otherwise. |
||||
|
||||
The package now exports a `defaultTabBinding` object that provides a recommended binding for tab (if you must bind tab). |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
# @codemirror/commands [](https://www.npmjs.org/package/@codemirror/commands) |
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#commands) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) ] |
||||
|
||||
This package implements a collection of editing commands for the |
||||
[CodeMirror](https://codemirror.net/) code editor. |
||||
|
||||
The [project page](https://codemirror.net/) has more information, a |
||||
number of [examples](https://codemirror.net/examples/) and the |
||||
[documentation](https://codemirror.net/docs/). |
||||
|
||||
This code is released under an |
||||
[MIT license](https://github.com/codemirror/commands/tree/main/LICENSE). |
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit, |
||||
we have a [code of |
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies |
||||
to communication around the project. |
||||
|
||||
## Usage |
||||
|
||||
```javascript |
||||
import {EditorView, keymap} from "@codemirror/view" |
||||
import {standardKeymap, selectLine} from "@codemirror/commands" |
||||
|
||||
const view = new EditorView({ |
||||
parent: document.body, |
||||
extensions: [ |
||||
keymap.of([ |
||||
...standardKeymap, |
||||
{key: "Alt-l", mac: "Ctrl-l", run: selectLine} |
||||
]) |
||||
] |
||||
}) |
||||
``` |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,650 @@
@@ -0,0 +1,650 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { StateCommand, Facet, Transaction, StateEffect, Extension, StateField, EditorState } from '@codemirror/state'; |
||||
import { KeyBinding, Command } from '@codemirror/view'; |
||||
|
||||
/** |
||||
An object of this type can be provided as [language |
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) under a `"commentTokens"` |
||||
property to configure comment syntax for a language. |
||||
*/ |
||||
interface CommentTokens { |
||||
/** |
||||
The block comment syntax, if any. For example, for HTML |
||||
you'd provide `{open: "<!--", close: "-->"}`. |
||||
*/ |
||||
block?: { |
||||
open: string; |
||||
close: string; |
||||
}; |
||||
/** |
||||
The line comment syntax. For example `"//"`. |
||||
*/ |
||||
line?: string; |
||||
} |
||||
/** |
||||
Comment or uncomment the current selection. Will use line comments |
||||
if available, otherwise falling back to block comments. |
||||
*/ |
||||
declare const toggleComment: StateCommand; |
||||
/** |
||||
Comment or uncomment the current selection using line comments. |
||||
The line comment syntax is taken from the |
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language |
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). |
||||
*/ |
||||
declare const toggleLineComment: StateCommand; |
||||
/** |
||||
Comment the current selection using line comments. |
||||
*/ |
||||
declare const lineComment: StateCommand; |
||||
/** |
||||
Uncomment the current selection using line comments. |
||||
*/ |
||||
declare const lineUncomment: StateCommand; |
||||
/** |
||||
Comment or uncomment the current selection using block comments. |
||||
The block comment syntax is taken from the |
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language |
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). |
||||
*/ |
||||
declare const toggleBlockComment: StateCommand; |
||||
/** |
||||
Comment the current selection using block comments. |
||||
*/ |
||||
declare const blockComment: StateCommand; |
||||
/** |
||||
Uncomment the current selection using block comments. |
||||
*/ |
||||
declare const blockUncomment: StateCommand; |
||||
/** |
||||
Comment or uncomment the lines around the current selection using |
||||
block comments. |
||||
*/ |
||||
declare const toggleBlockCommentByLine: StateCommand; |
||||
|
||||
/** |
||||
Transaction annotation that will prevent that transaction from |
||||
being combined with other transactions in the undo history. Given |
||||
`"before"`, it'll prevent merging with previous transactions. With |
||||
`"after"`, subsequent transactions won't be combined with this |
||||
one. With `"full"`, the transaction is isolated on both sides. |
||||
*/ |
||||
declare const isolateHistory: _codemirror_state.AnnotationType<"after" | "before" | "full">; |
||||
/** |
||||
This facet provides a way to register functions that, given a |
||||
transaction, provide a set of effects that the history should |
||||
store when inverting the transaction. This can be used to |
||||
integrate some kinds of effects in the history, so that they can |
||||
be undone (and redone again). |
||||
*/ |
||||
declare const invertedEffects: Facet<(tr: Transaction) => readonly StateEffect<any>[], readonly ((tr: Transaction) => readonly StateEffect<any>[])[]>; |
||||
interface HistoryConfig { |
||||
/** |
||||
The minimum depth (amount of events) to store. Defaults to 100. |
||||
*/ |
||||
minDepth?: number; |
||||
/** |
||||
The maximum time (in milliseconds) that adjacent events can be |
||||
apart and still be grouped together. Defaults to 500. |
||||
*/ |
||||
newGroupDelay?: number; |
||||
/** |
||||
By default, when close enough together in time, changes are |
||||
joined into an existing undo event if they touch any of the |
||||
changed ranges from that event. You can pass a custom predicate |
||||
here to influence that logic. |
||||
*/ |
||||
joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean; |
||||
} |
||||
/** |
||||
Create a history extension with the given configuration. |
||||
*/ |
||||
declare function history(config?: HistoryConfig): Extension; |
||||
/** |
||||
The state field used to store the history data. Should probably |
||||
only be used when you want to |
||||
[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or |
||||
[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way |
||||
that preserves history. |
||||
*/ |
||||
declare const historyField: StateField<unknown>; |
||||
/** |
||||
Undo a single group of history events. Returns false if no group |
||||
was available. |
||||
*/ |
||||
declare const undo: StateCommand; |
||||
/** |
||||
Redo a group of history events. Returns false if no group was |
||||
available. |
||||
*/ |
||||
declare const redo: StateCommand; |
||||
/** |
||||
Undo a change or selection change. |
||||
*/ |
||||
declare const undoSelection: StateCommand; |
||||
/** |
||||
Redo a change or selection change. |
||||
*/ |
||||
declare const redoSelection: StateCommand; |
||||
/** |
||||
The amount of undoable change events available in a given state. |
||||
*/ |
||||
declare const undoDepth: (state: EditorState) => number; |
||||
/** |
||||
The amount of redoable change events available in a given state. |
||||
*/ |
||||
declare const redoDepth: (state: EditorState) => number; |
||||
/** |
||||
Default key bindings for the undo history. |
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo). |
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo). |
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection). |
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection). |
||||
*/ |
||||
declare const historyKeymap: readonly KeyBinding[]; |
||||
|
||||
/** |
||||
Move the selection one character to the left (which is backward in |
||||
left-to-right text, forward in right-to-left text). |
||||
*/ |
||||
declare const cursorCharLeft: Command; |
||||
/** |
||||
Move the selection one character to the right. |
||||
*/ |
||||
declare const cursorCharRight: Command; |
||||
/** |
||||
Move the selection one character forward. |
||||
*/ |
||||
declare const cursorCharForward: Command; |
||||
/** |
||||
Move the selection one character backward. |
||||
*/ |
||||
declare const cursorCharBackward: Command; |
||||
/** |
||||
Move the selection one character forward, in logical |
||||
(non-text-direction-aware) string index order. |
||||
*/ |
||||
declare const cursorCharForwardLogical: StateCommand; |
||||
/** |
||||
Move the selection one character backward, in logical string index |
||||
order. |
||||
*/ |
||||
declare const cursorCharBackwardLogical: StateCommand; |
||||
/** |
||||
Move the selection to the left across one group of word or |
||||
non-word (but also non-space) characters. |
||||
*/ |
||||
declare const cursorGroupLeft: Command; |
||||
/** |
||||
Move the selection one group to the right. |
||||
*/ |
||||
declare const cursorGroupRight: Command; |
||||
/** |
||||
Move the selection one group forward. |
||||
*/ |
||||
declare const cursorGroupForward: Command; |
||||
/** |
||||
Move the selection one group backward. |
||||
*/ |
||||
declare const cursorGroupBackward: Command; |
||||
/** |
||||
Move the cursor one group forward in the default Windows style, |
||||
where it moves to the start of the next group. |
||||
*/ |
||||
declare const cursorGroupForwardWin: Command; |
||||
/** |
||||
Move the selection one group or camel-case subword forward. |
||||
*/ |
||||
declare const cursorSubwordForward: Command; |
||||
/** |
||||
Move the selection one group or camel-case subword backward. |
||||
*/ |
||||
declare const cursorSubwordBackward: Command; |
||||
/** |
||||
Move the cursor over the next syntactic element to the left. |
||||
*/ |
||||
declare const cursorSyntaxLeft: Command; |
||||
/** |
||||
Move the cursor over the next syntactic element to the right. |
||||
*/ |
||||
declare const cursorSyntaxRight: Command; |
||||
/** |
||||
Move the selection one line up. |
||||
*/ |
||||
declare const cursorLineUp: Command; |
||||
/** |
||||
Move the selection one line down. |
||||
*/ |
||||
declare const cursorLineDown: Command; |
||||
/** |
||||
Move the selection one page up. |
||||
*/ |
||||
declare const cursorPageUp: Command; |
||||
/** |
||||
Move the selection one page down. |
||||
*/ |
||||
declare const cursorPageDown: Command; |
||||
/** |
||||
Move the selection to the next line wrap point, or to the end of |
||||
the line if there isn't one left on this line. |
||||
*/ |
||||
declare const cursorLineBoundaryForward: Command; |
||||
/** |
||||
Move the selection to previous line wrap point, or failing that to |
||||
the start of the line. If the line is indented, and the cursor |
||||
isn't already at the end of the indentation, this will move to the |
||||
end of the indentation instead of the start of the line. |
||||
*/ |
||||
declare const cursorLineBoundaryBackward: Command; |
||||
/** |
||||
Move the selection one line wrap point to the left. |
||||
*/ |
||||
declare const cursorLineBoundaryLeft: Command; |
||||
/** |
||||
Move the selection one line wrap point to the right. |
||||
*/ |
||||
declare const cursorLineBoundaryRight: Command; |
||||
/** |
||||
Move the selection to the start of the line. |
||||
*/ |
||||
declare const cursorLineStart: Command; |
||||
/** |
||||
Move the selection to the end of the line. |
||||
*/ |
||||
declare const cursorLineEnd: Command; |
||||
/** |
||||
Move the selection to the bracket matching the one it is currently |
||||
on, if any. |
||||
*/ |
||||
declare const cursorMatchingBracket: StateCommand; |
||||
/** |
||||
Extend the selection to the bracket matching the one the selection |
||||
head is currently on, if any. |
||||
*/ |
||||
declare const selectMatchingBracket: StateCommand; |
||||
/** |
||||
Move the selection head one character to the left, while leaving |
||||
the anchor in place. |
||||
*/ |
||||
declare const selectCharLeft: Command; |
||||
/** |
||||
Move the selection head one character to the right. |
||||
*/ |
||||
declare const selectCharRight: Command; |
||||
/** |
||||
Move the selection head one character forward. |
||||
*/ |
||||
declare const selectCharForward: Command; |
||||
/** |
||||
Move the selection head one character backward. |
||||
*/ |
||||
declare const selectCharBackward: Command; |
||||
/** |
||||
Move the selection head one character forward by logical |
||||
(non-direction aware) string index order. |
||||
*/ |
||||
declare const selectCharForwardLogical: StateCommand; |
||||
/** |
||||
Move the selection head one character backward by logical string |
||||
index order. |
||||
*/ |
||||
declare const selectCharBackwardLogical: StateCommand; |
||||
/** |
||||
Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to |
||||
the left. |
||||
*/ |
||||
declare const selectGroupLeft: Command; |
||||
/** |
||||
Move the selection head one group to the right. |
||||
*/ |
||||
declare const selectGroupRight: Command; |
||||
/** |
||||
Move the selection head one group forward. |
||||
*/ |
||||
declare const selectGroupForward: Command; |
||||
/** |
||||
Move the selection head one group backward. |
||||
*/ |
||||
declare const selectGroupBackward: Command; |
||||
/** |
||||
Move the selection head one group forward in the default Windows |
||||
style, skipping to the start of the next group. |
||||
*/ |
||||
declare const selectGroupForwardWin: Command; |
||||
/** |
||||
Move the selection head one group or camel-case subword forward. |
||||
*/ |
||||
declare const selectSubwordForward: Command; |
||||
/** |
||||
Move the selection head one group or subword backward. |
||||
*/ |
||||
declare const selectSubwordBackward: Command; |
||||
/** |
||||
Move the selection head over the next syntactic element to the left. |
||||
*/ |
||||
declare const selectSyntaxLeft: Command; |
||||
/** |
||||
Move the selection head over the next syntactic element to the right. |
||||
*/ |
||||
declare const selectSyntaxRight: Command; |
||||
/** |
||||
Move the selection head one line up. |
||||
*/ |
||||
declare const selectLineUp: Command; |
||||
/** |
||||
Move the selection head one line down. |
||||
*/ |
||||
declare const selectLineDown: Command; |
||||
/** |
||||
Move the selection head one page up. |
||||
*/ |
||||
declare const selectPageUp: Command; |
||||
/** |
||||
Move the selection head one page down. |
||||
*/ |
||||
declare const selectPageDown: Command; |
||||
/** |
||||
Move the selection head to the next line boundary. |
||||
*/ |
||||
declare const selectLineBoundaryForward: Command; |
||||
/** |
||||
Move the selection head to the previous line boundary. |
||||
*/ |
||||
declare const selectLineBoundaryBackward: Command; |
||||
/** |
||||
Move the selection head one line boundary to the left. |
||||
*/ |
||||
declare const selectLineBoundaryLeft: Command; |
||||
/** |
||||
Move the selection head one line boundary to the right. |
||||
*/ |
||||
declare const selectLineBoundaryRight: Command; |
||||
/** |
||||
Move the selection head to the start of the line. |
||||
*/ |
||||
declare const selectLineStart: Command; |
||||
/** |
||||
Move the selection head to the end of the line. |
||||
*/ |
||||
declare const selectLineEnd: Command; |
||||
/** |
||||
Move the selection to the start of the document. |
||||
*/ |
||||
declare const cursorDocStart: StateCommand; |
||||
/** |
||||
Move the selection to the end of the document. |
||||
*/ |
||||
declare const cursorDocEnd: StateCommand; |
||||
/** |
||||
Move the selection head to the start of the document. |
||||
*/ |
||||
declare const selectDocStart: StateCommand; |
||||
/** |
||||
Move the selection head to the end of the document. |
||||
*/ |
||||
declare const selectDocEnd: StateCommand; |
||||
/** |
||||
Select the entire document. |
||||
*/ |
||||
declare const selectAll: StateCommand; |
||||
/** |
||||
Expand the selection to cover entire lines. |
||||
*/ |
||||
declare const selectLine: StateCommand; |
||||
/** |
||||
Select the next syntactic construct that is larger than the |
||||
selection. Note that this will only work insofar as the language |
||||
[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full |
||||
syntax tree. |
||||
*/ |
||||
declare const selectParentSyntax: StateCommand; |
||||
/** |
||||
Expand the selection by adding a cursor above the heads of |
||||
currently selected ranges. |
||||
*/ |
||||
declare const addCursorAbove: Command; |
||||
/** |
||||
Expand the selection by adding a cursor below the heads of |
||||
currently selected ranges. |
||||
*/ |
||||
declare const addCursorBelow: Command; |
||||
/** |
||||
Simplify the current selection. When multiple ranges are selected, |
||||
reduce it to its main range. Otherwise, if the selection is |
||||
non-empty, convert it to a cursor selection. |
||||
*/ |
||||
declare const simplifySelection: StateCommand; |
||||
/** |
||||
Delete the selection, or, for cursor selections, the character or |
||||
indentation unit before the cursor. |
||||
*/ |
||||
declare const deleteCharBackward: Command; |
||||
/** |
||||
Delete the selection or the character before the cursor. Does not |
||||
implement any extended behavior like deleting whole indentation |
||||
units in one go. |
||||
*/ |
||||
declare const deleteCharBackwardStrict: Command; |
||||
/** |
||||
Delete the selection or the character after the cursor. |
||||
*/ |
||||
declare const deleteCharForward: Command; |
||||
/** |
||||
Delete the selection or backward until the end of the next |
||||
[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of |
||||
whitespace when they consist of a single space. |
||||
*/ |
||||
declare const deleteGroupBackward: StateCommand; |
||||
/** |
||||
Delete the selection or forward until the end of the next group. |
||||
*/ |
||||
declare const deleteGroupForward: StateCommand; |
||||
/** |
||||
Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) |
||||
that uses the Windows convention of also deleting the whitespace |
||||
after a word. |
||||
*/ |
||||
declare const deleteGroupForwardWin: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the end of the line. If the cursor is directly at the end of the |
||||
line, delete the line break after it. |
||||
*/ |
||||
declare const deleteToLineEnd: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the start of the line. If the cursor is directly at the start of the |
||||
line, delete the line break before it. |
||||
*/ |
||||
declare const deleteToLineStart: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the start of the line or the next line wrap before the cursor. |
||||
*/ |
||||
declare const deleteLineBoundaryBackward: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the end of the line or the next line wrap after the cursor. |
||||
*/ |
||||
declare const deleteLineBoundaryForward: Command; |
||||
/** |
||||
Delete all whitespace directly before a line end from the |
||||
document. |
||||
*/ |
||||
declare const deleteTrailingWhitespace: StateCommand; |
||||
/** |
||||
Replace each selection range with a line break, leaving the cursor |
||||
on the line before the break. |
||||
*/ |
||||
declare const splitLine: StateCommand; |
||||
/** |
||||
Flip the characters before and after the cursor(s). |
||||
*/ |
||||
declare const transposeChars: StateCommand; |
||||
/** |
||||
Move the selected lines up one line. |
||||
*/ |
||||
declare const moveLineUp: StateCommand; |
||||
/** |
||||
Move the selected lines down one line. |
||||
*/ |
||||
declare const moveLineDown: StateCommand; |
||||
/** |
||||
Create a copy of the selected lines. Keep the selection in the top copy. |
||||
*/ |
||||
declare const copyLineUp: StateCommand; |
||||
/** |
||||
Create a copy of the selected lines. Keep the selection in the bottom copy. |
||||
*/ |
||||
declare const copyLineDown: StateCommand; |
||||
/** |
||||
Delete selected lines. |
||||
*/ |
||||
declare const deleteLine: Command; |
||||
/** |
||||
Replace the selection with a newline. |
||||
*/ |
||||
declare const insertNewline: StateCommand; |
||||
/** |
||||
Replace the selection with a newline and the same amount of |
||||
indentation as the line above. |
||||
*/ |
||||
declare const insertNewlineKeepIndent: StateCommand; |
||||
/** |
||||
Replace the selection with a newline and indent the newly created |
||||
line(s). If the current line consists only of whitespace, this |
||||
will also delete that whitespace. When the cursor is between |
||||
matching brackets, an additional newline will be inserted after |
||||
the cursor. |
||||
*/ |
||||
declare const insertNewlineAndIndent: StateCommand; |
||||
/** |
||||
Create a blank, indented line below the current line. |
||||
*/ |
||||
declare const insertBlankLine: StateCommand; |
||||
/** |
||||
Auto-indent the selected lines. This uses the [indentation service |
||||
facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent |
||||
information. |
||||
*/ |
||||
declare const indentSelection: StateCommand; |
||||
/** |
||||
Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected |
||||
lines. |
||||
*/ |
||||
declare const indentMore: StateCommand; |
||||
/** |
||||
Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all |
||||
selected lines. |
||||
*/ |
||||
declare const indentLess: StateCommand; |
||||
/** |
||||
Enables or disables |
||||
[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this |
||||
prevents the editor's key bindings from capturing Tab or |
||||
Shift-Tab, making it possible for the user to move focus out of |
||||
the editor with the keyboard. |
||||
*/ |
||||
declare const toggleTabFocusMode: Command; |
||||
/** |
||||
Temporarily enables [tab-focus |
||||
mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until |
||||
another key is pressed. |
||||
*/ |
||||
declare const temporarilySetTabFocusMode: Command; |
||||
/** |
||||
Insert a tab character at the cursor or, if something is selected, |
||||
use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire |
||||
selection. |
||||
*/ |
||||
declare const insertTab: StateCommand; |
||||
/** |
||||
Array of key bindings containing the Emacs-style bindings that are |
||||
available on macOS by default. |
||||
|
||||
- Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) |
||||
- Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) |
||||
- Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) |
||||
- Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) |
||||
- Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) |
||||
- Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) |
||||
- Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) |
||||
- Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) |
||||
- Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd) |
||||
- Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) |
||||
- Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine) |
||||
- Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars) |
||||
- Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) |
||||
- Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) |
||||
*/ |
||||
declare const emacsStyleKeymap: readonly KeyBinding[]; |
||||
/** |
||||
An array of key bindings closely sticking to platform-standard or |
||||
widely used bindings. (This includes the bindings from |
||||
[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key` |
||||
property changed to `mac`.) |
||||
|
||||
- ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift) |
||||
- ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift) |
||||
- Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift) |
||||
- Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift) |
||||
- Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift) |
||||
- Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift) |
||||
- ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift) |
||||
- ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift) |
||||
- Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) |
||||
- Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) |
||||
- Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) |
||||
- Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) |
||||
- PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift) |
||||
- PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift) |
||||
- Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift) |
||||
- End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift) |
||||
- Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift) |
||||
- Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift) |
||||
- Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent) |
||||
- Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll) |
||||
- Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward) |
||||
- Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward) |
||||
- Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward) |
||||
- Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward) |
||||
- Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward). |
||||
- Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward). |
||||
*/ |
||||
declare const standardKeymap: readonly KeyBinding[]; |
||||
/** |
||||
The default keymap. Includes all bindings from |
||||
[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following: |
||||
|
||||
- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift) |
||||
- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift) |
||||
- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp) |
||||
- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown) |
||||
- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp) |
||||
- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown) |
||||
- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove). |
||||
- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow). |
||||
- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection) |
||||
- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine) |
||||
- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine) |
||||
- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax) |
||||
- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess) |
||||
- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) |
||||
- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection) |
||||
- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine) |
||||
- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket) |
||||
- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment). |
||||
- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment). |
||||
- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode). |
||||
*/ |
||||
declare const defaultKeymap: readonly KeyBinding[]; |
||||
/** |
||||
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and |
||||
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess). |
||||
Please see the [Tab example](../../examples/tab/) before using |
||||
this. |
||||
*/ |
||||
declare const indentWithTab: KeyBinding; |
||||
|
||||
export { type CommentTokens, addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection }; |
||||
@ -0,0 +1,650 @@
@@ -0,0 +1,650 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { StateCommand, Facet, Transaction, StateEffect, Extension, StateField, EditorState } from '@codemirror/state'; |
||||
import { KeyBinding, Command } from '@codemirror/view'; |
||||
|
||||
/** |
||||
An object of this type can be provided as [language |
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) under a `"commentTokens"`
|
||||
property to configure comment syntax for a language. |
||||
*/ |
||||
interface CommentTokens { |
||||
/** |
||||
The block comment syntax, if any. For example, for HTML |
||||
you'd provide `{open: "<!--", close: "-->"}`. |
||||
*/ |
||||
block?: { |
||||
open: string; |
||||
close: string; |
||||
}; |
||||
/** |
||||
The line comment syntax. For example `"//"`. |
||||
*/ |
||||
line?: string; |
||||
} |
||||
/** |
||||
Comment or uncomment the current selection. Will use line comments |
||||
if available, otherwise falling back to block comments. |
||||
*/ |
||||
declare const toggleComment: StateCommand; |
||||
/** |
||||
Comment or uncomment the current selection using line comments. |
||||
The line comment syntax is taken from the |
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/ |
||||
declare const toggleLineComment: StateCommand; |
||||
/** |
||||
Comment the current selection using line comments. |
||||
*/ |
||||
declare const lineComment: StateCommand; |
||||
/** |
||||
Uncomment the current selection using line comments. |
||||
*/ |
||||
declare const lineUncomment: StateCommand; |
||||
/** |
||||
Comment or uncomment the current selection using block comments. |
||||
The block comment syntax is taken from the |
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/ |
||||
declare const toggleBlockComment: StateCommand; |
||||
/** |
||||
Comment the current selection using block comments. |
||||
*/ |
||||
declare const blockComment: StateCommand; |
||||
/** |
||||
Uncomment the current selection using block comments. |
||||
*/ |
||||
declare const blockUncomment: StateCommand; |
||||
/** |
||||
Comment or uncomment the lines around the current selection using |
||||
block comments. |
||||
*/ |
||||
declare const toggleBlockCommentByLine: StateCommand; |
||||
|
||||
/** |
||||
Transaction annotation that will prevent that transaction from |
||||
being combined with other transactions in the undo history. Given |
||||
`"before"`, it'll prevent merging with previous transactions. With |
||||
`"after"`, subsequent transactions won't be combined with this |
||||
one. With `"full"`, the transaction is isolated on both sides. |
||||
*/ |
||||
declare const isolateHistory: _codemirror_state.AnnotationType<"after" | "before" | "full">; |
||||
/** |
||||
This facet provides a way to register functions that, given a |
||||
transaction, provide a set of effects that the history should |
||||
store when inverting the transaction. This can be used to |
||||
integrate some kinds of effects in the history, so that they can |
||||
be undone (and redone again). |
||||
*/ |
||||
declare const invertedEffects: Facet<(tr: Transaction) => readonly StateEffect<any>[], readonly ((tr: Transaction) => readonly StateEffect<any>[])[]>; |
||||
interface HistoryConfig { |
||||
/** |
||||
The minimum depth (amount of events) to store. Defaults to 100. |
||||
*/ |
||||
minDepth?: number; |
||||
/** |
||||
The maximum time (in milliseconds) that adjacent events can be |
||||
apart and still be grouped together. Defaults to 500. |
||||
*/ |
||||
newGroupDelay?: number; |
||||
/** |
||||
By default, when close enough together in time, changes are |
||||
joined into an existing undo event if they touch any of the |
||||
changed ranges from that event. You can pass a custom predicate |
||||
here to influence that logic. |
||||
*/ |
||||
joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean; |
||||
} |
||||
/** |
||||
Create a history extension with the given configuration. |
||||
*/ |
||||
declare function history(config?: HistoryConfig): Extension; |
||||
/** |
||||
The state field used to store the history data. Should probably |
||||
only be used when you want to |
||||
[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or
|
||||
[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way
|
||||
that preserves history. |
||||
*/ |
||||
declare const historyField: StateField<unknown>; |
||||
/** |
||||
Undo a single group of history events. Returns false if no group |
||||
was available. |
||||
*/ |
||||
declare const undo: StateCommand; |
||||
/** |
||||
Redo a group of history events. Returns false if no group was |
||||
available. |
||||
*/ |
||||
declare const redo: StateCommand; |
||||
/** |
||||
Undo a change or selection change. |
||||
*/ |
||||
declare const undoSelection: StateCommand; |
||||
/** |
||||
Redo a change or selection change. |
||||
*/ |
||||
declare const redoSelection: StateCommand; |
||||
/** |
||||
The amount of undoable change events available in a given state. |
||||
*/ |
||||
declare const undoDepth: (state: EditorState) => number; |
||||
/** |
||||
The amount of redoable change events available in a given state. |
||||
*/ |
||||
declare const redoDepth: (state: EditorState) => number; |
||||
/** |
||||
Default key bindings for the undo history. |
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
||||
*/ |
||||
declare const historyKeymap: readonly KeyBinding[]; |
||||
|
||||
/** |
||||
Move the selection one character to the left (which is backward in |
||||
left-to-right text, forward in right-to-left text). |
||||
*/ |
||||
declare const cursorCharLeft: Command; |
||||
/** |
||||
Move the selection one character to the right. |
||||
*/ |
||||
declare const cursorCharRight: Command; |
||||
/** |
||||
Move the selection one character forward. |
||||
*/ |
||||
declare const cursorCharForward: Command; |
||||
/** |
||||
Move the selection one character backward. |
||||
*/ |
||||
declare const cursorCharBackward: Command; |
||||
/** |
||||
Move the selection one character forward, in logical |
||||
(non-text-direction-aware) string index order. |
||||
*/ |
||||
declare const cursorCharForwardLogical: StateCommand; |
||||
/** |
||||
Move the selection one character backward, in logical string index |
||||
order. |
||||
*/ |
||||
declare const cursorCharBackwardLogical: StateCommand; |
||||
/** |
||||
Move the selection to the left across one group of word or |
||||
non-word (but also non-space) characters. |
||||
*/ |
||||
declare const cursorGroupLeft: Command; |
||||
/** |
||||
Move the selection one group to the right. |
||||
*/ |
||||
declare const cursorGroupRight: Command; |
||||
/** |
||||
Move the selection one group forward. |
||||
*/ |
||||
declare const cursorGroupForward: Command; |
||||
/** |
||||
Move the selection one group backward. |
||||
*/ |
||||
declare const cursorGroupBackward: Command; |
||||
/** |
||||
Move the cursor one group forward in the default Windows style, |
||||
where it moves to the start of the next group. |
||||
*/ |
||||
declare const cursorGroupForwardWin: Command; |
||||
/** |
||||
Move the selection one group or camel-case subword forward. |
||||
*/ |
||||
declare const cursorSubwordForward: Command; |
||||
/** |
||||
Move the selection one group or camel-case subword backward. |
||||
*/ |
||||
declare const cursorSubwordBackward: Command; |
||||
/** |
||||
Move the cursor over the next syntactic element to the left. |
||||
*/ |
||||
declare const cursorSyntaxLeft: Command; |
||||
/** |
||||
Move the cursor over the next syntactic element to the right. |
||||
*/ |
||||
declare const cursorSyntaxRight: Command; |
||||
/** |
||||
Move the selection one line up. |
||||
*/ |
||||
declare const cursorLineUp: Command; |
||||
/** |
||||
Move the selection one line down. |
||||
*/ |
||||
declare const cursorLineDown: Command; |
||||
/** |
||||
Move the selection one page up. |
||||
*/ |
||||
declare const cursorPageUp: Command; |
||||
/** |
||||
Move the selection one page down. |
||||
*/ |
||||
declare const cursorPageDown: Command; |
||||
/** |
||||
Move the selection to the next line wrap point, or to the end of |
||||
the line if there isn't one left on this line. |
||||
*/ |
||||
declare const cursorLineBoundaryForward: Command; |
||||
/** |
||||
Move the selection to previous line wrap point, or failing that to |
||||
the start of the line. If the line is indented, and the cursor |
||||
isn't already at the end of the indentation, this will move to the |
||||
end of the indentation instead of the start of the line. |
||||
*/ |
||||
declare const cursorLineBoundaryBackward: Command; |
||||
/** |
||||
Move the selection one line wrap point to the left. |
||||
*/ |
||||
declare const cursorLineBoundaryLeft: Command; |
||||
/** |
||||
Move the selection one line wrap point to the right. |
||||
*/ |
||||
declare const cursorLineBoundaryRight: Command; |
||||
/** |
||||
Move the selection to the start of the line. |
||||
*/ |
||||
declare const cursorLineStart: Command; |
||||
/** |
||||
Move the selection to the end of the line. |
||||
*/ |
||||
declare const cursorLineEnd: Command; |
||||
/** |
||||
Move the selection to the bracket matching the one it is currently |
||||
on, if any. |
||||
*/ |
||||
declare const cursorMatchingBracket: StateCommand; |
||||
/** |
||||
Extend the selection to the bracket matching the one the selection |
||||
head is currently on, if any. |
||||
*/ |
||||
declare const selectMatchingBracket: StateCommand; |
||||
/** |
||||
Move the selection head one character to the left, while leaving |
||||
the anchor in place. |
||||
*/ |
||||
declare const selectCharLeft: Command; |
||||
/** |
||||
Move the selection head one character to the right. |
||||
*/ |
||||
declare const selectCharRight: Command; |
||||
/** |
||||
Move the selection head one character forward. |
||||
*/ |
||||
declare const selectCharForward: Command; |
||||
/** |
||||
Move the selection head one character backward. |
||||
*/ |
||||
declare const selectCharBackward: Command; |
||||
/** |
||||
Move the selection head one character forward by logical |
||||
(non-direction aware) string index order. |
||||
*/ |
||||
declare const selectCharForwardLogical: StateCommand; |
||||
/** |
||||
Move the selection head one character backward by logical string |
||||
index order. |
||||
*/ |
||||
declare const selectCharBackwardLogical: StateCommand; |
||||
/** |
||||
Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
|
||||
the left. |
||||
*/ |
||||
declare const selectGroupLeft: Command; |
||||
/** |
||||
Move the selection head one group to the right. |
||||
*/ |
||||
declare const selectGroupRight: Command; |
||||
/** |
||||
Move the selection head one group forward. |
||||
*/ |
||||
declare const selectGroupForward: Command; |
||||
/** |
||||
Move the selection head one group backward. |
||||
*/ |
||||
declare const selectGroupBackward: Command; |
||||
/** |
||||
Move the selection head one group forward in the default Windows |
||||
style, skipping to the start of the next group. |
||||
*/ |
||||
declare const selectGroupForwardWin: Command; |
||||
/** |
||||
Move the selection head one group or camel-case subword forward. |
||||
*/ |
||||
declare const selectSubwordForward: Command; |
||||
/** |
||||
Move the selection head one group or subword backward. |
||||
*/ |
||||
declare const selectSubwordBackward: Command; |
||||
/** |
||||
Move the selection head over the next syntactic element to the left. |
||||
*/ |
||||
declare const selectSyntaxLeft: Command; |
||||
/** |
||||
Move the selection head over the next syntactic element to the right. |
||||
*/ |
||||
declare const selectSyntaxRight: Command; |
||||
/** |
||||
Move the selection head one line up. |
||||
*/ |
||||
declare const selectLineUp: Command; |
||||
/** |
||||
Move the selection head one line down. |
||||
*/ |
||||
declare const selectLineDown: Command; |
||||
/** |
||||
Move the selection head one page up. |
||||
*/ |
||||
declare const selectPageUp: Command; |
||||
/** |
||||
Move the selection head one page down. |
||||
*/ |
||||
declare const selectPageDown: Command; |
||||
/** |
||||
Move the selection head to the next line boundary. |
||||
*/ |
||||
declare const selectLineBoundaryForward: Command; |
||||
/** |
||||
Move the selection head to the previous line boundary. |
||||
*/ |
||||
declare const selectLineBoundaryBackward: Command; |
||||
/** |
||||
Move the selection head one line boundary to the left. |
||||
*/ |
||||
declare const selectLineBoundaryLeft: Command; |
||||
/** |
||||
Move the selection head one line boundary to the right. |
||||
*/ |
||||
declare const selectLineBoundaryRight: Command; |
||||
/** |
||||
Move the selection head to the start of the line. |
||||
*/ |
||||
declare const selectLineStart: Command; |
||||
/** |
||||
Move the selection head to the end of the line. |
||||
*/ |
||||
declare const selectLineEnd: Command; |
||||
/** |
||||
Move the selection to the start of the document. |
||||
*/ |
||||
declare const cursorDocStart: StateCommand; |
||||
/** |
||||
Move the selection to the end of the document. |
||||
*/ |
||||
declare const cursorDocEnd: StateCommand; |
||||
/** |
||||
Move the selection head to the start of the document. |
||||
*/ |
||||
declare const selectDocStart: StateCommand; |
||||
/** |
||||
Move the selection head to the end of the document. |
||||
*/ |
||||
declare const selectDocEnd: StateCommand; |
||||
/** |
||||
Select the entire document. |
||||
*/ |
||||
declare const selectAll: StateCommand; |
||||
/** |
||||
Expand the selection to cover entire lines. |
||||
*/ |
||||
declare const selectLine: StateCommand; |
||||
/** |
||||
Select the next syntactic construct that is larger than the |
||||
selection. Note that this will only work insofar as the language |
||||
[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
|
||||
syntax tree. |
||||
*/ |
||||
declare const selectParentSyntax: StateCommand; |
||||
/** |
||||
Expand the selection by adding a cursor above the heads of |
||||
currently selected ranges. |
||||
*/ |
||||
declare const addCursorAbove: Command; |
||||
/** |
||||
Expand the selection by adding a cursor below the heads of |
||||
currently selected ranges. |
||||
*/ |
||||
declare const addCursorBelow: Command; |
||||
/** |
||||
Simplify the current selection. When multiple ranges are selected, |
||||
reduce it to its main range. Otherwise, if the selection is |
||||
non-empty, convert it to a cursor selection. |
||||
*/ |
||||
declare const simplifySelection: StateCommand; |
||||
/** |
||||
Delete the selection, or, for cursor selections, the character or |
||||
indentation unit before the cursor. |
||||
*/ |
||||
declare const deleteCharBackward: Command; |
||||
/** |
||||
Delete the selection or the character before the cursor. Does not |
||||
implement any extended behavior like deleting whole indentation |
||||
units in one go. |
||||
*/ |
||||
declare const deleteCharBackwardStrict: Command; |
||||
/** |
||||
Delete the selection or the character after the cursor. |
||||
*/ |
||||
declare const deleteCharForward: Command; |
||||
/** |
||||
Delete the selection or backward until the end of the next |
||||
[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
|
||||
whitespace when they consist of a single space. |
||||
*/ |
||||
declare const deleteGroupBackward: StateCommand; |
||||
/** |
||||
Delete the selection or forward until the end of the next group. |
||||
*/ |
||||
declare const deleteGroupForward: StateCommand; |
||||
/** |
||||
Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
||||
that uses the Windows convention of also deleting the whitespace |
||||
after a word. |
||||
*/ |
||||
declare const deleteGroupForwardWin: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the end of the line. If the cursor is directly at the end of the |
||||
line, delete the line break after it. |
||||
*/ |
||||
declare const deleteToLineEnd: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the start of the line. If the cursor is directly at the start of the |
||||
line, delete the line break before it. |
||||
*/ |
||||
declare const deleteToLineStart: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the start of the line or the next line wrap before the cursor. |
||||
*/ |
||||
declare const deleteLineBoundaryBackward: Command; |
||||
/** |
||||
Delete the selection, or, if it is a cursor selection, delete to |
||||
the end of the line or the next line wrap after the cursor. |
||||
*/ |
||||
declare const deleteLineBoundaryForward: Command; |
||||
/** |
||||
Delete all whitespace directly before a line end from the |
||||
document. |
||||
*/ |
||||
declare const deleteTrailingWhitespace: StateCommand; |
||||
/** |
||||
Replace each selection range with a line break, leaving the cursor |
||||
on the line before the break. |
||||
*/ |
||||
declare const splitLine: StateCommand; |
||||
/** |
||||
Flip the characters before and after the cursor(s). |
||||
*/ |
||||
declare const transposeChars: StateCommand; |
||||
/** |
||||
Move the selected lines up one line. |
||||
*/ |
||||
declare const moveLineUp: StateCommand; |
||||
/** |
||||
Move the selected lines down one line. |
||||
*/ |
||||
declare const moveLineDown: StateCommand; |
||||
/** |
||||
Create a copy of the selected lines. Keep the selection in the top copy. |
||||
*/ |
||||
declare const copyLineUp: StateCommand; |
||||
/** |
||||
Create a copy of the selected lines. Keep the selection in the bottom copy. |
||||
*/ |
||||
declare const copyLineDown: StateCommand; |
||||
/** |
||||
Delete selected lines. |
||||
*/ |
||||
declare const deleteLine: Command; |
||||
/** |
||||
Replace the selection with a newline. |
||||
*/ |
||||
declare const insertNewline: StateCommand; |
||||
/** |
||||
Replace the selection with a newline and the same amount of |
||||
indentation as the line above. |
||||
*/ |
||||
declare const insertNewlineKeepIndent: StateCommand; |
||||
/** |
||||
Replace the selection with a newline and indent the newly created |
||||
line(s). If the current line consists only of whitespace, this |
||||
will also delete that whitespace. When the cursor is between |
||||
matching brackets, an additional newline will be inserted after |
||||
the cursor. |
||||
*/ |
||||
declare const insertNewlineAndIndent: StateCommand; |
||||
/** |
||||
Create a blank, indented line below the current line. |
||||
*/ |
||||
declare const insertBlankLine: StateCommand; |
||||
/** |
||||
Auto-indent the selected lines. This uses the [indentation service |
||||
facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
|
||||
information. |
||||
*/ |
||||
declare const indentSelection: StateCommand; |
||||
/** |
||||
Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
|
||||
lines. |
||||
*/ |
||||
declare const indentMore: StateCommand; |
||||
/** |
||||
Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
|
||||
selected lines. |
||||
*/ |
||||
declare const indentLess: StateCommand; |
||||
/** |
||||
Enables or disables |
||||
[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this
|
||||
prevents the editor's key bindings from capturing Tab or |
||||
Shift-Tab, making it possible for the user to move focus out of |
||||
the editor with the keyboard. |
||||
*/ |
||||
declare const toggleTabFocusMode: Command; |
||||
/** |
||||
Temporarily enables [tab-focus |
||||
mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until
|
||||
another key is pressed. |
||||
*/ |
||||
declare const temporarilySetTabFocusMode: Command; |
||||
/** |
||||
Insert a tab character at the cursor or, if something is selected, |
||||
use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire
|
||||
selection. |
||||
*/ |
||||
declare const insertTab: StateCommand; |
||||
/** |
||||
Array of key bindings containing the Emacs-style bindings that are |
||||
available on macOS by default. |
||||
|
||||
- Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
||||
- Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
||||
- Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
||||
- Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
||||
- Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
||||
- Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
||||
- Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
||||
- Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
||||
- Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
|
||||
- Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
||||
- Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
|
||||
- Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
|
||||
- Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
|
||||
- Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
|
||||
*/ |
||||
declare const emacsStyleKeymap: readonly KeyBinding[]; |
||||
/** |
||||
An array of key bindings closely sticking to platform-standard or |
||||
widely used bindings. (This includes the bindings from |
||||
[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
|
||||
property changed to `mac`.) |
||||
|
||||
- ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
||||
- ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
||||
- Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
|
||||
- Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
|
||||
- Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
||||
- Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
||||
- ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
||||
- ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
||||
- Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
||||
- Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
||||
- Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
||||
- Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
||||
- PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
||||
- PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
||||
- Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
|
||||
- End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
|
||||
- Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
||||
- Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
||||
- Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
|
||||
- Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
|
||||
- Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
||||
- Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
||||
- Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
||||
- Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
||||
- Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward).
|
||||
- Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward).
|
||||
*/ |
||||
declare const standardKeymap: readonly KeyBinding[]; |
||||
/** |
||||
The default keymap. Includes all bindings from |
||||
[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
|
||||
|
||||
- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
|
||||
- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
|
||||
- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
|
||||
- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
|
||||
- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
|
||||
- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
|
||||
- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove).
|
||||
- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow).
|
||||
- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
|
||||
- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
|
||||
- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
|
||||
- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
|
||||
- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
|
||||
- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
|
||||
- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
|
||||
- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
|
||||
- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
|
||||
- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
|
||||
- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
|
||||
- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode).
|
||||
*/ |
||||
declare const defaultKeymap: readonly KeyBinding[]; |
||||
/** |
||||
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
|
||||
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
|
||||
Please see the [Tab example](../../examples/tab/) before using |
||||
this. |
||||
*/ |
||||
declare const indentWithTab: KeyBinding; |
||||
|
||||
export { type CommentTokens, addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection }; |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
{ |
||||
"name": "@codemirror/commands", |
||||
"version": "6.10.1", |
||||
"description": "Collection of editing commands for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/commands.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.4.0", |
||||
"@codemirror/view": "^6.27.0", |
||||
"@lezer/common": "^1.1.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0", |
||||
"@codemirror/lang-javascript": "^6.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/commands.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
## 6.3.1 (2024-11-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
When completing a property name, insert a colon and space after the name. |
||||
|
||||
## 6.3.0 (2024-09-07) |
||||
|
||||
### New features |
||||
|
||||
CSS autocompletion now completes `@`-keywords. |
||||
|
||||
## 6.2.1 (2023-08-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Allow keyframe blocks to be code-folded. |
||||
|
||||
## 6.2.0 (2023-04-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Explicitly list @lezer/common as a package dependency. |
||||
|
||||
### New features |
||||
|
||||
Export `defineCSSCompletionSource`, which allows one to define a CSS-style completion source for dialects with their own variable syntax. |
||||
|
||||
## 6.1.1 (2023-03-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Provide better completions when completing directly in a `Styles` top node. |
||||
|
||||
## 6.1.0 (2023-03-06) |
||||
|
||||
### New features |
||||
|
||||
CSS completion can now complete variable names. |
||||
|
||||
## 6.0.2 (2023-01-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fetch the available CSS property names in a way that works on Chrome. |
||||
|
||||
## 6.0.1 (2022-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
CSS completion now supports a number of additional recent and semi-standardized pseudo-class names. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 6.0.0 |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.20.0 |
||||
|
||||
## 0.19.3 (2021-09-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Use more appropriate highlighting tags for attribute names, tag names, and CSS variables. |
||||
|
||||
## 0.19.2 (2021-09-22) |
||||
|
||||
### New features |
||||
|
||||
The package now exports a completion source function, rather than a prebuilt completion extension. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.19.0 |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.18. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,269 @@
@@ -0,0 +1,269 @@
|
||||
'use strict'; |
||||
|
||||
var css$1 = require('@lezer/css'); |
||||
var language = require('@codemirror/language'); |
||||
var common = require('@lezer/common'); |
||||
|
||||
let _properties = null; |
||||
function properties() { |
||||
if (!_properties && typeof document == "object" && document.body) { |
||||
let { style } = document.body, names = [], seen = new Set; |
||||
for (let prop in style) |
||||
if (prop != "cssText" && prop != "cssFloat") { |
||||
if (typeof style[prop] == "string") { |
||||
if (/[A-Z]/.test(prop)) |
||||
prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase()); |
||||
if (!seen.has(prop)) { |
||||
names.push(prop); |
||||
seen.add(prop); |
||||
} |
||||
} |
||||
} |
||||
_properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " })); |
||||
} |
||||
return _properties || []; |
||||
} |
||||
const pseudoClasses = [ |
||||
"active", "after", "any-link", "autofill", "backdrop", "before", |
||||
"checked", "cue", "default", "defined", "disabled", "empty", |
||||
"enabled", "file-selector-button", "first", "first-child", |
||||
"first-letter", "first-line", "first-of-type", "focus", |
||||
"focus-visible", "focus-within", "fullscreen", "has", "host", |
||||
"host-context", "hover", "in-range", "indeterminate", "invalid", |
||||
"is", "lang", "last-child", "last-of-type", "left", "link", "marker", |
||||
"modal", "not", "nth-child", "nth-last-child", "nth-last-of-type", |
||||
"nth-of-type", "only-child", "only-of-type", "optional", "out-of-range", |
||||
"part", "placeholder", "placeholder-shown", "read-only", "read-write", |
||||
"required", "right", "root", "scope", "selection", "slotted", "target", |
||||
"target-text", "valid", "visited", "where" |
||||
].map(name => ({ type: "class", label: name })); |
||||
const values = [ |
||||
"above", "absolute", "activeborder", "additive", "activecaption", "after-white-space", |
||||
"ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", |
||||
"antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", |
||||
"avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", |
||||
"bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", |
||||
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", |
||||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize", |
||||
"caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", |
||||
"cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", |
||||
"color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content", |
||||
"contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", |
||||
"crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", |
||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in", |
||||
"destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed", |
||||
"disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", |
||||
"ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end", |
||||
"ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion", |
||||
"expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box", |
||||
"fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", |
||||
"geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide", |
||||
"higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", |
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", |
||||
"inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid", |
||||
"inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all", |
||||
"landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear", |
||||
"linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", |
||||
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation", |
||||
"match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic", |
||||
"mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower", |
||||
"ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", |
||||
"normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", |
||||
"oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside", |
||||
"outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", |
||||
"perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", |
||||
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", |
||||
"read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat", |
||||
"repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", |
||||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", |
||||
"row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", |
||||
"scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position", |
||||
"se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show", |
||||
"single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", |
||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", |
||||
"small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out", |
||||
"source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start", |
||||
"static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks", |
||||
"super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", |
||||
"table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", |
||||
"table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin", |
||||
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top", |
||||
"transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent", |
||||
"ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin", |
||||
"uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", |
||||
"visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", |
||||
"windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" |
||||
].map(name => ({ type: "keyword", label: name })).concat([ |
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", |
||||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", |
||||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", |
||||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", |
||||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", |
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", |
||||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet", |
||||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", |
||||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", |
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", |
||||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", |
||||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", |
||||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", |
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", |
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", |
||||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", |
||||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", |
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", |
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", |
||||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", |
||||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", |
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", |
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", |
||||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", |
||||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", |
||||
"whitesmoke", "yellow", "yellowgreen" |
||||
].map(name => ({ type: "constant", label: name }))); |
||||
const tags = [ |
||||
"a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body", |
||||
"br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del", |
||||
"details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer", |
||||
"form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", |
||||
"img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output", |
||||
"p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary", |
||||
"sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul" |
||||
].map(name => ({ type: "type", label: name })); |
||||
const atRules = [ |
||||
"@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values", |
||||
"@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page", |
||||
"@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition" |
||||
].map(label => ({ type: "keyword", label })); |
||||
const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/; |
||||
function isVarArg(node, doc) { |
||||
var _a; |
||||
if (node.name == "(" || node.type.isError) |
||||
node = node.parent || node; |
||||
if (node.name != "ArgList") |
||||
return false; |
||||
let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild; |
||||
if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee") |
||||
return false; |
||||
return doc.sliceString(callee.from, callee.to) == "var"; |
||||
} |
||||
const VariablesByNode = new common.NodeWeakMap(); |
||||
const declSelector = ["Declaration"]; |
||||
function astTop(node) { |
||||
for (let cur = node;;) { |
||||
if (cur.type.isTop) |
||||
return cur; |
||||
if (!(cur = cur.parent)) |
||||
return node; |
||||
} |
||||
} |
||||
function variableNames(doc, node, isVariable) { |
||||
if (node.to - node.from > 4096) { |
||||
let known = VariablesByNode.get(node); |
||||
if (known) |
||||
return known; |
||||
let result = [], seen = new Set, cursor = node.cursor(common.IterMode.IncludeAnonymous); |
||||
if (cursor.firstChild()) |
||||
do { |
||||
for (let option of variableNames(doc, cursor.node, isVariable)) |
||||
if (!seen.has(option.label)) { |
||||
seen.add(option.label); |
||||
result.push(option); |
||||
} |
||||
} while (cursor.nextSibling()); |
||||
VariablesByNode.set(node, result); |
||||
return result; |
||||
} |
||||
else { |
||||
let result = [], seen = new Set; |
||||
node.cursor().iterate(node => { |
||||
var _a; |
||||
if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") { |
||||
let name = doc.sliceString(node.from, node.to); |
||||
if (!seen.has(name)) { |
||||
seen.add(name); |
||||
result.push({ label: name, type: "variable" }); |
||||
} |
||||
} |
||||
}); |
||||
return result; |
||||
} |
||||
} |
||||
/** |
||||
Create a completion source for a CSS dialect, providing a |
||||
predicate for determining what kind of syntax node can act as a |
||||
completable variable. This is used by language modes like Sass and |
||||
Less to reuse this package's completion logic. |
||||
*/ |
||||
const defineCSSCompletionSource = (isVariable) => context => { |
||||
let { state, pos } = context, node = language.syntaxTree(state).resolveInner(pos, -1); |
||||
let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-"; |
||||
if (node.name == "PropertyName" || |
||||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name)) |
||||
return { from: node.from, options: properties(), validFor: identifier }; |
||||
if (node.name == "ValueName") |
||||
return { from: node.from, options: values, validFor: identifier }; |
||||
if (node.name == "PseudoClassName") |
||||
return { from: node.from, options: pseudoClasses, validFor: identifier }; |
||||
if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc)) |
||||
return { from: isVariable(node) || isDash ? node.from : pos, |
||||
options: variableNames(state.doc, astTop(node), isVariable), |
||||
validFor: variable }; |
||||
if (node.name == "TagName") { |
||||
for (let { parent } = node; parent; parent = parent.parent) |
||||
if (parent.name == "Block") |
||||
return { from: node.from, options: properties(), validFor: identifier }; |
||||
return { from: node.from, options: tags, validFor: identifier }; |
||||
} |
||||
if (node.name == "AtKeyword") |
||||
return { from: node.from, options: atRules, validFor: identifier }; |
||||
if (!context.explicit) |
||||
return null; |
||||
let above = node.resolve(pos), before = above.childBefore(pos); |
||||
if (before && before.name == ":" && above.name == "PseudoClassSelector") |
||||
return { from: pos, options: pseudoClasses, validFor: identifier }; |
||||
if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList") |
||||
return { from: pos, options: values, validFor: identifier }; |
||||
if (above.name == "Block" || above.name == "Styles") |
||||
return { from: pos, options: properties(), validFor: identifier }; |
||||
return null; |
||||
}; |
||||
/** |
||||
CSS property, variable, and value keyword completion source. |
||||
*/ |
||||
const cssCompletionSource = defineCSSCompletionSource(n => n.name == "VariableName"); |
||||
|
||||
/** |
||||
A language provider based on the [Lezer CSS |
||||
parser](https://github.com/lezer-parser/css), extended with |
||||
highlighting and indentation information. |
||||
*/ |
||||
const cssLanguage = language.LRLanguage.define({ |
||||
name: "css", |
||||
parser: css$1.parser.configure({ |
||||
props: [ |
||||
language.indentNodeProp.add({ |
||||
Declaration: language.continuedIndent() |
||||
}), |
||||
language.foldNodeProp.add({ |
||||
"Block KeyframeList": language.foldInside |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
commentTokens: { block: { open: "/*", close: "*/" } }, |
||||
indentOnInput: /^\s*\}$/, |
||||
wordChars: "-" |
||||
} |
||||
}); |
||||
/** |
||||
Language support for CSS. |
||||
*/ |
||||
function css() { |
||||
return new language.LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource })); |
||||
} |
||||
|
||||
exports.css = css; |
||||
exports.cssCompletionSource = cssCompletionSource; |
||||
exports.cssLanguage = cssLanguage; |
||||
exports.defineCSSCompletionSource = defineCSSCompletionSource; |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { CompletionSource } from '@codemirror/autocomplete'; |
||||
import { SyntaxNodeRef } from '@lezer/common'; |
||||
|
||||
/** |
||||
Create a completion source for a CSS dialect, providing a |
||||
predicate for determining what kind of syntax node can act as a |
||||
completable variable. This is used by language modes like Sass and |
||||
Less to reuse this package's completion logic. |
||||
*/ |
||||
declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource; |
||||
/** |
||||
CSS property, variable, and value keyword completion source. |
||||
*/ |
||||
declare const cssCompletionSource: CompletionSource; |
||||
|
||||
/** |
||||
A language provider based on the [Lezer CSS |
||||
parser](https://github.com/lezer-parser/css), extended with |
||||
highlighting and indentation information. |
||||
*/ |
||||
declare const cssLanguage: LRLanguage; |
||||
/** |
||||
Language support for CSS. |
||||
*/ |
||||
declare function css(): LanguageSupport; |
||||
|
||||
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource }; |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { CompletionSource } from '@codemirror/autocomplete'; |
||||
import { SyntaxNodeRef } from '@lezer/common'; |
||||
|
||||
/** |
||||
Create a completion source for a CSS dialect, providing a |
||||
predicate for determining what kind of syntax node can act as a |
||||
completable variable. This is used by language modes like Sass and |
||||
Less to reuse this package's completion logic. |
||||
*/ |
||||
declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource; |
||||
/** |
||||
CSS property, variable, and value keyword completion source. |
||||
*/ |
||||
declare const cssCompletionSource: CompletionSource; |
||||
|
||||
/** |
||||
A language provider based on the [Lezer CSS |
||||
parser](https://github.com/lezer-parser/css), extended with
|
||||
highlighting and indentation information. |
||||
*/ |
||||
declare const cssLanguage: LRLanguage; |
||||
/** |
||||
Language support for CSS. |
||||
*/ |
||||
declare function css(): LanguageSupport; |
||||
|
||||
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource }; |
||||
@ -0,0 +1,264 @@
@@ -0,0 +1,264 @@
|
||||
import { parser } from '@lezer/css'; |
||||
import { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language'; |
||||
import { NodeWeakMap, IterMode } from '@lezer/common'; |
||||
|
||||
let _properties = null; |
||||
function properties() { |
||||
if (!_properties && typeof document == "object" && document.body) { |
||||
let { style } = document.body, names = [], seen = new Set; |
||||
for (let prop in style) |
||||
if (prop != "cssText" && prop != "cssFloat") { |
||||
if (typeof style[prop] == "string") { |
||||
if (/[A-Z]/.test(prop)) |
||||
prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase()); |
||||
if (!seen.has(prop)) { |
||||
names.push(prop); |
||||
seen.add(prop); |
||||
} |
||||
} |
||||
} |
||||
_properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " })); |
||||
} |
||||
return _properties || []; |
||||
} |
||||
const pseudoClasses = /*@__PURE__*/[ |
||||
"active", "after", "any-link", "autofill", "backdrop", "before", |
||||
"checked", "cue", "default", "defined", "disabled", "empty", |
||||
"enabled", "file-selector-button", "first", "first-child", |
||||
"first-letter", "first-line", "first-of-type", "focus", |
||||
"focus-visible", "focus-within", "fullscreen", "has", "host", |
||||
"host-context", "hover", "in-range", "indeterminate", "invalid", |
||||
"is", "lang", "last-child", "last-of-type", "left", "link", "marker", |
||||
"modal", "not", "nth-child", "nth-last-child", "nth-last-of-type", |
||||
"nth-of-type", "only-child", "only-of-type", "optional", "out-of-range", |
||||
"part", "placeholder", "placeholder-shown", "read-only", "read-write", |
||||
"required", "right", "root", "scope", "selection", "slotted", "target", |
||||
"target-text", "valid", "visited", "where" |
||||
].map(name => ({ type: "class", label: name })); |
||||
const values = /*@__PURE__*/[ |
||||
"above", "absolute", "activeborder", "additive", "activecaption", "after-white-space", |
||||
"ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", |
||||
"antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", |
||||
"avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", |
||||
"bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", |
||||
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", |
||||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize", |
||||
"caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", |
||||
"cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", |
||||
"color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content", |
||||
"contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", |
||||
"crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", |
||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in", |
||||
"destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed", |
||||
"disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", |
||||
"ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end", |
||||
"ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion", |
||||
"expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box", |
||||
"fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", |
||||
"geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide", |
||||
"higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", |
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", |
||||
"inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid", |
||||
"inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all", |
||||
"landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear", |
||||
"linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", |
||||
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation", |
||||
"match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic", |
||||
"mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower", |
||||
"ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", |
||||
"normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", |
||||
"oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside", |
||||
"outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", |
||||
"perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", |
||||
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", |
||||
"read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat", |
||||
"repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", |
||||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", |
||||
"row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", |
||||
"scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position", |
||||
"se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show", |
||||
"single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", |
||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", |
||||
"small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out", |
||||
"source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start", |
||||
"static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks", |
||||
"super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", |
||||
"table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", |
||||
"table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin", |
||||
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top", |
||||
"transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent", |
||||
"ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin", |
||||
"uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", |
||||
"visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", |
||||
"windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" |
||||
].map(name => ({ type: "keyword", label: name })).concat(/*@__PURE__*/[ |
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", |
||||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", |
||||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", |
||||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", |
||||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", |
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", |
||||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet", |
||||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", |
||||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", |
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", |
||||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", |
||||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", |
||||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", |
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", |
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", |
||||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", |
||||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", |
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", |
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", |
||||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", |
||||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", |
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", |
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", |
||||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", |
||||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", |
||||
"whitesmoke", "yellow", "yellowgreen" |
||||
].map(name => ({ type: "constant", label: name }))); |
||||
const tags = /*@__PURE__*/[ |
||||
"a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body", |
||||
"br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del", |
||||
"details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer", |
||||
"form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", |
||||
"img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output", |
||||
"p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary", |
||||
"sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul" |
||||
].map(name => ({ type: "type", label: name })); |
||||
const atRules = /*@__PURE__*/[ |
||||
"@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values", |
||||
"@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page", |
||||
"@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition" |
||||
].map(label => ({ type: "keyword", label })); |
||||
const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/; |
||||
function isVarArg(node, doc) { |
||||
var _a; |
||||
if (node.name == "(" || node.type.isError) |
||||
node = node.parent || node; |
||||
if (node.name != "ArgList") |
||||
return false; |
||||
let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild; |
||||
if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee") |
||||
return false; |
||||
return doc.sliceString(callee.from, callee.to) == "var"; |
||||
} |
||||
const VariablesByNode = /*@__PURE__*/new NodeWeakMap(); |
||||
const declSelector = ["Declaration"]; |
||||
function astTop(node) { |
||||
for (let cur = node;;) { |
||||
if (cur.type.isTop) |
||||
return cur; |
||||
if (!(cur = cur.parent)) |
||||
return node; |
||||
} |
||||
} |
||||
function variableNames(doc, node, isVariable) { |
||||
if (node.to - node.from > 4096) { |
||||
let known = VariablesByNode.get(node); |
||||
if (known) |
||||
return known; |
||||
let result = [], seen = new Set, cursor = node.cursor(IterMode.IncludeAnonymous); |
||||
if (cursor.firstChild()) |
||||
do { |
||||
for (let option of variableNames(doc, cursor.node, isVariable)) |
||||
if (!seen.has(option.label)) { |
||||
seen.add(option.label); |
||||
result.push(option); |
||||
} |
||||
} while (cursor.nextSibling()); |
||||
VariablesByNode.set(node, result); |
||||
return result; |
||||
} |
||||
else { |
||||
let result = [], seen = new Set; |
||||
node.cursor().iterate(node => { |
||||
var _a; |
||||
if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") { |
||||
let name = doc.sliceString(node.from, node.to); |
||||
if (!seen.has(name)) { |
||||
seen.add(name); |
||||
result.push({ label: name, type: "variable" }); |
||||
} |
||||
} |
||||
}); |
||||
return result; |
||||
} |
||||
} |
||||
/** |
||||
Create a completion source for a CSS dialect, providing a |
||||
predicate for determining what kind of syntax node can act as a |
||||
completable variable. This is used by language modes like Sass and |
||||
Less to reuse this package's completion logic. |
||||
*/ |
||||
const defineCSSCompletionSource = (isVariable) => context => { |
||||
let { state, pos } = context, node = syntaxTree(state).resolveInner(pos, -1); |
||||
let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-"; |
||||
if (node.name == "PropertyName" || |
||||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name)) |
||||
return { from: node.from, options: properties(), validFor: identifier }; |
||||
if (node.name == "ValueName") |
||||
return { from: node.from, options: values, validFor: identifier }; |
||||
if (node.name == "PseudoClassName") |
||||
return { from: node.from, options: pseudoClasses, validFor: identifier }; |
||||
if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc)) |
||||
return { from: isVariable(node) || isDash ? node.from : pos, |
||||
options: variableNames(state.doc, astTop(node), isVariable), |
||||
validFor: variable }; |
||||
if (node.name == "TagName") { |
||||
for (let { parent } = node; parent; parent = parent.parent) |
||||
if (parent.name == "Block") |
||||
return { from: node.from, options: properties(), validFor: identifier }; |
||||
return { from: node.from, options: tags, validFor: identifier }; |
||||
} |
||||
if (node.name == "AtKeyword") |
||||
return { from: node.from, options: atRules, validFor: identifier }; |
||||
if (!context.explicit) |
||||
return null; |
||||
let above = node.resolve(pos), before = above.childBefore(pos); |
||||
if (before && before.name == ":" && above.name == "PseudoClassSelector") |
||||
return { from: pos, options: pseudoClasses, validFor: identifier }; |
||||
if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList") |
||||
return { from: pos, options: values, validFor: identifier }; |
||||
if (above.name == "Block" || above.name == "Styles") |
||||
return { from: pos, options: properties(), validFor: identifier }; |
||||
return null; |
||||
}; |
||||
/** |
||||
CSS property, variable, and value keyword completion source. |
||||
*/ |
||||
const cssCompletionSource = /*@__PURE__*/defineCSSCompletionSource(n => n.name == "VariableName"); |
||||
|
||||
/** |
||||
A language provider based on the [Lezer CSS |
||||
parser](https://github.com/lezer-parser/css), extended with
|
||||
highlighting and indentation information. |
||||
*/ |
||||
const cssLanguage = /*@__PURE__*/LRLanguage.define({ |
||||
name: "css", |
||||
parser: /*@__PURE__*/parser.configure({ |
||||
props: [ |
||||
/*@__PURE__*/indentNodeProp.add({ |
||||
Declaration: /*@__PURE__*/continuedIndent() |
||||
}), |
||||
/*@__PURE__*/foldNodeProp.add({ |
||||
"Block KeyframeList": foldInside |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
commentTokens: { block: { open: "/*", close: "*/" } }, |
||||
indentOnInput: /^\s*\}$/, |
||||
wordChars: "-" |
||||
} |
||||
}); |
||||
/** |
||||
Language support for CSS. |
||||
*/ |
||||
function css() { |
||||
return new LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource })); |
||||
} |
||||
|
||||
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource }; |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
{ |
||||
"name": "@codemirror/lang-css", |
||||
"version": "6.3.1", |
||||
"description": "CSS language support for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/css.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/language": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@lezer/common": "^1.0.2", |
||||
"@lezer/css": "^1.1.7" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/lang-css.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,210 @@
@@ -0,0 +1,210 @@
|
||||
## 6.4.11 (2025-10-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Adjust autocompletion to work with @lezer/html's improved handling of `<` characters without tag name after them. |
||||
|
||||
## 6.4.10 (2025-09-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't include period characters in the language's word characters. |
||||
|
||||
## 6.4.9 (2024-04-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug in `autoCloseTags` that made tags not close when typing > after an attribute. |
||||
|
||||
## 6.4.8 (2024-01-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
Complete attribute names after whitespace in a tag even when completion isn't explicitly triggered. |
||||
|
||||
## 6.4.7 (2023-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Parse `script` tags with `application/json` type as JSON syntax. |
||||
|
||||
## 6.4.6 (2023-08-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
`autoCloseTags` now generates two separate transactions, so that the completion can be undone separately. |
||||
|
||||
Add highlighting for the content of `<script>` tags with a type of `importmap` or `speculationrules`. |
||||
|
||||
## 6.4.5 (2023-06-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where HTML autocompletion didn't work when the cursor was at the end of a bit of HTML code inside a mixed-language document. |
||||
|
||||
## 6.4.4 (2023-06-05) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where the completed tag names didn't take into account the parent node's declared children in the schema in some circumstances. |
||||
|
||||
## 6.4.3 (2023-03-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that could cause some nested language regions to be parsed multiple times. |
||||
|
||||
## 6.4.2 (2023-02-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `autoCloseTags` would close self-closing tags when typed directly in front of a word. |
||||
|
||||
## 6.4.1 (2023-01-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Use only the tag name for matching of opening and closing tags. |
||||
|
||||
## 6.4.0 (2022-11-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Directly depend on @lang/css 1.1.0, since we're using a new top rule name introduced in that. |
||||
|
||||
### New features |
||||
|
||||
Add a `globalAttrs` property to (completion) `TagSpec` objects that controls whether global attributes are completed in that tag. |
||||
|
||||
## 6.3.1 (2022-11-29) |
||||
|
||||
### Bug fixes |
||||
|
||||
Remove incorrect pure annotation that broke the code after tree-shaking. |
||||
|
||||
## 6.3.0 (2022-11-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Parse type=text/babel script tags as JSX. |
||||
|
||||
### New features |
||||
|
||||
The new `nestedLanguages` option can be used to configure how the content of script, style, and textarea tags is parsed. |
||||
|
||||
The content of style attributes will now be parsed as CSS, and the content of on[event] attributes as JavaScript. The new `nestedAttributes` option can be used to configure the parsing of other attribute values. |
||||
|
||||
## 6.2.0 (2022-11-16) |
||||
|
||||
### New features |
||||
|
||||
Add a `selfClosingTags` option to `html` that enables `/>` syntax. |
||||
|
||||
## 6.1.4 (2022-11-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Parse the content of text/javascript or lang=ts script tags as TypeScript, use JS for text/jsx, and TSX for text/typescript-jsx. |
||||
|
||||
## 6.1.3 (2022-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Remove deprecated HTML tags from the completions. |
||||
|
||||
## 6.1.2 (2022-09-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make tag auto-closing consume `>` characters after the cursor. |
||||
|
||||
## 6.1.1 (2022-09-05) |
||||
|
||||
### Bug fixes |
||||
|
||||
Properly list the dependency on @codemirror/view in package.json. |
||||
|
||||
## 6.1.0 (2022-06-22) |
||||
|
||||
### New features |
||||
|
||||
It is now possible to pass in options to extend the set of tags and attributes provided by autocompletion. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 6.0.0 |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### New features |
||||
|
||||
Autocompletion now suggests the `<template>` and `<slot>` elements. |
||||
|
||||
## 0.19.4 (2021-11-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where autoclosing a tag directly in front of alphanumeric text would include nonsense text in the completed tag name. |
||||
|
||||
## 0.19.3 (2021-09-23) |
||||
|
||||
### New features |
||||
|
||||
The package now exports a completion source function, rather than a prebuilt completion extension. |
||||
|
||||
Use more specific highlighting tags for attribute names and values. |
||||
|
||||
## 0.19.2 (2021-09-21) |
||||
|
||||
### New features |
||||
|
||||
The new `autoCloseTags` extension (included by default in `html()`) finishes closing tags when you type a `>` or `/` character. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Improve autocompletion in/after unclosed opening tags. |
||||
|
||||
### New features |
||||
|
||||
`html()` now takes a `matchClosingTags` option to turn off closing tag matching. |
||||
|
||||
## 0.18.1 (2021-05-05) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where the completer would sometimes try to complete an opening tag to its own close tag. |
||||
|
||||
Fix a bug that would sometimes produce the wrong indentation in HTML elements. |
||||
|
||||
Fix a bug that broke tag-specific attribute completion in tags like `<input>` or `<script>`. |
||||
|
||||
Move a new version of lezer-html which solves some issues with autocompletion. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Improves indentation at end of implicitly closed elements. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,667 @@
@@ -0,0 +1,667 @@
|
||||
'use strict'; |
||||
|
||||
var html$1 = require('@lezer/html'); |
||||
var langCss = require('@codemirror/lang-css'); |
||||
var langJavascript = require('@codemirror/lang-javascript'); |
||||
var view = require('@codemirror/view'); |
||||
var state = require('@codemirror/state'); |
||||
var language = require('@codemirror/language'); |
||||
|
||||
const Targets = ["_blank", "_self", "_top", "_parent"]; |
||||
const Charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"]; |
||||
const Methods = ["get", "post", "put", "delete"]; |
||||
const Encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]; |
||||
const Bool = ["true", "false"]; |
||||
const S = {}; // Empty tag spec |
||||
const Tags = { |
||||
a: { |
||||
attrs: { |
||||
href: null, ping: null, type: null, |
||||
media: null, |
||||
target: Targets, |
||||
hreflang: null |
||||
} |
||||
}, |
||||
abbr: S, |
||||
address: S, |
||||
area: { |
||||
attrs: { |
||||
alt: null, coords: null, href: null, target: null, ping: null, |
||||
media: null, hreflang: null, type: null, |
||||
shape: ["default", "rect", "circle", "poly"] |
||||
} |
||||
}, |
||||
article: S, |
||||
aside: S, |
||||
audio: { |
||||
attrs: { |
||||
src: null, mediagroup: null, |
||||
crossorigin: ["anonymous", "use-credentials"], |
||||
preload: ["none", "metadata", "auto"], |
||||
autoplay: ["autoplay"], |
||||
loop: ["loop"], |
||||
controls: ["controls"] |
||||
} |
||||
}, |
||||
b: S, |
||||
base: { attrs: { href: null, target: Targets } }, |
||||
bdi: S, |
||||
bdo: S, |
||||
blockquote: { attrs: { cite: null } }, |
||||
body: S, |
||||
br: S, |
||||
button: { |
||||
attrs: { |
||||
form: null, formaction: null, name: null, value: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["autofocus"], |
||||
formenctype: Encs, |
||||
formmethod: Methods, |
||||
formnovalidate: ["novalidate"], |
||||
formtarget: Targets, |
||||
type: ["submit", "reset", "button"] |
||||
} |
||||
}, |
||||
canvas: { attrs: { width: null, height: null } }, |
||||
caption: S, |
||||
center: S, |
||||
cite: S, |
||||
code: S, |
||||
col: { attrs: { span: null } }, |
||||
colgroup: { attrs: { span: null } }, |
||||
command: { |
||||
attrs: { |
||||
type: ["command", "checkbox", "radio"], |
||||
label: null, icon: null, radiogroup: null, command: null, title: null, |
||||
disabled: ["disabled"], |
||||
checked: ["checked"] |
||||
} |
||||
}, |
||||
data: { attrs: { value: null } }, |
||||
datagrid: { attrs: { disabled: ["disabled"], multiple: ["multiple"] } }, |
||||
datalist: { attrs: { data: null } }, |
||||
dd: S, |
||||
del: { attrs: { cite: null, datetime: null } }, |
||||
details: { attrs: { open: ["open"] } }, |
||||
dfn: S, |
||||
div: S, |
||||
dl: S, |
||||
dt: S, |
||||
em: S, |
||||
embed: { attrs: { src: null, type: null, width: null, height: null } }, |
||||
eventsource: { attrs: { src: null } }, |
||||
fieldset: { attrs: { disabled: ["disabled"], form: null, name: null } }, |
||||
figcaption: S, |
||||
figure: S, |
||||
footer: S, |
||||
form: { |
||||
attrs: { |
||||
action: null, name: null, |
||||
"accept-charset": Charsets, |
||||
autocomplete: ["on", "off"], |
||||
enctype: Encs, |
||||
method: Methods, |
||||
novalidate: ["novalidate"], |
||||
target: Targets |
||||
} |
||||
}, |
||||
h1: S, h2: S, h3: S, h4: S, h5: S, h6: S, |
||||
head: { |
||||
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"] |
||||
}, |
||||
header: S, |
||||
hgroup: S, |
||||
hr: S, |
||||
html: { |
||||
attrs: { manifest: null } |
||||
}, |
||||
i: S, |
||||
iframe: { |
||||
attrs: { |
||||
src: null, srcdoc: null, name: null, width: null, height: null, |
||||
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"], |
||||
seamless: ["seamless"] |
||||
} |
||||
}, |
||||
img: { |
||||
attrs: { |
||||
alt: null, src: null, ismap: null, usemap: null, width: null, height: null, |
||||
crossorigin: ["anonymous", "use-credentials"] |
||||
} |
||||
}, |
||||
input: { |
||||
attrs: { |
||||
alt: null, dirname: null, form: null, formaction: null, |
||||
height: null, list: null, max: null, maxlength: null, min: null, |
||||
name: null, pattern: null, placeholder: null, size: null, src: null, |
||||
step: null, value: null, width: null, |
||||
accept: ["audio/*", "video/*", "image/*"], |
||||
autocomplete: ["on", "off"], |
||||
autofocus: ["autofocus"], |
||||
checked: ["checked"], |
||||
disabled: ["disabled"], |
||||
formenctype: Encs, |
||||
formmethod: Methods, |
||||
formnovalidate: ["novalidate"], |
||||
formtarget: Targets, |
||||
multiple: ["multiple"], |
||||
readonly: ["readonly"], |
||||
required: ["required"], |
||||
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month", |
||||
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", |
||||
"file", "submit", "image", "reset", "button"] |
||||
} |
||||
}, |
||||
ins: { attrs: { cite: null, datetime: null } }, |
||||
kbd: S, |
||||
keygen: { |
||||
attrs: { |
||||
challenge: null, form: null, name: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["disabled"], |
||||
keytype: ["RSA"] |
||||
} |
||||
}, |
||||
label: { attrs: { for: null, form: null } }, |
||||
legend: S, |
||||
li: { attrs: { value: null } }, |
||||
link: { |
||||
attrs: { |
||||
href: null, type: null, |
||||
hreflang: null, |
||||
media: null, |
||||
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"] |
||||
} |
||||
}, |
||||
map: { attrs: { name: null } }, |
||||
mark: S, |
||||
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } }, |
||||
meta: { |
||||
attrs: { |
||||
content: null, |
||||
charset: Charsets, |
||||
name: ["viewport", "application-name", "author", "description", "generator", "keywords"], |
||||
"http-equiv": ["content-language", "content-type", "default-style", "refresh"] |
||||
} |
||||
}, |
||||
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } }, |
||||
nav: S, |
||||
noscript: S, |
||||
object: { |
||||
attrs: { |
||||
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null, |
||||
typemustmatch: ["typemustmatch"] |
||||
} |
||||
}, |
||||
ol: { attrs: { reversed: ["reversed"], start: null, type: ["1", "a", "A", "i", "I"] }, |
||||
children: ["li", "script", "template", "ul", "ol"] }, |
||||
optgroup: { attrs: { disabled: ["disabled"], label: null } }, |
||||
option: { attrs: { disabled: ["disabled"], label: null, selected: ["selected"], value: null } }, |
||||
output: { attrs: { for: null, form: null, name: null } }, |
||||
p: S, |
||||
param: { attrs: { name: null, value: null } }, |
||||
pre: S, |
||||
progress: { attrs: { value: null, max: null } }, |
||||
q: { attrs: { cite: null } }, |
||||
rp: S, |
||||
rt: S, |
||||
ruby: S, |
||||
samp: S, |
||||
script: { |
||||
attrs: { |
||||
type: ["text/javascript"], |
||||
src: null, |
||||
async: ["async"], |
||||
defer: ["defer"], |
||||
charset: Charsets |
||||
} |
||||
}, |
||||
section: S, |
||||
select: { |
||||
attrs: { |
||||
form: null, name: null, size: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["disabled"], |
||||
multiple: ["multiple"] |
||||
} |
||||
}, |
||||
slot: { attrs: { name: null } }, |
||||
small: S, |
||||
source: { attrs: { src: null, type: null, media: null } }, |
||||
span: S, |
||||
strong: S, |
||||
style: { |
||||
attrs: { |
||||
type: ["text/css"], |
||||
media: null, |
||||
scoped: null |
||||
} |
||||
}, |
||||
sub: S, |
||||
summary: S, |
||||
sup: S, |
||||
table: S, |
||||
tbody: S, |
||||
td: { attrs: { colspan: null, rowspan: null, headers: null } }, |
||||
template: S, |
||||
textarea: { |
||||
attrs: { |
||||
dirname: null, form: null, maxlength: null, name: null, placeholder: null, |
||||
rows: null, cols: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["disabled"], |
||||
readonly: ["readonly"], |
||||
required: ["required"], |
||||
wrap: ["soft", "hard"] |
||||
} |
||||
}, |
||||
tfoot: S, |
||||
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } }, |
||||
thead: S, |
||||
time: { attrs: { datetime: null } }, |
||||
title: S, |
||||
tr: S, |
||||
track: { |
||||
attrs: { |
||||
src: null, label: null, default: null, |
||||
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"], |
||||
srclang: null |
||||
} |
||||
}, |
||||
ul: { children: ["li", "script", "template", "ul", "ol"] }, |
||||
var: S, |
||||
video: { |
||||
attrs: { |
||||
src: null, poster: null, width: null, height: null, |
||||
crossorigin: ["anonymous", "use-credentials"], |
||||
preload: ["auto", "metadata", "none"], |
||||
autoplay: ["autoplay"], |
||||
mediagroup: ["movie"], |
||||
muted: ["muted"], |
||||
controls: ["controls"] |
||||
} |
||||
}, |
||||
wbr: S |
||||
}; |
||||
const GlobalAttrs = { |
||||
accesskey: null, |
||||
class: null, |
||||
contenteditable: Bool, |
||||
contextmenu: null, |
||||
dir: ["ltr", "rtl", "auto"], |
||||
draggable: ["true", "false", "auto"], |
||||
dropzone: ["copy", "move", "link", "string:", "file:"], |
||||
hidden: ["hidden"], |
||||
id: null, |
||||
inert: ["inert"], |
||||
itemid: null, |
||||
itemprop: null, |
||||
itemref: null, |
||||
itemscope: ["itemscope"], |
||||
itemtype: null, |
||||
lang: ["ar", "bn", "de", "en-GB", "en-US", "es", "fr", "hi", "id", "ja", "pa", "pt", "ru", "tr", "zh"], |
||||
spellcheck: Bool, |
||||
autocorrect: Bool, |
||||
autocapitalize: Bool, |
||||
style: null, |
||||
tabindex: null, |
||||
title: null, |
||||
translate: ["yes", "no"], |
||||
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"], |
||||
role: "alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "), |
||||
"aria-activedescendant": null, |
||||
"aria-atomic": Bool, |
||||
"aria-autocomplete": ["inline", "list", "both", "none"], |
||||
"aria-busy": Bool, |
||||
"aria-checked": ["true", "false", "mixed", "undefined"], |
||||
"aria-controls": null, |
||||
"aria-describedby": null, |
||||
"aria-disabled": Bool, |
||||
"aria-dropeffect": null, |
||||
"aria-expanded": ["true", "false", "undefined"], |
||||
"aria-flowto": null, |
||||
"aria-grabbed": ["true", "false", "undefined"], |
||||
"aria-haspopup": Bool, |
||||
"aria-hidden": Bool, |
||||
"aria-invalid": ["true", "false", "grammar", "spelling"], |
||||
"aria-label": null, |
||||
"aria-labelledby": null, |
||||
"aria-level": null, |
||||
"aria-live": ["off", "polite", "assertive"], |
||||
"aria-multiline": Bool, |
||||
"aria-multiselectable": Bool, |
||||
"aria-owns": null, |
||||
"aria-posinset": null, |
||||
"aria-pressed": ["true", "false", "mixed", "undefined"], |
||||
"aria-readonly": Bool, |
||||
"aria-relevant": null, |
||||
"aria-required": Bool, |
||||
"aria-selected": ["true", "false", "undefined"], |
||||
"aria-setsize": null, |
||||
"aria-sort": ["ascending", "descending", "none", "other"], |
||||
"aria-valuemax": null, |
||||
"aria-valuemin": null, |
||||
"aria-valuenow": null, |
||||
"aria-valuetext": null |
||||
}; |
||||
const eventAttributes = ("beforeunload copy cut dragstart dragover dragleave dragenter dragend " + |
||||
"drag paste focus blur change click load mousedown mouseenter mouseleave " + |
||||
"mouseup keydown keyup resize scroll unload").split(" ").map(n => "on" + n); |
||||
for (let a of eventAttributes) |
||||
GlobalAttrs[a] = null; |
||||
class Schema { |
||||
constructor(extraTags, extraAttrs) { |
||||
this.tags = { ...Tags, ...extraTags }; |
||||
this.globalAttrs = { ...GlobalAttrs, ...extraAttrs }; |
||||
this.allTags = Object.keys(this.tags); |
||||
this.globalAttrNames = Object.keys(this.globalAttrs); |
||||
} |
||||
} |
||||
Schema.default = new Schema; |
||||
function elementName(doc, tree, max = doc.length) { |
||||
if (!tree) |
||||
return ""; |
||||
let tag = tree.firstChild; |
||||
let name = tag && tag.getChild("TagName"); |
||||
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : ""; |
||||
} |
||||
function findParentElement(tree, skip = false) { |
||||
for (; tree; tree = tree.parent) |
||||
if (tree.name == "Element") { |
||||
if (skip) |
||||
skip = false; |
||||
else |
||||
return tree; |
||||
} |
||||
return null; |
||||
} |
||||
function allowedChildren(doc, tree, schema) { |
||||
let parentInfo = schema.tags[elementName(doc, findParentElement(tree))]; |
||||
return (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.children) || schema.allTags; |
||||
} |
||||
function openTags(doc, tree) { |
||||
let open = []; |
||||
for (let parent = findParentElement(tree); parent && !parent.type.isTop; parent = findParentElement(parent.parent)) { |
||||
let tagName = elementName(doc, parent); |
||||
if (tagName && parent.lastChild.name == "CloseTag") |
||||
break; |
||||
if (tagName && open.indexOf(tagName) < 0 && (tree.name == "EndTag" || tree.from >= parent.firstChild.to)) |
||||
open.push(tagName); |
||||
} |
||||
return open; |
||||
} |
||||
const identifier = /^[:\-\.\w\u00b7-\uffff]*$/; |
||||
function completeTag(state, schema, tree, from, to) { |
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">"; |
||||
let parent = findParentElement(tree, tree.name == "StartTag" || tree.name == "TagName"); |
||||
return { from, to, |
||||
options: allowedChildren(state.doc, parent, schema).map(tagName => ({ label: tagName, type: "type" })).concat(openTags(state.doc, tree).map((tag, i) => ({ label: "/" + tag, apply: "/" + tag + end, |
||||
type: "type", boost: 99 - i }))), |
||||
validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/ }; |
||||
} |
||||
function completeCloseTag(state, tree, from, to) { |
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">"; |
||||
return { from, to, |
||||
options: openTags(state.doc, tree).map((tag, i) => ({ label: tag, apply: tag + end, type: "type", boost: 99 - i })), |
||||
validFor: identifier }; |
||||
} |
||||
function completeStartTag(state, schema, tree, pos) { |
||||
let options = [], level = 0; |
||||
for (let tagName of allowedChildren(state.doc, tree, schema)) |
||||
options.push({ label: "<" + tagName, type: "type" }); |
||||
for (let open of openTags(state.doc, tree)) |
||||
options.push({ label: "</" + open + ">", type: "type", boost: 99 - level++ }); |
||||
return { from: pos, to: pos, options, validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/ }; |
||||
} |
||||
function completeAttrName(state, schema, tree, from, to) { |
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null; |
||||
let localAttrs = info && info.attrs ? Object.keys(info.attrs) : []; |
||||
let names = info && info.globalAttrs === false ? localAttrs |
||||
: localAttrs.length ? localAttrs.concat(schema.globalAttrNames) : schema.globalAttrNames; |
||||
return { from, to, |
||||
options: names.map(attrName => ({ label: attrName, type: "property" })), |
||||
validFor: identifier }; |
||||
} |
||||
function completeAttrValue(state, schema, tree, from, to) { |
||||
var _a; |
||||
let nameNode = (_a = tree.parent) === null || _a === void 0 ? void 0 : _a.getChild("AttributeName"); |
||||
let options = [], token = undefined; |
||||
if (nameNode) { |
||||
let attrName = state.sliceDoc(nameNode.from, nameNode.to); |
||||
let attrs = schema.globalAttrs[attrName]; |
||||
if (!attrs) { |
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null; |
||||
attrs = (info === null || info === void 0 ? void 0 : info.attrs) && info.attrs[attrName]; |
||||
} |
||||
if (attrs) { |
||||
let base = state.sliceDoc(from, to).toLowerCase(), quoteStart = '"', quoteEnd = '"'; |
||||
if (/^['"]/.test(base)) { |
||||
token = base[0] == '"' ? /^[^"]*$/ : /^[^']*$/; |
||||
quoteStart = ""; |
||||
quoteEnd = state.sliceDoc(to, to + 1) == base[0] ? "" : base[0]; |
||||
base = base.slice(1); |
||||
from++; |
||||
} |
||||
else { |
||||
token = /^[^\s<>='"]*$/; |
||||
} |
||||
for (let value of attrs) |
||||
options.push({ label: value, apply: quoteStart + value + quoteEnd, type: "constant" }); |
||||
} |
||||
} |
||||
return { from, to, options, validFor: token }; |
||||
} |
||||
function htmlCompletionFor(schema, context) { |
||||
let { state, pos } = context, tree = language.syntaxTree(state).resolveInner(pos, -1), around = tree.resolve(pos); |
||||
for (let scan = pos, before; around == tree && (before = tree.childBefore(scan));) { |
||||
let last = before.lastChild; |
||||
if (!last || !last.type.isError || last.from < last.to) |
||||
break; |
||||
around = tree = before; |
||||
scan = last.from; |
||||
} |
||||
if (tree.name == "TagName") { |
||||
return tree.parent && /CloseTag$/.test(tree.parent.name) ? completeCloseTag(state, tree, tree.from, pos) |
||||
: completeTag(state, schema, tree, tree.from, pos); |
||||
} |
||||
else if (tree.name == "StartTag" || tree.name == "IncompleteTag") { |
||||
return completeTag(state, schema, tree, pos, pos); |
||||
} |
||||
else if (tree.name == "StartCloseTag" || tree.name == "IncompleteCloseTag") { |
||||
return completeCloseTag(state, tree, pos, pos); |
||||
} |
||||
else if (tree.name == "OpenTag" || tree.name == "SelfClosingTag" || tree.name == "AttributeName") { |
||||
return completeAttrName(state, schema, tree, tree.name == "AttributeName" ? tree.from : pos, pos); |
||||
} |
||||
else if (tree.name == "Is" || tree.name == "AttributeValue" || tree.name == "UnquotedAttributeValue") { |
||||
return completeAttrValue(state, schema, tree, tree.name == "Is" ? pos : tree.from, pos); |
||||
} |
||||
else if (context.explicit && (around.name == "Element" || around.name == "Text" || around.name == "Document")) { |
||||
return completeStartTag(state, schema, tree, pos); |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
/** |
||||
HTML tag completion. Opens and closes tags and attributes in a |
||||
context-aware way. |
||||
*/ |
||||
function htmlCompletionSource(context) { |
||||
return htmlCompletionFor(Schema.default, context); |
||||
} |
||||
/** |
||||
Create a completion source for HTML extended with additional tags |
||||
or attributes. |
||||
*/ |
||||
function htmlCompletionSourceWith(config) { |
||||
let { extraTags, extraGlobalAttributes: extraAttrs } = config; |
||||
let schema = extraAttrs || extraTags ? new Schema(extraTags, extraAttrs) : Schema.default; |
||||
return (context) => htmlCompletionFor(schema, context); |
||||
} |
||||
|
||||
const jsonParser = langJavascript.javascriptLanguage.parser.configure({ top: "SingleExpression" }); |
||||
const defaultNesting = [ |
||||
{ tag: "script", |
||||
attrs: attrs => attrs.type == "text/typescript" || attrs.lang == "ts", |
||||
parser: langJavascript.typescriptLanguage.parser }, |
||||
{ tag: "script", |
||||
attrs: attrs => attrs.type == "text/babel" || attrs.type == "text/jsx", |
||||
parser: langJavascript.jsxLanguage.parser }, |
||||
{ tag: "script", |
||||
attrs: attrs => attrs.type == "text/typescript-jsx", |
||||
parser: langJavascript.tsxLanguage.parser }, |
||||
{ tag: "script", |
||||
attrs(attrs) { |
||||
return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(attrs.type); |
||||
}, |
||||
parser: jsonParser }, |
||||
{ tag: "script", |
||||
attrs(attrs) { |
||||
return !attrs.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs.type); |
||||
}, |
||||
parser: langJavascript.javascriptLanguage.parser }, |
||||
{ tag: "style", |
||||
attrs(attrs) { |
||||
return (!attrs.lang || attrs.lang == "css") && (!attrs.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(attrs.type)); |
||||
}, |
||||
parser: langCss.cssLanguage.parser } |
||||
]; |
||||
const defaultAttrs = [ |
||||
{ name: "style", |
||||
parser: langCss.cssLanguage.parser.configure({ top: "Styles" }) } |
||||
].concat(eventAttributes.map(name => ({ name, parser: langJavascript.javascriptLanguage.parser }))); |
||||
const htmlPlain = language.LRLanguage.define({ |
||||
name: "html", |
||||
parser: html$1.parser.configure({ |
||||
props: [ |
||||
language.indentNodeProp.add({ |
||||
Element(context) { |
||||
let after = /^(\s*)(<\/)?/.exec(context.textAfter); |
||||
if (context.node.to <= context.pos + after[0].length) |
||||
return context.continue(); |
||||
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit); |
||||
}, |
||||
"OpenTag CloseTag SelfClosingTag"(context) { |
||||
return context.column(context.node.from) + context.unit; |
||||
}, |
||||
Document(context) { |
||||
if (context.pos + /\s*/.exec(context.textAfter)[0].length < context.node.to) |
||||
return context.continue(); |
||||
let endElt = null, close; |
||||
for (let cur = context.node;;) { |
||||
let last = cur.lastChild; |
||||
if (!last || last.name != "Element" || last.to != cur.to) |
||||
break; |
||||
endElt = cur = last; |
||||
} |
||||
if (endElt && !((close = endElt.lastChild) && (close.name == "CloseTag" || close.name == "SelfClosingTag"))) |
||||
return context.lineIndent(endElt.from) + context.unit; |
||||
return null; |
||||
} |
||||
}), |
||||
language.foldNodeProp.add({ |
||||
Element(node) { |
||||
let first = node.firstChild, last = node.lastChild; |
||||
if (!first || first.name != "OpenTag") |
||||
return null; |
||||
return { from: first.to, to: last.name == "CloseTag" ? last.from : node.to }; |
||||
} |
||||
}), |
||||
language.bracketMatchingHandle.add({ |
||||
"OpenTag CloseTag": node => node.getChild("TagName") |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
commentTokens: { block: { open: "<!--", close: "-->" } }, |
||||
indentOnInput: /^\s*<\/\w+\W$/, |
||||
wordChars: "-_" |
||||
} |
||||
}); |
||||
/** |
||||
A language provider based on the [Lezer HTML |
||||
parser](https://github.com/lezer-parser/html), extended with the |
||||
JavaScript and CSS parsers to parse the content of `<script>` and |
||||
`<style>` tags. |
||||
*/ |
||||
const htmlLanguage = htmlPlain.configure({ |
||||
wrap: html$1.configureNesting(defaultNesting, defaultAttrs) |
||||
}); |
||||
/** |
||||
Language support for HTML, including |
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and |
||||
CSS support extensions. |
||||
*/ |
||||
function html(config = {}) { |
||||
let dialect = "", wrap; |
||||
if (config.matchClosingTags === false) |
||||
dialect = "noMatch"; |
||||
if (config.selfClosingTags === true) |
||||
dialect = (dialect ? dialect + " " : "") + "selfClosing"; |
||||
if (config.nestedLanguages && config.nestedLanguages.length || |
||||
config.nestedAttributes && config.nestedAttributes.length) |
||||
wrap = html$1.configureNesting((config.nestedLanguages || []).concat(defaultNesting), (config.nestedAttributes || []).concat(defaultAttrs)); |
||||
let lang = wrap ? htmlPlain.configure({ wrap, dialect }) : dialect ? htmlLanguage.configure({ dialect }) : htmlLanguage; |
||||
return new language.LanguageSupport(lang, [ |
||||
htmlLanguage.data.of({ autocomplete: htmlCompletionSourceWith(config) }), |
||||
config.autoCloseTags !== false ? autoCloseTags : [], |
||||
langJavascript.javascript().support, |
||||
langCss.css().support |
||||
]); |
||||
} |
||||
const selfClosers = new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")); |
||||
/** |
||||
Extension that will automatically insert close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
const autoCloseTags = view.EditorView.inputHandler.of((view, from, to, text, insertTransaction) => { |
||||
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") || |
||||
!htmlLanguage.isActiveAt(view.state, from, -1)) |
||||
return false; |
||||
let base = insertTransaction(), { state: state$1 } = base; |
||||
let closeTags = state$1.changeByRange(range => { |
||||
var _a, _b, _c; |
||||
let didType = state$1.doc.sliceString(range.from - 1, range.to) == text; |
||||
let { head } = range, after = language.syntaxTree(state$1).resolveInner(head, -1), name; |
||||
if (didType && text == ">" && after.name == "EndTag") { |
||||
let tag = after.parent; |
||||
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" && |
||||
(name = elementName(state$1.doc, tag.parent, head)) && |
||||
!selfClosers.has(name)) { |
||||
let to = head + (state$1.doc.sliceString(head, head + 1) === ">" ? 1 : 0); |
||||
let insert = `</${name}>`; |
||||
return { range, changes: { from: head, to, insert } }; |
||||
} |
||||
} |
||||
else if (didType && text == "/" && after.name == "IncompleteCloseTag") { |
||||
let tag = after.parent; |
||||
if (after.from == head - 2 && ((_c = tag.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" && |
||||
(name = elementName(state$1.doc, tag, head)) && !selfClosers.has(name)) { |
||||
let to = head + (state$1.doc.sliceString(head, head + 1) === ">" ? 1 : 0); |
||||
let insert = `${name}>`; |
||||
return { |
||||
range: state.EditorSelection.cursor(head + insert.length, -1), |
||||
changes: { from: head, to, insert } |
||||
}; |
||||
} |
||||
} |
||||
return { range }; |
||||
}); |
||||
if (closeTags.changes.empty) |
||||
return false; |
||||
view.dispatch([ |
||||
base, |
||||
state$1.update(closeTags, { |
||||
userEvent: "input.complete", |
||||
scrollIntoView: true |
||||
}) |
||||
]); |
||||
return true; |
||||
}); |
||||
|
||||
exports.autoCloseTags = autoCloseTags; |
||||
exports.html = html; |
||||
exports.htmlCompletionSource = htmlCompletionSource; |
||||
exports.htmlCompletionSourceWith = htmlCompletionSourceWith; |
||||
exports.htmlLanguage = htmlLanguage; |
||||
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { Parser } from '@lezer/common'; |
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete'; |
||||
|
||||
/** |
||||
Type used to specify tags to complete. |
||||
*/ |
||||
interface TagSpec { |
||||
/** |
||||
Define tag-specific attributes. Property names are attribute |
||||
names, and property values can be null to indicate free-form |
||||
attributes, or a list of strings for suggested attribute values. |
||||
*/ |
||||
attrs?: Record<string, null | readonly string[]>; |
||||
/** |
||||
When set to false, don't complete global attributes on this tag. |
||||
*/ |
||||
globalAttrs?: boolean; |
||||
/** |
||||
Can be used to specify a list of child tags that are valid |
||||
inside this tag. The default is to allow any tag. |
||||
*/ |
||||
children?: readonly string[]; |
||||
} |
||||
/** |
||||
HTML tag completion. Opens and closes tags and attributes in a |
||||
context-aware way. |
||||
*/ |
||||
declare function htmlCompletionSource(context: CompletionContext): CompletionResult | null; |
||||
/** |
||||
Create a completion source for HTML extended with additional tags |
||||
or attributes. |
||||
*/ |
||||
declare function htmlCompletionSourceWith(config: { |
||||
/** |
||||
Define extra tag names to complete. |
||||
*/ |
||||
extraTags?: Record<string, TagSpec>; |
||||
/** |
||||
Add global attributes that are available on all tags. |
||||
*/ |
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>; |
||||
}): (context: CompletionContext) => CompletionResult | null; |
||||
|
||||
type NestedLang = { |
||||
tag: string; |
||||
attrs?: (attrs: { |
||||
[attr: string]: string; |
||||
}) => boolean; |
||||
parser: Parser; |
||||
}; |
||||
type NestedAttr = { |
||||
name: string; |
||||
tagName?: string; |
||||
parser: Parser; |
||||
}; |
||||
/** |
||||
A language provider based on the [Lezer HTML |
||||
parser](https://github.com/lezer-parser/html), extended with the |
||||
JavaScript and CSS parsers to parse the content of `<script>` and |
||||
`<style>` tags. |
||||
*/ |
||||
declare const htmlLanguage: LRLanguage; |
||||
/** |
||||
Language support for HTML, including |
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and |
||||
CSS support extensions. |
||||
*/ |
||||
declare function html(config?: { |
||||
/** |
||||
By default, the syntax tree will highlight mismatched closing |
||||
tags. Set this to `false` to turn that off (for example when you |
||||
expect to only be parsing a fragment of HTML text, not a full |
||||
document). |
||||
*/ |
||||
matchClosingTags?: boolean; |
||||
/** |
||||
By default, the parser does not allow arbitrary self-closing tags. |
||||
Set this to `true` to turn on support for `/>` self-closing tag |
||||
syntax. |
||||
*/ |
||||
selfClosingTags?: boolean; |
||||
/** |
||||
Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-html.autoCloseTags) |
||||
is included in the support extensions. Defaults to true. |
||||
*/ |
||||
autoCloseTags?: boolean; |
||||
/** |
||||
Add additional tags that can be completed. |
||||
*/ |
||||
extraTags?: Record<string, TagSpec>; |
||||
/** |
||||
Add additional completable attributes to all tags. |
||||
*/ |
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>; |
||||
/** |
||||
Register additional languages to parse the content of specific |
||||
tags. If given, `attrs` should be a function that, given an |
||||
object representing the tag's attributes, returns `true` if this |
||||
language applies. |
||||
*/ |
||||
nestedLanguages?: NestedLang[]; |
||||
/** |
||||
Register additional languages to parse attribute values with. |
||||
*/ |
||||
nestedAttributes?: NestedAttr[]; |
||||
}): LanguageSupport; |
||||
/** |
||||
Extension that will automatically insert close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
declare const autoCloseTags: _codemirror_state.Extension; |
||||
|
||||
export { type TagSpec, autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage }; |
||||
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { Parser } from '@lezer/common'; |
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete'; |
||||
|
||||
/** |
||||
Type used to specify tags to complete. |
||||
*/ |
||||
interface TagSpec { |
||||
/** |
||||
Define tag-specific attributes. Property names are attribute |
||||
names, and property values can be null to indicate free-form |
||||
attributes, or a list of strings for suggested attribute values. |
||||
*/ |
||||
attrs?: Record<string, null | readonly string[]>; |
||||
/** |
||||
When set to false, don't complete global attributes on this tag. |
||||
*/ |
||||
globalAttrs?: boolean; |
||||
/** |
||||
Can be used to specify a list of child tags that are valid |
||||
inside this tag. The default is to allow any tag. |
||||
*/ |
||||
children?: readonly string[]; |
||||
} |
||||
/** |
||||
HTML tag completion. Opens and closes tags and attributes in a |
||||
context-aware way. |
||||
*/ |
||||
declare function htmlCompletionSource(context: CompletionContext): CompletionResult | null; |
||||
/** |
||||
Create a completion source for HTML extended with additional tags |
||||
or attributes. |
||||
*/ |
||||
declare function htmlCompletionSourceWith(config: { |
||||
/** |
||||
Define extra tag names to complete. |
||||
*/ |
||||
extraTags?: Record<string, TagSpec>; |
||||
/** |
||||
Add global attributes that are available on all tags. |
||||
*/ |
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>; |
||||
}): (context: CompletionContext) => CompletionResult | null; |
||||
|
||||
type NestedLang = { |
||||
tag: string; |
||||
attrs?: (attrs: { |
||||
[attr: string]: string; |
||||
}) => boolean; |
||||
parser: Parser; |
||||
}; |
||||
type NestedAttr = { |
||||
name: string; |
||||
tagName?: string; |
||||
parser: Parser; |
||||
}; |
||||
/** |
||||
A language provider based on the [Lezer HTML |
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and |
||||
`<style>` tags. |
||||
*/ |
||||
declare const htmlLanguage: LRLanguage; |
||||
/** |
||||
Language support for HTML, including |
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
|
||||
CSS support extensions. |
||||
*/ |
||||
declare function html(config?: { |
||||
/** |
||||
By default, the syntax tree will highlight mismatched closing |
||||
tags. Set this to `false` to turn that off (for example when you |
||||
expect to only be parsing a fragment of HTML text, not a full |
||||
document). |
||||
*/ |
||||
matchClosingTags?: boolean; |
||||
/** |
||||
By default, the parser does not allow arbitrary self-closing tags. |
||||
Set this to `true` to turn on support for `/>` self-closing tag |
||||
syntax. |
||||
*/ |
||||
selfClosingTags?: boolean; |
||||
/** |
||||
Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-html.autoCloseTags)
|
||||
is included in the support extensions. Defaults to true. |
||||
*/ |
||||
autoCloseTags?: boolean; |
||||
/** |
||||
Add additional tags that can be completed. |
||||
*/ |
||||
extraTags?: Record<string, TagSpec>; |
||||
/** |
||||
Add additional completable attributes to all tags. |
||||
*/ |
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>; |
||||
/** |
||||
Register additional languages to parse the content of specific |
||||
tags. If given, `attrs` should be a function that, given an |
||||
object representing the tag's attributes, returns `true` if this |
||||
language applies. |
||||
*/ |
||||
nestedLanguages?: NestedLang[]; |
||||
/** |
||||
Register additional languages to parse attribute values with. |
||||
*/ |
||||
nestedAttributes?: NestedAttr[]; |
||||
}): LanguageSupport; |
||||
/** |
||||
Extension that will automatically insert close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
declare const autoCloseTags: _codemirror_state.Extension; |
||||
|
||||
export { type TagSpec, autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage }; |
||||
@ -0,0 +1,661 @@
@@ -0,0 +1,661 @@
|
||||
import { parser, configureNesting } from '@lezer/html'; |
||||
import { cssLanguage, css } from '@codemirror/lang-css'; |
||||
import { javascriptLanguage, typescriptLanguage, jsxLanguage, tsxLanguage, javascript } from '@codemirror/lang-javascript'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
import { EditorSelection } from '@codemirror/state'; |
||||
import { syntaxTree, LRLanguage, indentNodeProp, foldNodeProp, bracketMatchingHandle, LanguageSupport } from '@codemirror/language'; |
||||
|
||||
const Targets = ["_blank", "_self", "_top", "_parent"]; |
||||
const Charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"]; |
||||
const Methods = ["get", "post", "put", "delete"]; |
||||
const Encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]; |
||||
const Bool = ["true", "false"]; |
||||
const S = {}; // Empty tag spec
|
||||
const Tags = { |
||||
a: { |
||||
attrs: { |
||||
href: null, ping: null, type: null, |
||||
media: null, |
||||
target: Targets, |
||||
hreflang: null |
||||
} |
||||
}, |
||||
abbr: S, |
||||
address: S, |
||||
area: { |
||||
attrs: { |
||||
alt: null, coords: null, href: null, target: null, ping: null, |
||||
media: null, hreflang: null, type: null, |
||||
shape: ["default", "rect", "circle", "poly"] |
||||
} |
||||
}, |
||||
article: S, |
||||
aside: S, |
||||
audio: { |
||||
attrs: { |
||||
src: null, mediagroup: null, |
||||
crossorigin: ["anonymous", "use-credentials"], |
||||
preload: ["none", "metadata", "auto"], |
||||
autoplay: ["autoplay"], |
||||
loop: ["loop"], |
||||
controls: ["controls"] |
||||
} |
||||
}, |
||||
b: S, |
||||
base: { attrs: { href: null, target: Targets } }, |
||||
bdi: S, |
||||
bdo: S, |
||||
blockquote: { attrs: { cite: null } }, |
||||
body: S, |
||||
br: S, |
||||
button: { |
||||
attrs: { |
||||
form: null, formaction: null, name: null, value: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["autofocus"], |
||||
formenctype: Encs, |
||||
formmethod: Methods, |
||||
formnovalidate: ["novalidate"], |
||||
formtarget: Targets, |
||||
type: ["submit", "reset", "button"] |
||||
} |
||||
}, |
||||
canvas: { attrs: { width: null, height: null } }, |
||||
caption: S, |
||||
center: S, |
||||
cite: S, |
||||
code: S, |
||||
col: { attrs: { span: null } }, |
||||
colgroup: { attrs: { span: null } }, |
||||
command: { |
||||
attrs: { |
||||
type: ["command", "checkbox", "radio"], |
||||
label: null, icon: null, radiogroup: null, command: null, title: null, |
||||
disabled: ["disabled"], |
||||
checked: ["checked"] |
||||
} |
||||
}, |
||||
data: { attrs: { value: null } }, |
||||
datagrid: { attrs: { disabled: ["disabled"], multiple: ["multiple"] } }, |
||||
datalist: { attrs: { data: null } }, |
||||
dd: S, |
||||
del: { attrs: { cite: null, datetime: null } }, |
||||
details: { attrs: { open: ["open"] } }, |
||||
dfn: S, |
||||
div: S, |
||||
dl: S, |
||||
dt: S, |
||||
em: S, |
||||
embed: { attrs: { src: null, type: null, width: null, height: null } }, |
||||
eventsource: { attrs: { src: null } }, |
||||
fieldset: { attrs: { disabled: ["disabled"], form: null, name: null } }, |
||||
figcaption: S, |
||||
figure: S, |
||||
footer: S, |
||||
form: { |
||||
attrs: { |
||||
action: null, name: null, |
||||
"accept-charset": Charsets, |
||||
autocomplete: ["on", "off"], |
||||
enctype: Encs, |
||||
method: Methods, |
||||
novalidate: ["novalidate"], |
||||
target: Targets |
||||
} |
||||
}, |
||||
h1: S, h2: S, h3: S, h4: S, h5: S, h6: S, |
||||
head: { |
||||
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"] |
||||
}, |
||||
header: S, |
||||
hgroup: S, |
||||
hr: S, |
||||
html: { |
||||
attrs: { manifest: null } |
||||
}, |
||||
i: S, |
||||
iframe: { |
||||
attrs: { |
||||
src: null, srcdoc: null, name: null, width: null, height: null, |
||||
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"], |
||||
seamless: ["seamless"] |
||||
} |
||||
}, |
||||
img: { |
||||
attrs: { |
||||
alt: null, src: null, ismap: null, usemap: null, width: null, height: null, |
||||
crossorigin: ["anonymous", "use-credentials"] |
||||
} |
||||
}, |
||||
input: { |
||||
attrs: { |
||||
alt: null, dirname: null, form: null, formaction: null, |
||||
height: null, list: null, max: null, maxlength: null, min: null, |
||||
name: null, pattern: null, placeholder: null, size: null, src: null, |
||||
step: null, value: null, width: null, |
||||
accept: ["audio/*", "video/*", "image/*"], |
||||
autocomplete: ["on", "off"], |
||||
autofocus: ["autofocus"], |
||||
checked: ["checked"], |
||||
disabled: ["disabled"], |
||||
formenctype: Encs, |
||||
formmethod: Methods, |
||||
formnovalidate: ["novalidate"], |
||||
formtarget: Targets, |
||||
multiple: ["multiple"], |
||||
readonly: ["readonly"], |
||||
required: ["required"], |
||||
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month", |
||||
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", |
||||
"file", "submit", "image", "reset", "button"] |
||||
} |
||||
}, |
||||
ins: { attrs: { cite: null, datetime: null } }, |
||||
kbd: S, |
||||
keygen: { |
||||
attrs: { |
||||
challenge: null, form: null, name: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["disabled"], |
||||
keytype: ["RSA"] |
||||
} |
||||
}, |
||||
label: { attrs: { for: null, form: null } }, |
||||
legend: S, |
||||
li: { attrs: { value: null } }, |
||||
link: { |
||||
attrs: { |
||||
href: null, type: null, |
||||
hreflang: null, |
||||
media: null, |
||||
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"] |
||||
} |
||||
}, |
||||
map: { attrs: { name: null } }, |
||||
mark: S, |
||||
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } }, |
||||
meta: { |
||||
attrs: { |
||||
content: null, |
||||
charset: Charsets, |
||||
name: ["viewport", "application-name", "author", "description", "generator", "keywords"], |
||||
"http-equiv": ["content-language", "content-type", "default-style", "refresh"] |
||||
} |
||||
}, |
||||
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } }, |
||||
nav: S, |
||||
noscript: S, |
||||
object: { |
||||
attrs: { |
||||
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null, |
||||
typemustmatch: ["typemustmatch"] |
||||
} |
||||
}, |
||||
ol: { attrs: { reversed: ["reversed"], start: null, type: ["1", "a", "A", "i", "I"] }, |
||||
children: ["li", "script", "template", "ul", "ol"] }, |
||||
optgroup: { attrs: { disabled: ["disabled"], label: null } }, |
||||
option: { attrs: { disabled: ["disabled"], label: null, selected: ["selected"], value: null } }, |
||||
output: { attrs: { for: null, form: null, name: null } }, |
||||
p: S, |
||||
param: { attrs: { name: null, value: null } }, |
||||
pre: S, |
||||
progress: { attrs: { value: null, max: null } }, |
||||
q: { attrs: { cite: null } }, |
||||
rp: S, |
||||
rt: S, |
||||
ruby: S, |
||||
samp: S, |
||||
script: { |
||||
attrs: { |
||||
type: ["text/javascript"], |
||||
src: null, |
||||
async: ["async"], |
||||
defer: ["defer"], |
||||
charset: Charsets |
||||
} |
||||
}, |
||||
section: S, |
||||
select: { |
||||
attrs: { |
||||
form: null, name: null, size: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["disabled"], |
||||
multiple: ["multiple"] |
||||
} |
||||
}, |
||||
slot: { attrs: { name: null } }, |
||||
small: S, |
||||
source: { attrs: { src: null, type: null, media: null } }, |
||||
span: S, |
||||
strong: S, |
||||
style: { |
||||
attrs: { |
||||
type: ["text/css"], |
||||
media: null, |
||||
scoped: null |
||||
} |
||||
}, |
||||
sub: S, |
||||
summary: S, |
||||
sup: S, |
||||
table: S, |
||||
tbody: S, |
||||
td: { attrs: { colspan: null, rowspan: null, headers: null } }, |
||||
template: S, |
||||
textarea: { |
||||
attrs: { |
||||
dirname: null, form: null, maxlength: null, name: null, placeholder: null, |
||||
rows: null, cols: null, |
||||
autofocus: ["autofocus"], |
||||
disabled: ["disabled"], |
||||
readonly: ["readonly"], |
||||
required: ["required"], |
||||
wrap: ["soft", "hard"] |
||||
} |
||||
}, |
||||
tfoot: S, |
||||
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } }, |
||||
thead: S, |
||||
time: { attrs: { datetime: null } }, |
||||
title: S, |
||||
tr: S, |
||||
track: { |
||||
attrs: { |
||||
src: null, label: null, default: null, |
||||
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"], |
||||
srclang: null |
||||
} |
||||
}, |
||||
ul: { children: ["li", "script", "template", "ul", "ol"] }, |
||||
var: S, |
||||
video: { |
||||
attrs: { |
||||
src: null, poster: null, width: null, height: null, |
||||
crossorigin: ["anonymous", "use-credentials"], |
||||
preload: ["auto", "metadata", "none"], |
||||
autoplay: ["autoplay"], |
||||
mediagroup: ["movie"], |
||||
muted: ["muted"], |
||||
controls: ["controls"] |
||||
} |
||||
}, |
||||
wbr: S |
||||
}; |
||||
const GlobalAttrs = { |
||||
accesskey: null, |
||||
class: null, |
||||
contenteditable: Bool, |
||||
contextmenu: null, |
||||
dir: ["ltr", "rtl", "auto"], |
||||
draggable: ["true", "false", "auto"], |
||||
dropzone: ["copy", "move", "link", "string:", "file:"], |
||||
hidden: ["hidden"], |
||||
id: null, |
||||
inert: ["inert"], |
||||
itemid: null, |
||||
itemprop: null, |
||||
itemref: null, |
||||
itemscope: ["itemscope"], |
||||
itemtype: null, |
||||
lang: ["ar", "bn", "de", "en-GB", "en-US", "es", "fr", "hi", "id", "ja", "pa", "pt", "ru", "tr", "zh"], |
||||
spellcheck: Bool, |
||||
autocorrect: Bool, |
||||
autocapitalize: Bool, |
||||
style: null, |
||||
tabindex: null, |
||||
title: null, |
||||
translate: ["yes", "no"], |
||||
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"], |
||||
role: /*@__PURE__*/"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "), |
||||
"aria-activedescendant": null, |
||||
"aria-atomic": Bool, |
||||
"aria-autocomplete": ["inline", "list", "both", "none"], |
||||
"aria-busy": Bool, |
||||
"aria-checked": ["true", "false", "mixed", "undefined"], |
||||
"aria-controls": null, |
||||
"aria-describedby": null, |
||||
"aria-disabled": Bool, |
||||
"aria-dropeffect": null, |
||||
"aria-expanded": ["true", "false", "undefined"], |
||||
"aria-flowto": null, |
||||
"aria-grabbed": ["true", "false", "undefined"], |
||||
"aria-haspopup": Bool, |
||||
"aria-hidden": Bool, |
||||
"aria-invalid": ["true", "false", "grammar", "spelling"], |
||||
"aria-label": null, |
||||
"aria-labelledby": null, |
||||
"aria-level": null, |
||||
"aria-live": ["off", "polite", "assertive"], |
||||
"aria-multiline": Bool, |
||||
"aria-multiselectable": Bool, |
||||
"aria-owns": null, |
||||
"aria-posinset": null, |
||||
"aria-pressed": ["true", "false", "mixed", "undefined"], |
||||
"aria-readonly": Bool, |
||||
"aria-relevant": null, |
||||
"aria-required": Bool, |
||||
"aria-selected": ["true", "false", "undefined"], |
||||
"aria-setsize": null, |
||||
"aria-sort": ["ascending", "descending", "none", "other"], |
||||
"aria-valuemax": null, |
||||
"aria-valuemin": null, |
||||
"aria-valuenow": null, |
||||
"aria-valuetext": null |
||||
}; |
||||
const eventAttributes = /*@__PURE__*/("beforeunload copy cut dragstart dragover dragleave dragenter dragend " + |
||||
"drag paste focus blur change click load mousedown mouseenter mouseleave " + |
||||
"mouseup keydown keyup resize scroll unload").split(" ").map(n => "on" + n); |
||||
for (let a of eventAttributes) |
||||
GlobalAttrs[a] = null; |
||||
class Schema { |
||||
constructor(extraTags, extraAttrs) { |
||||
this.tags = { ...Tags, ...extraTags }; |
||||
this.globalAttrs = { ...GlobalAttrs, ...extraAttrs }; |
||||
this.allTags = Object.keys(this.tags); |
||||
this.globalAttrNames = Object.keys(this.globalAttrs); |
||||
} |
||||
} |
||||
Schema.default = /*@__PURE__*/new Schema; |
||||
function elementName(doc, tree, max = doc.length) { |
||||
if (!tree) |
||||
return ""; |
||||
let tag = tree.firstChild; |
||||
let name = tag && tag.getChild("TagName"); |
||||
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : ""; |
||||
} |
||||
function findParentElement(tree, skip = false) { |
||||
for (; tree; tree = tree.parent) |
||||
if (tree.name == "Element") { |
||||
if (skip) |
||||
skip = false; |
||||
else |
||||
return tree; |
||||
} |
||||
return null; |
||||
} |
||||
function allowedChildren(doc, tree, schema) { |
||||
let parentInfo = schema.tags[elementName(doc, findParentElement(tree))]; |
||||
return (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.children) || schema.allTags; |
||||
} |
||||
function openTags(doc, tree) { |
||||
let open = []; |
||||
for (let parent = findParentElement(tree); parent && !parent.type.isTop; parent = findParentElement(parent.parent)) { |
||||
let tagName = elementName(doc, parent); |
||||
if (tagName && parent.lastChild.name == "CloseTag") |
||||
break; |
||||
if (tagName && open.indexOf(tagName) < 0 && (tree.name == "EndTag" || tree.from >= parent.firstChild.to)) |
||||
open.push(tagName); |
||||
} |
||||
return open; |
||||
} |
||||
const identifier = /^[:\-\.\w\u00b7-\uffff]*$/; |
||||
function completeTag(state, schema, tree, from, to) { |
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">"; |
||||
let parent = findParentElement(tree, tree.name == "StartTag" || tree.name == "TagName"); |
||||
return { from, to, |
||||
options: allowedChildren(state.doc, parent, schema).map(tagName => ({ label: tagName, type: "type" })).concat(openTags(state.doc, tree).map((tag, i) => ({ label: "/" + tag, apply: "/" + tag + end, |
||||
type: "type", boost: 99 - i }))), |
||||
validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/ }; |
||||
} |
||||
function completeCloseTag(state, tree, from, to) { |
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">"; |
||||
return { from, to, |
||||
options: openTags(state.doc, tree).map((tag, i) => ({ label: tag, apply: tag + end, type: "type", boost: 99 - i })), |
||||
validFor: identifier }; |
||||
} |
||||
function completeStartTag(state, schema, tree, pos) { |
||||
let options = [], level = 0; |
||||
for (let tagName of allowedChildren(state.doc, tree, schema)) |
||||
options.push({ label: "<" + tagName, type: "type" }); |
||||
for (let open of openTags(state.doc, tree)) |
||||
options.push({ label: "</" + open + ">", type: "type", boost: 99 - level++ }); |
||||
return { from: pos, to: pos, options, validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/ }; |
||||
} |
||||
function completeAttrName(state, schema, tree, from, to) { |
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null; |
||||
let localAttrs = info && info.attrs ? Object.keys(info.attrs) : []; |
||||
let names = info && info.globalAttrs === false ? localAttrs |
||||
: localAttrs.length ? localAttrs.concat(schema.globalAttrNames) : schema.globalAttrNames; |
||||
return { from, to, |
||||
options: names.map(attrName => ({ label: attrName, type: "property" })), |
||||
validFor: identifier }; |
||||
} |
||||
function completeAttrValue(state, schema, tree, from, to) { |
||||
var _a; |
||||
let nameNode = (_a = tree.parent) === null || _a === void 0 ? void 0 : _a.getChild("AttributeName"); |
||||
let options = [], token = undefined; |
||||
if (nameNode) { |
||||
let attrName = state.sliceDoc(nameNode.from, nameNode.to); |
||||
let attrs = schema.globalAttrs[attrName]; |
||||
if (!attrs) { |
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null; |
||||
attrs = (info === null || info === void 0 ? void 0 : info.attrs) && info.attrs[attrName]; |
||||
} |
||||
if (attrs) { |
||||
let base = state.sliceDoc(from, to).toLowerCase(), quoteStart = '"', quoteEnd = '"'; |
||||
if (/^['"]/.test(base)) { |
||||
token = base[0] == '"' ? /^[^"]*$/ : /^[^']*$/; |
||||
quoteStart = ""; |
||||
quoteEnd = state.sliceDoc(to, to + 1) == base[0] ? "" : base[0]; |
||||
base = base.slice(1); |
||||
from++; |
||||
} |
||||
else { |
||||
token = /^[^\s<>='"]*$/; |
||||
} |
||||
for (let value of attrs) |
||||
options.push({ label: value, apply: quoteStart + value + quoteEnd, type: "constant" }); |
||||
} |
||||
} |
||||
return { from, to, options, validFor: token }; |
||||
} |
||||
function htmlCompletionFor(schema, context) { |
||||
let { state, pos } = context, tree = syntaxTree(state).resolveInner(pos, -1), around = tree.resolve(pos); |
||||
for (let scan = pos, before; around == tree && (before = tree.childBefore(scan));) { |
||||
let last = before.lastChild; |
||||
if (!last || !last.type.isError || last.from < last.to) |
||||
break; |
||||
around = tree = before; |
||||
scan = last.from; |
||||
} |
||||
if (tree.name == "TagName") { |
||||
return tree.parent && /CloseTag$/.test(tree.parent.name) ? completeCloseTag(state, tree, tree.from, pos) |
||||
: completeTag(state, schema, tree, tree.from, pos); |
||||
} |
||||
else if (tree.name == "StartTag" || tree.name == "IncompleteTag") { |
||||
return completeTag(state, schema, tree, pos, pos); |
||||
} |
||||
else if (tree.name == "StartCloseTag" || tree.name == "IncompleteCloseTag") { |
||||
return completeCloseTag(state, tree, pos, pos); |
||||
} |
||||
else if (tree.name == "OpenTag" || tree.name == "SelfClosingTag" || tree.name == "AttributeName") { |
||||
return completeAttrName(state, schema, tree, tree.name == "AttributeName" ? tree.from : pos, pos); |
||||
} |
||||
else if (tree.name == "Is" || tree.name == "AttributeValue" || tree.name == "UnquotedAttributeValue") { |
||||
return completeAttrValue(state, schema, tree, tree.name == "Is" ? pos : tree.from, pos); |
||||
} |
||||
else if (context.explicit && (around.name == "Element" || around.name == "Text" || around.name == "Document")) { |
||||
return completeStartTag(state, schema, tree, pos); |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
/** |
||||
HTML tag completion. Opens and closes tags and attributes in a |
||||
context-aware way. |
||||
*/ |
||||
function htmlCompletionSource(context) { |
||||
return htmlCompletionFor(Schema.default, context); |
||||
} |
||||
/** |
||||
Create a completion source for HTML extended with additional tags |
||||
or attributes. |
||||
*/ |
||||
function htmlCompletionSourceWith(config) { |
||||
let { extraTags, extraGlobalAttributes: extraAttrs } = config; |
||||
let schema = extraAttrs || extraTags ? new Schema(extraTags, extraAttrs) : Schema.default; |
||||
return (context) => htmlCompletionFor(schema, context); |
||||
} |
||||
|
||||
const jsonParser = /*@__PURE__*/javascriptLanguage.parser.configure({ top: "SingleExpression" }); |
||||
const defaultNesting = [ |
||||
{ tag: "script", |
||||
attrs: attrs => attrs.type == "text/typescript" || attrs.lang == "ts", |
||||
parser: typescriptLanguage.parser }, |
||||
{ tag: "script", |
||||
attrs: attrs => attrs.type == "text/babel" || attrs.type == "text/jsx", |
||||
parser: jsxLanguage.parser }, |
||||
{ tag: "script", |
||||
attrs: attrs => attrs.type == "text/typescript-jsx", |
||||
parser: tsxLanguage.parser }, |
||||
{ tag: "script", |
||||
attrs(attrs) { |
||||
return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(attrs.type); |
||||
}, |
||||
parser: jsonParser }, |
||||
{ tag: "script", |
||||
attrs(attrs) { |
||||
return !attrs.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs.type); |
||||
}, |
||||
parser: javascriptLanguage.parser }, |
||||
{ tag: "style", |
||||
attrs(attrs) { |
||||
return (!attrs.lang || attrs.lang == "css") && (!attrs.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(attrs.type)); |
||||
}, |
||||
parser: cssLanguage.parser } |
||||
]; |
||||
const defaultAttrs = /*@__PURE__*/[ |
||||
{ name: "style", |
||||
parser: /*@__PURE__*/cssLanguage.parser.configure({ top: "Styles" }) } |
||||
].concat(/*@__PURE__*/eventAttributes.map(name => ({ name, parser: javascriptLanguage.parser }))); |
||||
const htmlPlain = /*@__PURE__*/LRLanguage.define({ |
||||
name: "html", |
||||
parser: /*@__PURE__*/parser.configure({ |
||||
props: [ |
||||
/*@__PURE__*/indentNodeProp.add({ |
||||
Element(context) { |
||||
let after = /^(\s*)(<\/)?/.exec(context.textAfter); |
||||
if (context.node.to <= context.pos + after[0].length) |
||||
return context.continue(); |
||||
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit); |
||||
}, |
||||
"OpenTag CloseTag SelfClosingTag"(context) { |
||||
return context.column(context.node.from) + context.unit; |
||||
}, |
||||
Document(context) { |
||||
if (context.pos + /\s*/.exec(context.textAfter)[0].length < context.node.to) |
||||
return context.continue(); |
||||
let endElt = null, close; |
||||
for (let cur = context.node;;) { |
||||
let last = cur.lastChild; |
||||
if (!last || last.name != "Element" || last.to != cur.to) |
||||
break; |
||||
endElt = cur = last; |
||||
} |
||||
if (endElt && !((close = endElt.lastChild) && (close.name == "CloseTag" || close.name == "SelfClosingTag"))) |
||||
return context.lineIndent(endElt.from) + context.unit; |
||||
return null; |
||||
} |
||||
}), |
||||
/*@__PURE__*/foldNodeProp.add({ |
||||
Element(node) { |
||||
let first = node.firstChild, last = node.lastChild; |
||||
if (!first || first.name != "OpenTag") |
||||
return null; |
||||
return { from: first.to, to: last.name == "CloseTag" ? last.from : node.to }; |
||||
} |
||||
}), |
||||
/*@__PURE__*/bracketMatchingHandle.add({ |
||||
"OpenTag CloseTag": node => node.getChild("TagName") |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
commentTokens: { block: { open: "<!--", close: "-->" } }, |
||||
indentOnInput: /^\s*<\/\w+\W$/, |
||||
wordChars: "-_" |
||||
} |
||||
}); |
||||
/** |
||||
A language provider based on the [Lezer HTML |
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and |
||||
`<style>` tags. |
||||
*/ |
||||
const htmlLanguage = /*@__PURE__*/htmlPlain.configure({ |
||||
wrap: /*@__PURE__*/configureNesting(defaultNesting, defaultAttrs) |
||||
}); |
||||
/** |
||||
Language support for HTML, including |
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
|
||||
CSS support extensions. |
||||
*/ |
||||
function html(config = {}) { |
||||
let dialect = "", wrap; |
||||
if (config.matchClosingTags === false) |
||||
dialect = "noMatch"; |
||||
if (config.selfClosingTags === true) |
||||
dialect = (dialect ? dialect + " " : "") + "selfClosing"; |
||||
if (config.nestedLanguages && config.nestedLanguages.length || |
||||
config.nestedAttributes && config.nestedAttributes.length) |
||||
wrap = configureNesting((config.nestedLanguages || []).concat(defaultNesting), (config.nestedAttributes || []).concat(defaultAttrs)); |
||||
let lang = wrap ? htmlPlain.configure({ wrap, dialect }) : dialect ? htmlLanguage.configure({ dialect }) : htmlLanguage; |
||||
return new LanguageSupport(lang, [ |
||||
htmlLanguage.data.of({ autocomplete: htmlCompletionSourceWith(config) }), |
||||
config.autoCloseTags !== false ? autoCloseTags : [], |
||||
javascript().support, |
||||
css().support |
||||
]); |
||||
} |
||||
const selfClosers = /*@__PURE__*/new Set(/*@__PURE__*/"area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")); |
||||
/** |
||||
Extension that will automatically insert close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, insertTransaction) => { |
||||
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") || |
||||
!htmlLanguage.isActiveAt(view.state, from, -1)) |
||||
return false; |
||||
let base = insertTransaction(), { state } = base; |
||||
let closeTags = state.changeByRange(range => { |
||||
var _a, _b, _c; |
||||
let didType = state.doc.sliceString(range.from - 1, range.to) == text; |
||||
let { head } = range, after = syntaxTree(state).resolveInner(head, -1), name; |
||||
if (didType && text == ">" && after.name == "EndTag") { |
||||
let tag = after.parent; |
||||
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" && |
||||
(name = elementName(state.doc, tag.parent, head)) && |
||||
!selfClosers.has(name)) { |
||||
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0); |
||||
let insert = `</${name}>`; |
||||
return { range, changes: { from: head, to, insert } }; |
||||
} |
||||
} |
||||
else if (didType && text == "/" && after.name == "IncompleteCloseTag") { |
||||
let tag = after.parent; |
||||
if (after.from == head - 2 && ((_c = tag.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" && |
||||
(name = elementName(state.doc, tag, head)) && !selfClosers.has(name)) { |
||||
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0); |
||||
let insert = `${name}>`; |
||||
return { |
||||
range: EditorSelection.cursor(head + insert.length, -1), |
||||
changes: { from: head, to, insert } |
||||
}; |
||||
} |
||||
} |
||||
return { range }; |
||||
}); |
||||
if (closeTags.changes.empty) |
||||
return false; |
||||
view.dispatch([ |
||||
base, |
||||
state.update(closeTags, { |
||||
userEvent: "input.complete", |
||||
scrollIntoView: true |
||||
}) |
||||
]); |
||||
return true; |
||||
}); |
||||
|
||||
export { autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage }; |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
{ |
||||
"name": "@codemirror/lang-html", |
||||
"version": "6.4.11", |
||||
"description": "HTML language support for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/html.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/lang-css": "^6.0.0", |
||||
"@codemirror/lang-javascript": "^6.0.0", |
||||
"@codemirror/language": "^6.4.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.17.0", |
||||
"@lezer/html": "^1.3.12", |
||||
"@lezer/common": "^1.0.0", |
||||
"@lezer/css": "^1.1.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/lang-html.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,198 @@
@@ -0,0 +1,198 @@
|
||||
## 6.2.4 (2025-05-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a crash in the `esLint` helper when a rule's `meta.docs` isn't defined. |
||||
|
||||
Properly dedent lines starting with an opening curly brace below composite statements like `for`/`while`. |
||||
|
||||
## 6.2.3 (2025-02-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Disable JavaScript completions in JSX context. |
||||
|
||||
## 6.2.2 (2024-02-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that would cause self-closing JSX tags to have another closing tag inserted when typing the final '>'. |
||||
|
||||
## 6.2.1 (2023-08-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
`autoCloseTags` now generates two separate transactions, so that the completion can be undone separately. |
||||
|
||||
## 6.2.0 (2023-08-26) |
||||
|
||||
### New features |
||||
|
||||
Export a `typescriptSnippets` array and include TypeScript keyword completions in the default support extension when in TypeScript mode. |
||||
|
||||
## 6.1.9 (2023-06-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure `scopeCompletionSource` doesn't try to complete property names that aren't simple identifier (such as numeric indices). |
||||
|
||||
## 6.1.8 (2023-05-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Stop completing keywords after `.` tokens. |
||||
|
||||
## 6.1.7 (2023-04-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix overeager JSX tag closing inside attribute values and in self-closing tags. |
||||
|
||||
## 6.1.6 (2023-04-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that allowed `autoCloseTags` to close JSX tags in JavaScript context. |
||||
|
||||
## 6.1.5 (2023-04-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make TypeScript object type syntax foldable. |
||||
|
||||
## 6.1.4 (2023-02-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure code in JSX context can be commented correctly. |
||||
|
||||
## 6.1.3 (2023-02-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix auto-closing of JSX fragments. |
||||
|
||||
## 6.1.2 (2022-12-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Automatic tag closing in JSX now works for namespaced and member-expression tag names. |
||||
|
||||
## 6.1.1 (2022-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `completionPath` handle `?.` syntax. |
||||
|
||||
## 6.1.0 (2022-09-20) |
||||
|
||||
### New features |
||||
|
||||
The `completionPath` helper can now be used to find the object path to complete at a given position. |
||||
|
||||
`scopeCompletionSource` provides a completion source based on a scope object. |
||||
|
||||
## 6.0.2 (2022-07-21) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix the `source` field in ESLint diagnostics to properly hold `"eslint"`. |
||||
|
||||
Fix (non-)auto indentation in template strings and comments. |
||||
|
||||
## 6.0.1 (2022-06-29) |
||||
|
||||
### Bug fixes |
||||
|
||||
Avoid completing variables/keywords in property or definition positions. |
||||
|
||||
Fix a bug that broke local variable completion if JavaScript was parsed an overlay in an outer language. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 6.0.0 |
||||
|
||||
## 0.20.1 (2022-06-01) |
||||
|
||||
### New features |
||||
|
||||
`localCompletionSource` (included in the support extensions returned from `javascript`) now provides a way to complete locally-defined names. |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### New features |
||||
|
||||
The new `autoCloseTags` extension (included by default in the `javascript` language extension when `jsx` is configured) finishes JSX closing tags when you type a `>` or `/` character. |
||||
|
||||
## 0.19.7 (2022-01-28) |
||||
|
||||
## 0.19.6 (2022-01-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Remove accidentally released unfinished changes. |
||||
|
||||
## 0.19.5 (2022-01-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add the `function` highlight modifier to variables used in tagged template expressions. |
||||
|
||||
## 0.19.4 (2022-01-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix highlighting of TypeScript private/public/protected keywords. |
||||
|
||||
## 0.19.3 (2021-11-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add styling for private properties. |
||||
|
||||
## 0.19.2 (2021-09-23) |
||||
|
||||
### New features |
||||
|
||||
Use more specific highlighting tags for JSX attribute names and values. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.19.0 |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Extend `indentOnInput` expression to cover closing JSX tags. |
||||
|
||||
## 0.17.2 (2021-02-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Improve highlighting tag specificity of defined function and class names. Add indentation information for JSX constructs |
||||
|
||||
Support smart indent for JSX syntax. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,511 @@
@@ -0,0 +1,511 @@
|
||||
'use strict'; |
||||
|
||||
var javascript$1 = require('@lezer/javascript'); |
||||
var language = require('@codemirror/language'); |
||||
var state = require('@codemirror/state'); |
||||
var view = require('@codemirror/view'); |
||||
var autocomplete = require('@codemirror/autocomplete'); |
||||
var common = require('@lezer/common'); |
||||
|
||||
/** |
||||
A collection of JavaScript-related |
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet). |
||||
*/ |
||||
const snippets = [ |
||||
autocomplete.snippetCompletion("function ${name}(${params}) {\n\t${}\n}", { |
||||
label: "function", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", { |
||||
label: "for", |
||||
detail: "loop", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", { |
||||
label: "for", |
||||
detail: "of loop", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("do {\n\t${}\n} while (${})", { |
||||
label: "do", |
||||
detail: "loop", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("while (${}) {\n\t${}\n}", { |
||||
label: "while", |
||||
detail: "loop", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", { |
||||
label: "try", |
||||
detail: "/ catch block", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("if (${}) {\n\t${}\n}", { |
||||
label: "if", |
||||
detail: "block", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", { |
||||
label: "if", |
||||
detail: "/ else block", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", { |
||||
label: "class", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("import {${names}} from \"${module}\"\n${}", { |
||||
label: "import", |
||||
detail: "named", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("import ${name} from \"${module}\"\n${}", { |
||||
label: "import", |
||||
detail: "default", |
||||
type: "keyword" |
||||
}) |
||||
]; |
||||
/** |
||||
A collection of snippet completions for TypeScript. Includes the |
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets). |
||||
*/ |
||||
const typescriptSnippets = snippets.concat([ |
||||
autocomplete.snippetCompletion("interface ${name} {\n\t${}\n}", { |
||||
label: "interface", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("type ${name} = ${type}", { |
||||
label: "type", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
autocomplete.snippetCompletion("enum ${name} {\n\t${}\n}", { |
||||
label: "enum", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}) |
||||
]); |
||||
|
||||
const cache = new common.NodeWeakMap(); |
||||
const ScopeNodes = new Set([ |
||||
"Script", "Block", |
||||
"FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration", |
||||
"ForStatement" |
||||
]); |
||||
function defID(type) { |
||||
return (node, def) => { |
||||
let id = node.node.getChild("VariableDefinition"); |
||||
if (id) |
||||
def(id, type); |
||||
return true; |
||||
}; |
||||
} |
||||
const functionContext = ["FunctionDeclaration"]; |
||||
const gatherCompletions = { |
||||
FunctionDeclaration: defID("function"), |
||||
ClassDeclaration: defID("class"), |
||||
ClassExpression: () => true, |
||||
EnumDeclaration: defID("constant"), |
||||
TypeAliasDeclaration: defID("type"), |
||||
NamespaceDeclaration: defID("namespace"), |
||||
VariableDefinition(node, def) { if (!node.matchContext(functionContext)) |
||||
def(node, "variable"); }, |
||||
TypeDefinition(node, def) { def(node, "type"); }, |
||||
__proto__: null |
||||
}; |
||||
function getScope(doc, node) { |
||||
let cached = cache.get(node); |
||||
if (cached) |
||||
return cached; |
||||
let completions = [], top = true; |
||||
function def(node, type) { |
||||
let name = doc.sliceString(node.from, node.to); |
||||
completions.push({ label: name, type }); |
||||
} |
||||
node.cursor(common.IterMode.IncludeAnonymous).iterate(node => { |
||||
if (top) { |
||||
top = false; |
||||
} |
||||
else if (node.name) { |
||||
let gather = gatherCompletions[node.name]; |
||||
if (gather && gather(node, def) || ScopeNodes.has(node.name)) |
||||
return false; |
||||
} |
||||
else if (node.to - node.from > 8192) { |
||||
// Allow caching for bigger internal nodes |
||||
for (let c of getScope(doc, node.node)) |
||||
completions.push(c); |
||||
return false; |
||||
} |
||||
}); |
||||
cache.set(node, completions); |
||||
return completions; |
||||
} |
||||
const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/; |
||||
const dontComplete = [ |
||||
"TemplateString", "String", "RegExp", |
||||
"LineComment", "BlockComment", |
||||
"VariableDefinition", "TypeDefinition", "Label", |
||||
"PropertyDefinition", "PropertyName", |
||||
"PrivatePropertyDefinition", "PrivatePropertyName", |
||||
"JSXText", "JSXAttributeValue", "JSXOpenTag", "JSXCloseTag", "JSXSelfClosingTag", |
||||
".", "?." |
||||
]; |
||||
/** |
||||
Completion source that looks up locally defined names in |
||||
JavaScript code. |
||||
*/ |
||||
function localCompletionSource(context) { |
||||
let inner = language.syntaxTree(context.state).resolveInner(context.pos, -1); |
||||
if (dontComplete.indexOf(inner.name) > -1) |
||||
return null; |
||||
let isWord = inner.name == "VariableName" || |
||||
inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to)); |
||||
if (!isWord && !context.explicit) |
||||
return null; |
||||
let options = []; |
||||
for (let pos = inner; pos; pos = pos.parent) { |
||||
if (ScopeNodes.has(pos.name)) |
||||
options = options.concat(getScope(context.state.doc, pos)); |
||||
} |
||||
return { |
||||
options, |
||||
from: isWord ? inner.from : context.pos, |
||||
validFor: Identifier |
||||
}; |
||||
} |
||||
function pathFor(read, member, name) { |
||||
var _a; |
||||
let path = []; |
||||
for (;;) { |
||||
let obj = member.firstChild, prop; |
||||
if ((obj === null || obj === void 0 ? void 0 : obj.name) == "VariableName") { |
||||
path.push(read(obj)); |
||||
return { path: path.reverse(), name }; |
||||
} |
||||
else if ((obj === null || obj === void 0 ? void 0 : obj.name) == "MemberExpression" && ((_a = (prop = obj.lastChild)) === null || _a === void 0 ? void 0 : _a.name) == "PropertyName") { |
||||
path.push(read(prop)); |
||||
member = obj; |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
/** |
||||
Helper function for defining JavaScript completion sources. It |
||||
returns the completable name and object path for a completion |
||||
context, or null if no name/property completion should happen at |
||||
that position. For example, when completing after `a.b.c` it will |
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x` |
||||
it will return `{path: [], name: "x"}`. When not in a property or |
||||
name, it will return null if `context.explicit` is false, and |
||||
`{path: [], name: ""}` otherwise. |
||||
*/ |
||||
function completionPath(context) { |
||||
let read = (node) => context.state.doc.sliceString(node.from, node.to); |
||||
let inner = language.syntaxTree(context.state).resolveInner(context.pos, -1); |
||||
if (inner.name == "PropertyName") { |
||||
return pathFor(read, inner.parent, read(inner)); |
||||
} |
||||
else if ((inner.name == "." || inner.name == "?.") && inner.parent.name == "MemberExpression") { |
||||
return pathFor(read, inner.parent, ""); |
||||
} |
||||
else if (dontComplete.indexOf(inner.name) > -1) { |
||||
return null; |
||||
} |
||||
else if (inner.name == "VariableName" || inner.to - inner.from < 20 && Identifier.test(read(inner))) { |
||||
return { path: [], name: read(inner) }; |
||||
} |
||||
else if (inner.name == "MemberExpression") { |
||||
return pathFor(read, inner, ""); |
||||
} |
||||
else { |
||||
return context.explicit ? { path: [], name: "" } : null; |
||||
} |
||||
} |
||||
function enumeratePropertyCompletions(obj, top) { |
||||
let options = [], seen = new Set; |
||||
for (let depth = 0;; depth++) { |
||||
for (let name of (Object.getOwnPropertyNames || Object.keys)(obj)) { |
||||
if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name) || seen.has(name)) |
||||
continue; |
||||
seen.add(name); |
||||
let value; |
||||
try { |
||||
value = obj[name]; |
||||
} |
||||
catch (_) { |
||||
continue; |
||||
} |
||||
options.push({ |
||||
label: name, |
||||
type: typeof value == "function" ? (/^[A-Z]/.test(name) ? "class" : top ? "function" : "method") |
||||
: top ? "variable" : "property", |
||||
boost: -depth |
||||
}); |
||||
} |
||||
let next = Object.getPrototypeOf(obj); |
||||
if (!next) |
||||
return options; |
||||
obj = next; |
||||
} |
||||
} |
||||
/** |
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that |
||||
completes from the given scope object (for example `globalThis`). |
||||
Will enter properties of the object when completing properties on |
||||
a directly-named path. |
||||
*/ |
||||
function scopeCompletionSource(scope) { |
||||
let cache = new Map; |
||||
return (context) => { |
||||
let path = completionPath(context); |
||||
if (!path) |
||||
return null; |
||||
let target = scope; |
||||
for (let step of path.path) { |
||||
target = target[step]; |
||||
if (!target) |
||||
return null; |
||||
} |
||||
let options = cache.get(target); |
||||
if (!options) |
||||
cache.set(target, options = enumeratePropertyCompletions(target, !path.path.length)); |
||||
return { |
||||
from: context.pos - path.name.length, |
||||
options, |
||||
validFor: Identifier |
||||
}; |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
A language provider based on the [Lezer JavaScript |
||||
parser](https://github.com/lezer-parser/javascript), extended with |
||||
highlighting and indentation information. |
||||
*/ |
||||
const javascriptLanguage = language.LRLanguage.define({ |
||||
name: "javascript", |
||||
parser: javascript$1.parser.configure({ |
||||
props: [ |
||||
language.indentNodeProp.add({ |
||||
IfStatement: language.continuedIndent({ except: /^\s*({|else\b)/ }), |
||||
TryStatement: language.continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }), |
||||
LabeledStatement: language.flatIndent, |
||||
SwitchBody: context => { |
||||
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after); |
||||
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit; |
||||
}, |
||||
Block: language.delimitedIndent({ closing: "}" }), |
||||
ArrowFunction: cx => cx.baseIndent + cx.unit, |
||||
"TemplateString BlockComment": () => null, |
||||
"Statement Property": language.continuedIndent({ except: /^\s*{/ }), |
||||
JSXElement(context) { |
||||
let closed = /^\s*<\//.test(context.textAfter); |
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit); |
||||
}, |
||||
JSXEscape(context) { |
||||
let closed = /\s*\}/.test(context.textAfter); |
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit); |
||||
}, |
||||
"JSXOpenTag JSXSelfClosingTag"(context) { |
||||
return context.column(context.node.from) + context.unit; |
||||
} |
||||
}), |
||||
language.foldNodeProp.add({ |
||||
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": language.foldInside, |
||||
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; } |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] }, |
||||
commentTokens: { line: "//", block: { open: "/*", close: "*/" } }, |
||||
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/, |
||||
wordChars: "$" |
||||
} |
||||
}); |
||||
const jsxSublanguage = { |
||||
test: node => /^JSX/.test(node.name), |
||||
facet: language.defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } }) |
||||
}; |
||||
/** |
||||
A language provider for TypeScript. |
||||
*/ |
||||
const typescriptLanguage = javascriptLanguage.configure({ dialect: "ts" }, "typescript"); |
||||
/** |
||||
Language provider for JSX. |
||||
*/ |
||||
const jsxLanguage = javascriptLanguage.configure({ |
||||
dialect: "jsx", |
||||
props: [language.sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)] |
||||
}); |
||||
/** |
||||
Language provider for JSX + TypeScript. |
||||
*/ |
||||
const tsxLanguage = javascriptLanguage.configure({ |
||||
dialect: "jsx ts", |
||||
props: [language.sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)] |
||||
}, "typescript"); |
||||
let kwCompletion = (name) => ({ label: name, type: "keyword" }); |
||||
const keywords = "break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion); |
||||
const typescriptKeywords = keywords.concat(["declare", "implements", "private", "protected", "public"].map(kwCompletion)); |
||||
/** |
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets) |
||||
and local variable completion. |
||||
*/ |
||||
function javascript(config = {}) { |
||||
let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage) |
||||
: config.typescript ? typescriptLanguage : javascriptLanguage; |
||||
let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords); |
||||
return new language.LanguageSupport(lang, [ |
||||
javascriptLanguage.data.of({ |
||||
autocomplete: autocomplete.ifNotIn(dontComplete, autocomplete.completeFromList(completions)) |
||||
}), |
||||
javascriptLanguage.data.of({ |
||||
autocomplete: localCompletionSource |
||||
}), |
||||
config.jsx ? autoCloseTags : [], |
||||
]); |
||||
} |
||||
function findOpenTag(node) { |
||||
for (;;) { |
||||
if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag") |
||||
return node; |
||||
if (node.name == "JSXEscape" || !node.parent) |
||||
return null; |
||||
node = node.parent; |
||||
} |
||||
} |
||||
function elementName(doc, tree, max = doc.length) { |
||||
for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) { |
||||
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" || |
||||
ch.name == "JSXMemberExpression") |
||||
return doc.sliceString(ch.from, Math.min(ch.to, max)); |
||||
} |
||||
return ""; |
||||
} |
||||
const android = typeof navigator == "object" && /Android\b/.test(navigator.userAgent); |
||||
/** |
||||
Extension that will automatically insert JSX close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
const autoCloseTags = view.EditorView.inputHandler.of((view, from, to, text, defaultInsert) => { |
||||
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || |
||||
from != to || (text != ">" && text != "/") || |
||||
!javascriptLanguage.isActiveAt(view.state, from, -1)) |
||||
return false; |
||||
let base = defaultInsert(), { state: state$1 } = base; |
||||
let closeTags = state$1.changeByRange(range => { |
||||
var _a; |
||||
let { head } = range, around = language.syntaxTree(state$1).resolveInner(head - 1, -1), name; |
||||
if (around.name == "JSXStartTag") |
||||
around = around.parent; |
||||
if (state$1.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ; |
||||
else if (text == ">" && around.name == "JSXFragmentTag") { |
||||
return { range, changes: { from: head, insert: `</>` } }; |
||||
} |
||||
else if (text == "/" && around.name == "JSXStartCloseTag") { |
||||
let empty = around.parent, base = empty.parent; |
||||
if (base && empty.from == head - 2 && |
||||
((name = elementName(state$1.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) { |
||||
let insert = `${name}>`; |
||||
return { range: state.EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } }; |
||||
} |
||||
} |
||||
else if (text == ">") { |
||||
let openTag = findOpenTag(around); |
||||
if (openTag && openTag.name == "JSXOpenTag" && |
||||
!/^\/?>|^<\//.test(state$1.doc.sliceString(head, head + 2)) && |
||||
(name = elementName(state$1.doc, openTag, head))) |
||||
return { range, changes: { from: head, insert: `</${name}>` } }; |
||||
} |
||||
return { range }; |
||||
}); |
||||
if (closeTags.changes.empty) |
||||
return false; |
||||
view.dispatch([ |
||||
base, |
||||
state$1.update(closeTags, { userEvent: "input.complete", scrollIntoView: true }) |
||||
]); |
||||
return true; |
||||
}); |
||||
|
||||
/** |
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's |
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the |
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter) |
||||
class, and `config` an optional ESLint configuration. The return |
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter) |
||||
to create a JavaScript linting extension. |
||||
|
||||
Note that ESLint targets node, and is tricky to run in the |
||||
browser. The |
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify) |
||||
package may help with that (see |
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)). |
||||
*/ |
||||
function esLint(eslint, config) { |
||||
if (!config) { |
||||
config = { |
||||
parserOptions: { ecmaVersion: 2019, sourceType: "module" }, |
||||
env: { browser: true, node: true, es6: true, es2015: true, es2017: true, es2020: true }, |
||||
rules: {} |
||||
}; |
||||
eslint.getRules().forEach((desc, name) => { |
||||
var _a; |
||||
if ((_a = desc.meta.docs) === null || _a === void 0 ? void 0 : _a.recommended) |
||||
config.rules[name] = 2; |
||||
}); |
||||
} |
||||
return (view) => { |
||||
let { state } = view, found = []; |
||||
for (let { from, to } of javascriptLanguage.findRegions(state)) { |
||||
let fromLine = state.doc.lineAt(from), offset = { line: fromLine.number - 1, col: from - fromLine.from, pos: from }; |
||||
for (let d of eslint.verify(state.sliceDoc(from, to), config)) |
||||
found.push(translateDiagnostic(d, state.doc, offset)); |
||||
} |
||||
return found; |
||||
}; |
||||
} |
||||
function mapPos(line, col, doc, offset) { |
||||
return doc.line(line + offset.line).from + col + (line == 1 ? offset.col - 1 : -1); |
||||
} |
||||
function translateDiagnostic(input, doc, offset) { |
||||
let start = mapPos(input.line, input.column, doc, offset); |
||||
let result = { |
||||
from: start, |
||||
to: input.endLine != null && input.endColumn != 1 ? mapPos(input.endLine, input.endColumn, doc, offset) : start, |
||||
message: input.message, |
||||
source: input.ruleId ? "eslint:" + input.ruleId : "eslint", |
||||
severity: input.severity == 1 ? "warning" : "error", |
||||
}; |
||||
if (input.fix) { |
||||
let { range, text } = input.fix, from = range[0] + offset.pos - start, to = range[1] + offset.pos - start; |
||||
result.actions = [{ |
||||
name: "fix", |
||||
apply(view, start) { |
||||
view.dispatch({ changes: { from: start + from, to: start + to, insert: text }, scrollIntoView: true }); |
||||
} |
||||
}]; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
exports.autoCloseTags = autoCloseTags; |
||||
exports.completionPath = completionPath; |
||||
exports.esLint = esLint; |
||||
exports.javascript = javascript; |
||||
exports.javascriptLanguage = javascriptLanguage; |
||||
exports.jsxLanguage = jsxLanguage; |
||||
exports.localCompletionSource = localCompletionSource; |
||||
exports.scopeCompletionSource = scopeCompletionSource; |
||||
exports.snippets = snippets; |
||||
exports.tsxLanguage = tsxLanguage; |
||||
exports.typescriptLanguage = typescriptLanguage; |
||||
exports.typescriptSnippets = typescriptSnippets; |
||||
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { Completion, CompletionContext, CompletionResult, CompletionSource } from '@codemirror/autocomplete'; |
||||
import { Diagnostic } from '@codemirror/lint'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
|
||||
/** |
||||
A language provider based on the [Lezer JavaScript |
||||
parser](https://github.com/lezer-parser/javascript), extended with |
||||
highlighting and indentation information. |
||||
*/ |
||||
declare const javascriptLanguage: LRLanguage; |
||||
/** |
||||
A language provider for TypeScript. |
||||
*/ |
||||
declare const typescriptLanguage: LRLanguage; |
||||
/** |
||||
Language provider for JSX. |
||||
*/ |
||||
declare const jsxLanguage: LRLanguage; |
||||
/** |
||||
Language provider for JSX + TypeScript. |
||||
*/ |
||||
declare const tsxLanguage: LRLanguage; |
||||
/** |
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets) |
||||
and local variable completion. |
||||
*/ |
||||
declare function javascript(config?: { |
||||
jsx?: boolean; |
||||
typescript?: boolean; |
||||
}): LanguageSupport; |
||||
/** |
||||
Extension that will automatically insert JSX close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
declare const autoCloseTags: _codemirror_state.Extension; |
||||
|
||||
/** |
||||
A collection of JavaScript-related |
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet). |
||||
*/ |
||||
declare const snippets: readonly Completion[]; |
||||
/** |
||||
A collection of snippet completions for TypeScript. Includes the |
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets). |
||||
*/ |
||||
declare const typescriptSnippets: Completion[]; |
||||
|
||||
/** |
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's |
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the |
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter) |
||||
class, and `config` an optional ESLint configuration. The return |
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter) |
||||
to create a JavaScript linting extension. |
||||
|
||||
Note that ESLint targets node, and is tricky to run in the |
||||
browser. The |
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify) |
||||
package may help with that (see |
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)). |
||||
*/ |
||||
declare function esLint(eslint: any, config?: any): (view: EditorView) => Diagnostic[]; |
||||
|
||||
/** |
||||
Completion source that looks up locally defined names in |
||||
JavaScript code. |
||||
*/ |
||||
declare function localCompletionSource(context: CompletionContext): CompletionResult | null; |
||||
/** |
||||
Helper function for defining JavaScript completion sources. It |
||||
returns the completable name and object path for a completion |
||||
context, or null if no name/property completion should happen at |
||||
that position. For example, when completing after `a.b.c` it will |
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x` |
||||
it will return `{path: [], name: "x"}`. When not in a property or |
||||
name, it will return null if `context.explicit` is false, and |
||||
`{path: [], name: ""}` otherwise. |
||||
*/ |
||||
declare function completionPath(context: CompletionContext): { |
||||
path: readonly string[]; |
||||
name: string; |
||||
} | null; |
||||
/** |
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that |
||||
completes from the given scope object (for example `globalThis`). |
||||
Will enter properties of the object when completing properties on |
||||
a directly-named path. |
||||
*/ |
||||
declare function scopeCompletionSource(scope: any): CompletionSource; |
||||
|
||||
export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets }; |
||||
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { Completion, CompletionContext, CompletionResult, CompletionSource } from '@codemirror/autocomplete'; |
||||
import { Diagnostic } from '@codemirror/lint'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
|
||||
/** |
||||
A language provider based on the [Lezer JavaScript |
||||
parser](https://github.com/lezer-parser/javascript), extended with
|
||||
highlighting and indentation information. |
||||
*/ |
||||
declare const javascriptLanguage: LRLanguage; |
||||
/** |
||||
A language provider for TypeScript. |
||||
*/ |
||||
declare const typescriptLanguage: LRLanguage; |
||||
/** |
||||
Language provider for JSX. |
||||
*/ |
||||
declare const jsxLanguage: LRLanguage; |
||||
/** |
||||
Language provider for JSX + TypeScript. |
||||
*/ |
||||
declare const tsxLanguage: LRLanguage; |
||||
/** |
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
||||
and local variable completion. |
||||
*/ |
||||
declare function javascript(config?: { |
||||
jsx?: boolean; |
||||
typescript?: boolean; |
||||
}): LanguageSupport; |
||||
/** |
||||
Extension that will automatically insert JSX close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
declare const autoCloseTags: _codemirror_state.Extension; |
||||
|
||||
/** |
||||
A collection of JavaScript-related |
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
||||
*/ |
||||
declare const snippets: readonly Completion[]; |
||||
/** |
||||
A collection of snippet completions for TypeScript. Includes the |
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
||||
*/ |
||||
declare const typescriptSnippets: Completion[]; |
||||
|
||||
/** |
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
|
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
|
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
|
||||
class, and `config` an optional ESLint configuration. The return |
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
|
||||
to create a JavaScript linting extension. |
||||
|
||||
Note that ESLint targets node, and is tricky to run in the |
||||
browser. The |
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)
|
||||
package may help with that (see |
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).
|
||||
*/ |
||||
declare function esLint(eslint: any, config?: any): (view: EditorView) => Diagnostic[]; |
||||
|
||||
/** |
||||
Completion source that looks up locally defined names in |
||||
JavaScript code. |
||||
*/ |
||||
declare function localCompletionSource(context: CompletionContext): CompletionResult | null; |
||||
/** |
||||
Helper function for defining JavaScript completion sources. It |
||||
returns the completable name and object path for a completion |
||||
context, or null if no name/property completion should happen at |
||||
that position. For example, when completing after `a.b.c` it will |
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x` |
||||
it will return `{path: [], name: "x"}`. When not in a property or |
||||
name, it will return null if `context.explicit` is false, and |
||||
`{path: [], name: ""}` otherwise. |
||||
*/ |
||||
declare function completionPath(context: CompletionContext): { |
||||
path: readonly string[]; |
||||
name: string; |
||||
} | null; |
||||
/** |
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that
|
||||
completes from the given scope object (for example `globalThis`). |
||||
Will enter properties of the object when completing properties on |
||||
a directly-named path. |
||||
*/ |
||||
declare function scopeCompletionSource(scope: any): CompletionSource; |
||||
|
||||
export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets }; |
||||
@ -0,0 +1,498 @@
@@ -0,0 +1,498 @@
|
||||
import { parser } from '@lezer/javascript'; |
||||
import { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, flatIndent, delimitedIndent, foldNodeProp, foldInside, defineLanguageFacet, sublanguageProp, LanguageSupport } from '@codemirror/language'; |
||||
import { EditorSelection } from '@codemirror/state'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
import { snippetCompletion, ifNotIn, completeFromList } from '@codemirror/autocomplete'; |
||||
import { NodeWeakMap, IterMode } from '@lezer/common'; |
||||
|
||||
/** |
||||
A collection of JavaScript-related |
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
||||
*/ |
||||
const snippets = [ |
||||
/*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", { |
||||
label: "function", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", { |
||||
label: "for", |
||||
detail: "loop", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", { |
||||
label: "for", |
||||
detail: "of loop", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${})", { |
||||
label: "do", |
||||
detail: "loop", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("while (${}) {\n\t${}\n}", { |
||||
label: "while", |
||||
detail: "loop", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", { |
||||
label: "try", |
||||
detail: "/ catch block", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n}", { |
||||
label: "if", |
||||
detail: "block", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", { |
||||
label: "if", |
||||
detail: "/ else block", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", { |
||||
label: "class", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", { |
||||
label: "import", |
||||
detail: "named", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", { |
||||
label: "import", |
||||
detail: "default", |
||||
type: "keyword" |
||||
}) |
||||
]; |
||||
/** |
||||
A collection of snippet completions for TypeScript. Includes the |
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
||||
*/ |
||||
const typescriptSnippets = /*@__PURE__*/snippets.concat([ |
||||
/*@__PURE__*/snippetCompletion("interface ${name} {\n\t${}\n}", { |
||||
label: "interface", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("type ${name} = ${type}", { |
||||
label: "type", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}), |
||||
/*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n}", { |
||||
label: "enum", |
||||
detail: "definition", |
||||
type: "keyword" |
||||
}) |
||||
]); |
||||
|
||||
const cache = /*@__PURE__*/new NodeWeakMap(); |
||||
const ScopeNodes = /*@__PURE__*/new Set([ |
||||
"Script", "Block", |
||||
"FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration", |
||||
"ForStatement" |
||||
]); |
||||
function defID(type) { |
||||
return (node, def) => { |
||||
let id = node.node.getChild("VariableDefinition"); |
||||
if (id) |
||||
def(id, type); |
||||
return true; |
||||
}; |
||||
} |
||||
const functionContext = ["FunctionDeclaration"]; |
||||
const gatherCompletions = { |
||||
FunctionDeclaration: /*@__PURE__*/defID("function"), |
||||
ClassDeclaration: /*@__PURE__*/defID("class"), |
||||
ClassExpression: () => true, |
||||
EnumDeclaration: /*@__PURE__*/defID("constant"), |
||||
TypeAliasDeclaration: /*@__PURE__*/defID("type"), |
||||
NamespaceDeclaration: /*@__PURE__*/defID("namespace"), |
||||
VariableDefinition(node, def) { if (!node.matchContext(functionContext)) |
||||
def(node, "variable"); }, |
||||
TypeDefinition(node, def) { def(node, "type"); }, |
||||
__proto__: null |
||||
}; |
||||
function getScope(doc, node) { |
||||
let cached = cache.get(node); |
||||
if (cached) |
||||
return cached; |
||||
let completions = [], top = true; |
||||
function def(node, type) { |
||||
let name = doc.sliceString(node.from, node.to); |
||||
completions.push({ label: name, type }); |
||||
} |
||||
node.cursor(IterMode.IncludeAnonymous).iterate(node => { |
||||
if (top) { |
||||
top = false; |
||||
} |
||||
else if (node.name) { |
||||
let gather = gatherCompletions[node.name]; |
||||
if (gather && gather(node, def) || ScopeNodes.has(node.name)) |
||||
return false; |
||||
} |
||||
else if (node.to - node.from > 8192) { |
||||
// Allow caching for bigger internal nodes
|
||||
for (let c of getScope(doc, node.node)) |
||||
completions.push(c); |
||||
return false; |
||||
} |
||||
}); |
||||
cache.set(node, completions); |
||||
return completions; |
||||
} |
||||
const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/; |
||||
const dontComplete = [ |
||||
"TemplateString", "String", "RegExp", |
||||
"LineComment", "BlockComment", |
||||
"VariableDefinition", "TypeDefinition", "Label", |
||||
"PropertyDefinition", "PropertyName", |
||||
"PrivatePropertyDefinition", "PrivatePropertyName", |
||||
"JSXText", "JSXAttributeValue", "JSXOpenTag", "JSXCloseTag", "JSXSelfClosingTag", |
||||
".", "?." |
||||
]; |
||||
/** |
||||
Completion source that looks up locally defined names in |
||||
JavaScript code. |
||||
*/ |
||||
function localCompletionSource(context) { |
||||
let inner = syntaxTree(context.state).resolveInner(context.pos, -1); |
||||
if (dontComplete.indexOf(inner.name) > -1) |
||||
return null; |
||||
let isWord = inner.name == "VariableName" || |
||||
inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to)); |
||||
if (!isWord && !context.explicit) |
||||
return null; |
||||
let options = []; |
||||
for (let pos = inner; pos; pos = pos.parent) { |
||||
if (ScopeNodes.has(pos.name)) |
||||
options = options.concat(getScope(context.state.doc, pos)); |
||||
} |
||||
return { |
||||
options, |
||||
from: isWord ? inner.from : context.pos, |
||||
validFor: Identifier |
||||
}; |
||||
} |
||||
function pathFor(read, member, name) { |
||||
var _a; |
||||
let path = []; |
||||
for (;;) { |
||||
let obj = member.firstChild, prop; |
||||
if ((obj === null || obj === void 0 ? void 0 : obj.name) == "VariableName") { |
||||
path.push(read(obj)); |
||||
return { path: path.reverse(), name }; |
||||
} |
||||
else if ((obj === null || obj === void 0 ? void 0 : obj.name) == "MemberExpression" && ((_a = (prop = obj.lastChild)) === null || _a === void 0 ? void 0 : _a.name) == "PropertyName") { |
||||
path.push(read(prop)); |
||||
member = obj; |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
/** |
||||
Helper function for defining JavaScript completion sources. It |
||||
returns the completable name and object path for a completion |
||||
context, or null if no name/property completion should happen at |
||||
that position. For example, when completing after `a.b.c` it will |
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x` |
||||
it will return `{path: [], name: "x"}`. When not in a property or |
||||
name, it will return null if `context.explicit` is false, and |
||||
`{path: [], name: ""}` otherwise. |
||||
*/ |
||||
function completionPath(context) { |
||||
let read = (node) => context.state.doc.sliceString(node.from, node.to); |
||||
let inner = syntaxTree(context.state).resolveInner(context.pos, -1); |
||||
if (inner.name == "PropertyName") { |
||||
return pathFor(read, inner.parent, read(inner)); |
||||
} |
||||
else if ((inner.name == "." || inner.name == "?.") && inner.parent.name == "MemberExpression") { |
||||
return pathFor(read, inner.parent, ""); |
||||
} |
||||
else if (dontComplete.indexOf(inner.name) > -1) { |
||||
return null; |
||||
} |
||||
else if (inner.name == "VariableName" || inner.to - inner.from < 20 && Identifier.test(read(inner))) { |
||||
return { path: [], name: read(inner) }; |
||||
} |
||||
else if (inner.name == "MemberExpression") { |
||||
return pathFor(read, inner, ""); |
||||
} |
||||
else { |
||||
return context.explicit ? { path: [], name: "" } : null; |
||||
} |
||||
} |
||||
function enumeratePropertyCompletions(obj, top) { |
||||
let options = [], seen = new Set; |
||||
for (let depth = 0;; depth++) { |
||||
for (let name of (Object.getOwnPropertyNames || Object.keys)(obj)) { |
||||
if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name) || seen.has(name)) |
||||
continue; |
||||
seen.add(name); |
||||
let value; |
||||
try { |
||||
value = obj[name]; |
||||
} |
||||
catch (_) { |
||||
continue; |
||||
} |
||||
options.push({ |
||||
label: name, |
||||
type: typeof value == "function" ? (/^[A-Z]/.test(name) ? "class" : top ? "function" : "method") |
||||
: top ? "variable" : "property", |
||||
boost: -depth |
||||
}); |
||||
} |
||||
let next = Object.getPrototypeOf(obj); |
||||
if (!next) |
||||
return options; |
||||
obj = next; |
||||
} |
||||
} |
||||
/** |
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that
|
||||
completes from the given scope object (for example `globalThis`). |
||||
Will enter properties of the object when completing properties on |
||||
a directly-named path. |
||||
*/ |
||||
function scopeCompletionSource(scope) { |
||||
let cache = new Map; |
||||
return (context) => { |
||||
let path = completionPath(context); |
||||
if (!path) |
||||
return null; |
||||
let target = scope; |
||||
for (let step of path.path) { |
||||
target = target[step]; |
||||
if (!target) |
||||
return null; |
||||
} |
||||
let options = cache.get(target); |
||||
if (!options) |
||||
cache.set(target, options = enumeratePropertyCompletions(target, !path.path.length)); |
||||
return { |
||||
from: context.pos - path.name.length, |
||||
options, |
||||
validFor: Identifier |
||||
}; |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
A language provider based on the [Lezer JavaScript |
||||
parser](https://github.com/lezer-parser/javascript), extended with
|
||||
highlighting and indentation information. |
||||
*/ |
||||
const javascriptLanguage = /*@__PURE__*/LRLanguage.define({ |
||||
name: "javascript", |
||||
parser: /*@__PURE__*/parser.configure({ |
||||
props: [ |
||||
/*@__PURE__*/indentNodeProp.add({ |
||||
IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }), |
||||
TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }), |
||||
LabeledStatement: flatIndent, |
||||
SwitchBody: context => { |
||||
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after); |
||||
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit; |
||||
}, |
||||
Block: /*@__PURE__*/delimitedIndent({ closing: "}" }), |
||||
ArrowFunction: cx => cx.baseIndent + cx.unit, |
||||
"TemplateString BlockComment": () => null, |
||||
"Statement Property": /*@__PURE__*/continuedIndent({ except: /^\s*{/ }), |
||||
JSXElement(context) { |
||||
let closed = /^\s*<\//.test(context.textAfter); |
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit); |
||||
}, |
||||
JSXEscape(context) { |
||||
let closed = /\s*\}/.test(context.textAfter); |
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit); |
||||
}, |
||||
"JSXOpenTag JSXSelfClosingTag"(context) { |
||||
return context.column(context.node.from) + context.unit; |
||||
} |
||||
}), |
||||
/*@__PURE__*/foldNodeProp.add({ |
||||
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside, |
||||
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; } |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] }, |
||||
commentTokens: { line: "//", block: { open: "/*", close: "*/" } }, |
||||
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/, |
||||
wordChars: "$" |
||||
} |
||||
}); |
||||
const jsxSublanguage = { |
||||
test: node => /^JSX/.test(node.name), |
||||
facet: /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } }) |
||||
}; |
||||
/** |
||||
A language provider for TypeScript. |
||||
*/ |
||||
const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" }, "typescript"); |
||||
/** |
||||
Language provider for JSX. |
||||
*/ |
||||
const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({ |
||||
dialect: "jsx", |
||||
props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)] |
||||
}); |
||||
/** |
||||
Language provider for JSX + TypeScript. |
||||
*/ |
||||
const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({ |
||||
dialect: "jsx ts", |
||||
props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)] |
||||
}, "typescript"); |
||||
let kwCompletion = (name) => ({ label: name, type: "keyword" }); |
||||
const keywords = /*@__PURE__*/"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion); |
||||
const typescriptKeywords = /*@__PURE__*/keywords.concat(/*@__PURE__*/["declare", "implements", "private", "protected", "public"].map(kwCompletion)); |
||||
/** |
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
||||
and local variable completion. |
||||
*/ |
||||
function javascript(config = {}) { |
||||
let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage) |
||||
: config.typescript ? typescriptLanguage : javascriptLanguage; |
||||
let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords); |
||||
return new LanguageSupport(lang, [ |
||||
javascriptLanguage.data.of({ |
||||
autocomplete: ifNotIn(dontComplete, completeFromList(completions)) |
||||
}), |
||||
javascriptLanguage.data.of({ |
||||
autocomplete: localCompletionSource |
||||
}), |
||||
config.jsx ? autoCloseTags : [], |
||||
]); |
||||
} |
||||
function findOpenTag(node) { |
||||
for (;;) { |
||||
if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag") |
||||
return node; |
||||
if (node.name == "JSXEscape" || !node.parent) |
||||
return null; |
||||
node = node.parent; |
||||
} |
||||
} |
||||
function elementName(doc, tree, max = doc.length) { |
||||
for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) { |
||||
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" || |
||||
ch.name == "JSXMemberExpression") |
||||
return doc.sliceString(ch.from, Math.min(ch.to, max)); |
||||
} |
||||
return ""; |
||||
} |
||||
const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent); |
||||
/** |
||||
Extension that will automatically insert JSX close tags when a `>` or |
||||
`/` is typed. |
||||
*/ |
||||
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => { |
||||
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || |
||||
from != to || (text != ">" && text != "/") || |
||||
!javascriptLanguage.isActiveAt(view.state, from, -1)) |
||||
return false; |
||||
let base = defaultInsert(), { state } = base; |
||||
let closeTags = state.changeByRange(range => { |
||||
var _a; |
||||
let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name; |
||||
if (around.name == "JSXStartTag") |
||||
around = around.parent; |
||||
if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ; |
||||
else if (text == ">" && around.name == "JSXFragmentTag") { |
||||
return { range, changes: { from: head, insert: `</>` } }; |
||||
} |
||||
else if (text == "/" && around.name == "JSXStartCloseTag") { |
||||
let empty = around.parent, base = empty.parent; |
||||
if (base && empty.from == head - 2 && |
||||
((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) { |
||||
let insert = `${name}>`; |
||||
return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } }; |
||||
} |
||||
} |
||||
else if (text == ">") { |
||||
let openTag = findOpenTag(around); |
||||
if (openTag && openTag.name == "JSXOpenTag" && |
||||
!/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) && |
||||
(name = elementName(state.doc, openTag, head))) |
||||
return { range, changes: { from: head, insert: `</${name}>` } }; |
||||
} |
||||
return { range }; |
||||
}); |
||||
if (closeTags.changes.empty) |
||||
return false; |
||||
view.dispatch([ |
||||
base, |
||||
state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true }) |
||||
]); |
||||
return true; |
||||
}); |
||||
|
||||
/** |
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
|
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
|
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
|
||||
class, and `config` an optional ESLint configuration. The return |
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
|
||||
to create a JavaScript linting extension. |
||||
|
||||
Note that ESLint targets node, and is tricky to run in the |
||||
browser. The |
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)
|
||||
package may help with that (see |
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).
|
||||
*/ |
||||
function esLint(eslint, config) { |
||||
if (!config) { |
||||
config = { |
||||
parserOptions: { ecmaVersion: 2019, sourceType: "module" }, |
||||
env: { browser: true, node: true, es6: true, es2015: true, es2017: true, es2020: true }, |
||||
rules: {} |
||||
}; |
||||
eslint.getRules().forEach((desc, name) => { |
||||
var _a; |
||||
if ((_a = desc.meta.docs) === null || _a === void 0 ? void 0 : _a.recommended) |
||||
config.rules[name] = 2; |
||||
}); |
||||
} |
||||
return (view) => { |
||||
let { state } = view, found = []; |
||||
for (let { from, to } of javascriptLanguage.findRegions(state)) { |
||||
let fromLine = state.doc.lineAt(from), offset = { line: fromLine.number - 1, col: from - fromLine.from, pos: from }; |
||||
for (let d of eslint.verify(state.sliceDoc(from, to), config)) |
||||
found.push(translateDiagnostic(d, state.doc, offset)); |
||||
} |
||||
return found; |
||||
}; |
||||
} |
||||
function mapPos(line, col, doc, offset) { |
||||
return doc.line(line + offset.line).from + col + (line == 1 ? offset.col - 1 : -1); |
||||
} |
||||
function translateDiagnostic(input, doc, offset) { |
||||
let start = mapPos(input.line, input.column, doc, offset); |
||||
let result = { |
||||
from: start, |
||||
to: input.endLine != null && input.endColumn != 1 ? mapPos(input.endLine, input.endColumn, doc, offset) : start, |
||||
message: input.message, |
||||
source: input.ruleId ? "eslint:" + input.ruleId : "eslint", |
||||
severity: input.severity == 1 ? "warning" : "error", |
||||
}; |
||||
if (input.fix) { |
||||
let { range, text } = input.fix, from = range[0] + offset.pos - start, to = range[1] + offset.pos - start; |
||||
result.actions = [{ |
||||
name: "fix", |
||||
apply(view, start) { |
||||
view.dispatch({ changes: { from: start + from, to: start + to, insert: text }, scrollIntoView: true }); |
||||
} |
||||
}]; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets }; |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
{ |
||||
"name": "@codemirror/lang-javascript", |
||||
"version": "6.2.4", |
||||
"description": "JavaScript language support for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/index.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.0.0", |
||||
"@codemirror/language": "^6.6.0", |
||||
"@codemirror/lint": "^6.0.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.17.0", |
||||
"@lezer/common": "^1.0.0", |
||||
"@lezer/javascript": "^1.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0", |
||||
"@lezer/lr": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/lang-javascript.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
## 6.0.2 (2025-06-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add a .d.cts file to make TypeScript happy. |
||||
## 6.0.1 (2022-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure the language object has a name. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 6.0.0 |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.20.0 |
||||
|
||||
## 0.19.2 (2022-02-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix highlighting of `null` tokens. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.19.0 |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.18. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
'use strict'; |
||||
|
||||
var json$1 = require('@lezer/json'); |
||||
var language = require('@codemirror/language'); |
||||
|
||||
/** |
||||
Calls |
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) |
||||
on the document and, if that throws an error, reports it as a |
||||
single diagnostic. |
||||
*/ |
||||
const jsonParseLinter = () => (view) => { |
||||
try { |
||||
JSON.parse(view.state.doc.toString()); |
||||
} |
||||
catch (e) { |
||||
if (!(e instanceof SyntaxError)) |
||||
throw e; |
||||
const pos = getErrorPosition(e, view.state.doc); |
||||
return [{ |
||||
from: pos, |
||||
message: e.message, |
||||
severity: 'error', |
||||
to: pos |
||||
}]; |
||||
} |
||||
return []; |
||||
}; |
||||
function getErrorPosition(error, doc) { |
||||
let m; |
||||
if (m = error.message.match(/at position (\d+)/)) |
||||
return Math.min(+m[1], doc.length); |
||||
if (m = error.message.match(/at line (\d+) column (\d+)/)) |
||||
return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length); |
||||
return 0; |
||||
} |
||||
|
||||
/** |
||||
A language provider that provides JSON parsing. |
||||
*/ |
||||
const jsonLanguage = language.LRLanguage.define({ |
||||
name: "json", |
||||
parser: json$1.parser.configure({ |
||||
props: [ |
||||
language.indentNodeProp.add({ |
||||
Object: language.continuedIndent({ except: /^\s*\}/ }), |
||||
Array: language.continuedIndent({ except: /^\s*\]/ }) |
||||
}), |
||||
language.foldNodeProp.add({ |
||||
"Object Array": language.foldInside |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
closeBrackets: { brackets: ["[", "{", '"'] }, |
||||
indentOnInput: /^\s*[\}\]]$/ |
||||
} |
||||
}); |
||||
/** |
||||
JSON language support. |
||||
*/ |
||||
function json() { |
||||
return new language.LanguageSupport(jsonLanguage); |
||||
} |
||||
|
||||
exports.json = json; |
||||
exports.jsonLanguage = jsonLanguage; |
||||
exports.jsonParseLinter = jsonParseLinter; |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { Diagnostic } from '@codemirror/lint'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
|
||||
/** |
||||
Calls |
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) |
||||
on the document and, if that throws an error, reports it as a |
||||
single diagnostic. |
||||
*/ |
||||
declare const jsonParseLinter: () => (view: EditorView) => Diagnostic[]; |
||||
|
||||
/** |
||||
A language provider that provides JSON parsing. |
||||
*/ |
||||
declare const jsonLanguage: LRLanguage; |
||||
/** |
||||
JSON language support. |
||||
*/ |
||||
declare function json(): LanguageSupport; |
||||
|
||||
export { json, jsonLanguage, jsonParseLinter }; |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language'; |
||||
import { Diagnostic } from '@codemirror/lint'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
|
||||
/** |
||||
Calls |
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
|
||||
on the document and, if that throws an error, reports it as a |
||||
single diagnostic. |
||||
*/ |
||||
declare const jsonParseLinter: () => (view: EditorView) => Diagnostic[]; |
||||
|
||||
/** |
||||
A language provider that provides JSON parsing. |
||||
*/ |
||||
declare const jsonLanguage: LRLanguage; |
||||
/** |
||||
JSON language support. |
||||
*/ |
||||
declare function json(): LanguageSupport; |
||||
|
||||
export { json, jsonLanguage, jsonParseLinter }; |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
import { parser } from '@lezer/json'; |
||||
import { LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language'; |
||||
|
||||
/** |
||||
Calls |
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
|
||||
on the document and, if that throws an error, reports it as a |
||||
single diagnostic. |
||||
*/ |
||||
const jsonParseLinter = () => (view) => { |
||||
try { |
||||
JSON.parse(view.state.doc.toString()); |
||||
} |
||||
catch (e) { |
||||
if (!(e instanceof SyntaxError)) |
||||
throw e; |
||||
const pos = getErrorPosition(e, view.state.doc); |
||||
return [{ |
||||
from: pos, |
||||
message: e.message, |
||||
severity: 'error', |
||||
to: pos |
||||
}]; |
||||
} |
||||
return []; |
||||
}; |
||||
function getErrorPosition(error, doc) { |
||||
let m; |
||||
if (m = error.message.match(/at position (\d+)/)) |
||||
return Math.min(+m[1], doc.length); |
||||
if (m = error.message.match(/at line (\d+) column (\d+)/)) |
||||
return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length); |
||||
return 0; |
||||
} |
||||
|
||||
/** |
||||
A language provider that provides JSON parsing. |
||||
*/ |
||||
const jsonLanguage = /*@__PURE__*/LRLanguage.define({ |
||||
name: "json", |
||||
parser: /*@__PURE__*/parser.configure({ |
||||
props: [ |
||||
/*@__PURE__*/indentNodeProp.add({ |
||||
Object: /*@__PURE__*/continuedIndent({ except: /^\s*\}/ }), |
||||
Array: /*@__PURE__*/continuedIndent({ except: /^\s*\]/ }) |
||||
}), |
||||
/*@__PURE__*/foldNodeProp.add({ |
||||
"Object Array": foldInside |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
closeBrackets: { brackets: ["[", "{", '"'] }, |
||||
indentOnInput: /^\s*[\}\]]$/ |
||||
} |
||||
}); |
||||
/** |
||||
JSON language support. |
||||
*/ |
||||
function json() { |
||||
return new LanguageSupport(jsonLanguage); |
||||
} |
||||
|
||||
export { json, jsonLanguage, jsonParseLinter }; |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
{ |
||||
"name": "@codemirror/lang-json", |
||||
"version": "6.0.2", |
||||
"description": "JSON language support for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/json.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/language": "^6.0.0", |
||||
"@lezer/json": "^1.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/lang-json.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,246 @@
@@ -0,0 +1,246 @@
|
||||
## 6.5.0 (2025-10-23) |
||||
|
||||
### New features |
||||
|
||||
Add a variant of `insertNewlineContinueMarkup` that supports configuration options. |
||||
|
||||
## 6.4.0 (2025-10-02) |
||||
|
||||
### New features |
||||
|
||||
The new `pasteURLAsLink` extension allows you to paste URLs over a selection to quickly create a link. |
||||
|
||||
## 6.3.4 (2025-08-01) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure header-based indentation is available even when Markdown isn't the editor's top-level language. |
||||
|
||||
## 6.3.3 (2025-06-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `insertNewlineContinueMarkup` take effect even when at the end of a nested range of Markdown content. |
||||
|
||||
## 6.3.2 (2025-01-09) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make Markdown-specific commands return false inside fenced code. |
||||
|
||||
Fix an infinite loop caused by `insertNewlineContinueMarkup`. |
||||
|
||||
## 6.3.1 (2024-11-06) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `insertNewlineContinueMarkup` didn't work with the cursor directly after an HTML tag. |
||||
|
||||
## 6.3.0 (2024-09-28) |
||||
|
||||
### New features |
||||
|
||||
The new `htmlTagLanguage` option allows client code to configure which language is used to parse HTML tags in the document. |
||||
|
||||
## 6.2.5 (2024-04-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
Disable folding for list nodes (since it will shadow the folding on the first list item). |
||||
|
||||
## 6.2.4 (2024-01-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Starting at the third list item, `insertNewlineContinueMarkup` will now keep the tightness of the list, and only require two presses to clear an empty list item. |
||||
|
||||
## 6.2.3 (2023-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Support code folding for GFM tables. |
||||
|
||||
## 6.2.2 (2023-10-06) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug in `insertNewlineContinueMarkup` that caused it to put the cursor in the wrong place when the editor's line break was more than one character long. |
||||
|
||||
## 6.2.1 (2023-09-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `insertNewlineContinueMarkup` and `deleteMarkupBackward` use tabs for indentation when appropriate. |
||||
|
||||
## 6.2.0 (2023-06-23) |
||||
|
||||
### New features |
||||
|
||||
The markdown package now installs a completion source that completes HTML tags when in Markdown context. |
||||
|
||||
## 6.1.1 (2023-04-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix the declaration of `comentTokens` language data for Markdown. |
||||
|
||||
Fix a bug in `deleteMarkupBackward` that would cause it to delete pieces of continued paragraphs below list item markers. |
||||
|
||||
## 6.1.0 (2023-02-17) |
||||
|
||||
### New features |
||||
|
||||
Add support for folding entire sections from the header. |
||||
|
||||
## 6.0.5 (2022-11-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure task lists are indented correctly even when deeply nested. |
||||
|
||||
## 6.0.4 (2022-11-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where nested task lists were indented too deeply. |
||||
|
||||
## 6.0.3 (2022-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add a `name` value to the Markdown language object. |
||||
|
||||
## 6.0.2 (2022-10-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Improve `insertNewlineContinueMarkup`'s behavior in a fenced code block. |
||||
|
||||
## 6.0.1 (2022-07-25) |
||||
|
||||
### Bug fixes |
||||
|
||||
Ignore text after whitespace in code block metadata, when determining which language the block is. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 6.0.0 |
||||
|
||||
## 0.20.1 (2022-05-20) |
||||
|
||||
### New features |
||||
|
||||
The `codeLanguages` option to `markdown` may now be a function from an info string to a language. |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### New features |
||||
|
||||
`insertNewlineContinueMarkup` can now continue task lists. Move highlighting information into @lezer/markdown |
||||
|
||||
## 0.19.6 (2022-02-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `deleteMarkupBackward` could get confused when there was only whitespace between the cursor and the start of the line. |
||||
|
||||
## 0.19.5 (2022-01-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `insertNewlineContinueMarkup` exit blockquotes after two blank lines. |
||||
|
||||
## 0.19.4 (2022-01-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where list items after a removed item were incorrectly renumbered. |
||||
|
||||
## 0.19.3 (2021-12-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
`insertNewlineContinueMarkup` will no longer exit lists when there is content after the cursor. |
||||
|
||||
Fix an issue in `deleteMarkupBackward` where it only deleted a single space when after a number marker. |
||||
|
||||
## 0.19.2 (2021-10-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where the monospace highlighting tag wasn't correctly applied to code block content. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.19.0 |
||||
|
||||
## 0.18.4 (2021-06-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a case where `deleteMarkupBackward` would return true without actually having an effect. |
||||
|
||||
## 0.18.3 (2021-05-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
`insertNewlineContinueMarkup` will not continue moving list markers down when they are after an empty line anymore. |
||||
|
||||
## 0.18.2 (2021-05-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where `insertNewlineContinueMarkup` could duplicate bits of content when in dededented continued list items. |
||||
|
||||
## 0.18.1 (2021-04-01) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add `monospace` style tag to all children of inline code nodes. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.18. |
||||
|
||||
## 0.17.3 (2021-02-22) |
||||
|
||||
### New features |
||||
|
||||
Include heading depth in style tags. |
||||
|
||||
## 0.17.2 (2021-02-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where `insertNewlineContinueMarkup` would sometimes duplicate bits of content. |
||||
|
||||
### New features |
||||
|
||||
The package now exports both a `commonmarkLanguage`, with just plain CommonMark, and a `markdownLanguage`, with GFM and some other extensions enabled. |
||||
|
||||
It is now possible to pass lezer-markdown extensions to the `markdown` function to configure the parser. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,501 @@
@@ -0,0 +1,501 @@
|
||||
'use strict'; |
||||
|
||||
var state = require('@codemirror/state'); |
||||
var view = require('@codemirror/view'); |
||||
var language = require('@codemirror/language'); |
||||
var autocomplete = require('@codemirror/autocomplete'); |
||||
var markdown$1 = require('@lezer/markdown'); |
||||
var langHtml = require('@codemirror/lang-html'); |
||||
var common = require('@lezer/common'); |
||||
|
||||
const data = language.defineLanguageFacet({ commentTokens: { block: { open: "<!--", close: "-->" } } }); |
||||
const headingProp = new common.NodeProp(); |
||||
const commonmark = markdown$1.parser.configure({ |
||||
props: [ |
||||
language.foldNodeProp.add(type => { |
||||
return !type.is("Block") || type.is("Document") || isHeading(type) != null || isList(type) ? undefined |
||||
: (tree, state) => ({ from: state.doc.lineAt(tree.from).to, to: tree.to }); |
||||
}), |
||||
headingProp.add(isHeading), |
||||
language.indentNodeProp.add({ |
||||
Document: () => null |
||||
}), |
||||
language.languageDataProp.add({ |
||||
Document: data |
||||
}) |
||||
] |
||||
}); |
||||
function isHeading(type) { |
||||
let match = /^(?:ATX|Setext)Heading(\d)$/.exec(type.name); |
||||
return match ? +match[1] : undefined; |
||||
} |
||||
function isList(type) { |
||||
return type.name == "OrderedList" || type.name == "BulletList"; |
||||
} |
||||
function findSectionEnd(headerNode, level) { |
||||
let last = headerNode; |
||||
for (;;) { |
||||
let next = last.nextSibling, heading; |
||||
if (!next || (heading = isHeading(next.type)) != null && heading <= level) |
||||
break; |
||||
last = next; |
||||
} |
||||
return last.to; |
||||
} |
||||
const headerIndent = language.foldService.of((state, start, end) => { |
||||
for (let node = language.syntaxTree(state).resolveInner(end, -1); node; node = node.parent) { |
||||
if (node.from < start) |
||||
break; |
||||
let heading = node.type.prop(headingProp); |
||||
if (heading == null) |
||||
continue; |
||||
let upto = findSectionEnd(node, heading); |
||||
if (upto > end) |
||||
return { from: end, to: upto }; |
||||
} |
||||
return null; |
||||
}); |
||||
function mkLang(parser) { |
||||
return new language.Language(data, parser, [], "markdown"); |
||||
} |
||||
/** |
||||
Language support for strict CommonMark. |
||||
*/ |
||||
const commonmarkLanguage = mkLang(commonmark); |
||||
const extended = commonmark.configure([markdown$1.GFM, markdown$1.Subscript, markdown$1.Superscript, markdown$1.Emoji, { |
||||
props: [ |
||||
language.foldNodeProp.add({ |
||||
Table: (tree, state) => ({ from: state.doc.lineAt(tree.from).to, to: tree.to }) |
||||
}) |
||||
] |
||||
}]); |
||||
/** |
||||
Language support for [GFM](https://github.github.com/gfm/) plus |
||||
subscript, superscript, and emoji syntax. |
||||
*/ |
||||
const markdownLanguage = mkLang(extended); |
||||
function getCodeParser(languages, defaultLanguage) { |
||||
return (info) => { |
||||
if (info && languages) { |
||||
let found = null; |
||||
// Strip anything after whitespace |
||||
info = /\S*/.exec(info)[0]; |
||||
if (typeof languages == "function") |
||||
found = languages(info); |
||||
else |
||||
found = language.LanguageDescription.matchLanguageName(languages, info, true); |
||||
if (found instanceof language.LanguageDescription) |
||||
return found.support ? found.support.language.parser : language.ParseContext.getSkippingParser(found.load()); |
||||
else if (found) |
||||
return found.parser; |
||||
} |
||||
return defaultLanguage ? defaultLanguage.parser : null; |
||||
}; |
||||
} |
||||
|
||||
class Context { |
||||
constructor(node, from, to, spaceBefore, spaceAfter, type, item) { |
||||
this.node = node; |
||||
this.from = from; |
||||
this.to = to; |
||||
this.spaceBefore = spaceBefore; |
||||
this.spaceAfter = spaceAfter; |
||||
this.type = type; |
||||
this.item = item; |
||||
} |
||||
blank(maxWidth, trailing = true) { |
||||
let result = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : ""); |
||||
if (maxWidth != null) { |
||||
while (result.length < maxWidth) |
||||
result += " "; |
||||
return result; |
||||
} |
||||
else { |
||||
for (let i = this.to - this.from - result.length - this.spaceAfter.length; i > 0; i--) |
||||
result += " "; |
||||
return result + (trailing ? this.spaceAfter : ""); |
||||
} |
||||
} |
||||
marker(doc, add) { |
||||
let number = this.node.name == "OrderedList" ? String((+itemNumber(this.item, doc)[2] + add)) : ""; |
||||
return this.spaceBefore + number + this.type + this.spaceAfter; |
||||
} |
||||
} |
||||
function getContext(node, doc) { |
||||
let nodes = [], context = []; |
||||
for (let cur = node; cur; cur = cur.parent) { |
||||
if (cur.name == "FencedCode") |
||||
return context; |
||||
if (cur.name == "ListItem" || cur.name == "Blockquote") |
||||
nodes.push(cur); |
||||
} |
||||
for (let i = nodes.length - 1; i >= 0; i--) { |
||||
let node = nodes[i], match; |
||||
let line = doc.lineAt(node.from), startPos = node.from - line.from; |
||||
if (node.name == "Blockquote" && (match = /^ *>( ?)/.exec(line.text.slice(startPos)))) { |
||||
context.push(new Context(node, startPos, startPos + match[0].length, "", match[1], ">", null)); |
||||
} |
||||
else if (node.name == "ListItem" && node.parent.name == "OrderedList" && |
||||
(match = /^( *)\d+([.)])( *)/.exec(line.text.slice(startPos)))) { |
||||
let after = match[3], len = match[0].length; |
||||
if (after.length >= 4) { |
||||
after = after.slice(0, after.length - 4); |
||||
len -= 4; |
||||
} |
||||
context.push(new Context(node.parent, startPos, startPos + len, match[1], after, match[2], node)); |
||||
} |
||||
else if (node.name == "ListItem" && node.parent.name == "BulletList" && |
||||
(match = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(line.text.slice(startPos)))) { |
||||
let after = match[4], len = match[0].length; |
||||
if (after.length > 4) { |
||||
after = after.slice(0, after.length - 4); |
||||
len -= 4; |
||||
} |
||||
let type = match[2]; |
||||
if (match[3]) |
||||
type += match[3].replace(/[xX]/, ' '); |
||||
context.push(new Context(node.parent, startPos, startPos + len, match[1], after, type, node)); |
||||
} |
||||
} |
||||
return context; |
||||
} |
||||
function itemNumber(item, doc) { |
||||
return /^(\s*)(\d+)(?=[.)])/.exec(doc.sliceString(item.from, item.from + 10)); |
||||
} |
||||
function renumberList(after, doc, changes, offset = 0) { |
||||
for (let prev = -1, node = after;;) { |
||||
if (node.name == "ListItem") { |
||||
let m = itemNumber(node, doc); |
||||
let number = +m[2]; |
||||
if (prev >= 0) { |
||||
if (number != prev + 1) |
||||
return; |
||||
changes.push({ from: node.from + m[1].length, to: node.from + m[0].length, insert: String(prev + 2 + offset) }); |
||||
} |
||||
prev = number; |
||||
} |
||||
let next = node.nextSibling; |
||||
if (!next) |
||||
break; |
||||
node = next; |
||||
} |
||||
} |
||||
function normalizeIndent(content, state$1) { |
||||
let blank = /^[ \t]*/.exec(content)[0].length; |
||||
if (!blank || state$1.facet(language.indentUnit) != "\t") |
||||
return content; |
||||
let col = state.countColumn(content, 4, blank); |
||||
let space = ""; |
||||
for (let i = col; i > 0;) { |
||||
if (i >= 4) { |
||||
space += "\t"; |
||||
i -= 4; |
||||
} |
||||
else { |
||||
space += " "; |
||||
i--; |
||||
} |
||||
} |
||||
return space + content.slice(blank); |
||||
} |
||||
/** |
||||
Returns a command like |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup), |
||||
allowing further configuration. |
||||
*/ |
||||
const insertNewlineContinueMarkupCommand = (config = {}) => ({ state: state$1, dispatch }) => { |
||||
let tree = language.syntaxTree(state$1), { doc } = state$1; |
||||
let dont = null, changes = state$1.changeByRange(range => { |
||||
if (!range.empty || !markdownLanguage.isActiveAt(state$1, range.from, -1) && !markdownLanguage.isActiveAt(state$1, range.from, 1)) |
||||
return dont = { range }; |
||||
let pos = range.from, line = doc.lineAt(pos); |
||||
let context = getContext(tree.resolveInner(pos, -1), doc); |
||||
while (context.length && context[context.length - 1].from > pos - line.from) |
||||
context.pop(); |
||||
if (!context.length) |
||||
return dont = { range }; |
||||
let inner = context[context.length - 1]; |
||||
if (inner.to - inner.spaceAfter.length > pos - line.from) |
||||
return dont = { range }; |
||||
let emptyLine = pos >= (inner.to - inner.spaceAfter.length) && !/\S/.test(line.text.slice(inner.to)); |
||||
// Empty line in list |
||||
if (inner.item && emptyLine) { |
||||
let first = inner.node.firstChild, second = inner.node.getChild("ListItem", "ListItem"); |
||||
// Not second item or blank line before: delete a level of markup |
||||
if (first.to >= pos || second && second.to < pos || |
||||
line.from > 0 && !/[^\s>]/.test(doc.lineAt(line.from - 1).text) || |
||||
config.nonTightLists === false) { |
||||
let next = context.length > 1 ? context[context.length - 2] : null; |
||||
let delTo, insert = ""; |
||||
if (next && next.item) { // Re-add marker for the list at the next level |
||||
delTo = line.from + next.from; |
||||
insert = next.marker(doc, 1); |
||||
} |
||||
else { |
||||
delTo = line.from + (next ? next.to : 0); |
||||
} |
||||
let changes = [{ from: delTo, to: pos, insert }]; |
||||
if (inner.node.name == "OrderedList") |
||||
renumberList(inner.item, doc, changes, -2); |
||||
if (next && next.node.name == "OrderedList") |
||||
renumberList(next.item, doc, changes); |
||||
return { range: state.EditorSelection.cursor(delTo + insert.length), changes }; |
||||
} |
||||
else { // Move second item down, making tight two-item list non-tight |
||||
let insert = blankLine(context, state$1, line); |
||||
return { range: state.EditorSelection.cursor(pos + insert.length + 1), |
||||
changes: { from: line.from, insert: insert + state$1.lineBreak } }; |
||||
} |
||||
} |
||||
if (inner.node.name == "Blockquote" && emptyLine && line.from) { |
||||
let prevLine = doc.lineAt(line.from - 1), quoted = />\s*$/.exec(prevLine.text); |
||||
// Two aligned empty quoted lines in a row |
||||
if (quoted && quoted.index == inner.from) { |
||||
let changes = state$1.changes([{ from: prevLine.from + quoted.index, to: prevLine.to }, |
||||
{ from: line.from + inner.from, to: line.to }]); |
||||
return { range: range.map(changes), changes }; |
||||
} |
||||
} |
||||
let changes = []; |
||||
if (inner.node.name == "OrderedList") |
||||
renumberList(inner.item, doc, changes); |
||||
let continued = inner.item && inner.item.from < line.from; |
||||
let insert = ""; |
||||
// If not dedented |
||||
if (!continued || /^[\s\d.)\-+*>]*/.exec(line.text)[0].length >= inner.to) { |
||||
for (let i = 0, e = context.length - 1; i <= e; i++) { |
||||
insert += i == e && !continued ? context[i].marker(doc, 1) |
||||
: context[i].blank(i < e ? state.countColumn(line.text, 4, context[i + 1].from) - insert.length : null); |
||||
} |
||||
} |
||||
let from = pos; |
||||
while (from > line.from && /\s/.test(line.text.charAt(from - line.from - 1))) |
||||
from--; |
||||
insert = normalizeIndent(insert, state$1); |
||||
if (nonTightList(inner.node, state$1.doc)) |
||||
insert = blankLine(context, state$1, line) + state$1.lineBreak + insert; |
||||
changes.push({ from, to: pos, insert: state$1.lineBreak + insert }); |
||||
return { range: state.EditorSelection.cursor(from + insert.length + 1), changes }; |
||||
}); |
||||
if (dont) |
||||
return false; |
||||
dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "input" })); |
||||
return true; |
||||
}; |
||||
/** |
||||
This command, when invoked in Markdown context with cursor |
||||
selection(s), will create a new line with the markup for |
||||
blockquotes and lists that were active on the old line. If the |
||||
cursor was directly after the end of the markup for the old line, |
||||
trailing whitespace and list markers are removed from that line. |
||||
|
||||
The command does nothing in non-Markdown context, so it should |
||||
not be used as the only binding for Enter (even in a Markdown |
||||
document, HTML and code regions might use a different language). |
||||
*/ |
||||
const insertNewlineContinueMarkup = insertNewlineContinueMarkupCommand(); |
||||
function isMark(node) { |
||||
return node.name == "QuoteMark" || node.name == "ListMark"; |
||||
} |
||||
function nonTightList(node, doc) { |
||||
if (node.name != "OrderedList" && node.name != "BulletList") |
||||
return false; |
||||
let first = node.firstChild, second = node.getChild("ListItem", "ListItem"); |
||||
if (!second) |
||||
return false; |
||||
let line1 = doc.lineAt(first.to), line2 = doc.lineAt(second.from); |
||||
let empty = /^[\s>]*$/.test(line1.text); |
||||
return line1.number + (empty ? 0 : 1) < line2.number; |
||||
} |
||||
function blankLine(context, state$1, line) { |
||||
let insert = ""; |
||||
for (let i = 0, e = context.length - 2; i <= e; i++) { |
||||
insert += context[i].blank(i < e |
||||
? state.countColumn(line.text, 4, context[i + 1].from) - insert.length |
||||
: null, i < e); |
||||
} |
||||
return normalizeIndent(insert, state$1); |
||||
} |
||||
function contextNodeForDelete(tree, pos) { |
||||
let node = tree.resolveInner(pos, -1), scan = pos; |
||||
if (isMark(node)) { |
||||
scan = node.from; |
||||
node = node.parent; |
||||
} |
||||
for (let prev; prev = node.childBefore(scan);) { |
||||
if (isMark(prev)) { |
||||
scan = prev.from; |
||||
} |
||||
else if (prev.name == "OrderedList" || prev.name == "BulletList") { |
||||
node = prev.lastChild; |
||||
scan = node.to; |
||||
} |
||||
else { |
||||
break; |
||||
} |
||||
} |
||||
return node; |
||||
} |
||||
/** |
||||
This command will, when invoked in a Markdown context with the |
||||
cursor directly after list or blockquote markup, delete one level |
||||
of markup. When the markup is for a list, it will be replaced by |
||||
spaces on the first invocation (a further invocation will delete |
||||
the spaces), to make it easy to continue a list. |
||||
|
||||
When not after Markdown block markup, this command will return |
||||
false, so it is intended to be bound alongside other deletion |
||||
commands, with a higher precedence than the more generic commands. |
||||
*/ |
||||
const deleteMarkupBackward = ({ state: state$1, dispatch }) => { |
||||
let tree = language.syntaxTree(state$1); |
||||
let dont = null, changes = state$1.changeByRange(range => { |
||||
let pos = range.from, { doc } = state$1; |
||||
if (range.empty && markdownLanguage.isActiveAt(state$1, range.from)) { |
||||
let line = doc.lineAt(pos); |
||||
let context = getContext(contextNodeForDelete(tree, pos), doc); |
||||
if (context.length) { |
||||
let inner = context[context.length - 1]; |
||||
let spaceEnd = inner.to - inner.spaceAfter.length + (inner.spaceAfter ? 1 : 0); |
||||
// Delete extra trailing space after markup |
||||
if (pos - line.from > spaceEnd && !/\S/.test(line.text.slice(spaceEnd, pos - line.from))) |
||||
return { range: state.EditorSelection.cursor(line.from + spaceEnd), |
||||
changes: { from: line.from + spaceEnd, to: pos } }; |
||||
if (pos - line.from == spaceEnd && |
||||
// Only apply this if we're on the line that has the |
||||
// construct's syntax, or there's only indentation in the |
||||
// target range |
||||
(!inner.item || line.from <= inner.item.from || !/\S/.test(line.text.slice(0, inner.to)))) { |
||||
let start = line.from + inner.from; |
||||
// Replace a list item marker with blank space |
||||
if (inner.item && inner.node.from < inner.item.from && /\S/.test(line.text.slice(inner.from, inner.to))) { |
||||
let insert = inner.blank(state.countColumn(line.text, 4, inner.to) - state.countColumn(line.text, 4, inner.from)); |
||||
if (start == line.from) |
||||
insert = normalizeIndent(insert, state$1); |
||||
return { range: state.EditorSelection.cursor(start + insert.length), |
||||
changes: { from: start, to: line.from + inner.to, insert } }; |
||||
} |
||||
// Delete one level of indentation |
||||
if (start < pos) |
||||
return { range: state.EditorSelection.cursor(start), changes: { from: start, to: pos } }; |
||||
} |
||||
} |
||||
} |
||||
return dont = { range }; |
||||
}); |
||||
if (dont) |
||||
return false; |
||||
dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "delete" })); |
||||
return true; |
||||
}; |
||||
|
||||
/** |
||||
A small keymap with Markdown-specific bindings. Binds Enter to |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup) |
||||
and Backspace to |
||||
[`deleteMarkupBackward`](https://codemirror.net/6/docs/ref/#lang-markdown.deleteMarkupBackward). |
||||
*/ |
||||
const markdownKeymap = [ |
||||
{ key: "Enter", run: insertNewlineContinueMarkup }, |
||||
{ key: "Backspace", run: deleteMarkupBackward } |
||||
]; |
||||
const htmlNoMatch = langHtml.html({ matchClosingTags: false }); |
||||
/** |
||||
Markdown language support. |
||||
*/ |
||||
function markdown(config = {}) { |
||||
let { codeLanguages, defaultCodeLanguage, addKeymap = true, base: { parser } = commonmarkLanguage, completeHTMLTags = true, pasteURLAsLink: pasteURL = true, htmlTagLanguage = htmlNoMatch } = config; |
||||
if (!(parser instanceof markdown$1.MarkdownParser)) |
||||
throw new RangeError("Base parser provided to `markdown` should be a Markdown parser"); |
||||
let extensions = config.extensions ? [config.extensions] : []; |
||||
let support = [htmlTagLanguage.support, headerIndent], defaultCode; |
||||
if (pasteURL) |
||||
support.push(pasteURLAsLink); |
||||
if (defaultCodeLanguage instanceof language.LanguageSupport) { |
||||
support.push(defaultCodeLanguage.support); |
||||
defaultCode = defaultCodeLanguage.language; |
||||
} |
||||
else if (defaultCodeLanguage) { |
||||
defaultCode = defaultCodeLanguage; |
||||
} |
||||
let codeParser = codeLanguages || defaultCode ? getCodeParser(codeLanguages, defaultCode) : undefined; |
||||
extensions.push(markdown$1.parseCode({ codeParser, htmlParser: htmlTagLanguage.language.parser })); |
||||
if (addKeymap) |
||||
support.push(state.Prec.high(view.keymap.of(markdownKeymap))); |
||||
let lang = mkLang(parser.configure(extensions)); |
||||
if (completeHTMLTags) |
||||
support.push(lang.data.of({ autocomplete: htmlTagCompletion })); |
||||
return new language.LanguageSupport(lang, support); |
||||
} |
||||
function htmlTagCompletion(context) { |
||||
let { state, pos } = context, m = /<[:\-\.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos - 25, pos)); |
||||
if (!m) |
||||
return null; |
||||
let tree = language.syntaxTree(state).resolveInner(pos, -1); |
||||
while (tree && !tree.type.isTop) { |
||||
if (tree.name == "CodeBlock" || tree.name == "FencedCode" || tree.name == "ProcessingInstructionBlock" || |
||||
tree.name == "CommentBlock" || tree.name == "Link" || tree.name == "Image") |
||||
return null; |
||||
tree = tree.parent; |
||||
} |
||||
return { |
||||
from: pos - m[0].length, to: pos, |
||||
options: htmlTagCompletions(), |
||||
validFor: /^<[:\-\.\w\u00b7-\uffff]*$/ |
||||
}; |
||||
} |
||||
let _tagCompletions = null; |
||||
function htmlTagCompletions() { |
||||
if (_tagCompletions) |
||||
return _tagCompletions; |
||||
let result = langHtml.htmlCompletionSource(new autocomplete.CompletionContext(state.EditorState.create({ extensions: htmlNoMatch }), 0, true)); |
||||
return _tagCompletions = result ? result.options : []; |
||||
} |
||||
const nonPlainText = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i; |
||||
/** |
||||
An extension that intercepts pastes when the pasted content looks |
||||
like a URL and the selection is non-empty and selects regular |
||||
text, making the selection a link with the pasted URL as target. |
||||
*/ |
||||
const pasteURLAsLink = view.EditorView.domEventHandlers({ |
||||
paste: (event, view) => { |
||||
var _a; |
||||
let { main } = view.state.selection; |
||||
if (main.empty) |
||||
return false; |
||||
let link = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text/plain"); |
||||
if (!link || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(link)) |
||||
return false; |
||||
if (/^www\./.test(link)) |
||||
link = "https://" + link; |
||||
if (!markdownLanguage.isActiveAt(view.state, main.from, 1)) |
||||
return false; |
||||
let tree = language.syntaxTree(view.state), crossesNode = false; |
||||
// Verify that no nodes are started/ended between the selection |
||||
// points, and we're not inside any non-plain-text construct. |
||||
tree.iterate({ |
||||
from: main.from, to: main.to, |
||||
enter: node => { if (node.from > main.from || nonPlainText.test(node.name)) |
||||
crossesNode = true; }, |
||||
leave: node => { if (node.to < main.to) |
||||
crossesNode = true; } |
||||
}); |
||||
if (crossesNode) |
||||
return false; |
||||
view.dispatch({ |
||||
changes: [{ from: main.from, insert: "[" }, { from: main.to, insert: `](${link})` }], |
||||
userEvent: "input.paste", |
||||
scrollIntoView: true |
||||
}); |
||||
return true; |
||||
} |
||||
}); |
||||
|
||||
exports.commonmarkLanguage = commonmarkLanguage; |
||||
exports.deleteMarkupBackward = deleteMarkupBackward; |
||||
exports.insertNewlineContinueMarkup = insertNewlineContinueMarkup; |
||||
exports.insertNewlineContinueMarkupCommand = insertNewlineContinueMarkupCommand; |
||||
exports.markdown = markdown; |
||||
exports.markdownKeymap = markdownKeymap; |
||||
exports.markdownLanguage = markdownLanguage; |
||||
exports.pasteURLAsLink = pasteURLAsLink; |
||||
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { StateCommand } from '@codemirror/state'; |
||||
import { KeyBinding } from '@codemirror/view'; |
||||
import { Language, LanguageSupport, LanguageDescription } from '@codemirror/language'; |
||||
import { MarkdownExtension } from '@lezer/markdown'; |
||||
|
||||
/** |
||||
Language support for strict CommonMark. |
||||
*/ |
||||
declare const commonmarkLanguage: Language; |
||||
/** |
||||
Language support for [GFM](https://github.github.com/gfm/) plus |
||||
subscript, superscript, and emoji syntax. |
||||
*/ |
||||
declare const markdownLanguage: Language; |
||||
|
||||
/** |
||||
Returns a command like |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup), |
||||
allowing further configuration. |
||||
*/ |
||||
declare const insertNewlineContinueMarkupCommand: (config?: { |
||||
/** |
||||
By default, when pressing enter in a blank second item in a |
||||
tight (no blank lines between items) list, the command will |
||||
insert a blank line above that item, starting a non-tight list. |
||||
Set this to false to disable this behavior. |
||||
*/ |
||||
nonTightLists?: boolean; |
||||
}) => StateCommand; |
||||
/** |
||||
This command, when invoked in Markdown context with cursor |
||||
selection(s), will create a new line with the markup for |
||||
blockquotes and lists that were active on the old line. If the |
||||
cursor was directly after the end of the markup for the old line, |
||||
trailing whitespace and list markers are removed from that line. |
||||
|
||||
The command does nothing in non-Markdown context, so it should |
||||
not be used as the only binding for Enter (even in a Markdown |
||||
document, HTML and code regions might use a different language). |
||||
*/ |
||||
declare const insertNewlineContinueMarkup: StateCommand; |
||||
/** |
||||
This command will, when invoked in a Markdown context with the |
||||
cursor directly after list or blockquote markup, delete one level |
||||
of markup. When the markup is for a list, it will be replaced by |
||||
spaces on the first invocation (a further invocation will delete |
||||
the spaces), to make it easy to continue a list. |
||||
|
||||
When not after Markdown block markup, this command will return |
||||
false, so it is intended to be bound alongside other deletion |
||||
commands, with a higher precedence than the more generic commands. |
||||
*/ |
||||
declare const deleteMarkupBackward: StateCommand; |
||||
|
||||
/** |
||||
A small keymap with Markdown-specific bindings. Binds Enter to |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup) |
||||
and Backspace to |
||||
[`deleteMarkupBackward`](https://codemirror.net/6/docs/ref/#lang-markdown.deleteMarkupBackward). |
||||
*/ |
||||
declare const markdownKeymap: readonly KeyBinding[]; |
||||
/** |
||||
Markdown language support. |
||||
*/ |
||||
declare function markdown(config?: { |
||||
/** |
||||
When given, this language will be used by default to parse code |
||||
blocks. |
||||
*/ |
||||
defaultCodeLanguage?: Language | LanguageSupport; |
||||
/** |
||||
A source of language support for highlighting fenced code |
||||
blocks. When it is an array, the parser will use |
||||
[`LanguageDescription.matchLanguageName`](https://codemirror.net/6/docs/ref/#language.LanguageDescription^matchLanguageName) |
||||
with the fenced code info to find a matching language. When it |
||||
is a function, will be called with the info string and may |
||||
return a language or `LanguageDescription` object. |
||||
*/ |
||||
codeLanguages?: readonly LanguageDescription[] | ((info: string) => Language | LanguageDescription | null); |
||||
/** |
||||
Set this to false to disable installation of the Markdown |
||||
[keymap](https://codemirror.net/6/docs/ref/#lang-markdown.markdownKeymap). |
||||
*/ |
||||
addKeymap?: boolean; |
||||
/** |
||||
Markdown parser |
||||
[extensions](https://github.com/lezer-parser/markdown#user-content-markdownextension) |
||||
to add to the parser. |
||||
*/ |
||||
extensions?: MarkdownExtension; |
||||
/** |
||||
The base language to use. Defaults to |
||||
[`commonmarkLanguage`](https://codemirror.net/6/docs/ref/#lang-markdown.commonmarkLanguage). |
||||
*/ |
||||
base?: Language; |
||||
/** |
||||
By default, the extension installs an autocompletion source that |
||||
completes HTML tags when a `<` is typed. Set this to false to |
||||
disable this. |
||||
*/ |
||||
completeHTMLTags?: boolean; |
||||
/** |
||||
The returned language contains |
||||
[`pasteURLAsLink`](https://codemirror.net/6/docs/ref/#lang-markdown.pasteURLAsLink) as a support |
||||
extension unless you set this to false. |
||||
*/ |
||||
pasteURLAsLink?: boolean; |
||||
/** |
||||
By default, HTML tags in the document are handled by the [HTML |
||||
language](https://github.com/codemirror/lang-html) package with |
||||
tag matching turned off. You can pass in an alternative language |
||||
configuration here if you want. |
||||
*/ |
||||
htmlTagLanguage?: LanguageSupport; |
||||
}): LanguageSupport; |
||||
/** |
||||
An extension that intercepts pastes when the pasted content looks |
||||
like a URL and the selection is non-empty and selects regular |
||||
text, making the selection a link with the pasted URL as target. |
||||
*/ |
||||
declare const pasteURLAsLink: _codemirror_state.Extension; |
||||
|
||||
export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, insertNewlineContinueMarkupCommand, markdown, markdownKeymap, markdownLanguage, pasteURLAsLink }; |
||||
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { StateCommand } from '@codemirror/state'; |
||||
import { KeyBinding } from '@codemirror/view'; |
||||
import { Language, LanguageSupport, LanguageDescription } from '@codemirror/language'; |
||||
import { MarkdownExtension } from '@lezer/markdown'; |
||||
|
||||
/** |
||||
Language support for strict CommonMark. |
||||
*/ |
||||
declare const commonmarkLanguage: Language; |
||||
/** |
||||
Language support for [GFM](https://github.github.com/gfm/) plus
|
||||
subscript, superscript, and emoji syntax. |
||||
*/ |
||||
declare const markdownLanguage: Language; |
||||
|
||||
/** |
||||
Returns a command like |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup),
|
||||
allowing further configuration. |
||||
*/ |
||||
declare const insertNewlineContinueMarkupCommand: (config?: { |
||||
/** |
||||
By default, when pressing enter in a blank second item in a |
||||
tight (no blank lines between items) list, the command will |
||||
insert a blank line above that item, starting a non-tight list. |
||||
Set this to false to disable this behavior. |
||||
*/ |
||||
nonTightLists?: boolean; |
||||
}) => StateCommand; |
||||
/** |
||||
This command, when invoked in Markdown context with cursor |
||||
selection(s), will create a new line with the markup for |
||||
blockquotes and lists that were active on the old line. If the |
||||
cursor was directly after the end of the markup for the old line, |
||||
trailing whitespace and list markers are removed from that line. |
||||
|
||||
The command does nothing in non-Markdown context, so it should |
||||
not be used as the only binding for Enter (even in a Markdown |
||||
document, HTML and code regions might use a different language). |
||||
*/ |
||||
declare const insertNewlineContinueMarkup: StateCommand; |
||||
/** |
||||
This command will, when invoked in a Markdown context with the |
||||
cursor directly after list or blockquote markup, delete one level |
||||
of markup. When the markup is for a list, it will be replaced by |
||||
spaces on the first invocation (a further invocation will delete |
||||
the spaces), to make it easy to continue a list. |
||||
|
||||
When not after Markdown block markup, this command will return |
||||
false, so it is intended to be bound alongside other deletion |
||||
commands, with a higher precedence than the more generic commands. |
||||
*/ |
||||
declare const deleteMarkupBackward: StateCommand; |
||||
|
||||
/** |
||||
A small keymap with Markdown-specific bindings. Binds Enter to |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup)
|
||||
and Backspace to |
||||
[`deleteMarkupBackward`](https://codemirror.net/6/docs/ref/#lang-markdown.deleteMarkupBackward).
|
||||
*/ |
||||
declare const markdownKeymap: readonly KeyBinding[]; |
||||
/** |
||||
Markdown language support. |
||||
*/ |
||||
declare function markdown(config?: { |
||||
/** |
||||
When given, this language will be used by default to parse code |
||||
blocks. |
||||
*/ |
||||
defaultCodeLanguage?: Language | LanguageSupport; |
||||
/** |
||||
A source of language support for highlighting fenced code |
||||
blocks. When it is an array, the parser will use |
||||
[`LanguageDescription.matchLanguageName`](https://codemirror.net/6/docs/ref/#language.LanguageDescription^matchLanguageName)
|
||||
with the fenced code info to find a matching language. When it |
||||
is a function, will be called with the info string and may |
||||
return a language or `LanguageDescription` object. |
||||
*/ |
||||
codeLanguages?: readonly LanguageDescription[] | ((info: string) => Language | LanguageDescription | null); |
||||
/** |
||||
Set this to false to disable installation of the Markdown |
||||
[keymap](https://codemirror.net/6/docs/ref/#lang-markdown.markdownKeymap).
|
||||
*/ |
||||
addKeymap?: boolean; |
||||
/** |
||||
Markdown parser |
||||
[extensions](https://github.com/lezer-parser/markdown#user-content-markdownextension)
|
||||
to add to the parser. |
||||
*/ |
||||
extensions?: MarkdownExtension; |
||||
/** |
||||
The base language to use. Defaults to |
||||
[`commonmarkLanguage`](https://codemirror.net/6/docs/ref/#lang-markdown.commonmarkLanguage).
|
||||
*/ |
||||
base?: Language; |
||||
/** |
||||
By default, the extension installs an autocompletion source that |
||||
completes HTML tags when a `<` is typed. Set this to false to |
||||
disable this. |
||||
*/ |
||||
completeHTMLTags?: boolean; |
||||
/** |
||||
The returned language contains |
||||
[`pasteURLAsLink`](https://codemirror.net/6/docs/ref/#lang-markdown.pasteURLAsLink) as a support
|
||||
extension unless you set this to false. |
||||
*/ |
||||
pasteURLAsLink?: boolean; |
||||
/** |
||||
By default, HTML tags in the document are handled by the [HTML |
||||
language](https://github.com/codemirror/lang-html) package with
|
||||
tag matching turned off. You can pass in an alternative language |
||||
configuration here if you want. |
||||
*/ |
||||
htmlTagLanguage?: LanguageSupport; |
||||
}): LanguageSupport; |
||||
/** |
||||
An extension that intercepts pastes when the pasted content looks |
||||
like a URL and the selection is non-empty and selects regular |
||||
text, making the selection a link with the pasted URL as target. |
||||
*/ |
||||
declare const pasteURLAsLink: _codemirror_state.Extension; |
||||
|
||||
export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, insertNewlineContinueMarkupCommand, markdown, markdownKeymap, markdownLanguage, pasteURLAsLink }; |
||||
@ -0,0 +1,492 @@
@@ -0,0 +1,492 @@
|
||||
import { EditorSelection, countColumn, Prec, EditorState } from '@codemirror/state'; |
||||
import { EditorView, keymap } from '@codemirror/view'; |
||||
import { defineLanguageFacet, foldNodeProp, indentNodeProp, languageDataProp, foldService, syntaxTree, Language, LanguageDescription, ParseContext, indentUnit, LanguageSupport } from '@codemirror/language'; |
||||
import { CompletionContext } from '@codemirror/autocomplete'; |
||||
import { parser, GFM, Subscript, Superscript, Emoji, MarkdownParser, parseCode } from '@lezer/markdown'; |
||||
import { html, htmlCompletionSource } from '@codemirror/lang-html'; |
||||
import { NodeProp } from '@lezer/common'; |
||||
|
||||
const data = /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "<!--", close: "-->" } } }); |
||||
const headingProp = /*@__PURE__*/new NodeProp(); |
||||
const commonmark = /*@__PURE__*/parser.configure({ |
||||
props: [ |
||||
/*@__PURE__*/foldNodeProp.add(type => { |
||||
return !type.is("Block") || type.is("Document") || isHeading(type) != null || isList(type) ? undefined |
||||
: (tree, state) => ({ from: state.doc.lineAt(tree.from).to, to: tree.to }); |
||||
}), |
||||
/*@__PURE__*/headingProp.add(isHeading), |
||||
/*@__PURE__*/indentNodeProp.add({ |
||||
Document: () => null |
||||
}), |
||||
/*@__PURE__*/languageDataProp.add({ |
||||
Document: data |
||||
}) |
||||
] |
||||
}); |
||||
function isHeading(type) { |
||||
let match = /^(?:ATX|Setext)Heading(\d)$/.exec(type.name); |
||||
return match ? +match[1] : undefined; |
||||
} |
||||
function isList(type) { |
||||
return type.name == "OrderedList" || type.name == "BulletList"; |
||||
} |
||||
function findSectionEnd(headerNode, level) { |
||||
let last = headerNode; |
||||
for (;;) { |
||||
let next = last.nextSibling, heading; |
||||
if (!next || (heading = isHeading(next.type)) != null && heading <= level) |
||||
break; |
||||
last = next; |
||||
} |
||||
return last.to; |
||||
} |
||||
const headerIndent = /*@__PURE__*/foldService.of((state, start, end) => { |
||||
for (let node = syntaxTree(state).resolveInner(end, -1); node; node = node.parent) { |
||||
if (node.from < start) |
||||
break; |
||||
let heading = node.type.prop(headingProp); |
||||
if (heading == null) |
||||
continue; |
||||
let upto = findSectionEnd(node, heading); |
||||
if (upto > end) |
||||
return { from: end, to: upto }; |
||||
} |
||||
return null; |
||||
}); |
||||
function mkLang(parser) { |
||||
return new Language(data, parser, [], "markdown"); |
||||
} |
||||
/** |
||||
Language support for strict CommonMark. |
||||
*/ |
||||
const commonmarkLanguage = /*@__PURE__*/mkLang(commonmark); |
||||
const extended = /*@__PURE__*/commonmark.configure([GFM, Subscript, Superscript, Emoji, { |
||||
props: [ |
||||
/*@__PURE__*/foldNodeProp.add({ |
||||
Table: (tree, state) => ({ from: state.doc.lineAt(tree.from).to, to: tree.to }) |
||||
}) |
||||
] |
||||
}]); |
||||
/** |
||||
Language support for [GFM](https://github.github.com/gfm/) plus
|
||||
subscript, superscript, and emoji syntax. |
||||
*/ |
||||
const markdownLanguage = /*@__PURE__*/mkLang(extended); |
||||
function getCodeParser(languages, defaultLanguage) { |
||||
return (info) => { |
||||
if (info && languages) { |
||||
let found = null; |
||||
// Strip anything after whitespace
|
||||
info = /\S*/.exec(info)[0]; |
||||
if (typeof languages == "function") |
||||
found = languages(info); |
||||
else |
||||
found = LanguageDescription.matchLanguageName(languages, info, true); |
||||
if (found instanceof LanguageDescription) |
||||
return found.support ? found.support.language.parser : ParseContext.getSkippingParser(found.load()); |
||||
else if (found) |
||||
return found.parser; |
||||
} |
||||
return defaultLanguage ? defaultLanguage.parser : null; |
||||
}; |
||||
} |
||||
|
||||
class Context { |
||||
constructor(node, from, to, spaceBefore, spaceAfter, type, item) { |
||||
this.node = node; |
||||
this.from = from; |
||||
this.to = to; |
||||
this.spaceBefore = spaceBefore; |
||||
this.spaceAfter = spaceAfter; |
||||
this.type = type; |
||||
this.item = item; |
||||
} |
||||
blank(maxWidth, trailing = true) { |
||||
let result = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : ""); |
||||
if (maxWidth != null) { |
||||
while (result.length < maxWidth) |
||||
result += " "; |
||||
return result; |
||||
} |
||||
else { |
||||
for (let i = this.to - this.from - result.length - this.spaceAfter.length; i > 0; i--) |
||||
result += " "; |
||||
return result + (trailing ? this.spaceAfter : ""); |
||||
} |
||||
} |
||||
marker(doc, add) { |
||||
let number = this.node.name == "OrderedList" ? String((+itemNumber(this.item, doc)[2] + add)) : ""; |
||||
return this.spaceBefore + number + this.type + this.spaceAfter; |
||||
} |
||||
} |
||||
function getContext(node, doc) { |
||||
let nodes = [], context = []; |
||||
for (let cur = node; cur; cur = cur.parent) { |
||||
if (cur.name == "FencedCode") |
||||
return context; |
||||
if (cur.name == "ListItem" || cur.name == "Blockquote") |
||||
nodes.push(cur); |
||||
} |
||||
for (let i = nodes.length - 1; i >= 0; i--) { |
||||
let node = nodes[i], match; |
||||
let line = doc.lineAt(node.from), startPos = node.from - line.from; |
||||
if (node.name == "Blockquote" && (match = /^ *>( ?)/.exec(line.text.slice(startPos)))) { |
||||
context.push(new Context(node, startPos, startPos + match[0].length, "", match[1], ">", null)); |
||||
} |
||||
else if (node.name == "ListItem" && node.parent.name == "OrderedList" && |
||||
(match = /^( *)\d+([.)])( *)/.exec(line.text.slice(startPos)))) { |
||||
let after = match[3], len = match[0].length; |
||||
if (after.length >= 4) { |
||||
after = after.slice(0, after.length - 4); |
||||
len -= 4; |
||||
} |
||||
context.push(new Context(node.parent, startPos, startPos + len, match[1], after, match[2], node)); |
||||
} |
||||
else if (node.name == "ListItem" && node.parent.name == "BulletList" && |
||||
(match = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(line.text.slice(startPos)))) { |
||||
let after = match[4], len = match[0].length; |
||||
if (after.length > 4) { |
||||
after = after.slice(0, after.length - 4); |
||||
len -= 4; |
||||
} |
||||
let type = match[2]; |
||||
if (match[3]) |
||||
type += match[3].replace(/[xX]/, ' '); |
||||
context.push(new Context(node.parent, startPos, startPos + len, match[1], after, type, node)); |
||||
} |
||||
} |
||||
return context; |
||||
} |
||||
function itemNumber(item, doc) { |
||||
return /^(\s*)(\d+)(?=[.)])/.exec(doc.sliceString(item.from, item.from + 10)); |
||||
} |
||||
function renumberList(after, doc, changes, offset = 0) { |
||||
for (let prev = -1, node = after;;) { |
||||
if (node.name == "ListItem") { |
||||
let m = itemNumber(node, doc); |
||||
let number = +m[2]; |
||||
if (prev >= 0) { |
||||
if (number != prev + 1) |
||||
return; |
||||
changes.push({ from: node.from + m[1].length, to: node.from + m[0].length, insert: String(prev + 2 + offset) }); |
||||
} |
||||
prev = number; |
||||
} |
||||
let next = node.nextSibling; |
||||
if (!next) |
||||
break; |
||||
node = next; |
||||
} |
||||
} |
||||
function normalizeIndent(content, state) { |
||||
let blank = /^[ \t]*/.exec(content)[0].length; |
||||
if (!blank || state.facet(indentUnit) != "\t") |
||||
return content; |
||||
let col = countColumn(content, 4, blank); |
||||
let space = ""; |
||||
for (let i = col; i > 0;) { |
||||
if (i >= 4) { |
||||
space += "\t"; |
||||
i -= 4; |
||||
} |
||||
else { |
||||
space += " "; |
||||
i--; |
||||
} |
||||
} |
||||
return space + content.slice(blank); |
||||
} |
||||
/** |
||||
Returns a command like |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup),
|
||||
allowing further configuration. |
||||
*/ |
||||
const insertNewlineContinueMarkupCommand = (config = {}) => ({ state, dispatch }) => { |
||||
let tree = syntaxTree(state), { doc } = state; |
||||
let dont = null, changes = state.changeByRange(range => { |
||||
if (!range.empty || !markdownLanguage.isActiveAt(state, range.from, -1) && !markdownLanguage.isActiveAt(state, range.from, 1)) |
||||
return dont = { range }; |
||||
let pos = range.from, line = doc.lineAt(pos); |
||||
let context = getContext(tree.resolveInner(pos, -1), doc); |
||||
while (context.length && context[context.length - 1].from > pos - line.from) |
||||
context.pop(); |
||||
if (!context.length) |
||||
return dont = { range }; |
||||
let inner = context[context.length - 1]; |
||||
if (inner.to - inner.spaceAfter.length > pos - line.from) |
||||
return dont = { range }; |
||||
let emptyLine = pos >= (inner.to - inner.spaceAfter.length) && !/\S/.test(line.text.slice(inner.to)); |
||||
// Empty line in list
|
||||
if (inner.item && emptyLine) { |
||||
let first = inner.node.firstChild, second = inner.node.getChild("ListItem", "ListItem"); |
||||
// Not second item or blank line before: delete a level of markup
|
||||
if (first.to >= pos || second && second.to < pos || |
||||
line.from > 0 && !/[^\s>]/.test(doc.lineAt(line.from - 1).text) || |
||||
config.nonTightLists === false) { |
||||
let next = context.length > 1 ? context[context.length - 2] : null; |
||||
let delTo, insert = ""; |
||||
if (next && next.item) { // Re-add marker for the list at the next level
|
||||
delTo = line.from + next.from; |
||||
insert = next.marker(doc, 1); |
||||
} |
||||
else { |
||||
delTo = line.from + (next ? next.to : 0); |
||||
} |
||||
let changes = [{ from: delTo, to: pos, insert }]; |
||||
if (inner.node.name == "OrderedList") |
||||
renumberList(inner.item, doc, changes, -2); |
||||
if (next && next.node.name == "OrderedList") |
||||
renumberList(next.item, doc, changes); |
||||
return { range: EditorSelection.cursor(delTo + insert.length), changes }; |
||||
} |
||||
else { // Move second item down, making tight two-item list non-tight
|
||||
let insert = blankLine(context, state, line); |
||||
return { range: EditorSelection.cursor(pos + insert.length + 1), |
||||
changes: { from: line.from, insert: insert + state.lineBreak } }; |
||||
} |
||||
} |
||||
if (inner.node.name == "Blockquote" && emptyLine && line.from) { |
||||
let prevLine = doc.lineAt(line.from - 1), quoted = />\s*$/.exec(prevLine.text); |
||||
// Two aligned empty quoted lines in a row
|
||||
if (quoted && quoted.index == inner.from) { |
||||
let changes = state.changes([{ from: prevLine.from + quoted.index, to: prevLine.to }, |
||||
{ from: line.from + inner.from, to: line.to }]); |
||||
return { range: range.map(changes), changes }; |
||||
} |
||||
} |
||||
let changes = []; |
||||
if (inner.node.name == "OrderedList") |
||||
renumberList(inner.item, doc, changes); |
||||
let continued = inner.item && inner.item.from < line.from; |
||||
let insert = ""; |
||||
// If not dedented
|
||||
if (!continued || /^[\s\d.)\-+*>]*/.exec(line.text)[0].length >= inner.to) { |
||||
for (let i = 0, e = context.length - 1; i <= e; i++) { |
||||
insert += i == e && !continued ? context[i].marker(doc, 1) |
||||
: context[i].blank(i < e ? countColumn(line.text, 4, context[i + 1].from) - insert.length : null); |
||||
} |
||||
} |
||||
let from = pos; |
||||
while (from > line.from && /\s/.test(line.text.charAt(from - line.from - 1))) |
||||
from--; |
||||
insert = normalizeIndent(insert, state); |
||||
if (nonTightList(inner.node, state.doc)) |
||||
insert = blankLine(context, state, line) + state.lineBreak + insert; |
||||
changes.push({ from, to: pos, insert: state.lineBreak + insert }); |
||||
return { range: EditorSelection.cursor(from + insert.length + 1), changes }; |
||||
}); |
||||
if (dont) |
||||
return false; |
||||
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" })); |
||||
return true; |
||||
}; |
||||
/** |
||||
This command, when invoked in Markdown context with cursor |
||||
selection(s), will create a new line with the markup for |
||||
blockquotes and lists that were active on the old line. If the |
||||
cursor was directly after the end of the markup for the old line, |
||||
trailing whitespace and list markers are removed from that line. |
||||
|
||||
The command does nothing in non-Markdown context, so it should |
||||
not be used as the only binding for Enter (even in a Markdown |
||||
document, HTML and code regions might use a different language). |
||||
*/ |
||||
const insertNewlineContinueMarkup = /*@__PURE__*/insertNewlineContinueMarkupCommand(); |
||||
function isMark(node) { |
||||
return node.name == "QuoteMark" || node.name == "ListMark"; |
||||
} |
||||
function nonTightList(node, doc) { |
||||
if (node.name != "OrderedList" && node.name != "BulletList") |
||||
return false; |
||||
let first = node.firstChild, second = node.getChild("ListItem", "ListItem"); |
||||
if (!second) |
||||
return false; |
||||
let line1 = doc.lineAt(first.to), line2 = doc.lineAt(second.from); |
||||
let empty = /^[\s>]*$/.test(line1.text); |
||||
return line1.number + (empty ? 0 : 1) < line2.number; |
||||
} |
||||
function blankLine(context, state, line) { |
||||
let insert = ""; |
||||
for (let i = 0, e = context.length - 2; i <= e; i++) { |
||||
insert += context[i].blank(i < e |
||||
? countColumn(line.text, 4, context[i + 1].from) - insert.length |
||||
: null, i < e); |
||||
} |
||||
return normalizeIndent(insert, state); |
||||
} |
||||
function contextNodeForDelete(tree, pos) { |
||||
let node = tree.resolveInner(pos, -1), scan = pos; |
||||
if (isMark(node)) { |
||||
scan = node.from; |
||||
node = node.parent; |
||||
} |
||||
for (let prev; prev = node.childBefore(scan);) { |
||||
if (isMark(prev)) { |
||||
scan = prev.from; |
||||
} |
||||
else if (prev.name == "OrderedList" || prev.name == "BulletList") { |
||||
node = prev.lastChild; |
||||
scan = node.to; |
||||
} |
||||
else { |
||||
break; |
||||
} |
||||
} |
||||
return node; |
||||
} |
||||
/** |
||||
This command will, when invoked in a Markdown context with the |
||||
cursor directly after list or blockquote markup, delete one level |
||||
of markup. When the markup is for a list, it will be replaced by |
||||
spaces on the first invocation (a further invocation will delete |
||||
the spaces), to make it easy to continue a list. |
||||
|
||||
When not after Markdown block markup, this command will return |
||||
false, so it is intended to be bound alongside other deletion |
||||
commands, with a higher precedence than the more generic commands. |
||||
*/ |
||||
const deleteMarkupBackward = ({ state, dispatch }) => { |
||||
let tree = syntaxTree(state); |
||||
let dont = null, changes = state.changeByRange(range => { |
||||
let pos = range.from, { doc } = state; |
||||
if (range.empty && markdownLanguage.isActiveAt(state, range.from)) { |
||||
let line = doc.lineAt(pos); |
||||
let context = getContext(contextNodeForDelete(tree, pos), doc); |
||||
if (context.length) { |
||||
let inner = context[context.length - 1]; |
||||
let spaceEnd = inner.to - inner.spaceAfter.length + (inner.spaceAfter ? 1 : 0); |
||||
// Delete extra trailing space after markup
|
||||
if (pos - line.from > spaceEnd && !/\S/.test(line.text.slice(spaceEnd, pos - line.from))) |
||||
return { range: EditorSelection.cursor(line.from + spaceEnd), |
||||
changes: { from: line.from + spaceEnd, to: pos } }; |
||||
if (pos - line.from == spaceEnd && |
||||
// Only apply this if we're on the line that has the
|
||||
// construct's syntax, or there's only indentation in the
|
||||
// target range
|
||||
(!inner.item || line.from <= inner.item.from || !/\S/.test(line.text.slice(0, inner.to)))) { |
||||
let start = line.from + inner.from; |
||||
// Replace a list item marker with blank space
|
||||
if (inner.item && inner.node.from < inner.item.from && /\S/.test(line.text.slice(inner.from, inner.to))) { |
||||
let insert = inner.blank(countColumn(line.text, 4, inner.to) - countColumn(line.text, 4, inner.from)); |
||||
if (start == line.from) |
||||
insert = normalizeIndent(insert, state); |
||||
return { range: EditorSelection.cursor(start + insert.length), |
||||
changes: { from: start, to: line.from + inner.to, insert } }; |
||||
} |
||||
// Delete one level of indentation
|
||||
if (start < pos) |
||||
return { range: EditorSelection.cursor(start), changes: { from: start, to: pos } }; |
||||
} |
||||
} |
||||
} |
||||
return dont = { range }; |
||||
}); |
||||
if (dont) |
||||
return false; |
||||
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "delete" })); |
||||
return true; |
||||
}; |
||||
|
||||
/** |
||||
A small keymap with Markdown-specific bindings. Binds Enter to |
||||
[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup)
|
||||
and Backspace to |
||||
[`deleteMarkupBackward`](https://codemirror.net/6/docs/ref/#lang-markdown.deleteMarkupBackward).
|
||||
*/ |
||||
const markdownKeymap = [ |
||||
{ key: "Enter", run: insertNewlineContinueMarkup }, |
||||
{ key: "Backspace", run: deleteMarkupBackward } |
||||
]; |
||||
const htmlNoMatch = /*@__PURE__*/html({ matchClosingTags: false }); |
||||
/** |
||||
Markdown language support. |
||||
*/ |
||||
function markdown(config = {}) { |
||||
let { codeLanguages, defaultCodeLanguage, addKeymap = true, base: { parser } = commonmarkLanguage, completeHTMLTags = true, pasteURLAsLink: pasteURL = true, htmlTagLanguage = htmlNoMatch } = config; |
||||
if (!(parser instanceof MarkdownParser)) |
||||
throw new RangeError("Base parser provided to `markdown` should be a Markdown parser"); |
||||
let extensions = config.extensions ? [config.extensions] : []; |
||||
let support = [htmlTagLanguage.support, headerIndent], defaultCode; |
||||
if (pasteURL) |
||||
support.push(pasteURLAsLink); |
||||
if (defaultCodeLanguage instanceof LanguageSupport) { |
||||
support.push(defaultCodeLanguage.support); |
||||
defaultCode = defaultCodeLanguage.language; |
||||
} |
||||
else if (defaultCodeLanguage) { |
||||
defaultCode = defaultCodeLanguage; |
||||
} |
||||
let codeParser = codeLanguages || defaultCode ? getCodeParser(codeLanguages, defaultCode) : undefined; |
||||
extensions.push(parseCode({ codeParser, htmlParser: htmlTagLanguage.language.parser })); |
||||
if (addKeymap) |
||||
support.push(Prec.high(keymap.of(markdownKeymap))); |
||||
let lang = mkLang(parser.configure(extensions)); |
||||
if (completeHTMLTags) |
||||
support.push(lang.data.of({ autocomplete: htmlTagCompletion })); |
||||
return new LanguageSupport(lang, support); |
||||
} |
||||
function htmlTagCompletion(context) { |
||||
let { state, pos } = context, m = /<[:\-\.\w\u00b7-\uffff]*$/.exec(state.sliceDoc(pos - 25, pos)); |
||||
if (!m) |
||||
return null; |
||||
let tree = syntaxTree(state).resolveInner(pos, -1); |
||||
while (tree && !tree.type.isTop) { |
||||
if (tree.name == "CodeBlock" || tree.name == "FencedCode" || tree.name == "ProcessingInstructionBlock" || |
||||
tree.name == "CommentBlock" || tree.name == "Link" || tree.name == "Image") |
||||
return null; |
||||
tree = tree.parent; |
||||
} |
||||
return { |
||||
from: pos - m[0].length, to: pos, |
||||
options: htmlTagCompletions(), |
||||
validFor: /^<[:\-\.\w\u00b7-\uffff]*$/ |
||||
}; |
||||
} |
||||
let _tagCompletions = null; |
||||
function htmlTagCompletions() { |
||||
if (_tagCompletions) |
||||
return _tagCompletions; |
||||
let result = htmlCompletionSource(new CompletionContext(EditorState.create({ extensions: htmlNoMatch }), 0, true)); |
||||
return _tagCompletions = result ? result.options : []; |
||||
} |
||||
const nonPlainText = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i; |
||||
/** |
||||
An extension that intercepts pastes when the pasted content looks |
||||
like a URL and the selection is non-empty and selects regular |
||||
text, making the selection a link with the pasted URL as target. |
||||
*/ |
||||
const pasteURLAsLink = /*@__PURE__*/EditorView.domEventHandlers({ |
||||
paste: (event, view) => { |
||||
var _a; |
||||
let { main } = view.state.selection; |
||||
if (main.empty) |
||||
return false; |
||||
let link = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text/plain"); |
||||
if (!link || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(link)) |
||||
return false; |
||||
if (/^www\./.test(link)) |
||||
link = "https://" + link; |
||||
if (!markdownLanguage.isActiveAt(view.state, main.from, 1)) |
||||
return false; |
||||
let tree = syntaxTree(view.state), crossesNode = false; |
||||
// Verify that no nodes are started/ended between the selection
|
||||
// points, and we're not inside any non-plain-text construct.
|
||||
tree.iterate({ |
||||
from: main.from, to: main.to, |
||||
enter: node => { if (node.from > main.from || nonPlainText.test(node.name)) |
||||
crossesNode = true; }, |
||||
leave: node => { if (node.to < main.to) |
||||
crossesNode = true; } |
||||
}); |
||||
if (crossesNode) |
||||
return false; |
||||
view.dispatch({ |
||||
changes: [{ from: main.from, insert: "[" }, { from: main.to, insert: `](${link})` }], |
||||
userEvent: "input.paste", |
||||
scrollIntoView: true |
||||
}); |
||||
return true; |
||||
} |
||||
}); |
||||
|
||||
export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, insertNewlineContinueMarkupCommand, markdown, markdownKeymap, markdownLanguage, pasteURLAsLink }; |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
{ |
||||
"name": "@codemirror/lang-markdown", |
||||
"version": "6.5.0", |
||||
"description": "Markdown language support for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/index.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/autocomplete": "^6.7.1", |
||||
"@codemirror/lang-html": "^6.0.0", |
||||
"@codemirror/language": "^6.3.0", |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.0.0", |
||||
"@lezer/markdown": "^1.0.0", |
||||
"@lezer/common": "^1.2.1" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/lang-markdown.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,398 @@
@@ -0,0 +1,398 @@
|
||||
## 6.12.1 (2025-12-22) |
||||
|
||||
### Bug fixes |
||||
|
||||
Improve finding inner language in syntax tree when the nested parse has been marked as bracketed. |
||||
|
||||
## 6.11.3 (2025-08-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make the stream parser user 4 times smaller chunks to reduce the amount of re-parsed code on changes. |
||||
|
||||
## 6.11.2 (2025-06-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure folded ranges open when backspacing or deleting into them. |
||||
|
||||
## 6.11.1 (2025-06-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where indentation would sometimes miss nodes in mixed-language situations. |
||||
|
||||
## 6.11.0 (2025-03-13) |
||||
|
||||
### New features |
||||
|
||||
Stream parsers now support a `mergeTokens` option that can be used to turn off automatic merging of adjacent tokens. |
||||
|
||||
## 6.10.8 (2024-12-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression introduced 6.10.7 that caused indention to sometimes crash on nested language boundaries. |
||||
|
||||
## 6.10.7 (2024-12-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where indentation for a stream language would fail to work when the parse covered only part of the document, far from the start. |
||||
|
||||
Make sure the inner mode gets a chance to indent when indenting right at the end of a nested language section. |
||||
|
||||
## 6.10.6 (2024-11-29) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a crash in `StreamLanguage` when the input range is entirely before the editor viewport. |
||||
|
||||
## 6.10.5 (2024-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where a `StreamLanguage` could get confused when trying to reuse existing parse data when the parsed range changed. |
||||
|
||||
## 6.10.4 (2024-11-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Join adjacent tokens of the same type into a single token in . |
||||
|
||||
Call stream language indent functions even when the language is used as a nested parser. |
||||
|
||||
Fix a crash in `StreamParser` when a parse was resumed with different input ranges. |
||||
|
||||
## 6.10.3 (2024-09-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a TypeScript error when using `HighlightStyle` with the `exactOptionalPropertyTypes` typechecking option enabled. |
||||
|
||||
Make `delimitedIndent` align to spaces after the opening token. |
||||
|
||||
## 6.10.2 (2024-06-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an infinite loop that could occur when enabling `bidiIsolates` in documents with both bidirectional text and very long lines. |
||||
|
||||
## 6.10.1 (2024-02-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where, when a lot of code is visible in the initial editor, the bottom bit of code is shown without highlighting for one frame. |
||||
|
||||
## 6.10.0 (2023-12-28) |
||||
|
||||
### New features |
||||
|
||||
The new `bidiIsolates` extension can be used to wrap syntactic elements where this is appropriate in an element that isolates their text direction, avoiding weird ordering of neutral characters on direction boundaries. |
||||
|
||||
## 6.9.3 (2023-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue in `StreamLanguage` where it ran out of node type ids if you repeatedly redefined a language with the same token table. |
||||
|
||||
## 6.9.2 (2023-10-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Allow `StreamParser` tokens get multiple highlighting tags. |
||||
|
||||
## 6.9.1 (2023-09-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
Indentation now works a lot better in mixed-language documents that interleave the languages in a complex way. |
||||
|
||||
Code folding is now able to pick the right foldable syntax node when the line end falls in a mixed-parsing language that doesn't match the target node. |
||||
|
||||
## 6.9.0 (2023-08-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `getIndentation` return null, rather than 0, when there is no syntax tree available. |
||||
|
||||
### New features |
||||
|
||||
The new `preparePlaceholder` option to `codeFolding` makes it possible to display contextual information in a folded range placeholder widget. |
||||
|
||||
## 6.8.0 (2023-06-12) |
||||
|
||||
### New features |
||||
|
||||
The new `baseIndentFor` method in `TreeIndentContext` can be used to find the base indentation for an arbitrary node. |
||||
|
||||
## 6.7.0 (2023-05-19) |
||||
|
||||
### New features |
||||
|
||||
Export `DocInput` class for feeding editor documents to a Lezer parser. |
||||
|
||||
## 6.6.0 (2023-02-13) |
||||
|
||||
### New features |
||||
|
||||
Syntax-driven language data queries now support sublanguages, which make it possible to return different data for specific parts of the tree produced by a single language. |
||||
|
||||
## 6.5.0 (2023-02-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make indentation for stream languages more reliable by having `StringStream.indentation` return overridden indentations from the indent context. |
||||
|
||||
### New features |
||||
|
||||
The `toggleFold` command folds or unfolds depending on whether there's an existing folded range on the current line. |
||||
|
||||
`indentUnit` now accepts any (repeated) whitespace character, not just spaces and tabs. |
||||
|
||||
## 6.4.0 (2023-01-12) |
||||
|
||||
### New features |
||||
|
||||
The `bracketMatchingHandle` node prop can now be used to limit bracket matching behavior for larger nodes to a single subnode (for example the tag name of an HTML tag). |
||||
|
||||
## 6.3.2 (2022-12-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused `ensureSyntaxTree` to return incomplete trees when using a viewport-aware parser like `StreamLanguage`. |
||||
|
||||
## 6.3.1 (2022-11-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make syntax-based folding include syntax nodes that start right at the end of a line as potential fold targets. |
||||
|
||||
Fix the `indentService` protocol to allow a distinction between declining to handle the indentation and returning null to indicate the line has no definite indentation. |
||||
|
||||
## 6.3.0 (2022-10-24) |
||||
|
||||
### New features |
||||
|
||||
`HighlightStyle` objects now have a `specs` property holding the tag styles that were used to define them. |
||||
|
||||
`Language` objects now have a `name` field holding the language name. |
||||
|
||||
## 6.2.1 (2022-07-21) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where `bracketMatching` would incorrectly match nested brackets in syntax trees that put multiple pairs of brackets in the same parent node. |
||||
|
||||
Fix a bug that could cause `indentRange` to loop infinitely. |
||||
|
||||
## 6.2.0 (2022-06-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that prevented bracket matching to recognize plain brackets inside a language parsed as an overlay. |
||||
|
||||
### New features |
||||
|
||||
The `indentRange` function provides an easy way to programatically auto-indent a range of the document. |
||||
|
||||
## 6.1.0 (2022-06-20) |
||||
|
||||
### New features |
||||
|
||||
The `foldState` field is now public, and can be used to serialize and deserialize the fold state. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### New features |
||||
|
||||
The `foldingChanged` option to `foldGutter` can now be used to trigger a recomputation of the fold markers. |
||||
|
||||
## 0.20.2 (2022-05-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
List style-mod as a dependency. |
||||
|
||||
## 0.20.1 (2022-05-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure `all` styles in the CSS generated for a `HighlightStyle` have a lower precedence than the other rules defined for the style. Use a shorthand property |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Breaking changes |
||||
|
||||
`HighlightStyle.get` is now called `highlightingFor`. |
||||
|
||||
`HighlightStyles` no longer function as extensions (to improve tree shaking), and must be wrapped with `syntaxHighlighting` to add to an editor configuration. |
||||
|
||||
`Language` objects no longer have a `topNode` property. |
||||
|
||||
### New features |
||||
|
||||
`HighlightStyle` and `defaultHighlightStyle` from the now-removed @codemirror/highlight package now live in this package. |
||||
|
||||
The new `forceParsing` function can be used to run the parser forward on an editor view. |
||||
|
||||
The exports that used to live in @codemirror/matchbrackets are now exported from this package. |
||||
|
||||
The @codemirror/fold package has been merged into this one. |
||||
|
||||
The exports from the old @codemirror/stream-parser package now live in this package. |
||||
|
||||
## 0.19.10 (2022-03-31) |
||||
|
||||
### Bug fixes |
||||
|
||||
Autocompletion may now also trigger automatic indentation on input. |
||||
|
||||
## 0.19.9 (2022-03-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure nodes that end at the end of a partial parse aren't treated as valid fold targets. |
||||
|
||||
Fix an issue where the parser sometimes wouldn't reuse parsing work done in the background on transactions. |
||||
|
||||
## 0.19.8 (2022-03-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue that could cause indentation logic to use the wrong line content when indenting multiple lines at once. |
||||
|
||||
## 0.19.7 (2021-12-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where the parse worker could incorrectly stop working when the parse tree has skipped gaps in it. |
||||
|
||||
## 0.19.6 (2021-11-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fixes an issue where the background parse work would be scheduled too aggressively, degrading responsiveness on a newly-created editor with a large document. |
||||
|
||||
Improve initial highlight for mixed-language editors and limit the amount of parsing done on state creation for faster startup. |
||||
|
||||
## 0.19.5 (2021-11-17) |
||||
|
||||
### New features |
||||
|
||||
The new function `syntaxTreeAvailable` can be used to check if a fully-parsed syntax tree is available up to a given document position. |
||||
|
||||
The module now exports `syntaxParserRunning`, which tells you whether the background parser is still planning to do more work for a given editor view. |
||||
|
||||
## 0.19.4 (2021-11-13) |
||||
|
||||
### New features |
||||
|
||||
`LanguageDescription.of` now takes an optional already-loaded extension. |
||||
|
||||
## 0.19.3 (2021-09-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where a parse that skipped content with `skipUntilInView` would in some cases not be restarted when the range came into view. |
||||
|
||||
## 0.19.2 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused `indentOnInput` to fire for the wrong kinds of transactions. |
||||
|
||||
Fix a bug that could cause `indentOnInput` to apply its changes incorrectly. |
||||
|
||||
## 0.19.1 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix incorrect versions for @lezer dependencies. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
CodeMirror now uses lezer 0.15, which means different package names (scoped with @lezer) and some breaking changes in the library. |
||||
|
||||
`EditorParseContext` is now called `ParseContext`. It is no longer passed to parsers, but must be retrieved with `ParseContext.get`. |
||||
|
||||
`IndentContext.lineIndent` now takes a position, not a `Line` object, as argument. |
||||
|
||||
`LezerLanguage` was renamed to `LRLanguage` (because all languages must emit Lezer-style trees, the name was misleading). |
||||
|
||||
`Language.parseString` no longer exists. You can just call `.parser.parse(...)` instead. |
||||
|
||||
### New features |
||||
|
||||
New `IndentContext.lineAt` method to access lines in a way that is aware of simulated line breaks. |
||||
|
||||
`IndentContext` now provides a `simulatedBreak` property through which client code can query whether the context has a simulated line break. |
||||
|
||||
## 0.18.2 (2021-06-01) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where asynchronous re-parsing (with dynamically loaded languages) sometimes failed to fully happen. |
||||
|
||||
## 0.18.1 (2021-03-31) |
||||
|
||||
### Breaking changes |
||||
|
||||
`EditorParseContext.getSkippingParser` now replaces `EditorParseContext.skippingParser` and allows you to provide a promise that'll cause parsing to start again. (The old property remains available until the next major release.) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where nested parsers could see past the end of the nested region. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.18. |
||||
|
||||
### Breaking changes |
||||
|
||||
The `Language` constructor takes an additional argument that provides the top node type. |
||||
|
||||
### New features |
||||
|
||||
`Language` instances now have a `topNode` property giving their top node type. |
||||
|
||||
`TreeIndentContext` now has a `continue` method that allows an indenter to defer to the indentation of the parent nodes. |
||||
|
||||
## 0.17.5 (2021-02-19) |
||||
|
||||
### New features |
||||
|
||||
This package now exports a `foldInside` helper function, a fold function that should work for most delimited node types. |
||||
|
||||
## 0.17.4 (2021-01-15) |
||||
|
||||
## 0.17.3 (2021-01-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Parse scheduling has been improved to reduce the likelyhood of the user looking at unparsed code in big documents. |
||||
|
||||
Prevent parser from running too far past the current viewport in huge documents. |
||||
|
||||
## 0.17.2 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.1 (2020-12-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where changing the editor configuration wouldn't update the language parser used. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
# @codemirror/language [](https://www.npmjs.org/package/@codemirror/language) |
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#language) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/language/blob/main/CHANGELOG.md) ] |
||||
|
||||
This package implements the language support infrastructure for the |
||||
[CodeMirror](https://codemirror.net/) code editor. |
||||
|
||||
The [project page](https://codemirror.net/) has more information, a |
||||
number of [examples](https://codemirror.net/examples/) and the |
||||
[documentation](https://codemirror.net/docs/). |
||||
|
||||
This code is released under an |
||||
[MIT license](https://github.com/codemirror/language/tree/main/LICENSE). |
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit, |
||||
we have a [code of |
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies |
||||
to communication around the project. |
||||
|
||||
## Usage |
||||
|
||||
Setting up a language from a [Lezer](https://lezer.codemirror.net) |
||||
parser looks like this: |
||||
|
||||
```javascript |
||||
import {parser} from "@lezer/json" |
||||
import {LRLanguage, continuedIndent, indentNodeProp, |
||||
foldNodeProp, foldInside} from "@codemirror/language" |
||||
|
||||
export const jsonLanguage = LRLanguage.define({ |
||||
name: "json", |
||||
parser: parser.configure({ |
||||
props: [ |
||||
indentNodeProp.add({ |
||||
Object: continuedIndent({except: /^\s*\}/}), |
||||
Array: continuedIndent({except: /^\s*\]/}) |
||||
}), |
||||
foldNodeProp.add({ |
||||
"Object Array": foldInside |
||||
}) |
||||
] |
||||
}), |
||||
languageData: { |
||||
closeBrackets: {brackets: ["[", "{", '"']}, |
||||
indentOnInput: /^\s*[\}\]]$/ |
||||
} |
||||
}) |
||||
``` |
||||
|
||||
Often, you'll also use this package just to access some specific |
||||
language-related features, such as accessing the editor's syntax |
||||
tree... |
||||
|
||||
```javascript |
||||
import {syntaxTree} from "@codemirror/language" |
||||
|
||||
const tree = syntaxTree(view) |
||||
``` |
||||
|
||||
... or computing the appriate indentation at a given point. |
||||
|
||||
```javascript |
||||
import {getIndentation} from "@codemirror/language" |
||||
|
||||
console.log(getIndentation(view.state, view.state.selection.main.head)) |
||||
``` |
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
{ |
||||
"name": "@codemirror/language", |
||||
"version": "6.12.1", |
||||
"description": "Language support infrastructure for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/index.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.23.0", |
||||
"@lezer/common": "^1.5.0", |
||||
"@lezer/highlight": "^1.0.0", |
||||
"@lezer/lr": "^1.0.0", |
||||
"style-mod": "^4.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0", |
||||
"@lezer/javascript": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/language.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,300 @@
@@ -0,0 +1,300 @@
|
||||
## 6.9.2 (2025-11-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an infinite loop that would occur when a diagnostic pointed beyond the end of the document. |
||||
|
||||
## 6.9.1 (2025-10-23) |
||||
|
||||
### Bug fixes |
||||
|
||||
Properly display diagnostics that just cover multiple newlines as widgets. |
||||
|
||||
## 6.9.0 (2025-10-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
Multiple configurations to `linter` will now be merged without raising an error. |
||||
|
||||
### New features |
||||
|
||||
The new `markClass` option to actions makes it possible to style action buttons. |
||||
|
||||
## 6.8.5 (2025-03-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression (since 6.8.4) that broke the `markerFilter` option. |
||||
|
||||
## 6.8.4 (2024-11-28) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't create overlapping decorations when diagnostics overlap. |
||||
|
||||
Fix an issue where block widgets could cause the lint gutter to show diagnostics multiple times. |
||||
|
||||
## 6.8.3 (2024-11-21) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue that prevented tooltips in the lint gutter from being displayed. |
||||
|
||||
## 6.8.2 (2024-09-24) |
||||
|
||||
### Bug fixes |
||||
|
||||
Show lint markers for code replaced by a block widget. |
||||
|
||||
When multiple linters are installed, start displaying results from ones that return quickly even if others are slow to return. |
||||
|
||||
## 6.8.1 (2024-06-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make lint markers non-inclusive again, since having them that way causes more issues than it solves. |
||||
|
||||
## 6.8.0 (2024-05-23) |
||||
|
||||
### New features |
||||
|
||||
The new `autoPanel` option can be used to make the panel automatically appear when diagnostics are added and close when no diagnostics are left. |
||||
|
||||
## 6.7.1 (2024-05-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't perform an additional superfluous timed lint run after `forceLinting` has been called. |
||||
|
||||
## 6.7.0 (2024-04-30) |
||||
|
||||
### New features |
||||
|
||||
The `renderMessage` function is now called with the editor view as first argument. |
||||
|
||||
## 6.6.0 (2024-04-29) |
||||
|
||||
### New features |
||||
|
||||
The new `hideOn` configuration option can be used to control in what circumstances lint tooltips get hidden by state changes. |
||||
|
||||
## 6.5.0 (2024-01-30) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make lint mark decorations inclusive, so that they are applied even if the marked content is replaced by a widget decoration. |
||||
|
||||
### New features |
||||
|
||||
`linter` can now be called with null as source to only provide a configuration. |
||||
|
||||
`markerFilter` and `tooltipFilter` function now get passed the current editor state. |
||||
|
||||
## 6.4.2 (2023-09-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure scrolling diagnostic into view in the panel works when the editor is scaled. |
||||
|
||||
## 6.4.1 (2023-08-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a crash that could occur when a view was reconfigured in a way that removed the lint extension. |
||||
|
||||
## 6.4.0 (2023-07-03) |
||||
|
||||
### New features |
||||
|
||||
Diagnostics can now use `"hint"` as a severity level. |
||||
|
||||
Diagnostics can now set a `markClass` property to add an additional CSS class to the text marked by the diagnostic. |
||||
|
||||
## 6.3.0 (2023-06-23) |
||||
|
||||
### New features |
||||
|
||||
A new `previousDiagnostic` command can be used to move back through the active diagnostics. |
||||
|
||||
## 6.2.2 (2023-06-05) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure lint gutter tooltips are properly closed when the content of their line changes. |
||||
|
||||
## 6.2.1 (2023-04-13) |
||||
|
||||
### Bug fixes |
||||
|
||||
The `linter` function now eagerly includes all lint-related extensions, rather than appending them to the configuration as-needed, so that turning off linting by clearing the compartment that contains it works properly. |
||||
|
||||
## 6.2.0 (2023-02-27) |
||||
|
||||
### New features |
||||
|
||||
The new `needsRefresh` option to `linter` makes it possible to cause linting to be recalculated for non-document state changes. |
||||
|
||||
## 6.1.1 (2023-02-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Give lint action buttons a pointer cursor style. |
||||
|
||||
Fix a bug that caused diagnostic action callbacks to be called twice when their button was clicked. |
||||
|
||||
## 6.1.0 (2022-11-15) |
||||
|
||||
### New features |
||||
|
||||
The new `forEachDiagnostic` function can be used to iterate over the diagnostics in an editor state. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 6.0.0 |
||||
|
||||
## 0.20.3 (2022-05-25) |
||||
|
||||
### New features |
||||
|
||||
Diagnostic objects may now have a `renderMessage` method to render their message to the DOM. |
||||
|
||||
## 0.20.2 (2022-05-02) |
||||
|
||||
### New features |
||||
|
||||
The package now exports the `LintSource` function type. |
||||
|
||||
The new `markerFilter` and `tooltipFilter` options to `linter` and `lintGutter` allow more control over which diagnostics are visible and which have tooltips. |
||||
|
||||
## 0.20.1 (2022-04-22) |
||||
|
||||
### Bug fixes |
||||
|
||||
Hide lint tooltips when the document is changed. |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.20.0 |
||||
|
||||
## 0.19.6 (2022-03-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where hovering over the icons in the lint gutter would sometimes fail to show a tooltip or show the tooltip for another line. |
||||
|
||||
## 0.19.5 (2022-02-25) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure the lint gutter tooltips are positioned under their icon, even when the line is wrapped. |
||||
|
||||
## 0.19.4 (2022-02-25) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where an outdated marker could stick around on the lint gutter after all diagnostics were removed. |
||||
|
||||
### New features |
||||
|
||||
Add a `hoverTime` option to the lint gutter. Change default hover time to 300 |
||||
|
||||
## 0.19.3 (2021-11-09) |
||||
|
||||
### New features |
||||
|
||||
Export a function `lintGutter` which returns an extension that installs a gutter marking lines with diagnostics. |
||||
|
||||
The package now exports the effect used to update the diagnostics (`setDiagnosticsEffect`). |
||||
|
||||
## 0.19.2 (2021-09-29) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where reconfiguring the lint source didn't restart linting. |
||||
|
||||
## 0.19.1 (2021-09-17) |
||||
|
||||
### Bug fixes |
||||
|
||||
Prevent decorations that cover just a line break from being invisible by showing a widget instead of range for them. |
||||
|
||||
### New features |
||||
|
||||
The `diagnosticCount` method can now be used to determine whether there are active diagnostics. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.19.0 |
||||
|
||||
## 0.18.6 (2021-08-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a crash in the key handler of the lint panel when no diagnostics are available. |
||||
|
||||
## 0.18.5 (2021-08-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue that caused `openLintPanel` to not actually open the panel when ran before the editor had any lint state loaded. |
||||
|
||||
### New features |
||||
|
||||
The package now exports a `forceLinting` function that forces pending lint queries to run immediately. |
||||
|
||||
## 0.18.4 (2021-06-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Multiple `linter` extensions can now be added to an editor without disrupting each other. |
||||
|
||||
Fix poor layout on lint tooltips due to changes in @codemirror/tooltip. |
||||
|
||||
## 0.18.3 (2021-05-10) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a regression where using `setDiagnostics` when linting hadn't been abled yet ignored the first set of diagnostics. |
||||
|
||||
## 0.18.2 (2021-04-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Newlines in line messages are now shown as line breaks to the user. |
||||
|
||||
### New features |
||||
|
||||
You can now pass a delay option to `linter` to configure how long it waits before calling the linter. |
||||
|
||||
## 0.18.1 (2021-03-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Adjust to current @codemirror/panel and @codemirror/tooltip interfaces. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure action access keys are discoverable for screen reader users. |
||||
|
||||
Selection in the lint panel should now be properly visible to screen readers. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
# @codemirror/lint [](https://www.npmjs.org/package/@codemirror/lint) |
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#lint) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lint/blob/main/CHANGELOG.md) ] |
||||
|
||||
This package implements linting support for the |
||||
[CodeMirror](https://codemirror.net/) code editor. |
||||
|
||||
The [project page](https://codemirror.net/) has more information, a |
||||
number of [examples](https://codemirror.net/examples/) and the |
||||
[documentation](https://codemirror.net/docs/). |
||||
|
||||
This code is released under an |
||||
[MIT license](https://github.com/codemirror/lint/tree/main/LICENSE). |
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit, |
||||
we have a [code of |
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies |
||||
to communication around the project. |
||||
@ -0,0 +1,950 @@
@@ -0,0 +1,950 @@
|
||||
'use strict'; |
||||
|
||||
var view = require('@codemirror/view'); |
||||
var state = require('@codemirror/state'); |
||||
var elt = require('crelt'); |
||||
|
||||
class SelectedDiagnostic { |
||||
constructor(from, to, diagnostic) { |
||||
this.from = from; |
||||
this.to = to; |
||||
this.diagnostic = diagnostic; |
||||
} |
||||
} |
||||
class LintState { |
||||
constructor(diagnostics, panel, selected) { |
||||
this.diagnostics = diagnostics; |
||||
this.panel = panel; |
||||
this.selected = selected; |
||||
} |
||||
static init(diagnostics, panel, state$1) { |
||||
// Filter the list of diagnostics for which to create markers |
||||
let diagnosticFilter = state$1.facet(lintConfig).markerFilter; |
||||
if (diagnosticFilter) |
||||
diagnostics = diagnosticFilter(diagnostics, state$1); |
||||
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to); |
||||
let deco = new state.RangeSetBuilder(), active = [], pos = 0; |
||||
let scan = state$1.doc.iter(), scanPos = 0, docLen = state$1.doc.length; |
||||
for (let i = 0;;) { |
||||
let next = i == sorted.length ? null : sorted[i]; |
||||
if (!next && !active.length) |
||||
break; |
||||
let from, to; |
||||
if (active.length) { |
||||
from = pos; |
||||
to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8); |
||||
} |
||||
else { |
||||
from = next.from; |
||||
if (from > docLen) |
||||
break; |
||||
to = next.to; |
||||
active.push(next); |
||||
i++; |
||||
} |
||||
while (i < sorted.length) { |
||||
let next = sorted[i]; |
||||
if (next.from == from && (next.to > next.from || next.to == from)) { |
||||
active.push(next); |
||||
i++; |
||||
to = Math.min(next.to, to); |
||||
} |
||||
else { |
||||
to = Math.min(next.from, to); |
||||
break; |
||||
} |
||||
} |
||||
to = Math.min(to, docLen); |
||||
let widget = false; |
||||
if (active.some(d => d.from == from && (d.to == to || to == docLen))) { |
||||
widget = from == to; |
||||
if (!widget && to - from < 10) { |
||||
let behind = from - (scanPos + scan.value.length); |
||||
if (behind > 0) { |
||||
scan.next(behind); |
||||
scanPos = from; |
||||
} |
||||
for (let check = from;;) { |
||||
if (check >= to) { |
||||
widget = true; |
||||
break; |
||||
} |
||||
if (!scan.lineBreak && scanPos + scan.value.length > check) |
||||
break; |
||||
check = scanPos + scan.value.length; |
||||
scanPos += scan.value.length; |
||||
scan.next(); |
||||
} |
||||
} |
||||
} |
||||
let sev = maxSeverity(active); |
||||
if (widget) { |
||||
deco.add(from, from, view.Decoration.widget({ |
||||
widget: new DiagnosticWidget(sev), |
||||
diagnostics: active.slice() |
||||
})); |
||||
} |
||||
else { |
||||
let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, ""); |
||||
deco.add(from, to, view.Decoration.mark({ |
||||
class: "cm-lintRange cm-lintRange-" + sev + markClass, |
||||
diagnostics: active.slice(), |
||||
inclusiveEnd: active.some(a => a.to > to) |
||||
})); |
||||
} |
||||
pos = to; |
||||
if (pos == docLen) |
||||
break; |
||||
for (let i = 0; i < active.length; i++) |
||||
if (active[i].to <= pos) |
||||
active.splice(i--, 1); |
||||
} |
||||
let set = deco.finish(); |
||||
return new LintState(set, panel, findDiagnostic(set)); |
||||
} |
||||
} |
||||
function findDiagnostic(diagnostics, diagnostic = null, after = 0) { |
||||
let found = null; |
||||
diagnostics.between(after, 1e9, (from, to, { spec }) => { |
||||
if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0) |
||||
return; |
||||
if (!found) |
||||
found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]); |
||||
else if (spec.diagnostics.indexOf(found.diagnostic) < 0) |
||||
return false; |
||||
else |
||||
found = new SelectedDiagnostic(found.from, to, found.diagnostic); |
||||
}); |
||||
return found; |
||||
} |
||||
function hideTooltip(tr, tooltip) { |
||||
let from = tooltip.pos, to = tooltip.end || from; |
||||
let result = tr.state.facet(lintConfig).hideOn(tr, from, to); |
||||
if (result != null) |
||||
return result; |
||||
let line = tr.startState.doc.lineAt(tooltip.pos); |
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to))); |
||||
} |
||||
function maybeEnableLint(state$1, effects) { |
||||
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of(lintExtensions)); |
||||
} |
||||
/** |
||||
Returns a transaction spec which updates the current set of |
||||
diagnostics, and enables the lint extension if if wasn't already |
||||
active. |
||||
*/ |
||||
function setDiagnostics(state, diagnostics) { |
||||
return { |
||||
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)]) |
||||
}; |
||||
} |
||||
/** |
||||
The state effect that updates the set of active diagnostics. Can |
||||
be useful when writing an extension that needs to track these. |
||||
*/ |
||||
const setDiagnosticsEffect = state.StateEffect.define(); |
||||
const togglePanel = state.StateEffect.define(); |
||||
const movePanelSelection = state.StateEffect.define(); |
||||
const lintState = state.StateField.define({ |
||||
create() { |
||||
return new LintState(view.Decoration.none, null, null); |
||||
}, |
||||
update(value, tr) { |
||||
if (tr.docChanged && value.diagnostics.size) { |
||||
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel; |
||||
if (value.selected) { |
||||
let selPos = tr.changes.mapPos(value.selected.from, 1); |
||||
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos); |
||||
} |
||||
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel) |
||||
panel = null; |
||||
value = new LintState(mapped, panel, selected); |
||||
} |
||||
for (let effect of tr.effects) { |
||||
if (effect.is(setDiagnosticsEffect)) { |
||||
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null; |
||||
value = LintState.init(effect.value, panel, tr.state); |
||||
} |
||||
else if (effect.is(togglePanel)) { |
||||
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected); |
||||
} |
||||
else if (effect.is(movePanelSelection)) { |
||||
value = new LintState(value.diagnostics, value.panel, effect.value); |
||||
} |
||||
} |
||||
return value; |
||||
}, |
||||
provide: f => [view.showPanel.from(f, val => val.panel), |
||||
view.EditorView.decorations.from(f, s => s.diagnostics)] |
||||
}); |
||||
/** |
||||
Returns the number of active lint diagnostics in the given state. |
||||
*/ |
||||
function diagnosticCount(state) { |
||||
let lint = state.field(lintState, false); |
||||
return lint ? lint.diagnostics.size : 0; |
||||
} |
||||
const activeMark = view.Decoration.mark({ class: "cm-lintRange cm-lintRange-active" }); |
||||
function lintTooltip(view, pos, side) { |
||||
let { diagnostics } = view.state.field(lintState); |
||||
let found, start = -1, end = -1; |
||||
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => { |
||||
if (pos >= from && pos <= to && |
||||
(from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) { |
||||
found = spec.diagnostics; |
||||
start = from; |
||||
end = to; |
||||
return false; |
||||
} |
||||
}); |
||||
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter; |
||||
if (found && diagnosticFilter) |
||||
found = diagnosticFilter(found, view.state); |
||||
if (!found) |
||||
return null; |
||||
return { |
||||
pos: start, |
||||
end: end, |
||||
above: view.state.doc.lineAt(start).to < end, |
||||
create() { |
||||
return { dom: diagnosticsTooltip(view, found) }; |
||||
} |
||||
}; |
||||
} |
||||
function diagnosticsTooltip(view, diagnostics) { |
||||
return elt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false))); |
||||
} |
||||
/** |
||||
Command to open and focus the lint panel. |
||||
*/ |
||||
const openLintPanel = (view$1) => { |
||||
let field = view$1.state.field(lintState, false); |
||||
if (!field || !field.panel) |
||||
view$1.dispatch({ effects: maybeEnableLint(view$1.state, [togglePanel.of(true)]) }); |
||||
let panel = view.getPanel(view$1, LintPanel.open); |
||||
if (panel) |
||||
panel.dom.querySelector(".cm-panel-lint ul").focus(); |
||||
return true; |
||||
}; |
||||
/** |
||||
Command to close the lint panel, when open. |
||||
*/ |
||||
const closeLintPanel = (view) => { |
||||
let field = view.state.field(lintState, false); |
||||
if (!field || !field.panel) |
||||
return false; |
||||
view.dispatch({ effects: togglePanel.of(false) }); |
||||
return true; |
||||
}; |
||||
/** |
||||
Move the selection to the next diagnostic. |
||||
*/ |
||||
const nextDiagnostic = (view) => { |
||||
let field = view.state.field(lintState, false); |
||||
if (!field) |
||||
return false; |
||||
let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1); |
||||
if (!next.value) { |
||||
next = field.diagnostics.iter(0); |
||||
if (!next.value || next.from == sel.from && next.to == sel.to) |
||||
return false; |
||||
} |
||||
view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true }); |
||||
return true; |
||||
}; |
||||
/** |
||||
Move the selection to the previous diagnostic. |
||||
*/ |
||||
const previousDiagnostic = (view) => { |
||||
let { state } = view, field = state.field(lintState, false); |
||||
if (!field) |
||||
return false; |
||||
let sel = state.selection.main; |
||||
let prevFrom, prevTo, lastFrom, lastTo; |
||||
field.diagnostics.between(0, state.doc.length, (from, to) => { |
||||
if (to < sel.to && (prevFrom == null || prevFrom < from)) { |
||||
prevFrom = from; |
||||
prevTo = to; |
||||
} |
||||
if (lastFrom == null || from > lastFrom) { |
||||
lastFrom = from; |
||||
lastTo = to; |
||||
} |
||||
}); |
||||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from) |
||||
return false; |
||||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true }); |
||||
return true; |
||||
}; |
||||
/** |
||||
A set of default key bindings for the lint functionality. |
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel) |
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic) |
||||
*/ |
||||
const lintKeymap = [ |
||||
{ key: "Mod-Shift-m", run: openLintPanel, preventDefault: true }, |
||||
{ key: "F8", run: nextDiagnostic } |
||||
]; |
||||
const lintPlugin = view.ViewPlugin.fromClass(class { |
||||
constructor(view) { |
||||
this.view = view; |
||||
this.timeout = -1; |
||||
this.set = true; |
||||
let { delay } = view.state.facet(lintConfig); |
||||
this.lintTime = Date.now() + delay; |
||||
this.run = this.run.bind(this); |
||||
this.timeout = setTimeout(this.run, delay); |
||||
} |
||||
run() { |
||||
clearTimeout(this.timeout); |
||||
let now = Date.now(); |
||||
if (now < this.lintTime - 10) { |
||||
this.timeout = setTimeout(this.run, this.lintTime - now); |
||||
} |
||||
else { |
||||
this.set = false; |
||||
let { state } = this.view, { sources } = state.facet(lintConfig); |
||||
if (sources.length) |
||||
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => { |
||||
if (this.view.state.doc == state.doc) |
||||
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b)))); |
||||
}, error => { view.logException(this.view.state, error); }); |
||||
} |
||||
} |
||||
update(update) { |
||||
let config = update.state.facet(lintConfig); |
||||
if (update.docChanged || config != update.startState.facet(lintConfig) || |
||||
config.needsRefresh && config.needsRefresh(update)) { |
||||
this.lintTime = Date.now() + config.delay; |
||||
if (!this.set) { |
||||
this.set = true; |
||||
this.timeout = setTimeout(this.run, config.delay); |
||||
} |
||||
} |
||||
} |
||||
force() { |
||||
if (this.set) { |
||||
this.lintTime = Date.now(); |
||||
this.run(); |
||||
} |
||||
} |
||||
destroy() { |
||||
clearTimeout(this.timeout); |
||||
} |
||||
}); |
||||
function batchResults(promises, sink, error) { |
||||
let collected = [], timeout = -1; |
||||
for (let p of promises) |
||||
p.then(value => { |
||||
collected.push(value); |
||||
clearTimeout(timeout); |
||||
if (collected.length == promises.length) |
||||
sink(collected); |
||||
else |
||||
timeout = setTimeout(() => sink(collected), 200); |
||||
}, error); |
||||
} |
||||
const lintConfig = state.Facet.define({ |
||||
combine(input) { |
||||
return { |
||||
sources: input.map(i => i.source).filter(x => x != null), |
||||
...state.combineConfig(input.map(i => i.config), { |
||||
delay: 750, |
||||
markerFilter: null, |
||||
tooltipFilter: null, |
||||
needsRefresh: null, |
||||
hideOn: () => null, |
||||
}, { |
||||
delay: Math.max, |
||||
markerFilter: combineFilter, |
||||
tooltipFilter: combineFilter, |
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u), |
||||
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y), |
||||
autoPanel: (a, b) => a || b |
||||
}) |
||||
}; |
||||
} |
||||
}); |
||||
function combineFilter(a, b) { |
||||
return !a ? b : !b ? a : (d, s) => b(a(d, s), s); |
||||
} |
||||
/** |
||||
Given a diagnostic source, this function returns an extension that |
||||
enables linting with that source. It will be called whenever the |
||||
editor is idle (after its content changed). |
||||
|
||||
Note that settings given here will apply to all linters active in |
||||
the editor. If `null` is given as source, this only configures the |
||||
lint extension. |
||||
*/ |
||||
function linter(source, config = {}) { |
||||
return [ |
||||
lintConfig.of({ source, config }), |
||||
lintPlugin, |
||||
lintExtensions |
||||
]; |
||||
} |
||||
/** |
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the |
||||
editor is idle to run right away. |
||||
*/ |
||||
function forceLinting(view) { |
||||
let plugin = view.plugin(lintPlugin); |
||||
if (plugin) |
||||
plugin.force(); |
||||
} |
||||
function assignKeys(actions) { |
||||
let assigned = []; |
||||
if (actions) |
||||
actions: for (let { name } of actions) { |
||||
for (let i = 0; i < name.length; i++) { |
||||
let ch = name[i]; |
||||
if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) { |
||||
assigned.push(ch); |
||||
continue actions; |
||||
} |
||||
} |
||||
assigned.push(""); |
||||
} |
||||
return assigned; |
||||
} |
||||
function renderDiagnostic(view, diagnostic, inPanel) { |
||||
var _a; |
||||
let keys = inPanel ? assignKeys(diagnostic.actions) : []; |
||||
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => { |
||||
let fired = false, click = (e) => { |
||||
e.preventDefault(); |
||||
if (fired) |
||||
return; |
||||
fired = true; |
||||
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic); |
||||
if (found) |
||||
action.apply(view, found.from, found.to); |
||||
}; |
||||
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1; |
||||
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex), |
||||
elt("u", name.slice(keyIndex, keyIndex + 1)), |
||||
name.slice(keyIndex + 1)]; |
||||
let markClass = action.markClass ? " " + action.markClass : ""; |
||||
return elt("button", { |
||||
type: "button", |
||||
class: "cm-diagnosticAction" + markClass, |
||||
onclick: click, |
||||
onmousedown: click, |
||||
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.` |
||||
}, nameElt); |
||||
}), diagnostic.source && elt("div", { class: "cm-diagnosticSource" }, diagnostic.source)); |
||||
} |
||||
class DiagnosticWidget extends view.WidgetType { |
||||
constructor(sev) { |
||||
super(); |
||||
this.sev = sev; |
||||
} |
||||
eq(other) { return other.sev == this.sev; } |
||||
toDOM() { |
||||
return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev }); |
||||
} |
||||
} |
||||
class PanelItem { |
||||
constructor(view, diagnostic) { |
||||
this.diagnostic = diagnostic; |
||||
this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16); |
||||
this.dom = renderDiagnostic(view, diagnostic, true); |
||||
this.dom.id = this.id; |
||||
this.dom.setAttribute("role", "option"); |
||||
} |
||||
} |
||||
class LintPanel { |
||||
constructor(view) { |
||||
this.view = view; |
||||
this.items = []; |
||||
let onkeydown = (event) => { |
||||
if (event.keyCode == 27) { // Escape |
||||
closeLintPanel(this.view); |
||||
this.view.focus(); |
||||
} |
||||
else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp |
||||
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length); |
||||
} |
||||
else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown |
||||
this.moveSelection((this.selectedIndex + 1) % this.items.length); |
||||
} |
||||
else if (event.keyCode == 36) { // Home |
||||
this.moveSelection(0); |
||||
} |
||||
else if (event.keyCode == 35) { // End |
||||
this.moveSelection(this.items.length - 1); |
||||
} |
||||
else if (event.keyCode == 13) { // Enter |
||||
this.view.focus(); |
||||
} |
||||
else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z |
||||
let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions); |
||||
for (let i = 0; i < keys.length; i++) |
||||
if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) { |
||||
let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic); |
||||
if (found) |
||||
diagnostic.actions[i].apply(view, found.from, found.to); |
||||
} |
||||
} |
||||
else { |
||||
return; |
||||
} |
||||
event.preventDefault(); |
||||
}; |
||||
let onclick = (event) => { |
||||
for (let i = 0; i < this.items.length; i++) { |
||||
if (this.items[i].dom.contains(event.target)) |
||||
this.moveSelection(i); |
||||
} |
||||
}; |
||||
this.list = elt("ul", { |
||||
tabIndex: 0, |
||||
role: "listbox", |
||||
"aria-label": this.view.state.phrase("Diagnostics"), |
||||
onkeydown, |
||||
onclick |
||||
}); |
||||
this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", { |
||||
type: "button", |
||||
name: "close", |
||||
"aria-label": this.view.state.phrase("close"), |
||||
onclick: () => closeLintPanel(this.view) |
||||
}, "×")); |
||||
this.update(); |
||||
} |
||||
get selectedIndex() { |
||||
let selected = this.view.state.field(lintState).selected; |
||||
if (!selected) |
||||
return -1; |
||||
for (let i = 0; i < this.items.length; i++) |
||||
if (this.items[i].diagnostic == selected.diagnostic) |
||||
return i; |
||||
return -1; |
||||
} |
||||
update() { |
||||
let { diagnostics, selected } = this.view.state.field(lintState); |
||||
let i = 0, needsSync = false, newSelectedItem = null; |
||||
let seen = new Set(); |
||||
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => { |
||||
for (let diagnostic of spec.diagnostics) { |
||||
if (seen.has(diagnostic)) |
||||
continue; |
||||
seen.add(diagnostic); |
||||
let found = -1, item; |
||||
for (let j = i; j < this.items.length; j++) |
||||
if (this.items[j].diagnostic == diagnostic) { |
||||
found = j; |
||||
break; |
||||
} |
||||
if (found < 0) { |
||||
item = new PanelItem(this.view, diagnostic); |
||||
this.items.splice(i, 0, item); |
||||
needsSync = true; |
||||
} |
||||
else { |
||||
item = this.items[found]; |
||||
if (found > i) { |
||||
this.items.splice(i, found - i); |
||||
needsSync = true; |
||||
} |
||||
} |
||||
if (selected && item.diagnostic == selected.diagnostic) { |
||||
if (!item.dom.hasAttribute("aria-selected")) { |
||||
item.dom.setAttribute("aria-selected", "true"); |
||||
newSelectedItem = item; |
||||
} |
||||
} |
||||
else if (item.dom.hasAttribute("aria-selected")) { |
||||
item.dom.removeAttribute("aria-selected"); |
||||
} |
||||
i++; |
||||
} |
||||
}); |
||||
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) { |
||||
needsSync = true; |
||||
this.items.pop(); |
||||
} |
||||
if (this.items.length == 0) { |
||||
this.items.push(new PanelItem(this.view, { |
||||
from: -1, to: -1, |
||||
severity: "info", |
||||
message: this.view.state.phrase("No diagnostics") |
||||
})); |
||||
needsSync = true; |
||||
} |
||||
if (newSelectedItem) { |
||||
this.list.setAttribute("aria-activedescendant", newSelectedItem.id); |
||||
this.view.requestMeasure({ |
||||
key: this, |
||||
read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }), |
||||
write: ({ sel, panel }) => { |
||||
let scaleY = panel.height / this.list.offsetHeight; |
||||
if (sel.top < panel.top) |
||||
this.list.scrollTop -= (panel.top - sel.top) / scaleY; |
||||
else if (sel.bottom > panel.bottom) |
||||
this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY; |
||||
} |
||||
}); |
||||
} |
||||
else if (this.selectedIndex < 0) { |
||||
this.list.removeAttribute("aria-activedescendant"); |
||||
} |
||||
if (needsSync) |
||||
this.sync(); |
||||
} |
||||
sync() { |
||||
let domPos = this.list.firstChild; |
||||
function rm() { |
||||
let prev = domPos; |
||||
domPos = prev.nextSibling; |
||||
prev.remove(); |
||||
} |
||||
for (let item of this.items) { |
||||
if (item.dom.parentNode == this.list) { |
||||
while (domPos != item.dom) |
||||
rm(); |
||||
domPos = item.dom.nextSibling; |
||||
} |
||||
else { |
||||
this.list.insertBefore(item.dom, domPos); |
||||
} |
||||
} |
||||
while (domPos) |
||||
rm(); |
||||
} |
||||
moveSelection(selectedIndex) { |
||||
if (this.selectedIndex < 0) |
||||
return; |
||||
let field = this.view.state.field(lintState); |
||||
let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic); |
||||
if (!selection) |
||||
return; |
||||
this.view.dispatch({ |
||||
selection: { anchor: selection.from, head: selection.to }, |
||||
scrollIntoView: true, |
||||
effects: movePanelSelection.of(selection) |
||||
}); |
||||
} |
||||
static open(view) { return new LintPanel(view); } |
||||
} |
||||
function svg(content, attrs = `viewBox="0 0 40 40"`) { |
||||
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`; |
||||
} |
||||
function underline(color) { |
||||
return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`); |
||||
} |
||||
const baseTheme = view.EditorView.baseTheme({ |
||||
".cm-diagnostic": { |
||||
padding: "3px 6px 3px 8px", |
||||
marginLeft: "-1px", |
||||
display: "block", |
||||
whiteSpace: "pre-wrap" |
||||
}, |
||||
".cm-diagnostic-error": { borderLeft: "5px solid #d11" }, |
||||
".cm-diagnostic-warning": { borderLeft: "5px solid orange" }, |
||||
".cm-diagnostic-info": { borderLeft: "5px solid #999" }, |
||||
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" }, |
||||
".cm-diagnosticAction": { |
||||
font: "inherit", |
||||
border: "none", |
||||
padding: "2px 4px", |
||||
backgroundColor: "#444", |
||||
color: "white", |
||||
borderRadius: "3px", |
||||
marginLeft: "8px", |
||||
cursor: "pointer" |
||||
}, |
||||
".cm-diagnosticSource": { |
||||
fontSize: "70%", |
||||
opacity: .7 |
||||
}, |
||||
".cm-lintRange": { |
||||
backgroundPosition: "left bottom", |
||||
backgroundRepeat: "repeat-x", |
||||
paddingBottom: "0.7px", |
||||
}, |
||||
".cm-lintRange-error": { backgroundImage: underline("#d11") }, |
||||
".cm-lintRange-warning": { backgroundImage: underline("orange") }, |
||||
".cm-lintRange-info": { backgroundImage: underline("#999") }, |
||||
".cm-lintRange-hint": { backgroundImage: underline("#66d") }, |
||||
".cm-lintRange-active": { backgroundColor: "#ffdd9980" }, |
||||
".cm-tooltip-lint": { |
||||
padding: 0, |
||||
margin: 0 |
||||
}, |
||||
".cm-lintPoint": { |
||||
position: "relative", |
||||
"&:after": { |
||||
content: '""', |
||||
position: "absolute", |
||||
bottom: 0, |
||||
left: "-2px", |
||||
borderLeft: "3px solid transparent", |
||||
borderRight: "3px solid transparent", |
||||
borderBottom: "4px solid #d11" |
||||
} |
||||
}, |
||||
".cm-lintPoint-warning": { |
||||
"&:after": { borderBottomColor: "orange" } |
||||
}, |
||||
".cm-lintPoint-info": { |
||||
"&:after": { borderBottomColor: "#999" } |
||||
}, |
||||
".cm-lintPoint-hint": { |
||||
"&:after": { borderBottomColor: "#66d" } |
||||
}, |
||||
".cm-panel.cm-panel-lint": { |
||||
position: "relative", |
||||
"& ul": { |
||||
maxHeight: "100px", |
||||
overflowY: "auto", |
||||
"& [aria-selected]": { |
||||
backgroundColor: "#ddd", |
||||
"& u": { textDecoration: "underline" } |
||||
}, |
||||
"&:focus [aria-selected]": { |
||||
background_fallback: "#bdf", |
||||
backgroundColor: "Highlight", |
||||
color_fallback: "white", |
||||
color: "HighlightText" |
||||
}, |
||||
"& u": { textDecoration: "none" }, |
||||
padding: 0, |
||||
margin: 0 |
||||
}, |
||||
"& [name=close]": { |
||||
position: "absolute", |
||||
top: "0", |
||||
right: "2px", |
||||
background: "inherit", |
||||
border: "none", |
||||
font: "inherit", |
||||
padding: 0, |
||||
margin: 0 |
||||
} |
||||
} |
||||
}); |
||||
function severityWeight(sev) { |
||||
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1; |
||||
} |
||||
function maxSeverity(diagnostics) { |
||||
let sev = "hint", weight = 1; |
||||
for (let d of diagnostics) { |
||||
let w = severityWeight(d.severity); |
||||
if (w > weight) { |
||||
weight = w; |
||||
sev = d.severity; |
||||
} |
||||
} |
||||
return sev; |
||||
} |
||||
class LintGutterMarker extends view.GutterMarker { |
||||
constructor(diagnostics) { |
||||
super(); |
||||
this.diagnostics = diagnostics; |
||||
this.severity = maxSeverity(diagnostics); |
||||
} |
||||
toDOM(view) { |
||||
let elt = document.createElement("div"); |
||||
elt.className = "cm-lint-marker cm-lint-marker-" + this.severity; |
||||
let diagnostics = this.diagnostics; |
||||
let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter; |
||||
if (diagnosticsFilter) |
||||
diagnostics = diagnosticsFilter(diagnostics, view.state); |
||||
if (diagnostics.length) |
||||
elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics); |
||||
return elt; |
||||
} |
||||
} |
||||
function trackHoverOn(view, marker) { |
||||
let mousemove = (event) => { |
||||
let rect = marker.getBoundingClientRect(); |
||||
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ && |
||||
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */) |
||||
return; |
||||
for (let target = event.target; target; target = target.parentNode) { |
||||
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint")) |
||||
return; |
||||
} |
||||
window.removeEventListener("mousemove", mousemove); |
||||
if (view.state.field(lintGutterTooltip)) |
||||
view.dispatch({ effects: setLintGutterTooltip.of(null) }); |
||||
}; |
||||
window.addEventListener("mousemove", mousemove); |
||||
} |
||||
function gutterMarkerMouseOver(view, marker, diagnostics) { |
||||
function hovered() { |
||||
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop); |
||||
const linePos = view.coordsAtPos(line.from); |
||||
if (linePos) { |
||||
view.dispatch({ effects: setLintGutterTooltip.of({ |
||||
pos: line.from, |
||||
above: false, |
||||
clip: false, |
||||
create() { |
||||
return { |
||||
dom: diagnosticsTooltip(view, diagnostics), |
||||
getCoords: () => marker.getBoundingClientRect() |
||||
}; |
||||
} |
||||
}) }); |
||||
} |
||||
marker.onmouseout = marker.onmousemove = null; |
||||
trackHoverOn(view, marker); |
||||
} |
||||
let { hoverTime } = view.state.facet(lintGutterConfig); |
||||
let hoverTimeout = setTimeout(hovered, hoverTime); |
||||
marker.onmouseout = () => { |
||||
clearTimeout(hoverTimeout); |
||||
marker.onmouseout = marker.onmousemove = null; |
||||
}; |
||||
marker.onmousemove = () => { |
||||
clearTimeout(hoverTimeout); |
||||
hoverTimeout = setTimeout(hovered, hoverTime); |
||||
}; |
||||
} |
||||
function markersForDiagnostics(doc, diagnostics) { |
||||
let byLine = Object.create(null); |
||||
for (let diagnostic of diagnostics) { |
||||
let line = doc.lineAt(diagnostic.from); |
||||
(byLine[line.from] || (byLine[line.from] = [])).push(diagnostic); |
||||
} |
||||
let markers = []; |
||||
for (let line in byLine) { |
||||
markers.push(new LintGutterMarker(byLine[line]).range(+line)); |
||||
} |
||||
return state.RangeSet.of(markers, true); |
||||
} |
||||
const lintGutterExtension = view.gutter({ |
||||
class: "cm-gutter-lint", |
||||
markers: view => view.state.field(lintGutterMarkers), |
||||
widgetMarker: (view, widget, block) => { |
||||
let diagnostics = []; |
||||
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => { |
||||
if (from > block.from && from < block.to) |
||||
diagnostics.push(...value.diagnostics); |
||||
}); |
||||
return diagnostics.length ? new LintGutterMarker(diagnostics) : null; |
||||
} |
||||
}); |
||||
const lintGutterMarkers = state.StateField.define({ |
||||
create() { |
||||
return state.RangeSet.empty; |
||||
}, |
||||
update(markers, tr) { |
||||
markers = markers.map(tr.changes); |
||||
let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter; |
||||
for (let effect of tr.effects) { |
||||
if (effect.is(setDiagnosticsEffect)) { |
||||
let diagnostics = effect.value; |
||||
if (diagnosticFilter) |
||||
diagnostics = diagnosticFilter(diagnostics || [], tr.state); |
||||
markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0)); |
||||
} |
||||
} |
||||
return markers; |
||||
} |
||||
}); |
||||
const setLintGutterTooltip = state.StateEffect.define(); |
||||
const lintGutterTooltip = state.StateField.define({ |
||||
create() { return null; }, |
||||
update(tooltip, tr) { |
||||
if (tooltip && tr.docChanged) |
||||
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) }; |
||||
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip); |
||||
}, |
||||
provide: field => view.showTooltip.from(field) |
||||
}); |
||||
const lintGutterTheme = view.EditorView.baseTheme({ |
||||
".cm-gutter-lint": { |
||||
width: "1.4em", |
||||
"& .cm-gutterElement": { |
||||
padding: ".2em" |
||||
} |
||||
}, |
||||
".cm-lint-marker": { |
||||
width: "1em", |
||||
height: "1em" |
||||
}, |
||||
".cm-lint-marker-info": { |
||||
content: svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`) |
||||
}, |
||||
".cm-lint-marker-warning": { |
||||
content: svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`), |
||||
}, |
||||
".cm-lint-marker-error": { |
||||
content: svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`) |
||||
}, |
||||
}); |
||||
const lintExtensions = [ |
||||
lintState, |
||||
view.EditorView.decorations.compute([lintState], state => { |
||||
let { selected, panel } = state.field(lintState); |
||||
return !selected || !panel || selected.from == selected.to ? view.Decoration.none : view.Decoration.set([ |
||||
activeMark.range(selected.from, selected.to) |
||||
]); |
||||
}), |
||||
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }), |
||||
baseTheme |
||||
]; |
||||
const lintGutterConfig = state.Facet.define({ |
||||
combine(configs) { |
||||
return state.combineConfig(configs, { |
||||
hoverTime: 300 /* Hover.Time */, |
||||
markerFilter: null, |
||||
tooltipFilter: null |
||||
}); |
||||
} |
||||
}); |
||||
/** |
||||
Returns an extension that installs a gutter showing markers for |
||||
each line that has diagnostics, which can be hovered over to see |
||||
the diagnostics. |
||||
*/ |
||||
function lintGutter(config = {}) { |
||||
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip]; |
||||
} |
||||
/** |
||||
Iterate over the marked diagnostics for the given editor state, |
||||
calling `f` for each of them. Note that, if the document changed |
||||
since the diagnostics were created, the `Diagnostic` object will |
||||
hold the original outdated position, whereas the `to` and `from` |
||||
arguments hold the diagnostic's current position. |
||||
*/ |
||||
function forEachDiagnostic(state$1, f) { |
||||
let lState = state$1.field(lintState, false); |
||||
if (lState && lState.diagnostics.size) { |
||||
let pending = [], pendingStart = [], lastEnd = -1; |
||||
for (let iter = state.RangeSet.iter([lState.diagnostics]);; iter.next()) { |
||||
for (let i = 0; i < pending.length; i++) |
||||
if (!iter.value || iter.value.spec.diagnostics.indexOf(pending[i]) < 0) { |
||||
f(pending[i], pendingStart[i], lastEnd); |
||||
pending.splice(i, 1); |
||||
pendingStart.splice(i--, 1); |
||||
} |
||||
if (!iter.value) |
||||
break; |
||||
for (let d of iter.value.spec.diagnostics) |
||||
if (pending.indexOf(d) < 0) { |
||||
pending.push(d); |
||||
pendingStart.push(iter.from); |
||||
} |
||||
lastEnd = iter.to; |
||||
} |
||||
} |
||||
} |
||||
|
||||
exports.closeLintPanel = closeLintPanel; |
||||
exports.diagnosticCount = diagnosticCount; |
||||
exports.forEachDiagnostic = forEachDiagnostic; |
||||
exports.forceLinting = forceLinting; |
||||
exports.lintGutter = lintGutter; |
||||
exports.lintKeymap = lintKeymap; |
||||
exports.linter = linter; |
||||
exports.nextDiagnostic = nextDiagnostic; |
||||
exports.openLintPanel = openLintPanel; |
||||
exports.previousDiagnostic = previousDiagnostic; |
||||
exports.setDiagnostics = setDiagnostics; |
||||
exports.setDiagnosticsEffect = setDiagnosticsEffect; |
||||
@ -0,0 +1,195 @@
@@ -0,0 +1,195 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { EditorState, TransactionSpec, Extension, Transaction } from '@codemirror/state'; |
||||
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view'; |
||||
|
||||
type Severity = "hint" | "info" | "warning" | "error"; |
||||
/** |
||||
Describes a problem or hint for a piece of code. |
||||
*/ |
||||
interface Diagnostic { |
||||
/** |
||||
The start position of the relevant text. |
||||
*/ |
||||
from: number; |
||||
/** |
||||
The end position. May be equal to `from`, though actually |
||||
covering text is preferable. |
||||
*/ |
||||
to: number; |
||||
/** |
||||
The severity of the problem. This will influence how it is |
||||
displayed. |
||||
*/ |
||||
severity: Severity; |
||||
/** |
||||
When given, add an extra CSS class to parts of the code that |
||||
this diagnostic applies to. |
||||
*/ |
||||
markClass?: string; |
||||
/** |
||||
An optional source string indicating where the diagnostic is |
||||
coming from. You can put the name of your linter here, if |
||||
applicable. |
||||
*/ |
||||
source?: string; |
||||
/** |
||||
The message associated with this diagnostic. |
||||
*/ |
||||
message: string; |
||||
/** |
||||
An optional custom rendering function that displays the message |
||||
as a DOM node. |
||||
*/ |
||||
renderMessage?: (view: EditorView) => Node; |
||||
/** |
||||
An optional array of actions that can be taken on this |
||||
diagnostic. |
||||
*/ |
||||
actions?: readonly Action[]; |
||||
} |
||||
/** |
||||
An action associated with a diagnostic. |
||||
*/ |
||||
interface Action { |
||||
/** |
||||
The label to show to the user. Should be relatively short. |
||||
*/ |
||||
name: string; |
||||
/** |
||||
When given, add an extra CSS class to the action button. |
||||
*/ |
||||
markClass?: string; |
||||
/** |
||||
The function to call when the user activates this action. Is |
||||
given the diagnostic's _current_ position, which may have |
||||
changed since the creation of the diagnostic, due to editing. |
||||
*/ |
||||
apply: (view: EditorView, from: number, to: number) => void; |
||||
} |
||||
type DiagnosticFilter = (diagnostics: readonly Diagnostic[], state: EditorState) => Diagnostic[]; |
||||
interface LintConfig { |
||||
/** |
||||
Time to wait (in milliseconds) after a change before running |
||||
the linter. Defaults to 750ms. |
||||
*/ |
||||
delay?: number; |
||||
/** |
||||
Optional predicate that can be used to indicate when diagnostics |
||||
need to be recomputed. Linting is always re-done on document |
||||
changes. |
||||
*/ |
||||
needsRefresh?: null | ((update: ViewUpdate) => boolean); |
||||
/** |
||||
Optional filter to determine which diagnostics produce markers |
||||
in the content. |
||||
*/ |
||||
markerFilter?: null | DiagnosticFilter; |
||||
/** |
||||
Filter applied to a set of diagnostics shown in a tooltip. No |
||||
tooltip will appear if the empty set is returned. |
||||
*/ |
||||
tooltipFilter?: null | DiagnosticFilter; |
||||
/** |
||||
Can be used to control what kind of transactions cause lint |
||||
hover tooltips associated with the given document range to be |
||||
hidden. By default any transactions that changes the line |
||||
around the range will hide it. Returning null falls back to this |
||||
behavior. |
||||
*/ |
||||
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null; |
||||
/** |
||||
When enabled (defaults to off), this will cause the lint panel |
||||
to automatically open when diagnostics are found, and close when |
||||
all diagnostics are resolved or removed. |
||||
*/ |
||||
autoPanel?: boolean; |
||||
} |
||||
interface LintGutterConfig { |
||||
/** |
||||
The delay before showing a tooltip when hovering over a lint gutter marker. |
||||
*/ |
||||
hoverTime?: number; |
||||
/** |
||||
Optional filter determining which diagnostics show a marker in |
||||
the gutter. |
||||
*/ |
||||
markerFilter?: null | DiagnosticFilter; |
||||
/** |
||||
Optional filter for diagnostics displayed in a tooltip, which |
||||
can also be used to prevent a tooltip appearing. |
||||
*/ |
||||
tooltipFilter?: null | DiagnosticFilter; |
||||
} |
||||
/** |
||||
Returns a transaction spec which updates the current set of |
||||
diagnostics, and enables the lint extension if if wasn't already |
||||
active. |
||||
*/ |
||||
declare function setDiagnostics(state: EditorState, diagnostics: readonly Diagnostic[]): TransactionSpec; |
||||
/** |
||||
The state effect that updates the set of active diagnostics. Can |
||||
be useful when writing an extension that needs to track these. |
||||
*/ |
||||
declare const setDiagnosticsEffect: _codemirror_state.StateEffectType<readonly Diagnostic[]>; |
||||
/** |
||||
Returns the number of active lint diagnostics in the given state. |
||||
*/ |
||||
declare function diagnosticCount(state: EditorState): number; |
||||
/** |
||||
Command to open and focus the lint panel. |
||||
*/ |
||||
declare const openLintPanel: Command; |
||||
/** |
||||
Command to close the lint panel, when open. |
||||
*/ |
||||
declare const closeLintPanel: Command; |
||||
/** |
||||
Move the selection to the next diagnostic. |
||||
*/ |
||||
declare const nextDiagnostic: Command; |
||||
/** |
||||
Move the selection to the previous diagnostic. |
||||
*/ |
||||
declare const previousDiagnostic: Command; |
||||
/** |
||||
A set of default key bindings for the lint functionality. |
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel) |
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic) |
||||
*/ |
||||
declare const lintKeymap: readonly KeyBinding[]; |
||||
/** |
||||
The type of a function that produces diagnostics. |
||||
*/ |
||||
type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>; |
||||
/** |
||||
Given a diagnostic source, this function returns an extension that |
||||
enables linting with that source. It will be called whenever the |
||||
editor is idle (after its content changed). |
||||
|
||||
Note that settings given here will apply to all linters active in |
||||
the editor. If `null` is given as source, this only configures the |
||||
lint extension. |
||||
*/ |
||||
declare function linter(source: LintSource | null, config?: LintConfig): Extension; |
||||
/** |
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the |
||||
editor is idle to run right away. |
||||
*/ |
||||
declare function forceLinting(view: EditorView): void; |
||||
/** |
||||
Returns an extension that installs a gutter showing markers for |
||||
each line that has diagnostics, which can be hovered over to see |
||||
the diagnostics. |
||||
*/ |
||||
declare function lintGutter(config?: LintGutterConfig): Extension; |
||||
/** |
||||
Iterate over the marked diagnostics for the given editor state, |
||||
calling `f` for each of them. Note that, if the document changed |
||||
since the diagnostics were created, the `Diagnostic` object will |
||||
hold the original outdated position, whereas the `to` and `from` |
||||
arguments hold the diagnostic's current position. |
||||
*/ |
||||
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void; |
||||
|
||||
export { type Action, type Diagnostic, type LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect }; |
||||
@ -0,0 +1,195 @@
@@ -0,0 +1,195 @@
|
||||
import * as _codemirror_state from '@codemirror/state'; |
||||
import { EditorState, TransactionSpec, Extension, Transaction } from '@codemirror/state'; |
||||
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view'; |
||||
|
||||
type Severity = "hint" | "info" | "warning" | "error"; |
||||
/** |
||||
Describes a problem or hint for a piece of code. |
||||
*/ |
||||
interface Diagnostic { |
||||
/** |
||||
The start position of the relevant text. |
||||
*/ |
||||
from: number; |
||||
/** |
||||
The end position. May be equal to `from`, though actually |
||||
covering text is preferable. |
||||
*/ |
||||
to: number; |
||||
/** |
||||
The severity of the problem. This will influence how it is |
||||
displayed. |
||||
*/ |
||||
severity: Severity; |
||||
/** |
||||
When given, add an extra CSS class to parts of the code that |
||||
this diagnostic applies to. |
||||
*/ |
||||
markClass?: string; |
||||
/** |
||||
An optional source string indicating where the diagnostic is |
||||
coming from. You can put the name of your linter here, if |
||||
applicable. |
||||
*/ |
||||
source?: string; |
||||
/** |
||||
The message associated with this diagnostic. |
||||
*/ |
||||
message: string; |
||||
/** |
||||
An optional custom rendering function that displays the message |
||||
as a DOM node. |
||||
*/ |
||||
renderMessage?: (view: EditorView) => Node; |
||||
/** |
||||
An optional array of actions that can be taken on this |
||||
diagnostic. |
||||
*/ |
||||
actions?: readonly Action[]; |
||||
} |
||||
/** |
||||
An action associated with a diagnostic. |
||||
*/ |
||||
interface Action { |
||||
/** |
||||
The label to show to the user. Should be relatively short. |
||||
*/ |
||||
name: string; |
||||
/** |
||||
When given, add an extra CSS class to the action button. |
||||
*/ |
||||
markClass?: string; |
||||
/** |
||||
The function to call when the user activates this action. Is |
||||
given the diagnostic's _current_ position, which may have |
||||
changed since the creation of the diagnostic, due to editing. |
||||
*/ |
||||
apply: (view: EditorView, from: number, to: number) => void; |
||||
} |
||||
type DiagnosticFilter = (diagnostics: readonly Diagnostic[], state: EditorState) => Diagnostic[]; |
||||
interface LintConfig { |
||||
/** |
||||
Time to wait (in milliseconds) after a change before running |
||||
the linter. Defaults to 750ms. |
||||
*/ |
||||
delay?: number; |
||||
/** |
||||
Optional predicate that can be used to indicate when diagnostics |
||||
need to be recomputed. Linting is always re-done on document |
||||
changes. |
||||
*/ |
||||
needsRefresh?: null | ((update: ViewUpdate) => boolean); |
||||
/** |
||||
Optional filter to determine which diagnostics produce markers |
||||
in the content. |
||||
*/ |
||||
markerFilter?: null | DiagnosticFilter; |
||||
/** |
||||
Filter applied to a set of diagnostics shown in a tooltip. No |
||||
tooltip will appear if the empty set is returned. |
||||
*/ |
||||
tooltipFilter?: null | DiagnosticFilter; |
||||
/** |
||||
Can be used to control what kind of transactions cause lint |
||||
hover tooltips associated with the given document range to be |
||||
hidden. By default any transactions that changes the line |
||||
around the range will hide it. Returning null falls back to this |
||||
behavior. |
||||
*/ |
||||
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null; |
||||
/** |
||||
When enabled (defaults to off), this will cause the lint panel |
||||
to automatically open when diagnostics are found, and close when |
||||
all diagnostics are resolved or removed. |
||||
*/ |
||||
autoPanel?: boolean; |
||||
} |
||||
interface LintGutterConfig { |
||||
/** |
||||
The delay before showing a tooltip when hovering over a lint gutter marker. |
||||
*/ |
||||
hoverTime?: number; |
||||
/** |
||||
Optional filter determining which diagnostics show a marker in |
||||
the gutter. |
||||
*/ |
||||
markerFilter?: null | DiagnosticFilter; |
||||
/** |
||||
Optional filter for diagnostics displayed in a tooltip, which |
||||
can also be used to prevent a tooltip appearing. |
||||
*/ |
||||
tooltipFilter?: null | DiagnosticFilter; |
||||
} |
||||
/** |
||||
Returns a transaction spec which updates the current set of |
||||
diagnostics, and enables the lint extension if if wasn't already |
||||
active. |
||||
*/ |
||||
declare function setDiagnostics(state: EditorState, diagnostics: readonly Diagnostic[]): TransactionSpec; |
||||
/** |
||||
The state effect that updates the set of active diagnostics. Can |
||||
be useful when writing an extension that needs to track these. |
||||
*/ |
||||
declare const setDiagnosticsEffect: _codemirror_state.StateEffectType<readonly Diagnostic[]>; |
||||
/** |
||||
Returns the number of active lint diagnostics in the given state. |
||||
*/ |
||||
declare function diagnosticCount(state: EditorState): number; |
||||
/** |
||||
Command to open and focus the lint panel. |
||||
*/ |
||||
declare const openLintPanel: Command; |
||||
/** |
||||
Command to close the lint panel, when open. |
||||
*/ |
||||
declare const closeLintPanel: Command; |
||||
/** |
||||
Move the selection to the next diagnostic. |
||||
*/ |
||||
declare const nextDiagnostic: Command; |
||||
/** |
||||
Move the selection to the previous diagnostic. |
||||
*/ |
||||
declare const previousDiagnostic: Command; |
||||
/** |
||||
A set of default key bindings for the lint functionality. |
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/ |
||||
declare const lintKeymap: readonly KeyBinding[]; |
||||
/** |
||||
The type of a function that produces diagnostics. |
||||
*/ |
||||
type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>; |
||||
/** |
||||
Given a diagnostic source, this function returns an extension that |
||||
enables linting with that source. It will be called whenever the |
||||
editor is idle (after its content changed). |
||||
|
||||
Note that settings given here will apply to all linters active in |
||||
the editor. If `null` is given as source, this only configures the |
||||
lint extension. |
||||
*/ |
||||
declare function linter(source: LintSource | null, config?: LintConfig): Extension; |
||||
/** |
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away. |
||||
*/ |
||||
declare function forceLinting(view: EditorView): void; |
||||
/** |
||||
Returns an extension that installs a gutter showing markers for |
||||
each line that has diagnostics, which can be hovered over to see |
||||
the diagnostics. |
||||
*/ |
||||
declare function lintGutter(config?: LintGutterConfig): Extension; |
||||
/** |
||||
Iterate over the marked diagnostics for the given editor state, |
||||
calling `f` for each of them. Note that, if the document changed |
||||
since the diagnostics were created, the `Diagnostic` object will |
||||
hold the original outdated position, whereas the `to` and `from` |
||||
arguments hold the diagnostic's current position. |
||||
*/ |
||||
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void; |
||||
|
||||
export { type Action, type Diagnostic, type LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect }; |
||||
@ -0,0 +1,937 @@
@@ -0,0 +1,937 @@
|
||||
import { Decoration, showPanel, EditorView, ViewPlugin, gutter, showTooltip, hoverTooltip, getPanel, logException, WidgetType, GutterMarker } from '@codemirror/view'; |
||||
import { StateEffect, StateField, Facet, combineConfig, RangeSet, RangeSetBuilder } from '@codemirror/state'; |
||||
import elt from 'crelt'; |
||||
|
||||
class SelectedDiagnostic { |
||||
constructor(from, to, diagnostic) { |
||||
this.from = from; |
||||
this.to = to; |
||||
this.diagnostic = diagnostic; |
||||
} |
||||
} |
||||
class LintState { |
||||
constructor(diagnostics, panel, selected) { |
||||
this.diagnostics = diagnostics; |
||||
this.panel = panel; |
||||
this.selected = selected; |
||||
} |
||||
static init(diagnostics, panel, state) { |
||||
// Filter the list of diagnostics for which to create markers
|
||||
let diagnosticFilter = state.facet(lintConfig).markerFilter; |
||||
if (diagnosticFilter) |
||||
diagnostics = diagnosticFilter(diagnostics, state); |
||||
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to); |
||||
let deco = new RangeSetBuilder(), active = [], pos = 0; |
||||
let scan = state.doc.iter(), scanPos = 0, docLen = state.doc.length; |
||||
for (let i = 0;;) { |
||||
let next = i == sorted.length ? null : sorted[i]; |
||||
if (!next && !active.length) |
||||
break; |
||||
let from, to; |
||||
if (active.length) { |
||||
from = pos; |
||||
to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8); |
||||
} |
||||
else { |
||||
from = next.from; |
||||
if (from > docLen) |
||||
break; |
||||
to = next.to; |
||||
active.push(next); |
||||
i++; |
||||
} |
||||
while (i < sorted.length) { |
||||
let next = sorted[i]; |
||||
if (next.from == from && (next.to > next.from || next.to == from)) { |
||||
active.push(next); |
||||
i++; |
||||
to = Math.min(next.to, to); |
||||
} |
||||
else { |
||||
to = Math.min(next.from, to); |
||||
break; |
||||
} |
||||
} |
||||
to = Math.min(to, docLen); |
||||
let widget = false; |
||||
if (active.some(d => d.from == from && (d.to == to || to == docLen))) { |
||||
widget = from == to; |
||||
if (!widget && to - from < 10) { |
||||
let behind = from - (scanPos + scan.value.length); |
||||
if (behind > 0) { |
||||
scan.next(behind); |
||||
scanPos = from; |
||||
} |
||||
for (let check = from;;) { |
||||
if (check >= to) { |
||||
widget = true; |
||||
break; |
||||
} |
||||
if (!scan.lineBreak && scanPos + scan.value.length > check) |
||||
break; |
||||
check = scanPos + scan.value.length; |
||||
scanPos += scan.value.length; |
||||
scan.next(); |
||||
} |
||||
} |
||||
} |
||||
let sev = maxSeverity(active); |
||||
if (widget) { |
||||
deco.add(from, from, Decoration.widget({ |
||||
widget: new DiagnosticWidget(sev), |
||||
diagnostics: active.slice() |
||||
})); |
||||
} |
||||
else { |
||||
let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, ""); |
||||
deco.add(from, to, Decoration.mark({ |
||||
class: "cm-lintRange cm-lintRange-" + sev + markClass, |
||||
diagnostics: active.slice(), |
||||
inclusiveEnd: active.some(a => a.to > to) |
||||
})); |
||||
} |
||||
pos = to; |
||||
if (pos == docLen) |
||||
break; |
||||
for (let i = 0; i < active.length; i++) |
||||
if (active[i].to <= pos) |
||||
active.splice(i--, 1); |
||||
} |
||||
let set = deco.finish(); |
||||
return new LintState(set, panel, findDiagnostic(set)); |
||||
} |
||||
} |
||||
function findDiagnostic(diagnostics, diagnostic = null, after = 0) { |
||||
let found = null; |
||||
diagnostics.between(after, 1e9, (from, to, { spec }) => { |
||||
if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0) |
||||
return; |
||||
if (!found) |
||||
found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]); |
||||
else if (spec.diagnostics.indexOf(found.diagnostic) < 0) |
||||
return false; |
||||
else |
||||
found = new SelectedDiagnostic(found.from, to, found.diagnostic); |
||||
}); |
||||
return found; |
||||
} |
||||
function hideTooltip(tr, tooltip) { |
||||
let from = tooltip.pos, to = tooltip.end || from; |
||||
let result = tr.state.facet(lintConfig).hideOn(tr, from, to); |
||||
if (result != null) |
||||
return result; |
||||
let line = tr.startState.doc.lineAt(tooltip.pos); |
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to))); |
||||
} |
||||
function maybeEnableLint(state, effects) { |
||||
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions)); |
||||
} |
||||
/** |
||||
Returns a transaction spec which updates the current set of |
||||
diagnostics, and enables the lint extension if if wasn't already |
||||
active. |
||||
*/ |
||||
function setDiagnostics(state, diagnostics) { |
||||
return { |
||||
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)]) |
||||
}; |
||||
} |
||||
/** |
||||
The state effect that updates the set of active diagnostics. Can |
||||
be useful when writing an extension that needs to track these. |
||||
*/ |
||||
const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define(); |
||||
const togglePanel = /*@__PURE__*/StateEffect.define(); |
||||
const movePanelSelection = /*@__PURE__*/StateEffect.define(); |
||||
const lintState = /*@__PURE__*/StateField.define({ |
||||
create() { |
||||
return new LintState(Decoration.none, null, null); |
||||
}, |
||||
update(value, tr) { |
||||
if (tr.docChanged && value.diagnostics.size) { |
||||
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel; |
||||
if (value.selected) { |
||||
let selPos = tr.changes.mapPos(value.selected.from, 1); |
||||
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos); |
||||
} |
||||
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel) |
||||
panel = null; |
||||
value = new LintState(mapped, panel, selected); |
||||
} |
||||
for (let effect of tr.effects) { |
||||
if (effect.is(setDiagnosticsEffect)) { |
||||
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null; |
||||
value = LintState.init(effect.value, panel, tr.state); |
||||
} |
||||
else if (effect.is(togglePanel)) { |
||||
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected); |
||||
} |
||||
else if (effect.is(movePanelSelection)) { |
||||
value = new LintState(value.diagnostics, value.panel, effect.value); |
||||
} |
||||
} |
||||
return value; |
||||
}, |
||||
provide: f => [showPanel.from(f, val => val.panel), |
||||
EditorView.decorations.from(f, s => s.diagnostics)] |
||||
}); |
||||
/** |
||||
Returns the number of active lint diagnostics in the given state. |
||||
*/ |
||||
function diagnosticCount(state) { |
||||
let lint = state.field(lintState, false); |
||||
return lint ? lint.diagnostics.size : 0; |
||||
} |
||||
const activeMark = /*@__PURE__*/Decoration.mark({ class: "cm-lintRange cm-lintRange-active" }); |
||||
function lintTooltip(view, pos, side) { |
||||
let { diagnostics } = view.state.field(lintState); |
||||
let found, start = -1, end = -1; |
||||
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => { |
||||
if (pos >= from && pos <= to && |
||||
(from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) { |
||||
found = spec.diagnostics; |
||||
start = from; |
||||
end = to; |
||||
return false; |
||||
} |
||||
}); |
||||
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter; |
||||
if (found && diagnosticFilter) |
||||
found = diagnosticFilter(found, view.state); |
||||
if (!found) |
||||
return null; |
||||
return { |
||||
pos: start, |
||||
end: end, |
||||
above: view.state.doc.lineAt(start).to < end, |
||||
create() { |
||||
return { dom: diagnosticsTooltip(view, found) }; |
||||
} |
||||
}; |
||||
} |
||||
function diagnosticsTooltip(view, diagnostics) { |
||||
return elt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false))); |
||||
} |
||||
/** |
||||
Command to open and focus the lint panel. |
||||
*/ |
||||
const openLintPanel = (view) => { |
||||
let field = view.state.field(lintState, false); |
||||
if (!field || !field.panel) |
||||
view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) }); |
||||
let panel = getPanel(view, LintPanel.open); |
||||
if (panel) |
||||
panel.dom.querySelector(".cm-panel-lint ul").focus(); |
||||
return true; |
||||
}; |
||||
/** |
||||
Command to close the lint panel, when open. |
||||
*/ |
||||
const closeLintPanel = (view) => { |
||||
let field = view.state.field(lintState, false); |
||||
if (!field || !field.panel) |
||||
return false; |
||||
view.dispatch({ effects: togglePanel.of(false) }); |
||||
return true; |
||||
}; |
||||
/** |
||||
Move the selection to the next diagnostic. |
||||
*/ |
||||
const nextDiagnostic = (view) => { |
||||
let field = view.state.field(lintState, false); |
||||
if (!field) |
||||
return false; |
||||
let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1); |
||||
if (!next.value) { |
||||
next = field.diagnostics.iter(0); |
||||
if (!next.value || next.from == sel.from && next.to == sel.to) |
||||
return false; |
||||
} |
||||
view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true }); |
||||
return true; |
||||
}; |
||||
/** |
||||
Move the selection to the previous diagnostic. |
||||
*/ |
||||
const previousDiagnostic = (view) => { |
||||
let { state } = view, field = state.field(lintState, false); |
||||
if (!field) |
||||
return false; |
||||
let sel = state.selection.main; |
||||
let prevFrom, prevTo, lastFrom, lastTo; |
||||
field.diagnostics.between(0, state.doc.length, (from, to) => { |
||||
if (to < sel.to && (prevFrom == null || prevFrom < from)) { |
||||
prevFrom = from; |
||||
prevTo = to; |
||||
} |
||||
if (lastFrom == null || from > lastFrom) { |
||||
lastFrom = from; |
||||
lastTo = to; |
||||
} |
||||
}); |
||||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from) |
||||
return false; |
||||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true }); |
||||
return true; |
||||
}; |
||||
/** |
||||
A set of default key bindings for the lint functionality. |
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/ |
||||
const lintKeymap = [ |
||||
{ key: "Mod-Shift-m", run: openLintPanel, preventDefault: true }, |
||||
{ key: "F8", run: nextDiagnostic } |
||||
]; |
||||
const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class { |
||||
constructor(view) { |
||||
this.view = view; |
||||
this.timeout = -1; |
||||
this.set = true; |
||||
let { delay } = view.state.facet(lintConfig); |
||||
this.lintTime = Date.now() + delay; |
||||
this.run = this.run.bind(this); |
||||
this.timeout = setTimeout(this.run, delay); |
||||
} |
||||
run() { |
||||
clearTimeout(this.timeout); |
||||
let now = Date.now(); |
||||
if (now < this.lintTime - 10) { |
||||
this.timeout = setTimeout(this.run, this.lintTime - now); |
||||
} |
||||
else { |
||||
this.set = false; |
||||
let { state } = this.view, { sources } = state.facet(lintConfig); |
||||
if (sources.length) |
||||
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => { |
||||
if (this.view.state.doc == state.doc) |
||||
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b)))); |
||||
}, error => { logException(this.view.state, error); }); |
||||
} |
||||
} |
||||
update(update) { |
||||
let config = update.state.facet(lintConfig); |
||||
if (update.docChanged || config != update.startState.facet(lintConfig) || |
||||
config.needsRefresh && config.needsRefresh(update)) { |
||||
this.lintTime = Date.now() + config.delay; |
||||
if (!this.set) { |
||||
this.set = true; |
||||
this.timeout = setTimeout(this.run, config.delay); |
||||
} |
||||
} |
||||
} |
||||
force() { |
||||
if (this.set) { |
||||
this.lintTime = Date.now(); |
||||
this.run(); |
||||
} |
||||
} |
||||
destroy() { |
||||
clearTimeout(this.timeout); |
||||
} |
||||
}); |
||||
function batchResults(promises, sink, error) { |
||||
let collected = [], timeout = -1; |
||||
for (let p of promises) |
||||
p.then(value => { |
||||
collected.push(value); |
||||
clearTimeout(timeout); |
||||
if (collected.length == promises.length) |
||||
sink(collected); |
||||
else |
||||
timeout = setTimeout(() => sink(collected), 200); |
||||
}, error); |
||||
} |
||||
const lintConfig = /*@__PURE__*/Facet.define({ |
||||
combine(input) { |
||||
return { |
||||
sources: input.map(i => i.source).filter(x => x != null), |
||||
...combineConfig(input.map(i => i.config), { |
||||
delay: 750, |
||||
markerFilter: null, |
||||
tooltipFilter: null, |
||||
needsRefresh: null, |
||||
hideOn: () => null, |
||||
}, { |
||||
delay: Math.max, |
||||
markerFilter: combineFilter, |
||||
tooltipFilter: combineFilter, |
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u), |
||||
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y), |
||||
autoPanel: (a, b) => a || b |
||||
}) |
||||
}; |
||||
} |
||||
}); |
||||
function combineFilter(a, b) { |
||||
return !a ? b : !b ? a : (d, s) => b(a(d, s), s); |
||||
} |
||||
/** |
||||
Given a diagnostic source, this function returns an extension that |
||||
enables linting with that source. It will be called whenever the |
||||
editor is idle (after its content changed). |
||||
|
||||
Note that settings given here will apply to all linters active in |
||||
the editor. If `null` is given as source, this only configures the |
||||
lint extension. |
||||
*/ |
||||
function linter(source, config = {}) { |
||||
return [ |
||||
lintConfig.of({ source, config }), |
||||
lintPlugin, |
||||
lintExtensions |
||||
]; |
||||
} |
||||
/** |
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away. |
||||
*/ |
||||
function forceLinting(view) { |
||||
let plugin = view.plugin(lintPlugin); |
||||
if (plugin) |
||||
plugin.force(); |
||||
} |
||||
function assignKeys(actions) { |
||||
let assigned = []; |
||||
if (actions) |
||||
actions: for (let { name } of actions) { |
||||
for (let i = 0; i < name.length; i++) { |
||||
let ch = name[i]; |
||||
if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) { |
||||
assigned.push(ch); |
||||
continue actions; |
||||
} |
||||
} |
||||
assigned.push(""); |
||||
} |
||||
return assigned; |
||||
} |
||||
function renderDiagnostic(view, diagnostic, inPanel) { |
||||
var _a; |
||||
let keys = inPanel ? assignKeys(diagnostic.actions) : []; |
||||
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => { |
||||
let fired = false, click = (e) => { |
||||
e.preventDefault(); |
||||
if (fired) |
||||
return; |
||||
fired = true; |
||||
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic); |
||||
if (found) |
||||
action.apply(view, found.from, found.to); |
||||
}; |
||||
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1; |
||||
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex), |
||||
elt("u", name.slice(keyIndex, keyIndex + 1)), |
||||
name.slice(keyIndex + 1)]; |
||||
let markClass = action.markClass ? " " + action.markClass : ""; |
||||
return elt("button", { |
||||
type: "button", |
||||
class: "cm-diagnosticAction" + markClass, |
||||
onclick: click, |
||||
onmousedown: click, |
||||
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.` |
||||
}, nameElt); |
||||
}), diagnostic.source && elt("div", { class: "cm-diagnosticSource" }, diagnostic.source)); |
||||
} |
||||
class DiagnosticWidget extends WidgetType { |
||||
constructor(sev) { |
||||
super(); |
||||
this.sev = sev; |
||||
} |
||||
eq(other) { return other.sev == this.sev; } |
||||
toDOM() { |
||||
return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev }); |
||||
} |
||||
} |
||||
class PanelItem { |
||||
constructor(view, diagnostic) { |
||||
this.diagnostic = diagnostic; |
||||
this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16); |
||||
this.dom = renderDiagnostic(view, diagnostic, true); |
||||
this.dom.id = this.id; |
||||
this.dom.setAttribute("role", "option"); |
||||
} |
||||
} |
||||
class LintPanel { |
||||
constructor(view) { |
||||
this.view = view; |
||||
this.items = []; |
||||
let onkeydown = (event) => { |
||||
if (event.keyCode == 27) { // Escape
|
||||
closeLintPanel(this.view); |
||||
this.view.focus(); |
||||
} |
||||
else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
|
||||
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length); |
||||
} |
||||
else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
|
||||
this.moveSelection((this.selectedIndex + 1) % this.items.length); |
||||
} |
||||
else if (event.keyCode == 36) { // Home
|
||||
this.moveSelection(0); |
||||
} |
||||
else if (event.keyCode == 35) { // End
|
||||
this.moveSelection(this.items.length - 1); |
||||
} |
||||
else if (event.keyCode == 13) { // Enter
|
||||
this.view.focus(); |
||||
} |
||||
else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
|
||||
let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions); |
||||
for (let i = 0; i < keys.length; i++) |
||||
if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) { |
||||
let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic); |
||||
if (found) |
||||
diagnostic.actions[i].apply(view, found.from, found.to); |
||||
} |
||||
} |
||||
else { |
||||
return; |
||||
} |
||||
event.preventDefault(); |
||||
}; |
||||
let onclick = (event) => { |
||||
for (let i = 0; i < this.items.length; i++) { |
||||
if (this.items[i].dom.contains(event.target)) |
||||
this.moveSelection(i); |
||||
} |
||||
}; |
||||
this.list = elt("ul", { |
||||
tabIndex: 0, |
||||
role: "listbox", |
||||
"aria-label": this.view.state.phrase("Diagnostics"), |
||||
onkeydown, |
||||
onclick |
||||
}); |
||||
this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", { |
||||
type: "button", |
||||
name: "close", |
||||
"aria-label": this.view.state.phrase("close"), |
||||
onclick: () => closeLintPanel(this.view) |
||||
}, "×")); |
||||
this.update(); |
||||
} |
||||
get selectedIndex() { |
||||
let selected = this.view.state.field(lintState).selected; |
||||
if (!selected) |
||||
return -1; |
||||
for (let i = 0; i < this.items.length; i++) |
||||
if (this.items[i].diagnostic == selected.diagnostic) |
||||
return i; |
||||
return -1; |
||||
} |
||||
update() { |
||||
let { diagnostics, selected } = this.view.state.field(lintState); |
||||
let i = 0, needsSync = false, newSelectedItem = null; |
||||
let seen = new Set(); |
||||
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => { |
||||
for (let diagnostic of spec.diagnostics) { |
||||
if (seen.has(diagnostic)) |
||||
continue; |
||||
seen.add(diagnostic); |
||||
let found = -1, item; |
||||
for (let j = i; j < this.items.length; j++) |
||||
if (this.items[j].diagnostic == diagnostic) { |
||||
found = j; |
||||
break; |
||||
} |
||||
if (found < 0) { |
||||
item = new PanelItem(this.view, diagnostic); |
||||
this.items.splice(i, 0, item); |
||||
needsSync = true; |
||||
} |
||||
else { |
||||
item = this.items[found]; |
||||
if (found > i) { |
||||
this.items.splice(i, found - i); |
||||
needsSync = true; |
||||
} |
||||
} |
||||
if (selected && item.diagnostic == selected.diagnostic) { |
||||
if (!item.dom.hasAttribute("aria-selected")) { |
||||
item.dom.setAttribute("aria-selected", "true"); |
||||
newSelectedItem = item; |
||||
} |
||||
} |
||||
else if (item.dom.hasAttribute("aria-selected")) { |
||||
item.dom.removeAttribute("aria-selected"); |
||||
} |
||||
i++; |
||||
} |
||||
}); |
||||
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) { |
||||
needsSync = true; |
||||
this.items.pop(); |
||||
} |
||||
if (this.items.length == 0) { |
||||
this.items.push(new PanelItem(this.view, { |
||||
from: -1, to: -1, |
||||
severity: "info", |
||||
message: this.view.state.phrase("No diagnostics") |
||||
})); |
||||
needsSync = true; |
||||
} |
||||
if (newSelectedItem) { |
||||
this.list.setAttribute("aria-activedescendant", newSelectedItem.id); |
||||
this.view.requestMeasure({ |
||||
key: this, |
||||
read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }), |
||||
write: ({ sel, panel }) => { |
||||
let scaleY = panel.height / this.list.offsetHeight; |
||||
if (sel.top < panel.top) |
||||
this.list.scrollTop -= (panel.top - sel.top) / scaleY; |
||||
else if (sel.bottom > panel.bottom) |
||||
this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY; |
||||
} |
||||
}); |
||||
} |
||||
else if (this.selectedIndex < 0) { |
||||
this.list.removeAttribute("aria-activedescendant"); |
||||
} |
||||
if (needsSync) |
||||
this.sync(); |
||||
} |
||||
sync() { |
||||
let domPos = this.list.firstChild; |
||||
function rm() { |
||||
let prev = domPos; |
||||
domPos = prev.nextSibling; |
||||
prev.remove(); |
||||
} |
||||
for (let item of this.items) { |
||||
if (item.dom.parentNode == this.list) { |
||||
while (domPos != item.dom) |
||||
rm(); |
||||
domPos = item.dom.nextSibling; |
||||
} |
||||
else { |
||||
this.list.insertBefore(item.dom, domPos); |
||||
} |
||||
} |
||||
while (domPos) |
||||
rm(); |
||||
} |
||||
moveSelection(selectedIndex) { |
||||
if (this.selectedIndex < 0) |
||||
return; |
||||
let field = this.view.state.field(lintState); |
||||
let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic); |
||||
if (!selection) |
||||
return; |
||||
this.view.dispatch({ |
||||
selection: { anchor: selection.from, head: selection.to }, |
||||
scrollIntoView: true, |
||||
effects: movePanelSelection.of(selection) |
||||
}); |
||||
} |
||||
static open(view) { return new LintPanel(view); } |
||||
} |
||||
function svg(content, attrs = `viewBox="0 0 40 40"`) { |
||||
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`; |
||||
} |
||||
function underline(color) { |
||||
return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`); |
||||
} |
||||
const baseTheme = /*@__PURE__*/EditorView.baseTheme({ |
||||
".cm-diagnostic": { |
||||
padding: "3px 6px 3px 8px", |
||||
marginLeft: "-1px", |
||||
display: "block", |
||||
whiteSpace: "pre-wrap" |
||||
}, |
||||
".cm-diagnostic-error": { borderLeft: "5px solid #d11" }, |
||||
".cm-diagnostic-warning": { borderLeft: "5px solid orange" }, |
||||
".cm-diagnostic-info": { borderLeft: "5px solid #999" }, |
||||
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" }, |
||||
".cm-diagnosticAction": { |
||||
font: "inherit", |
||||
border: "none", |
||||
padding: "2px 4px", |
||||
backgroundColor: "#444", |
||||
color: "white", |
||||
borderRadius: "3px", |
||||
marginLeft: "8px", |
||||
cursor: "pointer" |
||||
}, |
||||
".cm-diagnosticSource": { |
||||
fontSize: "70%", |
||||
opacity: .7 |
||||
}, |
||||
".cm-lintRange": { |
||||
backgroundPosition: "left bottom", |
||||
backgroundRepeat: "repeat-x", |
||||
paddingBottom: "0.7px", |
||||
}, |
||||
".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") }, |
||||
".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") }, |
||||
".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") }, |
||||
".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/underline("#66d") }, |
||||
".cm-lintRange-active": { backgroundColor: "#ffdd9980" }, |
||||
".cm-tooltip-lint": { |
||||
padding: 0, |
||||
margin: 0 |
||||
}, |
||||
".cm-lintPoint": { |
||||
position: "relative", |
||||
"&:after": { |
||||
content: '""', |
||||
position: "absolute", |
||||
bottom: 0, |
||||
left: "-2px", |
||||
borderLeft: "3px solid transparent", |
||||
borderRight: "3px solid transparent", |
||||
borderBottom: "4px solid #d11" |
||||
} |
||||
}, |
||||
".cm-lintPoint-warning": { |
||||
"&:after": { borderBottomColor: "orange" } |
||||
}, |
||||
".cm-lintPoint-info": { |
||||
"&:after": { borderBottomColor: "#999" } |
||||
}, |
||||
".cm-lintPoint-hint": { |
||||
"&:after": { borderBottomColor: "#66d" } |
||||
}, |
||||
".cm-panel.cm-panel-lint": { |
||||
position: "relative", |
||||
"& ul": { |
||||
maxHeight: "100px", |
||||
overflowY: "auto", |
||||
"& [aria-selected]": { |
||||
backgroundColor: "#ddd", |
||||
"& u": { textDecoration: "underline" } |
||||
}, |
||||
"&:focus [aria-selected]": { |
||||
background_fallback: "#bdf", |
||||
backgroundColor: "Highlight", |
||||
color_fallback: "white", |
||||
color: "HighlightText" |
||||
}, |
||||
"& u": { textDecoration: "none" }, |
||||
padding: 0, |
||||
margin: 0 |
||||
}, |
||||
"& [name=close]": { |
||||
position: "absolute", |
||||
top: "0", |
||||
right: "2px", |
||||
background: "inherit", |
||||
border: "none", |
||||
font: "inherit", |
||||
padding: 0, |
||||
margin: 0 |
||||
} |
||||
} |
||||
}); |
||||
function severityWeight(sev) { |
||||
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1; |
||||
} |
||||
function maxSeverity(diagnostics) { |
||||
let sev = "hint", weight = 1; |
||||
for (let d of diagnostics) { |
||||
let w = severityWeight(d.severity); |
||||
if (w > weight) { |
||||
weight = w; |
||||
sev = d.severity; |
||||
} |
||||
} |
||||
return sev; |
||||
} |
||||
class LintGutterMarker extends GutterMarker { |
||||
constructor(diagnostics) { |
||||
super(); |
||||
this.diagnostics = diagnostics; |
||||
this.severity = maxSeverity(diagnostics); |
||||
} |
||||
toDOM(view) { |
||||
let elt = document.createElement("div"); |
||||
elt.className = "cm-lint-marker cm-lint-marker-" + this.severity; |
||||
let diagnostics = this.diagnostics; |
||||
let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter; |
||||
if (diagnosticsFilter) |
||||
diagnostics = diagnosticsFilter(diagnostics, view.state); |
||||
if (diagnostics.length) |
||||
elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics); |
||||
return elt; |
||||
} |
||||
} |
||||
function trackHoverOn(view, marker) { |
||||
let mousemove = (event) => { |
||||
let rect = marker.getBoundingClientRect(); |
||||
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ && |
||||
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */) |
||||
return; |
||||
for (let target = event.target; target; target = target.parentNode) { |
||||
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint")) |
||||
return; |
||||
} |
||||
window.removeEventListener("mousemove", mousemove); |
||||
if (view.state.field(lintGutterTooltip)) |
||||
view.dispatch({ effects: setLintGutterTooltip.of(null) }); |
||||
}; |
||||
window.addEventListener("mousemove", mousemove); |
||||
} |
||||
function gutterMarkerMouseOver(view, marker, diagnostics) { |
||||
function hovered() { |
||||
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop); |
||||
const linePos = view.coordsAtPos(line.from); |
||||
if (linePos) { |
||||
view.dispatch({ effects: setLintGutterTooltip.of({ |
||||
pos: line.from, |
||||
above: false, |
||||
clip: false, |
||||
create() { |
||||
return { |
||||
dom: diagnosticsTooltip(view, diagnostics), |
||||
getCoords: () => marker.getBoundingClientRect() |
||||
}; |
||||
} |
||||
}) }); |
||||
} |
||||
marker.onmouseout = marker.onmousemove = null; |
||||
trackHoverOn(view, marker); |
||||
} |
||||
let { hoverTime } = view.state.facet(lintGutterConfig); |
||||
let hoverTimeout = setTimeout(hovered, hoverTime); |
||||
marker.onmouseout = () => { |
||||
clearTimeout(hoverTimeout); |
||||
marker.onmouseout = marker.onmousemove = null; |
||||
}; |
||||
marker.onmousemove = () => { |
||||
clearTimeout(hoverTimeout); |
||||
hoverTimeout = setTimeout(hovered, hoverTime); |
||||
}; |
||||
} |
||||
function markersForDiagnostics(doc, diagnostics) { |
||||
let byLine = Object.create(null); |
||||
for (let diagnostic of diagnostics) { |
||||
let line = doc.lineAt(diagnostic.from); |
||||
(byLine[line.from] || (byLine[line.from] = [])).push(diagnostic); |
||||
} |
||||
let markers = []; |
||||
for (let line in byLine) { |
||||
markers.push(new LintGutterMarker(byLine[line]).range(+line)); |
||||
} |
||||
return RangeSet.of(markers, true); |
||||
} |
||||
const lintGutterExtension = /*@__PURE__*/gutter({ |
||||
class: "cm-gutter-lint", |
||||
markers: view => view.state.field(lintGutterMarkers), |
||||
widgetMarker: (view, widget, block) => { |
||||
let diagnostics = []; |
||||
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => { |
||||
if (from > block.from && from < block.to) |
||||
diagnostics.push(...value.diagnostics); |
||||
}); |
||||
return diagnostics.length ? new LintGutterMarker(diagnostics) : null; |
||||
} |
||||
}); |
||||
const lintGutterMarkers = /*@__PURE__*/StateField.define({ |
||||
create() { |
||||
return RangeSet.empty; |
||||
}, |
||||
update(markers, tr) { |
||||
markers = markers.map(tr.changes); |
||||
let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter; |
||||
for (let effect of tr.effects) { |
||||
if (effect.is(setDiagnosticsEffect)) { |
||||
let diagnostics = effect.value; |
||||
if (diagnosticFilter) |
||||
diagnostics = diagnosticFilter(diagnostics || [], tr.state); |
||||
markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0)); |
||||
} |
||||
} |
||||
return markers; |
||||
} |
||||
}); |
||||
const setLintGutterTooltip = /*@__PURE__*/StateEffect.define(); |
||||
const lintGutterTooltip = /*@__PURE__*/StateField.define({ |
||||
create() { return null; }, |
||||
update(tooltip, tr) { |
||||
if (tooltip && tr.docChanged) |
||||
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) }; |
||||
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip); |
||||
}, |
||||
provide: field => showTooltip.from(field) |
||||
}); |
||||
const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({ |
||||
".cm-gutter-lint": { |
||||
width: "1.4em", |
||||
"& .cm-gutterElement": { |
||||
padding: ".2em" |
||||
} |
||||
}, |
||||
".cm-lint-marker": { |
||||
width: "1em", |
||||
height: "1em" |
||||
}, |
||||
".cm-lint-marker-info": { |
||||
content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`) |
||||
}, |
||||
".cm-lint-marker-warning": { |
||||
content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`), |
||||
}, |
||||
".cm-lint-marker-error": { |
||||
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`) |
||||
}, |
||||
}); |
||||
const lintExtensions = [ |
||||
lintState, |
||||
/*@__PURE__*/EditorView.decorations.compute([lintState], state => { |
||||
let { selected, panel } = state.field(lintState); |
||||
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([ |
||||
activeMark.range(selected.from, selected.to) |
||||
]); |
||||
}), |
||||
/*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }), |
||||
baseTheme |
||||
]; |
||||
const lintGutterConfig = /*@__PURE__*/Facet.define({ |
||||
combine(configs) { |
||||
return combineConfig(configs, { |
||||
hoverTime: 300 /* Hover.Time */, |
||||
markerFilter: null, |
||||
tooltipFilter: null |
||||
}); |
||||
} |
||||
}); |
||||
/** |
||||
Returns an extension that installs a gutter showing markers for |
||||
each line that has diagnostics, which can be hovered over to see |
||||
the diagnostics. |
||||
*/ |
||||
function lintGutter(config = {}) { |
||||
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip]; |
||||
} |
||||
/** |
||||
Iterate over the marked diagnostics for the given editor state, |
||||
calling `f` for each of them. Note that, if the document changed |
||||
since the diagnostics were created, the `Diagnostic` object will |
||||
hold the original outdated position, whereas the `to` and `from` |
||||
arguments hold the diagnostic's current position. |
||||
*/ |
||||
function forEachDiagnostic(state, f) { |
||||
let lState = state.field(lintState, false); |
||||
if (lState && lState.diagnostics.size) { |
||||
let pending = [], pendingStart = [], lastEnd = -1; |
||||
for (let iter = RangeSet.iter([lState.diagnostics]);; iter.next()) { |
||||
for (let i = 0; i < pending.length; i++) |
||||
if (!iter.value || iter.value.spec.diagnostics.indexOf(pending[i]) < 0) { |
||||
f(pending[i], pendingStart[i], lastEnd); |
||||
pending.splice(i, 1); |
||||
pendingStart.splice(i--, 1); |
||||
} |
||||
if (!iter.value) |
||||
break; |
||||
for (let d of iter.value.spec.diagnostics) |
||||
if (pending.indexOf(d) < 0) { |
||||
pending.push(d); |
||||
pendingStart.push(iter.from); |
||||
} |
||||
lastEnd = iter.to; |
||||
} |
||||
} |
||||
} |
||||
|
||||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect }; |
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
{ |
||||
"name": "@codemirror/lint", |
||||
"version": "6.9.2", |
||||
"description": "Linting support for the CodeMirror code editor", |
||||
"scripts": { |
||||
"test": "cm-runtests", |
||||
"prepare": "cm-buildhelper src/lint.ts" |
||||
}, |
||||
"keywords": [ |
||||
"editor", |
||||
"code" |
||||
], |
||||
"author": { |
||||
"name": "Marijn Haverbeke", |
||||
"email": "marijn@haverbeke.berlin", |
||||
"url": "http://marijnhaverbeke.nl" |
||||
}, |
||||
"type": "module", |
||||
"main": "dist/index.cjs", |
||||
"exports": { |
||||
"import": "./dist/index.js", |
||||
"require": "./dist/index.cjs" |
||||
}, |
||||
"types": "dist/index.d.ts", |
||||
"module": "dist/index.js", |
||||
"sideEffects": false, |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@codemirror/state": "^6.0.0", |
||||
"@codemirror/view": "^6.35.0", |
||||
"crelt": "^1.0.5" |
||||
}, |
||||
"devDependencies": { |
||||
"@codemirror/buildhelper": "^1.0.0" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/codemirror/lint.git" |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI |
||||
on: push |
||||
|
||||
jobs: |
||||
build: |
||||
name: Dispatch to main repo |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Emit repository_dispatch |
||||
uses: mvasigh/dispatch-action@main |
||||
with: |
||||
# You should create a personal access token and store it in your repository |
||||
token: ${{ secrets.DISPATCH_AUTH }} |
||||
repo: dev |
||||
owner: codemirror |
||||
event_type: push |
||||
@ -0,0 +1,318 @@
@@ -0,0 +1,318 @@
|
||||
## 6.5.11 (2025-05-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue in `replaceNext` that could cause it to create an invalid selection when replacing past the end of the document. |
||||
|
||||
## 6.5.10 (2025-02-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add a close button to the `gotoLine` panel. |
||||
|
||||
## 6.5.9 (2025-02-12) |
||||
|
||||
### Bug fixes |
||||
|
||||
When replacing a regexp match, don't expand multi-digit replacement markers to numbers beyond the captured group count in the query. |
||||
|
||||
## 6.5.8 (2024-11-22) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that put the selection in the wrong place after running `replaceNext` with a regexp query that could match strings of different length. |
||||
|
||||
## 6.5.7 (2024-11-01) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where `findNext` and `findPrevious` would do nothing when the only match in the document was partially selected. |
||||
|
||||
Fix an infinite loop in `SearchCursor` when the normalizer function deletes characters. |
||||
|
||||
## 6.5.6 (2024-02-07) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `highlightSelectionMatches` include whitespace in the selection in its matches. |
||||
|
||||
Fix a bug that caused `SearchCursor` to return invalid ranges when matching astral chars that the the normalizer normalized to single-code-unit chars. |
||||
|
||||
## 6.5.5 (2023-11-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused codes like `\n` to be unescaped in strings inserted via replace placeholders like `$&`. |
||||
|
||||
Use the keybinding Mod-Alt-g for `gotoLine` to the search keymap, to make it usable for people whose keyboard layout uses Alt/Option-g to type some character. |
||||
|
||||
## 6.5.4 (2023-09-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused whole-word search to incorrectly check for word boundaries in some circumstances. |
||||
|
||||
## 6.5.3 (2023-09-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
The `gotoLine` dialog is now populated with the current line number when you open it. |
||||
|
||||
## 6.5.2 (2023-08-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't use the very lowest precedence for match highlighting decorations. |
||||
|
||||
## 6.5.1 (2023-08-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `gotoLine` prefer to scroll the target line to the middle of the view. |
||||
|
||||
Fix an issue in `SearchCursor` where character normalization could produce nonsensical matches. |
||||
|
||||
## 6.5.0 (2023-06-05) |
||||
|
||||
### New features |
||||
|
||||
The new `regexp` option to `search` can be used to control whether queries have the regexp flag on by default. |
||||
|
||||
## 6.4.0 (2023-04-25) |
||||
|
||||
### Bug fixes |
||||
|
||||
The `findNext` and `findPrevious` commands now select the search field text if that field is focused. |
||||
|
||||
### New features |
||||
|
||||
The `scrollToMatch` callback option now receives the editor view as a second parameter. |
||||
|
||||
## 6.3.0 (2023-03-20) |
||||
|
||||
### New features |
||||
|
||||
The new `scrollToMatch` search option allows you to adjust the way the editor scrolls search matches into view. |
||||
|
||||
## 6.2.3 (2022-11-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that hid the search dialog's close button when the editor was read-only. |
||||
|
||||
## 6.2.2 (2022-10-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
When `literal` is off, \n, \r, and \t escapes are now also supported in replacement text. |
||||
|
||||
Make sure search dialog inputs don't get treated as form fields when the editor is created inside a form. |
||||
|
||||
Fix a bug in `RegExpCursor` that would cause it to stop matching in the middle of a line when its current match position was equal to the length of the line. |
||||
|
||||
## 6.2.1 (2022-09-26) |
||||
|
||||
### Bug fixes |
||||
|
||||
By-word search queries will now skip any result that had word characters both before and after a match boundary. |
||||
|
||||
## 6.2.0 (2022-08-25) |
||||
|
||||
### New features |
||||
|
||||
A new `wholeWord` search query flag can be used to limit matches to whole words. |
||||
|
||||
`SearchCursor` and `RegExpCursor` now support a `test` parameter that can be used to ignore certain matches. |
||||
|
||||
## 6.1.0 (2022-08-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an infinite loop when the match position of a `RegExpCursor` ended up in the middle of an UTF16 surrogate pair. |
||||
|
||||
### New features |
||||
|
||||
The `literal` search option can now be set to make literal queries the default. |
||||
|
||||
The new `searchPanelOpen` function can be used to find out whether the search panel is open for a given state. |
||||
|
||||
## 6.0.1 (2022-07-22) |
||||
|
||||
### Bug fixes |
||||
|
||||
`findNext` and `findPrevious` will now return to the current result (and scroll it into view) if no other matches are found. |
||||
|
||||
## 6.0.0 (2022-06-08) |
||||
|
||||
### Bug fixes |
||||
|
||||
Don't crash when a custom search panel doesn't have a field named 'search'. |
||||
|
||||
Make sure replacements are announced to screen readers. |
||||
|
||||
## 0.20.1 (2022-04-22) |
||||
|
||||
### New features |
||||
|
||||
It is now possible to disable backslash escapes in search queries with the `literal` option. |
||||
|
||||
## 0.20.0 (2022-04-20) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make the `wholeWords` option to `highlightSelectionMatches` default to false, as intended. |
||||
|
||||
## 0.19.10 (2022-04-04) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure search matches are highlighted when scrolling new content into view. |
||||
|
||||
## 0.19.9 (2022-03-03) |
||||
|
||||
### New features |
||||
|
||||
The selection-matching extension now accepts a `wholeWords` option that makes it only highlight matches that span a whole word. Add SearchQuery.getCursor |
||||
|
||||
The `SearchQuery` class now has a `getCursor` method that allows external code to create a cursor for the query. |
||||
|
||||
## 0.19.8 (2022-02-14) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug that caused the search panel to start open when configuring a state with the `search()` extension. |
||||
|
||||
## 0.19.7 (2022-02-14) |
||||
|
||||
### Breaking changes |
||||
|
||||
`searchConfig` is deprecated in favor of `search` (but will exist until next major release). |
||||
|
||||
### New features |
||||
|
||||
The new `search` function is now used to enable and configure the search extension. |
||||
|
||||
## 0.19.6 (2022-01-27) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `selectNextOccurrence` scroll the newly selected range into view. |
||||
|
||||
## 0.19.5 (2021-12-16) |
||||
|
||||
### Breaking changes |
||||
|
||||
The search option `matchCase` was renamed to `caseSensitive` (the old name will continue to work until the next breaking release). |
||||
|
||||
### Bug fixes |
||||
|
||||
`openSearchPanel` will now update the search query to the current selection even if the panel was already open. |
||||
|
||||
### New features |
||||
|
||||
Client code can now pass a custom search panel creation function in the search configuration. |
||||
|
||||
The `getSearchQuery` function and `setSearchQuery` effect can now be used to inspect or change the current search query. |
||||
|
||||
## 0.19.4 (2021-12-02) |
||||
|
||||
### Bug fixes |
||||
|
||||
The search panel will no longer show the replace interface when the editor is read-only. |
||||
|
||||
## 0.19.3 (2021-11-22) |
||||
|
||||
### Bug fixes |
||||
|
||||
Add `userEvent` annotations to search and replace transactions. |
||||
|
||||
Make sure the editor handles keys bound to `findNext`/`findPrevious` even when there are no matches, to avoid the browser's search interrupting users. |
||||
|
||||
### New features |
||||
|
||||
Add a `Symbol.iterator` property to the cursor types, so that they can be used with `for`/`of`. |
||||
|
||||
## 0.19.2 (2021-09-16) |
||||
|
||||
### Bug fixes |
||||
|
||||
`selectNextOccurrence` will now only select partial words if the current main selection hold a partial word. |
||||
|
||||
Explicitly set the button's type to prevent the browser from submitting forms wrapped around the editor. |
||||
|
||||
## 0.19.1 (2021-09-06) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make `highlightSelectionMatches` not produce overlapping decorations, since those tend to just get unreadable. |
||||
|
||||
Make sure any existing search text is selected when opening the search panel. Add search config option to not match case when search panel is opened (#4) |
||||
|
||||
### New features |
||||
|
||||
The `searchConfig` function now takes a `matchCase` option that controls whether the search panel starts in case-sensitive mode. |
||||
|
||||
## 0.19.0 (2021-08-11) |
||||
|
||||
### Bug fixes |
||||
|
||||
Make sure to prevent the native Mod-d behavior so that the editor doesn't lose focus after selecting past the last occurrence. |
||||
|
||||
## 0.18.4 (2021-05-27) |
||||
|
||||
### New features |
||||
|
||||
Initialize the search query to the current selection, when there is one, when opening the search dialog. |
||||
|
||||
Add a `searchConfig` function, supporting an option to put the search panel at the top of the editor. |
||||
|
||||
## 0.18.3 (2021-05-18) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix a bug where the first search command in a new editor wouldn't properly open the panel. |
||||
|
||||
### New features |
||||
|
||||
New command `selectNextOccurrence` that selects the next occurrence of the selected word (bound to Mod-d in the search keymap). |
||||
|
||||
## 0.18.2 (2021-03-19) |
||||
|
||||
### Bug fixes |
||||
|
||||
The search interface and cursor will no longer include overlapping matches (aligning with what all other editors are doing). |
||||
|
||||
### New features |
||||
|
||||
The package now exports a `RegExpCursor` which is a search cursor that matches regular expression patterns. |
||||
|
||||
The search/replace interface now allows the user to use regular expressions. |
||||
|
||||
The `SearchCursor` class now has a `nextOverlapping` method that includes matches that start inside the previous match. |
||||
|
||||
Basic backslash escapes (\n, \r, \t, and \\) are now accepted in string search patterns in the UI. |
||||
|
||||
## 0.18.1 (2021-03-15) |
||||
|
||||
### Bug fixes |
||||
|
||||
Fix an issue where entering an invalid input in the goto-line dialog would submit a form and reload the page. |
||||
|
||||
## 0.18.0 (2021-03-03) |
||||
|
||||
### Breaking changes |
||||
|
||||
Update dependencies to 0.18. |
||||
|
||||
## 0.17.1 (2021-01-06) |
||||
|
||||
### New features |
||||
|
||||
The package now also exports a CommonJS module. |
||||
|
||||
## 0.17.0 (2020-12-29) |
||||
|
||||
### Breaking changes |
||||
|
||||
First numbered release. |
||||
|
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
# @codemirror/search [](https://www.npmjs.org/package/@codemirror/search) |
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#search) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/search/blob/main/CHANGELOG.md) ] |
||||
|
||||
This package implements search functionality for the |
||||
[CodeMirror](https://codemirror.net/) code editor. |
||||
|
||||
The [project page](https://codemirror.net/) has more information, a |
||||
number of [examples](https://codemirror.net/examples/) and the |
||||
[documentation](https://codemirror.net/docs/). |
||||
|
||||
This code is released under an |
||||
[MIT license](https://github.com/codemirror/search/tree/main/LICENSE). |
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit, |
||||
we have a [code of |
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies |
||||
to communication around the project. |
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue