Skip to content

Commit

Permalink
Merge pull request #200 from CoreMedia/CMS-26944-Link-Balloon-closes-…
Browse files Browse the repository at this point in the history
…during-drag-and-drop

CMS-26944-Link-Balloon-closes-during-drag-and-drop
  • Loading branch information
jens-meisner authored Dec 5, 2024
2 parents 030f510 + 1cecb7c commit e7c10ee
Show file tree
Hide file tree
Showing 4 changed files with 662 additions and 1,128 deletions.
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/plugin-transform-runtime": "^7.25.4",
"@ckeditor/ckeditor5-dev-translations": "^43.0.1",
"@ckeditor/ckeditor5-dev-utils": "^43.0.1",
"@ckeditor/ckeditor5-dev-translations": "^45.0.8",
"@ckeditor/ckeditor5-dev-utils": "^45.0.8",
"@ckeditor/ckeditor5-inspector": "^4.1.0",
"@ckeditor/ckeditor5-theme-lark": "43.3.1",
"@types/node": "^20.14.10",
Expand Down
24 changes: 14 additions & 10 deletions app/webpack.config.cjs → app/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@

/* eslint-env node */

const path = require("path");
const webpack = require("webpack");
const { bundler, loaders } = require("@ckeditor/ckeditor5-dev-utils");
const { CKEditorTranslationsPlugin } = require("@ckeditor/ckeditor5-dev-translations");
const TerserPlugin = require("terser-webpack-plugin");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const { default: path } = await import("path");
const { default: webpack } = await import("webpack");
const { bundler, loaders } = await import("@ckeditor/ckeditor5-dev-utils");
const { CKEditorTranslationsPlugin } = await import("@ckeditor/ckeditor5-dev-translations");
const { default: TerserPlugin } = await import("terser-webpack-plugin");
const { default: CircularDependencyPlugin } = await import("circular-dependency-plugin");
import { fileURLToPath } from "url";

module.exports = {
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);

export default {
devtool: "source-map",
performance: { hints: false },

entry: path.resolve(__dirname, "src", "index.ts"),
entry: path.resolve(dirname, "src", "index.ts"),

output: {
// The name under which the editor will be exported.
library: "ClassicEditor",

path: path.resolve(__dirname, "dist"),
path: path.resolve(dirname, "dist"),
filename: "ckeditor.js",
libraryTarget: "umd",
libraryExport: "default",
Expand Down Expand Up @@ -57,7 +61,7 @@ module.exports = {
rules: [
loaders.getIconsLoader({ matchExtensionOnly: true }),
loaders.getStylesLoader({
themePath: require.resolve("@ckeditor/ckeditor5-theme-lark"),
themePath: import.meta.resolve("@ckeditor/ckeditor5-theme-lark"),
minify: true,
}),
loaders.getTypeScriptLoader(),
Expand Down
19 changes: 14 additions & 5 deletions packages/ckeditor5-coremedia-link/src/contentlink/ContentLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default class ContentLinks extends Plugin {
readonly #logger = LoggerProvider.getLogger("ContentLinks");
#serviceRegisteredSubscription: Pick<Subscription, "unsubscribe"> | undefined = undefined;
#initialized = false;
#currentWorkAreaService: WorkAreaService | undefined = undefined;
#activeEntity: string | undefined = "";

/**
* Closes the contextual balloon whenever a new active entity is set.
Expand All @@ -40,10 +42,14 @@ export default class ContentLinks extends Plugin {
*/
#listenForActiveEntityChanges(workAreaService: WorkAreaService): void {
workAreaService.observe_activeEntity().subscribe({
next: (activeEntities) => {
this.#logger.debug("Closing balloon because active entity changed", activeEntities);
next: (activeEntity) => {
if (this.#activeEntity === activeEntity) {
return;
}
this.#logger.debug("Closing balloon because active entity changed", activeEntity);
this.#removeEditorFocusAndSelection();
closeContextualBalloon(this.editor);
this.#activeEntity = typeof activeEntity === "string" ? activeEntity : undefined;
},
});
}
Expand Down Expand Up @@ -86,12 +92,15 @@ export default class ContentLinks extends Plugin {
this.#logger.debug("No WorkAreaService registered yet");
return;
}
if (this.#currentWorkAreaService && services.includes(this.#currentWorkAreaService)) {
return;
}
if (this.#serviceRegisteredSubscription) {
this.#serviceRegisteredSubscription.unsubscribe();
}
this.#logger.debug("WorkAreaService is registered now, listening for activeEntities will be started");
const clipboardService = services[0];
this.#listenForActiveEntityChanges(clipboardService);
this.#logger.debug("WorkAreaService is registered now, listening for activeEntity will be started");
this.#currentWorkAreaService = services[0];
this.#listenForActiveEntityChanges(this.#currentWorkAreaService);
};
this.#serviceRegisteredSubscription = serviceAgent
.observeServices<WorkAreaService>(createWorkAreaServiceDescriptor())
Expand Down
Loading

0 comments on commit e7c10ee

Please sign in to comment.