Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
linkit
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
linkit
Commits
39caca6c
Commit
39caca6c
authored
11 months ago
by
Luhur Abdi Rizal
Committed by
Mark Fullmer
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3422951
: Allow listening to suggestion being selected
parent
d09ab3ff
No related branches found
No related tags found
3 merge requests
!78
Issue #3472672: Fix the issues reported by PHP_CodeSniffer
,
!59
Revert "Issue #2900766 by rubendello: Not all autocomplete values are...
,
!39
Allow listening to suggestion being selected
Pipeline
#114198
failed
11 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/build/linkit.js
+1
-1
1 addition, 1 deletion
js/build/linkit.js
js/ckeditor5_plugins/linkit/src/index.js
+1
-1
1 addition, 1 deletion
js/ckeditor5_plugins/linkit/src/index.js
with
2 additions
and
2 deletions
js/build/linkit.js
+
1
−
1
View file @
39caca6c
!
function
(
t
,
e
){
"
object
"
==
typeof
exports
&&
"
object
"
==
typeof
module
?
module
.
exports
=
e
():
"
function
"
==
typeof
define
&&
define
.
amd
?
define
([],
e
):
"
object
"
==
typeof
exports
?
exports
.
CKEditor5
=
e
():(
t
.
CKEditor5
=
t
.
CKEditor5
||
{},
t
.
CKEditor5
.
linkit
=
e
())}(
self
,(()
=>
(()
=>
{
var
t
=
{
"
ckeditor5/src/core.js
"
:(
t
,
e
,
i
)
=>
{
t
.
exports
=
i
(
"
dll-reference CKEditor5.dll
"
)(
"
./src/core.js
"
)},
"
ckeditor5/src/typing.js
"
:(
t
,
e
,
i
)
=>
{
t
.
exports
=
i
(
"
dll-reference CKEditor5.dll
"
)(
"
./src/typing.js
"
)},
"
dll-reference CKEditor5.dll
"
:
t
=>
{
"
use strict
"
;
t
.
exports
=
CKEditor5
.
dll
}},
e
=
{};
function
i
(
n
){
var
s
=
e
[
n
];
if
(
void
0
!==
s
)
return
s
.
exports
;
var
o
=
e
[
n
]
=
{
exports
:{}};
return
t
[
n
](
o
,
o
.
exports
,
i
),
o
.
exports
}
i
.
d
=
(
t
,
e
)
=>
{
for
(
var
n
in
e
)
i
.
o
(
e
,
n
)
&&!
i
.
o
(
t
,
n
)
&&
Object
.
defineProperty
(
t
,
n
,{
enumerable
:
!
0
,
get
:
e
[
n
]})},
i
.
o
=
(
t
,
e
)
=>
Object
.
prototype
.
hasOwnProperty
.
call
(
t
,
e
);
var
n
=
{};
return
(()
=>
{
"
use strict
"
;
i
.
d
(
n
,{
default
:()
=>
u
});
var
t
=
i
(
"
ckeditor5/src/core.js
"
),
e
=
i
(
"
ckeditor5/src/typing.js
"
);
class
s
extends
t
.
Plugin
{
init
(){
this
.
attrs
=
[
"
data-entity-type
"
,
"
data-entity-uuid
"
,
"
data-entity-substitution
"
],
this
.
_allowAndConvertExtraAttributes
(),
this
.
_removeExtraAttributesOnUnlinkCommandExecute
(),
this
.
_refreshExtraAttributeValues
(),
this
.
_addExtraAttributesOnLinkCommandExecute
()}
_allowAndConvertExtraAttributes
(){
const
t
=
this
.
editor
;
t
.
model
.
schema
.
extend
(
"
$text
"
,{
allowAttributes
:
this
.
attrs
}),
this
.
attrs
.
forEach
((
e
=>
{
t
.
conversion
.
for
(
"
downcast
"
).
attributeToElement
({
model
:
e
,
view
:(
t
,{
writer
:
i
})
=>
{
const
n
=
i
.
createAttributeElement
(
"
a
"
,{[
e
]:
t
},{
priority
:
5
});
return
i
.
setCustomProperty
(
"
link
"
,
!
0
,
n
),
n
}}),
t
.
conversion
.
for
(
"
upcast
"
).
elementToAttribute
({
view
:{
name
:
"
a
"
,
attributes
:{[
e
]:
!
0
}},
model
:{
key
:
e
,
value
:
t
=>
t
.
getAttribute
(
e
)}})}))}
_addExtraAttributesOnLinkCommandExecute
(){
const
t
=
this
.
editor
,
e
=
t
.
commands
.
get
(
"
link
"
);
let
i
=!
1
;
e
.
on
(
"
execute
"
,((
e
,
n
)
=>
{
if
(
n
.
length
<
3
)
return
;
if
(
i
)
return
void
(
i
=!
1
);
e
.
stop
(),
i
=!
0
;
const
s
=
n
[
n
.
length
-
1
],
o
=
this
.
editor
.
model
,
r
=
o
.
document
.
selection
;
o
.
change
((
e
=>
{
t
.
execute
(
"
link
"
,...
n
);
const
i
=
r
.
getFirstPosition
();
this
.
attrs
.
forEach
((
t
=>
{
if
(
r
.
isCollapsed
){
const
n
=
i
.
textNode
||
i
.
nodeBefore
;
s
[
t
]?
e
.
setAttribute
(
t
,
s
[
t
],
e
.
createRangeOn
(
n
)):
e
.
removeAttribute
(
t
,
e
.
createRangeOn
(
n
)),
e
.
removeSelectionAttribute
(
t
)}
else
{
const
i
=
o
.
schema
.
getValidRanges
(
r
.
getRanges
(),
t
);
for
(
const
n
of
i
)
s
[
t
]?
e
.
setAttribute
(
t
,
s
[
t
],
n
):
e
.
removeAttribute
(
t
,
n
)}}))}))}),{
priority
:
"
high
"
})}
_removeExtraAttributesOnUnlinkCommandExecute
(){
const
t
=
this
.
editor
,
i
=
t
.
commands
.
get
(
"
unlink
"
),
n
=
this
.
editor
.
model
,
s
=
n
.
document
.
selection
;
let
o
=!
1
;
i
.
on
(
"
execute
"
,(
i
=>
{
o
||
(
i
.
stop
(),
n
.
change
((()
=>
{
o
=!
0
,
t
.
execute
(
"
unlink
"
),
o
=!
1
,
n
.
change
((
t
=>
{
let
i
;
this
.
attrs
.
forEach
((
o
=>
{
i
=
s
.
isCollapsed
?[(
0
,
e
.
findAttributeRange
)(
s
.
getFirstPosition
(),
o
,
s
.
getAttribute
(
o
),
n
)]:
n
.
schema
.
getValidRanges
(
s
.
getRanges
(),
o
);
for
(
const
e
of
i
)
t
.
removeAttribute
(
o
,
e
)}))}))})))}),{
priority
:
"
high
"
})}
_refreshExtraAttributeValues
(){
const
t
=
this
.
editor
,
e
=
this
.
attrs
,
i
=
t
.
commands
.
get
(
"
link
"
),
n
=
this
.
editor
.
model
,
s
=
n
.
document
.
selection
;
e
.
forEach
((
t
=>
{
i
.
set
(
t
,
null
)})),
n
.
document
.
on
(
"
change
"
,(()
=>
{
e
.
forEach
((
t
=>
{
i
[
t
]
=
s
.
getAttribute
(
t
)}))}))}
static
get
pluginName
(){
return
"
LinkitEditing
"
}}
const
o
=
jQuery
;
function
r
(
t
,
e
){
var
i
=
o
(
"
<li>
"
).
addClass
(
"
linkit-result-line
"
),
n
=
o
(
"
<div>
"
).
addClass
(
"
linkit-result-line-wrapper
"
);
return
n
.
addClass
(
e
.
status
),
n
.
append
(
o
(
"
<span>
"
).
html
(
e
.
label
).
addClass
(
"
linkit-result-line--title
"
)),
e
.
hasOwnProperty
(
"
description
"
)
&&
n
.
append
(
o
(
"
<span>
"
).
html
(
e
.
description
).
addClass
(
"
linkit-result-line--description
"
)),
i
.
append
(
n
).
appendTo
(
t
)}
function
a
(
t
,
e
){
var
i
=
this
.
element
.
autocomplete
(
"
instance
"
),
n
=
{};
e
.
forEach
((
function
(
t
){
const
e
=
t
.
hasOwnProperty
(
"
group
"
)?
t
.
group
:
""
;
n
.
hasOwnProperty
(
e
)
||
(
n
[
e
]
=
[]),
n
[
e
].
push
(
t
)})),
o
.
each
(
n
,(
function
(
e
,
n
){
e
.
length
&&
t
.
append
(
'
<li class="linkit-result-line--group ui-menu-divider">
'
+
e
+
"
</li>
"
),
o
.
each
(
n
,(
function
(
e
,
n
){
i
.
_renderItemData
(
t
,
n
)}))}))}
class
l
extends
t
.
Plugin
{
static
get
requires
(){
return
[
s
]}
init
(){
this
.
_state
=
{};
const
t
=
this
.
editor
;
t
.
config
.
get
(
"
linkit
"
);
t
.
plugins
.
get
(
"
LinkUI
"
).
_createViews
(),
this
.
_enableLinkAutocomplete
(),
this
.
_handleExtraFormFieldSubmit
(),
this
.
_handleDataLoadingIntoExtraFormField
()}
_enableLinkAutocomplete
(){
const
t
=
this
.
editor
,
e
=
t
.
config
.
get
(
"
linkit
"
),
i
=
t
.
plugins
.
get
(
"
LinkUI
"
).
formView
;
let
n
=!
1
;
i
.
extendTemplate
({
attributes
:{
class
:[
"
ck-vertical-form
"
,
"
ck-link-form_layout-vertical
"
]}}),
t
.
plugins
.
get
(
"
ContextualBalloon
"
).
on
(
"
set:visibleView
"
,((
t
,
s
,
l
,
u
)
=>
{
if
(
l
!==
i
||
n
)
return
;
let
d
;
!
function
(
t
,
e
){
const
{
autocompleteUrl
:
i
,
selectHandler
:
n
,
closeHandler
:
s
,
openHandler
:
l
}
=
e
,
u
=
{
cache
:{},
ajax
:{
dataType
:
"
json
"
,
jsonp
:
!
1
}},
d
=
{
appendTo
:
t
.
closest
(
"
.ck-labeled-field-view
"
),
source
:
function
(
t
,
e
){
const
{
cache
:
n
}
=
u
;
var
s
=
t
.
term
;
n
.
hasOwnProperty
(
s
)?
e
(
n
[
s
]):
o
.
ajax
(
i
,{
success
:
function
(
t
){
n
[
s
]
=
t
.
suggestions
,
e
(
t
.
suggestions
)},
data
:{
q
:
s
},...
u
.
ajax
})},
select
:
n
,
focus
:()
=>!
1
,
search
:()
=>!
d
.
isComposing
,
close
:
s
,
open
:
l
,
minLength
:
1
,
isComposing
:
!
1
},
c
=
o
(
t
).
autocomplete
(
d
),
p
=
c
.
data
(
"
ui-autocomplete
"
);
p
.
widget
().
menu
(
"
option
"
,
"
items
"
,
"
> :not(.linkit-result-line--group)
"
),
p
.
_renderMenu
=
a
,
p
.
_renderItem
=
r
,
c
.
autocomplete
(
"
widget
"
).
addClass
(
"
linkit-ui-autocomplete ck-reset_all-excluded
"
),
c
.
on
(
"
click
"
,(
function
(){
c
.
autocomplete
(
"
search
"
,
c
.
val
())})),
c
.
on
(
"
compositionstart.autocomplete
"
,(
function
(){
d
.
isComposing
=!
0
})),
c
.
on
(
"
compositionend.autocomplete
"
,(
function
(){
d
.
isComposing
=!
1
}))}(
i
.
urlInputView
.
fieldView
.
element
,{...
e
,
selectHandler
:(
t
,{
item
:
e
})
=>
{
if
(
!
e
.
path
)
throw
"
Missing path param.
"
+
JSON
.
stringify
(
e
);
if
(
e
.
entity_type_id
||
e
.
entity_uuid
||
e
.
substitution_id
){
if
(
!
e
.
entity_type_id
||!
e
.
entity_uuid
||!
e
.
substitution_id
)
throw
"
Missing path param.
"
+
JSON
.
stringify
(
e
);
this
.
set
(
"
entityType
"
,
e
.
entity_type_id
),
this
.
set
(
"
entityUuid
"
,
e
.
entity_uuid
),
this
.
set
(
"
entitySubstitution
"
,
e
.
substitution_id
)}
else
this
.
set
(
"
entityType
"
,
null
),
this
.
set
(
"
entityUuid
"
,
null
),
this
.
set
(
"
entitySubstitution
"
,
null
);
return
t
.
target
.
value
=
e
.
path
,
d
=!
0
,
!
1
},
openHandler
:
t
=>
{
d
=!
1
},
closeHandler
:
t
=>
{
d
||
(
this
.
set
(
"
entityType
"
,
null
),
this
.
set
(
"
entityUuid
"
,
null
),
this
.
set
(
"
entitySubstitution
"
,
null
)),
d
=!
1
}}),
n
=!
0
,
i
.
urlInputView
.
fieldView
.
template
.
attributes
.
class
.
push
(
"
form-linkit-autocomplete
"
)}))}
_handleExtraFormFieldSubmit
(){
const
t
=
this
.
editor
,
e
=
t
.
plugins
.
get
(
"
LinkUI
"
).
formView
,
i
=
t
.
commands
.
get
(
"
link
"
);
this
.
listenTo
(
e
,
"
submit
"
,(()
=>
{
const
t
=
{
"
data-entity-type
"
:
this
.
entityType
,
"
data-entity-uuid
"
:
this
.
entityUuid
,
"
data-entity-substitution
"
:
this
.
entitySubstitution
};
i
.
once
(
"
execute
"
,((
e
,
i
)
=>
{
if
(
i
.
length
<
3
)
i
.
push
(
t
);
else
{
if
(
3
!==
i
.
length
)
throw
Error
(
"
The link command has more than 3 arguments.
"
);
Object
.
assign
(
i
[
2
],
t
)}}),{
priority
:
"
highest
"
})}),{
priority
:
"
high
"
})}
_handleDataLoadingIntoExtraFormField
(){
const
t
=
this
.
editor
.
commands
.
get
(
"
link
"
);
this
.
bind
(
"
entityType
"
).
to
(
t
,
"
data-entity-type
"
),
this
.
bind
(
"
entityUuid
"
).
to
(
t
,
"
data-entity-uuid
"
),
this
.
bind
(
"
entitySubstitution
"
).
to
(
t
,
"
data-entity-substitution
"
)}
static
get
pluginName
(){
return
"
Linkit
"
}}
const
u
=
{
Linkit
:
l
}})(),
n
=
n
.
default
})()));
\ No newline at end of file
!
function
(
t
,
e
){
"
object
"
==
typeof
exports
&&
"
object
"
==
typeof
module
?
module
.
exports
=
e
():
"
function
"
==
typeof
define
&&
define
.
amd
?
define
([],
e
):
"
object
"
==
typeof
exports
?
exports
.
CKEditor5
=
e
():(
t
.
CKEditor5
=
t
.
CKEditor5
||
{},
t
.
CKEditor5
.
linkit
=
e
())}(
self
,(
function
(){
return
function
(){
var
t
=
{
"
ckeditor5/src/core.js
"
:
function
(
t
,
e
,
i
){
t
.
exports
=
i
(
"
dll-reference CKEditor5.dll
"
)(
"
./src/core.js
"
)},
"
ckeditor5/src/typing.js
"
:
function
(
t
,
e
,
i
){
t
.
exports
=
i
(
"
dll-reference CKEditor5.dll
"
)(
"
./src/typing.js
"
)},
"
dll-reference CKEditor5.dll
"
:
function
(
t
){
"
use strict
"
;
t
.
exports
=
CKEditor5
.
dll
}},
e
=
{};
function
i
(
n
){
var
o
=
e
[
n
];
if
(
void
0
!==
o
)
return
o
.
exports
;
var
s
=
e
[
n
]
=
{
exports
:{}};
return
t
[
n
](
s
,
s
.
exports
,
i
),
s
.
exports
}
i
.
d
=
function
(
t
,
e
){
for
(
var
n
in
e
)
i
.
o
(
e
,
n
)
&&!
i
.
o
(
t
,
n
)
&&
Object
.
defineProperty
(
t
,
n
,{
enumerable
:
!
0
,
get
:
e
[
n
]})},
i
.
o
=
function
(
t
,
e
){
return
Object
.
prototype
.
hasOwnProperty
.
call
(
t
,
e
)};
var
n
=
{};
return
function
(){
"
use strict
"
;
i
.
d
(
n
,{
default
:
function
(){
return
u
}});
var
t
=
i
(
"
ckeditor5/src/core.js
"
),
e
=
i
(
"
ckeditor5/src/typing.js
"
);
class
o
extends
t
.
Plugin
{
init
(){
this
.
attrs
=
[
"
data-entity-type
"
,
"
data-entity-uuid
"
,
"
data-entity-substitution
"
],
this
.
_allowAndConvertExtraAttributes
(),
this
.
_removeExtraAttributesOnUnlinkCommandExecute
(),
this
.
_refreshExtraAttributeValues
(),
this
.
_addExtraAttributesOnLinkCommandExecute
()}
_allowAndConvertExtraAttributes
(){
const
t
=
this
.
editor
;
t
.
model
.
schema
.
extend
(
"
$text
"
,{
allowAttributes
:
this
.
attrs
}),
this
.
attrs
.
forEach
((
e
=>
{
t
.
conversion
.
for
(
"
downcast
"
).
attributeToElement
({
model
:
e
,
view
:(
t
,{
writer
:
i
})
=>
{
const
n
=
i
.
createAttributeElement
(
"
a
"
,{[
e
]:
t
},{
priority
:
5
});
return
i
.
setCustomProperty
(
"
link
"
,
!
0
,
n
),
n
}}),
t
.
conversion
.
for
(
"
upcast
"
).
elementToAttribute
({
view
:{
name
:
"
a
"
,
attributes
:{[
e
]:
!
0
}},
model
:{
key
:
e
,
value
:
t
=>
t
.
getAttribute
(
e
)}})}))}
_addExtraAttributesOnLinkCommandExecute
(){
const
t
=
this
.
editor
,
e
=
t
.
commands
.
get
(
"
link
"
);
let
i
=!
1
;
e
.
on
(
"
execute
"
,((
e
,
n
)
=>
{
if
(
n
.
length
<
3
)
return
;
if
(
i
)
return
void
(
i
=!
1
);
e
.
stop
(),
i
=!
0
;
const
o
=
n
[
n
.
length
-
1
],
s
=
this
.
editor
.
model
,
r
=
s
.
document
.
selection
;
s
.
change
((
e
=>
{
t
.
execute
(
"
link
"
,...
n
);
const
i
=
r
.
getFirstPosition
();
this
.
attrs
.
forEach
((
t
=>
{
if
(
r
.
isCollapsed
){
const
n
=
i
.
textNode
||
i
.
nodeBefore
;
o
[
t
]?
e
.
setAttribute
(
t
,
o
[
t
],
e
.
createRangeOn
(
n
)):
e
.
removeAttribute
(
t
,
e
.
createRangeOn
(
n
)),
e
.
removeSelectionAttribute
(
t
)}
else
{
const
i
=
s
.
schema
.
getValidRanges
(
r
.
getRanges
(),
t
);
for
(
const
n
of
i
)
o
[
t
]?
e
.
setAttribute
(
t
,
o
[
t
],
n
):
e
.
removeAttribute
(
t
,
n
)}}))}))}),{
priority
:
"
high
"
})}
_removeExtraAttributesOnUnlinkCommandExecute
(){
const
t
=
this
.
editor
,
i
=
t
.
commands
.
get
(
"
unlink
"
),
n
=
this
.
editor
.
model
,
o
=
n
.
document
.
selection
;
let
s
=!
1
;
i
.
on
(
"
execute
"
,(
i
=>
{
s
||
(
i
.
stop
(),
n
.
change
((()
=>
{
s
=!
0
,
t
.
execute
(
"
unlink
"
),
s
=!
1
,
n
.
change
((
t
=>
{
let
i
;
this
.
attrs
.
forEach
((
s
=>
{
i
=
o
.
isCollapsed
?[(
0
,
e
.
findAttributeRange
)(
o
.
getFirstPosition
(),
s
,
o
.
getAttribute
(
s
),
n
)]:
n
.
schema
.
getValidRanges
(
o
.
getRanges
(),
s
);
for
(
const
e
of
i
)
t
.
removeAttribute
(
s
,
e
)}))}))})))}),{
priority
:
"
high
"
})}
_refreshExtraAttributeValues
(){
const
t
=
this
.
editor
,
e
=
this
.
attrs
,
i
=
t
.
commands
.
get
(
"
link
"
),
n
=
this
.
editor
.
model
,
o
=
n
.
document
.
selection
;
e
.
forEach
((
t
=>
{
i
.
set
(
t
,
null
)})),
n
.
document
.
on
(
"
change
"
,(()
=>
{
e
.
forEach
((
t
=>
{
i
[
t
]
=
o
.
getAttribute
(
t
)}))}))}
static
get
pluginName
(){
return
"
LinkitEditing
"
}}
const
s
=
jQuery
;
function
r
(
t
,
e
){
var
i
=
s
(
"
<li>
"
).
addClass
(
"
linkit-result-line
"
),
n
=
s
(
"
<div>
"
).
addClass
(
"
linkit-result-line-wrapper
"
);
return
n
.
addClass
(
e
.
status
),
n
.
append
(
s
(
"
<span>
"
).
html
(
e
.
label
).
addClass
(
"
linkit-result-line--title
"
)),
e
.
hasOwnProperty
(
"
description
"
)
&&
n
.
append
(
s
(
"
<span>
"
).
html
(
e
.
description
).
addClass
(
"
linkit-result-line--description
"
)),
i
.
append
(
n
).
appendTo
(
t
)}
function
a
(
t
,
e
){
var
i
=
this
.
element
.
autocomplete
(
"
instance
"
),
n
=
{};
e
.
forEach
((
function
(
t
){
const
e
=
t
.
hasOwnProperty
(
"
group
"
)?
t
.
group
:
""
;
n
.
hasOwnProperty
(
e
)
||
(
n
[
e
]
=
[]),
n
[
e
].
push
(
t
)})),
s
.
each
(
n
,(
function
(
e
,
n
){
e
.
length
&&
t
.
append
(
'
<li class="linkit-result-line--group ui-menu-divider">
'
+
e
+
"
</li>
"
),
s
.
each
(
n
,(
function
(
e
,
n
){
i
.
_renderItemData
(
t
,
n
)}))}))}
class
l
extends
t
.
Plugin
{
static
get
requires
(){
return
[
o
]}
init
(){
this
.
_state
=
{};
const
t
=
this
.
editor
;
t
.
config
.
get
(
"
linkit
"
);
t
.
plugins
.
get
(
"
LinkUI
"
).
_createViews
(),
this
.
_enableLinkAutocomplete
(),
this
.
_handleExtraFormFieldSubmit
(),
this
.
_handleDataLoadingIntoExtraFormField
()}
_enableLinkAutocomplete
(){
const
t
=
this
.
editor
,
e
=
t
.
config
.
get
(
"
linkit
"
),
i
=
t
.
plugins
.
get
(
"
LinkUI
"
).
formView
;
let
n
=!
1
;
i
.
extendTemplate
({
attributes
:{
class
:[
"
ck-vertical-form
"
,
"
ck-link-form_layout-vertical
"
]}}),
t
.
plugins
.
get
(
"
ContextualBalloon
"
).
on
(
"
set:visibleView
"
,((
t
,
o
,
l
,
u
)
=>
{
if
(
l
!==
i
||
n
)
return
;
let
c
;
!
function
(
t
,
e
){
const
{
autocompleteUrl
:
i
,
selectHandler
:
n
,
closeHandler
:
o
,
openHandler
:
l
}
=
e
,
u
=
{
cache
:{},
ajax
:{
dataType
:
"
json
"
,
jsonp
:
!
1
}},
c
=
{
appendTo
:
t
.
closest
(
"
.ck-labeled-field-view
"
),
source
:
function
(
t
,
e
){
const
{
cache
:
n
}
=
u
;
var
o
=
t
.
term
;
n
.
hasOwnProperty
(
o
)?
e
(
n
[
o
]):
s
.
ajax
(
i
,{
success
:
function
(
t
){
n
[
o
]
=
t
.
suggestions
,
e
(
t
.
suggestions
)},
data
:{
q
:
o
},...
u
.
ajax
})},
select
:
n
,
focus
:()
=>!
1
,
search
:()
=>!
c
.
isComposing
,
close
:
o
,
open
:
l
,
minLength
:
1
,
isComposing
:
!
1
},
d
=
s
(
t
).
autocomplete
(
c
),
p
=
d
.
data
(
"
ui-autocomplete
"
);
p
.
widget
().
menu
(
"
option
"
,
"
items
"
,
"
> :not(.linkit-result-line--group)
"
),
p
.
_renderMenu
=
a
,
p
.
_renderItem
=
r
,
d
.
autocomplete
(
"
widget
"
).
addClass
(
"
linkit-ui-autocomplete ck-reset_all-excluded
"
),
d
.
on
(
"
click
"
,(
function
(){
d
.
autocomplete
(
"
search
"
,
d
.
val
())})),
d
.
on
(
"
compositionstart.autocomplete
"
,(
function
(){
c
.
isComposing
=!
0
})),
d
.
on
(
"
compositionend.autocomplete
"
,(
function
(){
c
.
isComposing
=!
1
}))}(
i
.
urlInputView
.
fieldView
.
element
,{...
e
,
selectHandler
:(
t
,{
item
:
e
})
=>
{
if
(
!
e
.
path
)
throw
"
Missing path param.
"
+
JSON
.
stringify
(
e
);
if
(
e
.
entity_type_id
||
e
.
entity_uuid
||
e
.
substitution_id
){
if
(
!
e
.
entity_type_id
||!
e
.
entity_uuid
||!
e
.
substitution_id
)
throw
"
Missing path param.
"
+
JSON
.
stringify
(
e
);
this
.
set
(
"
entityType
"
,
e
.
entity_type_id
),
this
.
set
(
"
entityUuid
"
,
e
.
entity_uuid
),
this
.
set
(
"
entitySubstitution
"
,
e
.
substitution_id
)}
else
this
.
set
(
"
entityType
"
,
null
),
this
.
set
(
"
entityUuid
"
,
null
),
this
.
set
(
"
entitySubstitution
"
,
null
);
return
i
.
urlInputView
.
fieldView
.
set
(
"
value
"
,
e
.
path
),
c
=!
0
,
!
1
},
openHandler
:
t
=>
{
c
=!
1
},
closeHandler
:
t
=>
{
c
||
(
this
.
set
(
"
entityType
"
,
null
),
this
.
set
(
"
entityUuid
"
,
null
),
this
.
set
(
"
entitySubstitution
"
,
null
)),
c
=!
1
}}),
n
=!
0
,
i
.
urlInputView
.
fieldView
.
template
.
attributes
.
class
.
push
(
"
form-linkit-autocomplete
"
)}))}
_handleExtraFormFieldSubmit
(){
const
t
=
this
.
editor
,
e
=
t
.
plugins
.
get
(
"
LinkUI
"
).
formView
,
i
=
t
.
commands
.
get
(
"
link
"
);
this
.
listenTo
(
e
,
"
submit
"
,(()
=>
{
const
t
=
{
"
data-entity-type
"
:
this
.
entityType
,
"
data-entity-uuid
"
:
this
.
entityUuid
,
"
data-entity-substitution
"
:
this
.
entitySubstitution
};
i
.
once
(
"
execute
"
,((
e
,
i
)
=>
{
if
(
i
.
length
<
3
)
i
.
push
(
t
);
else
{
if
(
3
!==
i
.
length
)
throw
Error
(
"
The link command has more than 3 arguments.
"
);
Object
.
assign
(
i
[
2
],
t
)}}),{
priority
:
"
highest
"
})}),{
priority
:
"
high
"
})}
_handleDataLoadingIntoExtraFormField
(){
const
t
=
this
.
editor
.
commands
.
get
(
"
link
"
);
this
.
bind
(
"
entityType
"
).
to
(
t
,
"
data-entity-type
"
),
this
.
bind
(
"
entityUuid
"
).
to
(
t
,
"
data-entity-uuid
"
),
this
.
bind
(
"
entitySubstitution
"
).
to
(
t
,
"
data-entity-substitution
"
)}
static
get
pluginName
(){
return
"
Linkit
"
}}
var
u
=
{
Linkit
:
l
}}(),
n
=
n
.
default
}()}));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/ckeditor5_plugins/linkit/src/index.js
+
1
−
1
View file @
39caca6c
...
...
@@ -71,7 +71,7 @@ class Linkit extends Plugin {
this
.
set
(
'
entitySubstitution
'
,
null
);
}
event
.
target
.
value
=
item
.
path
;
linkFormView
.
urlInputView
.
fieldView
.
set
(
'
value
'
,
item
.
path
)
;
selected
=
true
;
return
false
;
},
...
...
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