-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Image Linking *without* Image Uploading #15291
Comments
You can use the ClassicEditor.create( document.querySelector( '#editor' ), {
plugins: [
Essentials,
Autoformat,
Bold,
Italic,
Heading,
Image,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageInsertViaUrl,
AutoImage,
Link,
LinkImage,
Paragraph
],
toolbar: [
'heading',
'|',
'bold', 'italic', 'link',
'|',
'insertImage',
'|',
'undo', 'redo'
],
image: {
toolbar: [
'imageStyle:inline', 'imageStyle:block', 'imageStyle:side',
'|',
'toggleImageCaption', 'imageTextAlternative'
]
}
} ) |
Hmmm, it's not the case I see in our manual tests, where insert via url can be the only button.
|
I'm having to use the Web Builder because I'm using it in an ASP application. Is there a way to extract the list of proper plugin names similar to the toolbar items, so that I can try listing all of them except that one explicitly, rather than removing just that one? That's the only difference I can see...? Just in case it's helpful, here's my full list of selected plugins, and the full text of my .create call:
Does the Builder-version even allow you to 'remove' the plugin if it's built with it?
|
Don't load |
If I expand to also doing:
Then both 'insertImage' and 'insertImageViaURL' give an error like
If I flip to just specifying the single plugin for testing purposes:
It gives an error like
|
I have trouble with this as well, somehow it works in our manual test 😮💨 cc @filipsobol could you check? Thankfully, #15149 will fix `insertImage` logic. |
I think the problem here is that we are mixing the two ways of creating the editor (editor class versus the In the project created using the Online Builder, there's a On the other hand, the With this in mind, it is best to configure the editor to your needs in These are the steps needed to only allow adding images via URL, using the exact plugin setup you shared before (which was a big help, by the way 🙏).
Then run the Entire setup code/**
* @license Copyright (c) 2014-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic';
import { Alignment } from '@ckeditor/ckeditor5-alignment';
import { Autoformat } from '@ckeditor/ckeditor5-autoformat';
import {
Bold,
Italic,
Strikethrough,
Subscript,
Superscript,
Underline
} from '@ckeditor/ckeditor5-basic-styles';
import { BlockQuote } from '@ckeditor/ckeditor5-block-quote';
import type { EditorConfig } from '@ckeditor/ckeditor5-core';
import { Essentials } from '@ckeditor/ckeditor5-essentials';
import { FindAndReplace } from '@ckeditor/ckeditor5-find-and-replace';
import { FontBackgroundColor, FontColor, FontFamily, FontSize } from '@ckeditor/ckeditor5-font';
import { Heading } from '@ckeditor/ckeditor5-heading';
import { HorizontalLine } from '@ckeditor/ckeditor5-horizontal-line';
import { HtmlEmbed } from '@ckeditor/ckeditor5-html-embed';
import { GeneralHtmlSupport } from '@ckeditor/ckeditor5-html-support';
import {
Image,
ImageCaption,
ImageResize,
ImageStyle,
ImageToolbar,
ImageInsertViaUrl
} from '@ckeditor/ckeditor5-image';
import { Indent, IndentBlock } from '@ckeditor/ckeditor5-indent';
import { Link } from '@ckeditor/ckeditor5-link';
import { List } from '@ckeditor/ckeditor5-list';
import { MediaEmbed } from '@ckeditor/ckeditor5-media-embed';
import { Paragraph } from '@ckeditor/ckeditor5-paragraph';
import { PasteFromOffice } from '@ckeditor/ckeditor5-paste-from-office';
import { RemoveFormat } from '@ckeditor/ckeditor5-remove-format';
import { SelectAll } from '@ckeditor/ckeditor5-select-all';
import { ShowBlocks } from '@ckeditor/ckeditor5-show-blocks';
import { SourceEditing } from '@ckeditor/ckeditor5-source-editing';
import { Style } from '@ckeditor/ckeditor5-style';
import { Table, TableToolbar } from '@ckeditor/ckeditor5-table';
import { TextTransformation } from '@ckeditor/ckeditor5-typing';
// You can read more about extending the build with additional plugins in the "Installing plugins" guide.
// See https://ckeditor.com/docs/ckeditor5/latest/installation/plugins/installing-plugins.html for details.
class Editor extends ClassicEditor {
public static override builtinPlugins = [
Alignment,
Autoformat,
BlockQuote,
Bold,
Essentials,
FindAndReplace,
FontBackgroundColor,
FontColor,
FontFamily,
FontSize,
GeneralHtmlSupport,
Heading,
HorizontalLine,
HtmlEmbed,
Image,
ImageCaption,
ImageResize,
ImageStyle,
ImageToolbar,
ImageInsertViaUrl,
Indent,
IndentBlock,
Italic,
Link,
List,
MediaEmbed,
Paragraph,
PasteFromOffice,
RemoveFormat,
SelectAll,
ShowBlocks,
SourceEditing,
Strikethrough,
Style,
Subscript,
Superscript,
Table,
TableToolbar,
TextTransformation,
Underline
];
public static override defaultConfig: EditorConfig = {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'outdent',
'indent',
'|',
'insertImage',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo'
]
},
language: 'en',
image: {
toolbar: [
'imageTextAlternative',
'toggleImageCaption',
'imageStyle:inline',
'imageStyle:block',
'imageStyle:side'
]
},
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells'
]
}
};
}
export default Editor; In the consuming project, all you need to do is: Editor.create( document.querySelector( '#editor' ) as HTMLElement ); |
Thank you both for your detailed response and assistance :)
However, it would mean I don't need to go through the rigamarole of having all sorts of Javascript-y development tools and environments and such approved for installation (and installed and worked out how to use them) in the Client's development environment to build the bundle.
So are you basically saying that the only way to properly decouple the ImageUpload and ImageInsert plugin buttons from CKEditor, and retain just the ImageInsertViaUrl button, is to skip the online Builder entirely and do a custom build, and then import that build into my .NET project? |
Assuming that to be the case, I fiddled around with installing NPM and doing the build in Windows Sandbox to get around the approvals issue, and while it threw me for a bit that the build wouldn't replace the ckeditor.js file and I had to delete it first, it has indeed allowed me to customise it as desired. Many thanks! :) |
📝 Provide a description of the new feature
For my use-case, images being used must be uploaded separately ahead of time, and only ever referenced as a URL by the content being edited in CKEditor.
We don't want to have to handle uploading via CKEditor as there are other things that must be done at upload time for an image, and the workflows for handling that stuff after the fact for one or more uploads via the editor would be... Vexing.
Consequently, we don't want to provide the option for upload to the users, if they're not going to be allowed to use it and/or it's not going to work.
Currently it is impossible to facilitate the concept of linking to an image that already exists, without having a big dedicated button for uploading (as far as I can tell).
So ideally, we would like to be able to indicate that image uploading is not allowed, and default the 'ImageRelatedThings' button to showing the Image Linking mechanism as happens with the dropdown beside it.
Especially as we're upgrading from CKEditor3 where the Image button manages the image URL and doesn't allow for Upload (in our configuration at least), so clicking the 'image' button is what they're used to doing
If you'd like to see this feature implemented, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: