mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-27 08:16:40 +01:00 
			
		
		
		
	feat(ckeditor): allow use of GPL license
This commit is contained in:
		| @@ -8,6 +8,9 @@ import utils from "../../../services/utils.js"; | |||||||
| import emojiDefinitionsUrl from "@triliumnext/ckeditor5/emoji_definitions/en.json?url"; | import emojiDefinitionsUrl from "@triliumnext/ckeditor5/emoji_definitions/en.json?url"; | ||||||
| import { copyTextWithToast } from "../../../services/clipboard_ext.js"; | import { copyTextWithToast } from "../../../services/clipboard_ext.js"; | ||||||
| import getTemplates from "./snippets.js"; | import getTemplates from "./snippets.js"; | ||||||
|  | import { PREMIUM_PLUGINS } from "../../../../../../packages/ckeditor5/src/plugins.js"; | ||||||
|  |  | ||||||
|  | const OPEN_SOURCE_LICENSE_KEY = "GPL"; | ||||||
|  |  | ||||||
| const TEXT_FORMATTING_GROUP = { | const TEXT_FORMATTING_GROUP = { | ||||||
|     label: "Text formatting", |     label: "Text formatting", | ||||||
| @@ -15,8 +18,11 @@ const TEXT_FORMATTING_GROUP = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| export async function buildConfig(): Promise<EditorConfig> { | export async function buildConfig(): Promise<EditorConfig> { | ||||||
|     return { |     const licenseKey = getLicenseKey(); | ||||||
|         licenseKey: getLicenseKey(), |     const hasPremiumLicense = (licenseKey !== OPEN_SOURCE_LICENSE_KEY); | ||||||
|  |  | ||||||
|  |     const config: EditorConfig = { | ||||||
|  |         licenseKey, | ||||||
|         image: { |         image: { | ||||||
|             styles: { |             styles: { | ||||||
|                 options: [ |                 options: [ | ||||||
| @@ -134,6 +140,15 @@ export async function buildConfig(): Promise<EditorConfig> { | |||||||
|         // This value must be kept in sync with the language defined in webpack.config.js. |         // This value must be kept in sync with the language defined in webpack.config.js. | ||||||
|         language: "en" |         language: "en" | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  |     // Enable premium plugins. | ||||||
|  |     if (hasPremiumLicense) { | ||||||
|  |         config.extraPlugins = [ | ||||||
|  |             ...PREMIUM_PLUGINS | ||||||
|  |         ]; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return config; | ||||||
| } | } | ||||||
|  |  | ||||||
| export function buildToolbarConfig(isClassicToolbar: boolean) { | export function buildToolbarConfig(isClassicToolbar: boolean) { | ||||||
| @@ -282,7 +297,7 @@ function getLicenseKey() { | |||||||
|     const premiumLicenseKey = import.meta.env.VITE_CKEDITOR_KEY; |     const premiumLicenseKey = import.meta.env.VITE_CKEDITOR_KEY; | ||||||
|     if (!premiumLicenseKey) { |     if (!premiumLicenseKey) { | ||||||
|         logError("CKEditor license key is not set, premium features will not be available."); |         logError("CKEditor license key is not set, premium features will not be available."); | ||||||
|         return "GPL"; |         return OPEN_SOURCE_LICENSE_KEY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return premiumLicenseKey; |     return premiumLicenseKey; | ||||||
|   | |||||||
| @@ -9,4 +9,6 @@ The license key is stored in the application and it enables the use of the previ | |||||||
|  |  | ||||||
| ## Can I opt out of these features? | ## Can I opt out of these features? | ||||||
|  |  | ||||||
| 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). | 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). | ||||||
|  |  | ||||||
|  | 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`. | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| import "ckeditor5/ckeditor5.css"; | import "ckeditor5/ckeditor5.css"; | ||||||
| import "./theme/code_block_toolbar.css"; | import "./theme/code_block_toolbar.css"; | ||||||
| import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins"; | import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS, PREMIUM_PLUGINS } from "./plugins"; | ||||||
| import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } from "ckeditor5"; | import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } from "ckeditor5"; | ||||||
| import "./translation_overrides.js"; | import "./translation_overrides.js"; | ||||||
| export { EditorWatchdog } from "ckeditor5"; | export { EditorWatchdog } from "ckeditor5"; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| 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"; | 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"; | ||||||
| import { SlashCommand, Template } from "ckeditor5-premium-features"; | import { SlashCommand, Template } from "ckeditor5-premium-features"; | ||||||
| import type { Plugin } from "ckeditor5"; | import type { Plugin } from "ckeditor5"; | ||||||
| import CutToNotePlugin from "./plugins/cuttonote.js"; | import CutToNotePlugin from "./plugins/cuttonote.js"; | ||||||
| @@ -148,8 +148,7 @@ export const COMMON_PLUGINS: typeof Plugin[] = [ | |||||||
|     Emoji, |     Emoji, | ||||||
|  |  | ||||||
|     ...TRILIUM_PLUGINS, |     ...TRILIUM_PLUGINS, | ||||||
|     ...EXTERNAL_PLUGINS, |     ...EXTERNAL_PLUGINS | ||||||
|     ...PREMIUM_PLUGINS |  | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -157,5 +156,5 @@ export const COMMON_PLUGINS: typeof Plugin[] = [ | |||||||
|  */ |  */ | ||||||
| export const POPUP_EDITOR_PLUGINS: typeof Plugin[] = [ | export const POPUP_EDITOR_PLUGINS: typeof Plugin[] = [ | ||||||
|     ...COMMON_PLUGINS, |     ...COMMON_PLUGINS, | ||||||
|     BlockToolbar |     BlockToolbar, | ||||||
| ]; | ]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user