Skip to content

Commit 073e97c

Browse files
committed
Merge branch '6.0'
2 parents efa5ffd + 8f0cbce commit 073e97c

7 files changed

Lines changed: 87 additions & 8 deletions

File tree

app.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
Table,
3232
Undo,
3333
WoltlabAttachment,
34+
WoltlabAutoLink,
3435
WoltlabAutosave,
3536
WoltlabBbcode,
3637
WoltlabBlockQuote,
@@ -98,6 +99,7 @@ const defaultConfig: Core.EditorConfig = {
9899

99100
// WoltLab
100101
WoltlabAttachment.WoltlabAttachment,
102+
WoltlabAutoLink.WoltlabAutoLink,
101103
WoltlabAutosave.WoltlabAutosave,
102104
WoltlabBlockQuote.WoltlabBlockQuote,
103105
WoltlabBbcode.WoltlabBbcode,
@@ -174,13 +176,5 @@ export async function create(
174176
configuration,
175177
);
176178

177-
// Unconditionally disable the `AutoLink` plugin which interferes with our
178-
// own link detection and all creates potentially invalid links.
179-
// See https://github.com/ckeditor/ckeditor5/issues/14497
180-
if (editor.plugins.has(Link.AutoLink)) {
181-
const autoLink = editor.plugins.get(Link.AutoLink);
182-
autoLink.forceDisabled("app.ts");
183-
}
184-
185179
return editor;
186180
}

modules.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export * as HorizontalLine from "@ckeditor/ckeditor5-horizontal-line";
1717
export * as HtmlEmbed from "@ckeditor/ckeditor5-html-embed";
1818
export * as Image from "@ckeditor/ckeditor5-image";
1919
export * as Indent from "@ckeditor/ckeditor5-indent";
20+
export * as Language from "@ckeditor/ckeditor5-language";
2021
export * as Link from "@ckeditor/ckeditor5-link";
2122
export * as List from "@ckeditor/ckeditor5-list";
2223
export * as Mention from "@ckeditor/ckeditor5-mention";
@@ -33,6 +34,7 @@ export * as Utils from "@ckeditor/ckeditor5-utils";
3334
export * as Widget from "@ckeditor/ckeditor5-widget";
3435

3536
export * as WoltlabAttachment from "./plugins/ckeditor5-woltlab-attachment/src";
37+
export * as WoltlabAutoLink from "./plugins/ckeditor5-woltlab-autolink/src";
3638
export * as WoltlabAutosave from "./plugins/ckeditor5-woltlab-autosave/src";
3739
export * as WoltlabBbcode from "./plugins/ckeditor5-woltlab-bbcode/src";
3840
export * as WoltlabBlockQuote from "./plugins/ckeditor5-woltlab-block-quote/src";
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"author": "WoltLab GmbH",
3+
"license": "LGPL-2.1-or-later",
4+
"main": "src/index.ts",
5+
"private": true
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @author Alexander Ebert
3+
* @copyright 2001-2024 WoltLab GmbH
4+
* @license LGPL-2.1-or-later
5+
* @since 6.0
6+
*/
7+
8+
export { WoltlabAutoLink } from "./woltlabautolink";
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Disables the AutoLink plugin during the normal editing to prevent incorrect
3+
* transformations and to defer the link detection to the server side. Pasting
4+
* a link while having an active text selection is selectively enabled.
5+
*
6+
* @author Alexander Ebert
7+
* @copyright 2001-2024 WoltLab GmbH
8+
* @license LGPL-2.1-or-later
9+
* @since 6.0
10+
*/
11+
12+
import { Plugin } from "@ckeditor/ckeditor5-core";
13+
import { AutoLink } from "@ckeditor/ckeditor5-link";
14+
15+
export class WoltlabAutoLink extends Plugin {
16+
readonly #key = "WoltlabAutoLink";
17+
18+
static get pluginName() {
19+
return "WoltlabAutoLink" as const;
20+
}
21+
22+
static get requires() {
23+
return [AutoLink] as const;
24+
}
25+
26+
init() {
27+
if (!this.editor.plugins.has(AutoLink)) {
28+
return;
29+
}
30+
31+
// Unconditionally disable the `AutoLink` plugin which interferes with our
32+
// own link detection and all creates potentially invalid links.
33+
// See https://github.com/ckeditor/ckeditor5/issues/14497
34+
const autoLink = this.editor.plugins.get(AutoLink);
35+
autoLink.forceDisabled(this.#key);
36+
37+
// Replacing text with a link from clipboard is provided by the `AutoLink`
38+
// plugin, requiring us to enable the plugin for the duration of the paste.
39+
//
40+
// AutoLink’s event listener uses the "high" priority.
41+
const clipboardPipeline = this.editor.plugins.get("ClipboardPipeline");
42+
clipboardPipeline.on(
43+
"inputTransformation",
44+
() => {
45+
autoLink.clearForceDisabled(this.#key);
46+
},
47+
{ priority: "highest" },
48+
);
49+
50+
clipboardPipeline.on(
51+
"inputTransformation",
52+
() => {
53+
autoLink.forceDisabled(this.#key);
54+
},
55+
{ priority: "normal" },
56+
);
57+
}
58+
}
59+
60+
export default WoltlabAutoLink;

plugins/ckeditor5-woltlab-metacode/src/woltlabmetacode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ export class WoltlabMetacode extends Plugin {
7676
this.#serializedAttributesToString(attributes);
7777
const openingTag = writer.createText(`[${name}${attributeString}]`);
7878
const closingTag = writer.createText(`[/${name}]`);
79+
const parent = modelCursor.parent;
7980

8081
// Check if the BBCode appears to be a block element.
8182
let isBlockElement = false;
8283
const ancestors = modelCursor.getAncestors();
8384
if (ancestors[ancestors.length - 1].name === "$root") {
8485
isBlockElement = true;
86+
} else if (parent.name === "blockQuote") {
87+
// Text nodes may only appear inside block nodes.
88+
isBlockElement = true;
8589
} else {
8690
for (const child of viewItem.getChildren()) {
8791
if (child.is("containerElement")) {

release.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
npm run build
3+
cp dist/ckeditor5.bundle.js ../WCF/wcfsetup/install/files/js/3rdParty/ckeditor/
4+
cp dist/ckeditor5.css ../WCF/wcfsetup/install/files/style/
5+
cp dist/translations/*.js ../WCF/wcfsetup/install/files/js/3rdParty/ckeditor/translations/

0 commit comments

Comments
 (0)