Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit e280968

Browse files
committed
feat(ckeditor): allow use of GPL license
1 parent b809137 commit e280968

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

apps/client/src/widgets/type_widgets/ckeditor/config.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@ import utils from "../../../services/utils.js";
88
import emojiDefinitionsUrl from "@triliumnext/ckeditor5/emoji_definitions/en.json?url";
99
import { copyTextWithToast } from "../../../services/clipboard_ext.js";
1010
import getTemplates from "./snippets.js";
11+
import { PREMIUM_PLUGINS } from "../../../../../../packages/ckeditor5/src/plugins.js";
12+
13+
const OPEN_SOURCE_LICENSE_KEY = "GPL";
1114

1215
const TEXT_FORMATTING_GROUP = {
1316
label: "Text formatting",
1417
icon: "text"
1518
};
1619

1720
export async function buildConfig(): Promise<EditorConfig> {
18-
return {
19-
licenseKey: getLicenseKey(),
21+
const licenseKey = getLicenseKey();
22+
const hasPremiumLicense = (licenseKey !== OPEN_SOURCE_LICENSE_KEY);
23+
24+
const config: EditorConfig = {
25+
licenseKey,
2026
image: {
2127
styles: {
2228
options: [
@@ -134,6 +140,15 @@ export async function buildConfig(): Promise<EditorConfig> {
134140
// This value must be kept in sync with the language defined in webpack.config.js.
135141
language: "en"
136142
};
143+
144+
// Enable premium plugins.
145+
if (hasPremiumLicense) {
146+
config.extraPlugins = [
147+
...PREMIUM_PLUGINS
148+
];
149+
}
150+
151+
return config;
137152
}
138153

139154
export function buildToolbarConfig(isClassicToolbar: boolean) {
@@ -282,7 +297,7 @@ function getLicenseKey() {
282297
const premiumLicenseKey = import.meta.env.VITE_CKEDITOR_KEY;
283298
if (!premiumLicenseKey) {
284299
logError("CKEditor license key is not set, premium features will not be available.");
285-
return "GPL";
300+
return OPEN_SOURCE_LICENSE_KEY;
286301
}
287302

288303
return premiumLicenseKey;

docs/User Guide/User Guide/Note Types/Text/Premium features.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ The license key is stored in the application and it enables the use of the previ
99

1010
## Can I opt out of these features?
1111

12-
At this moment there is no way to disable this features, apart from manually modifying the source code. If this is a problem, [let us know](../../Troubleshooting/Reporting%20issues.md).
12+
At this moment there is no way to disable these features, apart from manually modifying the source code. If this is a problem, [let us know](../../Troubleshooting/Reporting%20issues.md).
13+
14+
If you have the possibility of rebuilding the source code (e.g. if a package maintainer), then modify `VITE_CKEDITOR_KEY` in `apps/client/.env` to be `GPL`.

packages/ckeditor5/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "ckeditor5/ckeditor5.css";
22
import "./theme/code_block_toolbar.css";
3-
import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins";
3+
import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS, PREMIUM_PLUGINS } from "./plugins";
44
import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } from "ckeditor5";
55
import "./translation_overrides.js";
66
export { EditorWatchdog } from "ckeditor5";

packages/ckeditor5/src/plugins.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Autoformat, AutoLink, BlockQuote, BlockToolbar, Bold, CKFinderUploadAdapter, Clipboard, Code, CodeBlock, Enter, FindAndReplace, Font, FontBackgroundColor, FontColor, GeneralHtmlSupport, Heading, HeadingButtonsUI, HorizontalLine, Image, ImageCaption, ImageInline, ImageResize, ImageStyle, ImageToolbar, ImageUpload, Alignment, Indent, IndentBlock, Italic, Link, List, ListProperties, Mention, PageBreak, Paragraph, ParagraphButtonUI, PasteFromOffice, PictureEditing, RemoveFormat, SelectAll, ShiftEnter, SpecialCharacters, SpecialCharactersEssentials, Strikethrough, Style, Subscript, Superscript, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableSelection, TableToolbar, TextPartLanguage, TextTransformation, TodoList, Typing, Underline, Undo, Bookmark, Emoji } from "ckeditor5";
1+
import { Autoformat, AutoLink, BlockQuote, BlockToolbar, Bold, CKFinderUploadAdapter, Clipboard, Code, CodeBlock, Enter, FindAndReplace, Font, FontBackgroundColor, FontColor, GeneralHtmlSupport, Heading, HeadingButtonsUI, HorizontalLine, Image, ImageCaption, ImageInline, ImageResize, ImageStyle, ImageToolbar, ImageUpload, Alignment, Indent, IndentBlock, Italic, Link, List, ListProperties, Mention, PageBreak, Paragraph, ParagraphButtonUI, PasteFromOffice, PictureEditing, RemoveFormat, SelectAll, ShiftEnter, SpecialCharacters, SpecialCharactersEssentials, Strikethrough, Style, Subscript, Superscript, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableSelection, TableToolbar, TextPartLanguage, TextTransformation, TodoList, Typing, Underline, Undo, Bookmark, Emoji, Notification } from "ckeditor5";
22
import { SlashCommand, Template } from "ckeditor5-premium-features";
33
import type { Plugin } from "ckeditor5";
44
import CutToNotePlugin from "./plugins/cuttonote.js";
@@ -148,14 +148,13 @@ export const COMMON_PLUGINS: typeof Plugin[] = [
148148
Emoji,
149149

150150
...TRILIUM_PLUGINS,
151-
...EXTERNAL_PLUGINS,
152-
...PREMIUM_PLUGINS
151+
...EXTERNAL_PLUGINS
153152
];
154153

155154
/**
156155
* The set of plugins specific to the popup editor (floating toolbar mode), and not the fixed toolbar mode.
157156
*/
158157
export const POPUP_EDITOR_PLUGINS: typeof Plugin[] = [
159158
...COMMON_PLUGINS,
160-
BlockToolbar
159+
BlockToolbar,
161160
];

0 commit comments

Comments
 (0)