Static
Readonly
pluginStatic
Readonly
requiresHook for FormView to register a content-name, which is about to be replaced as soon as CKEditor's Link Features tries to insert the "raw link" into CKEditor text.
For any unregistered URI path, the name generated by CKEditor's Link Feature won't be vetoed.
Subsequent calls to this method will override a previous replacement, i.e., only one replacement is remembered at a time.
The registration must be done prior to the execution of LinkCommand
.
The replacement cache is cleared as soon as LinkCommand
finished
execution.
URI path of the content (content/123
) or content URI
as stored in the model (content:123
).
resolved name
LinkCommand has a special handling when inserting links with a collapsed (not expanded) selection (aka: no selection). We need to take care of this behavior, which is, that LinkCommand inserts the
linkHref
attribute as text within the editor and afterwards places the cursor after the link.For content-links this is no valid approach. We don't want
content:123
to be written into the CKEditor text field. We want the content's name to be written, and, perhaps, if not available because of concurrent changes, fallback to thecontent:123
form.Approach: While several approaches exist, the given approach ensures that only one Undo-step is created when (instead of one for the raw content-ID and the content-name afterwards) and that it does not require deep integration into the private API of CKEditor's link feature.
Thus, this hook is provided as post-fixer registered at the document. To replace content names, it requires to be informed by the
FormView
of a content name to replace. This is, because content names can only be retrieved asynchronously, while a post-fixer needs to evaluate synchronously.The suggested approach is, that the Save button is disabled until the
FormView
has a valid name to hand over to this plugin, which will then use this name for replacement.Usage Example:
If
registerContentName
is called multiple times, only the last registered replacement will be considered.Important: The name must be registered, before
LinkCommand
is executed.No need to check if replacement required on registration: It is this plugin, which decides, if a replacement is required or not. More specifically, it will only respond to content insertion events (via
document.differ
) and not to attribute changes. I.e., with the current implementation ofLinkCommand
(as of CKEditor 29.x) it will be triggered if theLinkCommands
callsinsertContent
for a collapsed selection outside an existing link — which again triggers thelinkHref
attribute to be written to the text, which is the scenario, we want to prevent for content-links.