Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/168-renamed-list-plugin-for-cke-v41
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/web/assets/ckeditor/dist/ckeditor5-craftcms.js
#	src/web/assets/ckeditor/dist/ckeditor5-craftcms.js.map
  • Loading branch information
brandonkelly committed Feb 21, 2024
2 parents 60e8f62 + a15a0d8 commit aea4168
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for CKEditor for Craft CMS

## Unreleased

- Added support for creating anchor links. ([#169](https://github.com/craftcms/ckeditor/discussions/169))
- Improved accessibility for screen readers. ([#74](https://github.com/craftcms/ckeditor/issues/74), [#166](https://github.com/craftcms/ckeditor/pull/166))
- Fixed a bug where resized images weren’t getting updated `width` and `height` attributes. ([#165](https://github.com/craftcms/ckeditor/pull/165))

## 3.7.3 - 2024-02-08

- Fixed a JavaScript error. ([#161](https://github.com/craftcms/ckeditor/issues/161))
Expand Down
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@ckeditor/ckeditor5-word-count": ">=41.0.0",
"@craftcms/sass": "^1.1.0",
"@craftcms/webpack": "^1.1.2",
"@northernco/ckeditor5-anchor-drupal": "^0.5.0",
"ckeditor5": ">=41.0.0",
"copy-webpack-plugin": "^12.0.2",
"husky": "^9.0.10",
Expand Down
36 changes: 36 additions & 0 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ protected function inputHtml(mixed $value, ElementInterface $element = null): st
$baseConfig = [
'defaultTransform' => $defaultTransform?->handle,
'elementSiteId' => $element?->siteId,
'accessibleFieldName' => $this->_accessibleFieldName($element),
'describedBy' => $this->_describedBy($view),
'findAndReplace' => [
'uiType' => 'dropdown',
],
Expand Down Expand Up @@ -910,4 +912,38 @@ private function _adjustPurifierConfig(HTMLPurifier_Config $purifierConfig): HTM

return $purifierConfig;
}

/**
* Returns an accessible name for the field (to be plugged into CKEditor's main editing area aria-label).
*
* @param ElementInterface|null $element
* @return string
*/
private function _accessibleFieldName(?ElementInterface $element = null): string
{
return Craft::t('site', $this->name) .
($element?->getFieldLayout()?->getField($this->handle)?->required ? ' ' . Craft::t('site', 'Required') : '') .
($this->getIsTranslatable($element) ? ' ' . $this->getTranslationDescription($element) : '');
}

/**
* Namespaces field's $describedBy value to be passed to the field.
*
* @param View $view
* @return string
*/
private function _describedBy(View $view): string
{
if (!empty($this->describedBy)) {
$describedByArray = explode(' ', $this->describedBy);
$namespace = trim(preg_replace('/\[|\]/', '-', $view->getNamespace()), '-');
foreach ($describedByArray as $key => $item) {
$describedByArray[$key] = "$namespace-$item";
}

return implode(' ', $describedByArray);
}

return '';
}
}
2 changes: 2 additions & 0 deletions src/controllers/CkeditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function actionImageUrl(): Response

return $this->asJson([
'url' => $asset->getUrl($transform, false),
'width' => $asset->getWidth($transform),
'height' => $asset->getHeight($transform),
]);
}
}
2 changes: 1 addition & 1 deletion src/web/assets/ckeditor/dist/ckeditor5-craftcms.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/web/assets/ckeditor/dist/ckeditor5-craftcms.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/

/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/ckeditor/dist/ckeditor5-craftcms.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit aea4168

Please sign in to comment.