Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
token
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
token
Merge requests
!36
Issue
#3334784
: Implement Token-Click-Insert for CKEditor 5
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3334784
: Implement Token-Click-Insert for CKEditor 5
issue/token-3334784:3334784-ckeditor5-token-click-insert
into
8.x-1.x
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Thomas Gauges
requested to merge
issue/token-3334784:3334784-ckeditor5-token-click-insert
into
8.x-1.x
2 years ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Compare
8.x-1.x
version 2
ba04aaa2
1 year ago
version 1
54f59a90
2 years ago
8.x-1.x (base)
and
latest version
latest version
ba04aaa2
1 commit,
1 year ago
version 2
ba04aaa2
1 commit,
1 year ago
version 1
54f59a90
1 commit,
2 years ago
1 file
+
19
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
js/token.js
+
19
−
0
Options
@@ -16,6 +16,16 @@
drupalSettings
.
tokenFocusedField
=
this
;
});
if
(
Drupal
.
CKEditor5Instances
)
{
Drupal
.
CKEditor5Instances
.
forEach
(
function
(
editor
)
{
editor
.
editing
.
view
.
document
.
on
(
'
change:isFocused
'
,
(
event
,
data
,
isFocused
)
=>
{
if
(
isFocused
)
{
drupalSettings
.
tokenFocusedCkeditor5
=
editor
;
}
});
})
}
once
(
'
token-click-insert
'
,
'
.token-click-insert .token-key
'
,
context
).
forEach
(
function
(
token
)
{
var
newThis
=
$
(
'
<a href="javascript:void(0);" title="
'
+
Drupal
.
t
(
'
Insert this token into your form
'
)
+
'
">
'
+
$
(
token
).
html
()
+
'
</a>
'
).
click
(
function
()
{
var
content
=
this
.
text
;
@@ -50,6 +60,15 @@
else
if
(
drupalSettings
.
tokenFocusedField
)
{
insertAtCursor
(
drupalSettings
.
tokenFocusedField
,
content
);
}
else
if
(
drupalSettings
.
tokenFocusedCkeditor5
)
{
const
editor
=
drupalSettings
.
tokenFocusedCkeditor5
;
editor
.
model
.
change
((
writer
)
=>
{
writer
.
insertText
(
content
,
editor
.
model
.
document
.
selection
.
getFirstPosition
(),
);
})
}
else
{
alert
(
Drupal
.
t
(
'
First click a text field to insert your tokens into.
'
));
}
Loading