Enable markdown for editing HTML

This commit is contained in:
Oliver Davies 2024-04-08 22:51:13 +01:00
parent 1b75a62d59
commit b5fff078f6
7 changed files with 365 additions and 73 deletions

View file

@ -16,16 +16,19 @@
],
"require": {
"composer/installers": "^2.0",
"cweagans/composer-patches": "^1.7",
"drupal/admin_toolbar": "^3.4",
"drupal/core-composer-scaffold": "^10.2",
"drupal/core-project-message": "^10.2",
"drupal/core-recommended": "^10.2",
"drupal/layout_builder_modal": "^1.2",
"drupal/markdown": "^3.0",
"drupal/pathauto": "^1.12",
"drupal/plausible": "^2.1",
"drupal/rabbit_hole": "^1.0@beta",
"drupal/redirect": "^1.9",
"drush/drush": "^12.5"
"drush/drush": "^12.5",
"league/commonmark": "^1.0"
},
"conflict": {
"drupal/drupal": "*"
@ -39,7 +42,8 @@
"drupal/core-project-message": true,
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"php-http/discovery": true
"php-http/discovery": true,
"cweagans/composer-patches": true
},
"sort-packages": true
},
@ -98,6 +102,11 @@
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
},
"patches": {
"drupal/markdown": {
"SubformState incorrect interface error": "./tools/patches/drupal/markdown/3409277-29.diff"
}
}
}
}

214
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "513fb0358414a9218ded9f4ad2ee7a2c",
"content-hash": "a3f73d0e9e54b5b30bf8913e0d87cb39",
"packages": [
{
"name": "asm89/stack-cors",
@ -864,6 +864,54 @@
},
"time": "2024-04-01T12:42:12+00:00"
},
{
"name": "cweagans/composer-patches",
"version": "1.7.3",
"source": {
"type": "git",
"url": "https://github.com/cweagans/composer-patches.git",
"reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweagans/composer-patches/zipball/e190d4466fe2b103a55467dfa83fc2fecfcaf2db",
"reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.3.0"
},
"require-dev": {
"composer/composer": "~1.0 || ~2.0",
"phpunit/phpunit": "~4.6"
},
"type": "composer-plugin",
"extra": {
"class": "cweagans\\Composer\\Patches"
},
"autoload": {
"psr-4": {
"cweagans\\Composer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Cameron Eagans",
"email": "me@cweagans.net"
}
],
"description": "Provides a way to patch Composer packages.",
"support": {
"issues": "https://github.com/cweagans/composer-patches/issues",
"source": "https://github.com/cweagans/composer-patches/tree/1.7.3"
},
"time": "2022-12-20T22:53:13+00:00"
},
{
"name": "dflydev/dot-access-data",
"version": "v3.0.2",
@ -1701,6 +1749,75 @@
"issues": "https://www.drupal.org/project/issues/layout_builder_modal"
}
},
{
"name": "drupal/markdown",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/markdown.git",
"reference": "3.0.1"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/markdown-3.0.1.zip",
"reference": "3.0.1",
"shasum": "ae33f2819c0f2591484ae02921781fb3ea783330"
},
"require": {
"composer/semver": "^1.0 || ^2.0 || ^3.0",
"drupal/core": "^9.1 || ^10",
"php": ">=5.5.9"
},
"suggest": {
"league/commonmark": "The PHP CommonMark parser is a robust, highly-extensible Markdown parser for PHP based on the CommonMark and Github-Flavored Markdown specifications."
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "3.0.1",
"datestamp": "1704727858",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
},
"drush": {
"services": {
"drush.services.yml": "^9 || ^10"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Mark Halliwell (markhalliwell)",
"homepage": "https://www.drupal.org/u/markhalliwell",
"role": "D8+ Maintainer"
},
{
"name": "Gisle Hannemyr (gisle)",
"homepage": "https://www.drupal.org/u/gisle",
"role": "D7 Maintainer"
},
{
"name": "joelpittet",
"homepage": "https://www.drupal.org/user/160302"
},
{
"name": "markdorison",
"homepage": "https://www.drupal.org/user/346106"
}
],
"description": "Provides Markdown integration for Drupal and allows content to be formatted in a simple plain-text syntax that is transformed into valid HTML.",
"homepage": "https://www.drupal.org/project/markdown",
"support": {
"source": "https://git.drupalcode.org/project/markdown",
"issues": "https://www.drupal.org/project/markdown"
}
},
{
"name": "drupal/pathauto",
"version": "1.12.0",
@ -2665,6 +2782,99 @@
],
"time": "2023-12-03T20:05:35+00:00"
},
{
"name": "league/commonmark",
"version": "1.6.7",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "2b8185c13bc9578367a5bf901881d1c1b5bbd09b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2b8185c13bc9578367a5bf901881d1c1b5bbd09b",
"reference": "2b8185c13bc9578367a5bf901881d1c1b5bbd09b",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": "^7.1 || ^8.0"
},
"conflict": {
"scrutinizer/ocular": "1.7.*"
},
"require-dev": {
"cebe/markdown": "~1.0",
"commonmark/commonmark.js": "0.29.2",
"erusev/parsedown": "~1.0",
"ext-json": "*",
"github/gfm": "0.29.0",
"michelf/php-markdown": "~1.4",
"mikehaertl/php-shellcommand": "^1.4",
"phpstan/phpstan": "^0.12.90",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.2",
"scrutinizer/ocular": "^1.5",
"symfony/finder": "^4.2"
},
"bin": [
"bin/commonmark"
],
"type": "library",
"autoload": {
"psr-4": {
"League\\CommonMark\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM)",
"homepage": "https://commonmark.thephpleague.com",
"keywords": [
"commonmark",
"flavored",
"gfm",
"github",
"github-flavored",
"markdown",
"md",
"parser"
],
"support": {
"docs": "https://commonmark.thephpleague.com/",
"issues": "https://github.com/thephpleague/commonmark/issues",
"rss": "https://github.com/thephpleague/commonmark/releases.atom",
"source": "https://github.com/thephpleague/commonmark"
},
"funding": [
{
"url": "https://www.colinodell.com/sponsor",
"type": "custom"
},
{
"url": "https://www.paypal.me/colinpodell/10.00",
"type": "custom"
},
{
"url": "https://github.com/colinodell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/commonmark",
"type": "tidelift"
}
],
"time": "2022-01-13T17:18:13+00:00"
},
{
"name": "league/container",
"version": "4.2.2",
@ -6659,5 +6869,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.3.0"
}

View file

@ -29,6 +29,7 @@ module:
layout_builder_modal: 0
layout_discovery: 0
link: 0
markdown: 0
menu_link_content: 0
menu_ui: 0
mysql: 0

View file

@ -1,68 +0,0 @@
uuid: f67aa435-ef0f-44c7-ae0d-45ee7bfb898d
langcode: en
status: true
dependencies:
config:
- filter.format.basic_html
module:
- ckeditor5
_core:
default_config_hash: rrcLa1jOgI7xezeJia25MS2tmm_3e6VZOQaCIPF9b-I
format: basic_html
editor: ckeditor5
settings:
toolbar:
items:
- bold
- italic
- '|'
- link
- '|'
- bulletedList
- numberedList
- '|'
- blockQuote
- drupalInsertImage
- '|'
- heading
- code
- '|'
- sourceEditing
plugins:
ckeditor5_heading:
enabled_headings:
- heading2
- heading3
- heading4
- heading5
- heading6
ckeditor5_imageResize:
allow_resize: true
ckeditor5_list:
properties:
reversed: false
startIndex: true
multiBlock: true
ckeditor5_sourceEditing:
allowed_tags:
- '<cite>'
- '<dl>'
- '<dt>'
- '<dd>'
- '<a hreflang>'
- '<blockquote cite>'
- '<ul type>'
- '<ol type>'
- '<h2 id>'
- '<h3 id>'
- '<h4 id>'
- '<h5 id>'
- '<h6 id>'
image_upload:
status: true
scheme: public
directory: inline-images
max_size: ''
max_dimensions:
width: 0
height: 0

View file

@ -4,6 +4,7 @@ status: true
dependencies:
module:
- editor
- markdown
_core:
default_config_hash: mclCbTlJwWJORez4Y1eX2MqA0aGjSMAoJb3TaBABcK8
name: 'Basic HTML'
@ -31,7 +32,7 @@ filters:
filter_html:
id: filter_html
provider: filter
status: true
status: false
weight: -10
settings:
allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>'
@ -49,3 +50,26 @@ filters:
status: true
weight: 15
settings: { }
markdown:
id: markdown
provider: markdown
status: true
weight: -15
settings:
id: commonmark
enabled: true
render_strategy:
type: filter_output
custom_allowed_html: ''
plugins:
commonmark: true
commonmark-external-links: false
commonmark-footnotes: false
commonmark-heading-permalink: false
commonmark-strikethrough: false
commonmark-table: false
commonmark-task-list: false
filter_align: true
filter_caption: true
override: false
filterFormat: basic_html

View file

@ -0,0 +1,79 @@
dependencies:
module:
- markdown
id: commonmark
enabled: true
weight: 0
render_strategy:
type: filter_output
custom_allowed_html: ''
plugins:
commonmark: true
commonmark-external-links: false
commonmark-footnotes: false
commonmark-heading-permalink: false
commonmark-strikethrough: false
commonmark-table: false
commonmark-task-list: false
settings:
allow_unsafe_links: true
enable_em: true
enable_strong: true
html_input: allow
max_nesting_level: 0
use_asterisk: true
use_underscore: true
extensions:
-
id: commonmark-attributes
enabled: false
weight: 0
-
id: commonmark-autolink
enabled: false
weight: 0
-
id: commonmark-disallowed-raw-html
enabled: false
weight: 0
-
id: commonmark-external-links
enabled: false
weight: 0
settings: { }
-
id: commonmark-footnotes
enabled: false
weight: 0
settings: { }
-
id: commonmark-heading-permalink
enabled: false
weight: 0
settings: { }
-
id: commonmark-mention
enabled: false
weight: 0
-
id: commonmark-smart-punctuation
enabled: false
weight: 0
settings: { }
-
id: commonmark-strikethrough
enabled: false
weight: 0
-
id: commonmark-table
enabled: false
weight: 0
-
id: commonmark-table-of-contents
enabled: false
weight: 0
settings: { }
-
id: commonmark-task-list
enabled: false
weight: 0

View file

@ -0,0 +1,37 @@
diff --git a/src/Form/SubformState.php b/src/Form/SubformState.php
index 9fc07775fa112001d2be2225c371eaa0968248df..92178c35d72b600f3cae6db3f410eadca17d0280 100644
--- a/src/Form/SubformState.php
+++ b/src/Form/SubformState.php
@@ -3,8 +3,9 @@
namespace Drupal\markdown\Form;
use Drupal\Component\Serialization\Json;
+use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\markdown\BcSupport\SubformState as CoreSubformState;
+use Drupal\Core\Form\SubformState as CoreSubformState;
use Drupal\markdown\Traits\FormTrait;
/**
@@ -54,7 +55,7 @@ class SubformState extends CoreSubformState implements SubformStateInterface {
/**
* {@inheritdoc}
*/
- public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) {
+ public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state, ?FormInterface $subform_form_object = null) {
// Attempt to construct #parents array based on passed values.
if (!isset($subform['#parents']) && $parent_form_state instanceof SubformStateInterface && ($name = array_search($subform, $parent_form, TRUE))) {
$subform['#parents'] = array_merge($parent_form_state->getAllParents(), [$name]);
diff --git a/src/Form/SubformStateInterface.php b/src/Form/SubformStateInterface.php
index a4f7d6260a175726632712536a0b619d137ccfb0..44bb98b38dc532d0eb5a973fb340e418e2b5a303 100644
--- a/src/Form/SubformStateInterface.php
+++ b/src/Form/SubformStateInterface.php
@@ -2,7 +2,7 @@
namespace Drupal\markdown\Form;
-use Drupal\markdown\BcSupport\SubformStateInterface as CoreSubformStateInterface;
+use Drupal\Core\Form\SubformStateInterface as CoreSubformStateInterface;
/**
* Interface for markdown plugin subforms.