Skip to content

Commit

Permalink
Merge branch 'release/3.0.10' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Aug 6, 2023
2 parents 0fbe208 + 472ac09 commit 0a5d9eb
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 40 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Create Release
run-name: Create release for ${{ github.event.client_payload.version }}

on:
repository_dispatch:
types:
- craftcms/new-release

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: ncipollo/release-action@v1
with:
body: ${{ github.event.client_payload.notes }}
makeLatest: ${{ github.event.client_payload.latest }}
name: ${{ github.event.client_payload.version }}
prerelease: ${{ github.event.client_payload.prerelease }}
tag: ${{ github.event.client_payload.tag }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file

## 3.0.10 - 2023.08.06
### Changed
* Clean up `IEditorOptionsSchema.json` to handle `<Record>` types and refactor `GoToLocationValues` to `$def`
* Automate release generation via GitHub action

### Fixed
* Handle the case where an existing field is being converted over to a Code Field, and it contains JSON data ([#11](https://github.com/nystudio107/craft-code-field/issues/11))
* Fixed an issue that would cause the **All** checkbox for the **Available Languages** field setting to not display the language dropdown ([#9](https://github.com/nystudio107/craft-code-field/issues/9))

## 3.0.9 - 2023.04.16
### Changed
* Refactor the `IEditorOptionsSchema.json` to use [`$defs`](https://json-schema.org/understanding-json-schema/structuring.html#defs) to make the JSON schema more structured/reusable
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-code-field",
"description": "Provides a Code Field that has a full-featured code editor with syntax highlighting & autocomplete",
"type": "craft-plugin",
"version": "3.0.9",
"version": "3.0.10",
"keywords": [
"craft",
"cms",
Expand All @@ -23,7 +23,7 @@
],
"require": {
"craftcms/cms": "^3.0.0",
"nystudio107/craft-code-editor": "^1.0.8"
"nystudio107/craft-code-editor": "^1.0.11"
},
"config": {
"allow-plugins": {
Expand Down
19 changes: 17 additions & 2 deletions src/fields/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,19 @@ public function normalizeValue($value, ElementInterface $element = null)
// If this is still a string (meaning it's not valid JSON), treat it as the value
if (\is_string($jsonValue)) {
$config['value'] = $jsonValue;
} else {
$value = $jsonValue;
}
if (\is_array($jsonValue)) {
// Check to make sure the array returned is an encoded `CodeData` config, with exactly
// the same expected key/value pairs
if (!array_diff_key($config, $jsonValue) && !array_diff_key($jsonValue, $config)) {
$value = $jsonValue;
} else {
// Otherwise treat it as JSON data
$value = [
'value' => $value,
'language' => 'json',
];
}
}
}
if (\is_array($value)) {
Expand Down Expand Up @@ -194,6 +205,10 @@ public function getInputHtml($value, ElementInterface $element = null): string
$monacoLanguages = require(__DIR__ . '/MonacoLanguages.php');
$decomposedLanguages = array_column($monacoLanguages, 'label', 'value');
$displayLanguages = array_intersect_key($decomposedLanguages, array_flip($this->availableLanguages));
// Handle "all" checkbox
if ($this->availableLanguages[0] === '*') {
$displayLanguages = $decomposedLanguages;
}
$displayLanguages = array_map(function ($k, $v) {
return ['value' => $k, 'label' => $v];
}, array_keys($displayLanguages), array_values($displayLanguages));
Expand Down
62 changes: 26 additions & 36 deletions src/resources/IEditorOptionsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,56 +910,34 @@
"type": "string"
},
"multiple": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
"$ref": "#/$defs/GoToLocationValues"
},
"multipleDeclarations": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
"$ref": "#/$defs/GoToLocationValues"
},
"multipleDefinitions": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
"$ref": "#/$defs/GoToLocationValues"
},
"multipleImplementations": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
"$ref": "#/$defs/GoToLocationValues"
},
"multipleReferences": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
"$ref": "#/$defs/GoToLocationValues"
},
"multipleTypeDefinitions": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
"$ref": "#/$defs/GoToLocationValues"
}
},
"type": "object"
},
"GoToLocationValues": {
"enum": [
"peek",
"gotoAndPeek",
"goto"
],
"type": "string"
},
"IGuidesOptions": {
"description": "Controls the behavior of editor guides.",
"properties": {
Expand Down Expand Up @@ -1566,10 +1544,22 @@
"description": "Controls the behavior of the unicode highlight feature (by default, ambiguous and invisible characters are highlighted).",
"properties": {
"allowedCharacters": {
"additionalProperties": {
"type": "boolean",
"enum": [
true
]
},
"description": "Defines allowed characters that are not being highlighted.",
"type": "object"
},
"allowedLocales": {
"additionalProperties": {
"type": "boolean",
"enum": [
true
]
},
"description": "Unicode characters that are common in allowed locales are not being highlighted.",
"type": "object"
},
Expand Down

0 comments on commit 0a5d9eb

Please sign in to comment.