-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(link): Introduce
index.ts
and augmentation.ts
Includes augmenting `LinkUI` by new `LinkActionsView` and `LinkFormView` supporting our (again augmented) properties `contentUriPath` and `contentName`. Due to several issues regarding not providing `LinkFormView` and `LinkActionsView` as named exports (which blocks augmenting them due to an unresolved TypeScript Issue), and `SingleBindChain.to` having too strict typing - at least from the implementation point of view here, this resulted in a bunch of changes to get typings straight. See-also: microsoft/TypeScript#14080 See-also: ckeditor/ckeditor5#13864 See-also: ckeditor/ckeditor5#13965
- Loading branch information
1 parent
5889fbd
commit 0fe31b1
Showing
13 changed files
with
222 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { | ||
ContentLinkActionsViewExtension, | ||
ContentLinkClipboardPlugin, | ||
ContentLinkCommandHook, | ||
ContentLinkFormViewExtension, | ||
ContentLinks, | ||
CustomLinkTargetUI, | ||
LinkTarget, | ||
LinkTargetActionsViewExtension, | ||
LinkTargetCommand, | ||
LinkTargetModelView, | ||
LinkUserActionsPlugin, | ||
} from "./index"; | ||
// TODO[cke] Use index import. | ||
import type { OpenInTabCommand } from "@coremedia/ckeditor5-coremedia-content/commands/OpenInTabCommand"; | ||
|
||
declare module "@ckeditor/ckeditor5-core" { | ||
interface PluginsMap { | ||
[ContentLinkActionsViewExtension.pluginName]: ContentLinkActionsViewExtension; | ||
[ContentLinkClipboardPlugin.pluginName]: ContentLinkClipboardPlugin; | ||
[ContentLinkCommandHook.pluginName]: ContentLinkCommandHook; | ||
[ContentLinkFormViewExtension.pluginName]: ContentLinkFormViewExtension; | ||
[ContentLinks.pluginName]: ContentLinks; | ||
[CustomLinkTargetUI.pluginName]: CustomLinkTargetUI; | ||
[LinkTarget.pluginName]: LinkTarget; | ||
[LinkTargetActionsViewExtension.pluginName]: LinkTargetActionsViewExtension; | ||
[LinkTargetModelView.pluginName]: LinkTargetModelView; | ||
[LinkUserActionsPlugin.pluginName]: LinkUserActionsPlugin; | ||
} | ||
|
||
interface CommandsMap { | ||
// While part of ckeditor5-coremedia-content, the command is added here | ||
// within the ContentLinks plugin. Thus, we should declare it here. | ||
openLinkInTab: OpenInTabCommand; | ||
linkTarget: LinkTargetCommand; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...es/ckeditor5-coremedia-link/src/contentlink/LazyLinkUIPropertiesNotInitializedYetError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/ckeditor5-coremedia-link/src/contentlink/ui/AugmentedLinkActionsView.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint no-null/no-null: off */ | ||
|
||
import LinkActionsView from "@ckeditor/ckeditor5-link/src/ui/linkactionsview"; | ||
|
||
/* | ||
* DevNote: | ||
* | ||
* Due to https://github.com/Microsoft/TypeScript/issues/14080 and `LinkActionsView` | ||
* provided as so-called named export (see https://github.com/ckeditor/ckeditor5/issues/13864), | ||
* transparent augmentation is cumbersome. | ||
* | ||
* For Migrating to CKEditor 5 37.x, we decided to stick to a plain on-demand | ||
* casting. | ||
*/ | ||
|
||
/** | ||
* Augmented properties for `LinkActionsView`. | ||
*/ | ||
export interface LinkActionsViewAugmentation { | ||
/** | ||
* URI path of linked content item. | ||
*/ | ||
// Must be non-optional due to: https://github.com/ckeditor/ckeditor5/issues/13965 | ||
contentUriPath: string | null | undefined; | ||
} | ||
|
||
/** | ||
* Combined type for augmented `LinkActionsView`. | ||
*/ | ||
export type AugmentedLinkActionsView = LinkActionsView & LinkActionsViewAugmentation; |
35 changes: 35 additions & 0 deletions
35
packages/ckeditor5-coremedia-link/src/contentlink/ui/AugmentedLinkFormView.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint no-null/no-null: off */ | ||
|
||
import LinkFormView from "@ckeditor/ckeditor5-link/src/ui/linkformview"; | ||
|
||
/* | ||
* DevNote: | ||
* | ||
* Due to https://github.com/Microsoft/TypeScript/issues/14080 and `LinkFormView` | ||
* provided as so-called named export (see https://github.com/ckeditor/ckeditor5/issues/13864), | ||
* transparent augmentation is cumbersome. | ||
* | ||
* For Migrating to CKEditor 5 37.x, we decided to stick to a plain on-demand | ||
* casting. | ||
*/ | ||
|
||
/** | ||
* Augmented properties for `LinkFormView`. | ||
*/ | ||
export interface LinkFormViewAugmentation { | ||
/** | ||
* Name of the linked content. | ||
*/ | ||
// Must be non-optional due to: https://github.com/ckeditor/ckeditor5/issues/13965 | ||
contentName: string | null | undefined; | ||
/** | ||
* URI path of linked content item. | ||
*/ | ||
// Must be non-optional due to: https://github.com/ckeditor/ckeditor5/issues/13965 | ||
contentUriPath: string | null | undefined; | ||
} | ||
|
||
/** | ||
* Combined type for augmented `LinkFormView`. | ||
*/ | ||
export type AugmentedLinkFormView = LinkFormView & LinkFormViewAugmentation; |
35 changes: 35 additions & 0 deletions
35
packages/ckeditor5-coremedia-link/src/contentlink/ui/AugmentedLinkUI.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { AugmentedLinkActionsView } from "./AugmentedLinkActionsView"; | ||
import { AugmentedLinkFormView } from "./AugmentedLinkFormView"; | ||
import { ViewWithCssTransitionDisabler } from "@ckeditor/ckeditor5-ui"; | ||
import { LinkUI } from "@ckeditor/ckeditor5-link"; | ||
|
||
/** | ||
* Augmented properties for `LinkUI`. | ||
*/ | ||
export interface LinkUIAugmentation { | ||
actionsView: AugmentedLinkActionsView | null; | ||
formView: (AugmentedLinkFormView & ViewWithCssTransitionDisabler) | null; | ||
} | ||
|
||
/** | ||
* Combined type for augmented `LinkUI`. | ||
*/ | ||
export type AugmentedLinkUI = Omit<LinkUI, "actionsView" | "formView"> & LinkUIAugmentation; | ||
|
||
/** | ||
* Cast to `AugmentedLinkUI` without explicit checks applied. | ||
* | ||
* @param linkUI - LinkUI to augment | ||
*/ | ||
export const asAugmentedLinkUI = (linkUI: LinkUI): AugmentedLinkUI => | ||
// We will just ignore the error for now, here. It is mostly dedicated to | ||
// https://github.com/ckeditor/ckeditor5/issues/13965, that we cannot set | ||
// properties to use in the context of observables as optional. Instead, we | ||
// need to make them `undefined´ as an explicitly selected type option, which | ||
// again would require properly setting defaults for augmented properties here | ||
// to `undefined`. | ||
// | ||
// If decision for the given issue is to support optional properties, we | ||
// expect that we can just remove the following ts-expect-error. | ||
// @ts-expect-error - Wait for decision on https://github.com/ckeditor/ckeditor5/issues/13965 | ||
linkUI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.