Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
maxlength
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
maxlength
Merge requests
!44
Issue
#3391779
: Re-attach maxlength counter behavior after text format change.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3391779
: Re-attach maxlength counter behavior after text format change.
issue/maxlength-3391779:3391779-ckeditor5---character
into
3.x
Overview
0
Commits
4
Pipelines
6
Changes
2
Merged
godotislate
requested to merge
issue/maxlength-3391779:3391779-ckeditor5---character
into
3.x
1 year ago
Overview
0
Commits
4
Pipelines
6
Changes
2
Expand
Closes
#3391779
0
0
Merge request reports
Compare
3.x
version 4
a89746cb
1 year ago
version 3
1bbc654d
1 year ago
version 2
f4e48502
1 year ago
version 1
031d47ed
1 year ago
3.x (base)
and
latest version
latest version
d692f3da
4 commits,
1 year ago
version 4
a89746cb
3 commits,
1 year ago
version 3
1bbc654d
1 commit,
1 year ago
version 2
f4e48502
2 commits,
1 year ago
version 1
031d47ed
1 commit,
1 year ago
2 files
+
71
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
js/maxlength.js
+
26
−
2
Options
(
function
(
$
,
Drupal
)
{
(
function
(
$
,
Drupal
,
once
)
{
// Make variables local.
var
ml
=
ml
||
{};
@@ -29,6 +29,30 @@
ml
.
ckeditor5
(
Drupal
.
CKEditor5Instances
.
get
(
eid
),
options
);
});
}
// Set up a mutation observer to re-attach this behavior when the text
// format has been changed. Observer will act on changes to the
// 'data-ckeditor5-id' attribute on the field.
// @see Drupal.editors.ckeditor5.attach() and setElementId() in Drupal core ckeditor5.js
if
(
Drupal
.
hasOwnProperty
(
'
CKEditor5Instances
'
))
{
const
observerOptions
=
{
attributes
:
true
,
attributeFilter
:
[
'
data-ckeditor5-id
'
]
};
const
observer
=
new
MutationObserver
((
mutations
)
=>
{
mutations
.
forEach
((
mutation
)
=>
{
const
eid
=
mutation
.
target
.
dataset
.
ckeditor5Id
;
if
(
!
Drupal
.
CKEditor5Instances
.
has
(
eid
))
{
observer
.
disconnect
();
Drupal
.
behaviors
.
maxlength
.
detach
(
context
);
Drupal
.
behaviors
.
maxlength
.
attach
(
context
);
// Remove `maxlengthbinding` set by ml.ckeditor5().
once
.
remove
(
'
maxlengthbinding
'
,
mutation
.
target
);
}
});
});
observer
.
observe
(
this
,
observerOptions
);
}
});
},
detach
:
function
(
context
,
settings
)
{
@@ -371,4 +395,4 @@
});
}
})(
jQuery
,
Drupal
);
})(
jQuery
,
Drupal
,
once
);
Loading