Static ReadonlypluginStatic ReadonlyrequiresClears resources, i.e., the name cache.
Registers the post-fixer.
Hook 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
linkHrefattribute 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:123to 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:123form.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
FormViewof 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
FormViewhas a valid name to hand over to this plugin, which will then use this name for replacement.Usage Example:
If
registerContentNameis called multiple times, only the last registered replacement will be considered.Important: The name must be registered, before
LinkCommandis 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 theLinkCommandscallsinsertContentfor a collapsed selection outside an existing link — which again triggers thelinkHrefattribute to be written to the text, which is the scenario, we want to prevent for content-links.