API reference

@thefinder/ckeditor

A connector for CKEditor 5 and CKEditor 4 that does what CKFinder does:

The picker is opened with openFilePicker, so @thefinder/react/styles.css must be loaded on the page.

CKEditor 5#

import { ClassicEditor, Essentials, Paragraph, Image, ImageUpload, Link } from "ckeditor5";
import { TheFinder } from "@thefinder/ckeditor";
import "@thefinder/react/styles.css";

ClassicEditor.create(el, {
  licenseKey: "GPL",
  plugins: [Essentials, Paragraph, Image, ImageUpload, Link, TheFinder],
  toolbar: ["bold", "link", "|", "theFinder"],
  theFinder: { endpoint: "/api/files", uploadFolder: "/editor" },
});

Requires ckeditor5 ≥ 42 (the unified ckeditor5 package). The plugin loads FileRepository by itself.

theFinder config (TheFinderEditorConfig)#

OptionTypeDefaultDescription
endpointstring"/api/files"API URL
headersRecord<string, string> \| () => Record<string, string>—Extra request headers
credentialsRequestCredentials—Cookie mode for cross-origin
clientTheFinderClient—A ready client; when given it replaces the three above
uploadFolderstring \| { volume, path } \| false"/editor"Folder for pasted images. A string is used as a path in the first volume. Created if missing. false keeps CKEditor's own upload setup.
absoluteUrlsbooleanfalseWrites full URLs (https://site/uploads/a.png) into the content
pickerPartial<FilePickerOptions>—Picker options: accept, theme, locale, multiple…
openPicker() => Promise<PickedFile[] \| null>—Opens your own picker instead of the built-in one

Components#

NameDescription
theFinder (toolbar item)Opens the file manager. Disabled while the editor is read-only. The button label follows the editor's UI language (English or Turkish).
editor.plugins.get("TheFinder").browse()Opens the picker from your own button
editor.plugins.get("TheFinder").insert(files)Inserts PickedFile[]. With the Image plugin loaded, images become images and everything else links. When a single file is picked and text is selected, the link goes on the selected text.
TheFinderUploadAdapterThe upload adapter class; exported for use in your own FileRepository setup

CKEditor 4#

CKEditor 4 works with a global CKEDITOR object, so the module registers a thefinder plugin on it:

import { registerTheFinder } from "@thefinder/ckeditor/v4";
import "@thefinder/react/styles.css";

registerTheFinder(window.CKEDITOR);
CKEDITOR.replace("body", {
  extraPlugins: "thefinder,uploadimage",
  theFinder: { endpoint: "/api/files", uploadFolder: "/editor" },
});

registerTheFinder(CKEDITOR) can be called more than once; the plugin is registered only once. The plugin needs the filebrowser plugin (included in the standard builds).

What the plugin does:

theFinder config (TheFinderEditor4Config)#

Same as CKEditor 5; the only difference is the openPicker signature:

openPicker?: (options: { images: boolean; multiple: boolean }) => Promise<PickedFile[] | null>;
// images: an image is expected (Image dialog), multiple: true for the toolbar button

The last open-source release of CKEditor 4 is 4.22.1; 4.23 and later require a commercial license key. The connector works with both.

Types#

TheFinderEditorConfig, TheFinderEditor4Config, CKEditorStatic (the part of the CKEditor 4 global that is used) and PickedFile.

This page is generated from docs/api/ckeditor.md.