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
Commits
bb35429a
Commit
bb35429a
authored
1 year ago
by
Adam Nagy
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3382403
: React only on 'change:data' editor event.
parent
3e19e130
No related branches found
No related tags found
1 merge request
!48
Issue #3382403: React only on 'change:data' editor event.
Pipeline
#185085
canceled
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/maxlength.js
+6
-5
6 additions, 5 deletions
js/maxlength.js
with
6 additions
and
5 deletions
js/maxlength.js
+
6
−
5
View file @
bb35429a
...
...
@@ -348,14 +348,15 @@
*/
ml
.
ckeditor5
=
function
(
editor
,
options
)
{
$
(
once
(
'
maxlengthbinding
'
,
editor
.
sourceElement
)).
each
(
function
()
{
editor
.
model
.
document
.
on
(
'
change
'
,
function
()
{
if
(
editor
.
getData
()
!==
editor
.
sourceElement
.
textContent
)
{
// Listen to changes to data only.
editor
.
model
.
document
.
on
(
'
change:data
'
,
function
()
{
let
editorData
=
editor
.
getData
();
if
(
editorData
!==
editor
.
sourceElement
.
textContent
)
{
// Trim if limit is reached and enforcing is activated.
if
(
options
[
'
enforce
'
])
{
let
maxlength
=
$
(
editor
.
sourceElement
).
data
(
'
maxlength
'
);
let
data
=
editor
.
getData
();
const
trimmed
=
ml
.
truncate_html
(
data
,
maxlength
);
if
(
data
.
length
!==
trimmed
.
length
)
{
const
trimmed
=
ml
.
truncate_html
(
editorData
,
maxlength
);
if
(
editorData
.
length
!==
trimmed
.
length
)
{
editor
.
setData
(
trimmed
);
setTimeout
(()
=>
{
editor
.
model
.
change
(
writer
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment