Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!7017
Issue
#2722319
: <textarea>s using Text Editor always fail HTML5 validation...
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#2722319
: <textarea>s using Text Editor always fail HTML5 validation...
issue/drupal-2722319:2722319-ckeditor-fields-required
into
11.x
Overview
7
Commits
5
Pipelines
8
Changes
5
Open
Adam Nagy
requested to merge
issue/drupal-2722319:2722319-ckeditor-fields-required
into
11.x
1 year ago
Overview
7
Commits
5
Pipelines
8
Changes
5
Expand
Closes
#2722319
0
0
Merge request reports
Compare
11.x
version 7
a111a207
1 year ago
version 6
90c37937
1 year ago
version 5
7ecc225e
1 year ago
version 4
332fea9d
1 year ago
version 3
0c1f77e4
1 year ago
version 2
a721c59c
1 year ago
version 1
d0400f2e
1 year ago
11.x (HEAD)
and
latest version
latest version
8c1634f7
5 commits,
1 year ago
version 7
a111a207
4 commits,
1 year ago
version 6
90c37937
3 commits,
1 year ago
version 5
7ecc225e
3 commits,
1 year ago
version 4
332fea9d
2 commits,
1 year ago
version 3
0c1f77e4
2 commits,
1 year ago
version 2
a721c59c
1 commit,
1 year ago
version 1
d0400f2e
1 commit,
1 year ago
5 files
+
193
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
core/modules/ckeditor5/js/ckeditor5.js
+
57
−
0
Options
@@ -625,6 +625,46 @@
@@ -625,6 +625,46 @@
},
},
};
};
/**
* Handle CKEditor change event to keep the source element up to date.
*
* @type {Drupal~behavior}
*/
Drupal
.
behaviors
.
ckeditor5SourceElementUpdater
=
{
attach
(
context
,
settings
)
{
const
$context
=
$
(
context
);
// Iterate through all CKEditors on the page.
$
(
once
(
'
ckeditor5-states
'
,
$context
.
find
(
'
[data-ckeditor5-id]
'
).
filter
(
'
:input
'
),
),
).
each
(
function
()
{
if
(
this
.
dataset
.
ckeditor5Id
)
{
const
editorId
=
this
.
dataset
.
ckeditor5Id
;
// Using setTimeout() to ensure all CKEditors are loaded.
setTimeout
(()
=>
{
const
editor
=
Drupal
.
CKEditor5Instances
.
get
(
editorId
);
if
(
editor
)
{
$
(
once
(
'
ckeditor5-states-binding
'
,
editor
.
sourceElement
)).
each
(
function
()
{
editor
.
model
.
document
.
on
(
'
change
'
,
function
()
{
if
(
editor
.
getData
()
!==
editor
.
sourceElement
.
textContent
)
{
editor
.
updateSourceElement
();
$
(
editor
.
sourceElement
).
trigger
(
'
change
'
,
[
true
]);
}
});
},
);
}
});
}
});
},
};
// Redirect on hash change when the original hash has an associated CKEditor 5.
// Redirect on hash change when the original hash has an associated CKEditor 5.
function
redirectTextareaFragmentToCKEditor5Instance
()
{
function
redirectTextareaFragmentToCKEditor5Instance
()
{
const
hash
=
window
.
location
.
hash
.
substring
(
1
);
const
hash
=
window
.
location
.
hash
.
substring
(
1
);
@@ -677,4 +717,21 @@
@@ -677,4 +717,21 @@
Drupal
.
ckeditor5
.
saveCallback
=
null
;
Drupal
.
ckeditor5
.
saveCallback
=
null
;
}
}
});
});
/**
* Listen to states API "required" event to remove HTML5 "required" from a hidden CKEditor source element.
*/
$
(
document
).
on
(
'
state:required
'
,
(
e
)
=>
{
if
(
e
.
trigger
)
{
if
(
e
.
value
)
{
const
targetIsRequired
=
e
.
target
.
hasAttribute
(
'
required
'
);
const
targetIsCkeditor5
=
e
.
target
.
hasAttribute
(
'
data-ckeditor5-id
'
);
if
(
targetIsRequired
&&
targetIsCkeditor5
)
{
// CKEditor 4 had a feature to remove the required attribute.
// see: https://www.drupal.org/project/drupal/issues/1954968
e
.
target
.
removeAttribute
(
'
required
'
);
}
}
}
});
})(
Drupal
,
Drupal
.
debounce
,
CKEditor5
,
jQuery
,
once
);
})(
Drupal
,
Drupal
.
debounce
,
CKEditor5
,
jQuery
,
once
);
Loading