-
Notifications
You must be signed in to change notification settings - Fork 105
Add support for paragraph like editor. #675
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
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d015796
Add support for paragraph like editor.
Mati365 18f7019
Fix failing tests.
Mati365 3e95729
Add support for passing `tagName` into `CKEditor` component.
Mati365 5a116cc
Add changelog and tests for `tagName` property.
Mati365 6f1faca
Add `addRoot` / `removeRoot` methods for `useMultiRootEditor`
Mati365 b4b76aa
Adjust creator.
Mati365 b6ddb11
Adjust handler.
Mati365 8601a13
Add testing.
Mati365 1d0761d
Add `EditorElement` component.
Mati365 ec4224f
Make it work.
Mati365 5452422
Add changelogs.
Mati365 f90e6e6
Re-export type
Mati365 fa99632
Rename type.
Mati365 090a64b
Fix edge case for classic editor.
Mati365 173064c
Fix `waitFor` behavior for editors rerenders
Mati365 83cb33b
Adjust handler.
Mati365 44483a6
Move element definition normalize to separate file.
Mati365 03e020e
Fix imports
Mati365 d40ebf9
Better syntax.
Mati365 cd4c032
CR fixes
Mati365 1298079
Add commnet.
Mati365 1fbfe74
Adjust mapper.
Mati365 e53f351
Bump integrations common to `2.4.0`.
Mati365 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| type: Feature | ||
| --- | ||
|
|
||
| The `useMultiRootEditor` hook now returns `addRoot` and `removeRoot` helpers directly. Previously, adding or removing a root required manually manipulating the `data` and `attributes` state outside the hook. You can now call them directly: | ||
|
|
||
| ```js | ||
| const { addRoot, removeRoot } = useMultiRootEditor( props ); | ||
|
|
||
| await addRoot({ | ||
| name: 'my-root', | ||
| data: '<p>Hello</p>', | ||
| attributes: { order: 10 }, | ||
| editableOptions: { | ||
| element: 'section', | ||
| placeholder: 'Start typing...', | ||
| label: 'My section' | ||
| } | ||
| }); | ||
|
|
||
| await removeRoot( 'my-root' ); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| type: Feature | ||
| --- | ||
|
|
||
| The `<CKEditor>` component now supports paragraph-like editor configurations. When `config.root.element` (or `config.roots.main.element`) is provided, you can customize the tag name, CSS classes and inline styles of the editable element instead of relying on the default plain `<div>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| type: Feature | ||
| --- | ||
|
|
||
| Each editable root in the multi-root editor can now be configured independently with its own HTML element type, placeholder text and accessible label. Pass an `editableOptions` object to `addRoot` to control the `element` (e.g. `'section'`, `'article'`), `placeholder` and assistive-technology `label` for that specific root. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. | ||
| * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options | ||
| */ | ||
|
|
||
| import React, { forwardRef, memo } from 'react'; | ||
|
|
||
| import { normalizeClassList } from './utils/normalizeClassList.js'; | ||
| import { normalizeStylesMap } from './utils/normalizeStylesMap.js'; | ||
|
|
||
| import { | ||
| type EditorElementDefinition, | ||
| normalizeEditorElementDefinition | ||
| } from './utils/normalizeEditorElementDefinition.js'; | ||
|
|
||
| /** | ||
| * Creates and renders a dynamic React element based on the element definition owned and provided by the editor. | ||
| * | ||
| * @param props The component properties. | ||
| */ | ||
| export const EditorElement = memo( forwardRef<HTMLElement, Props>( ( { definition }, ref ) => { | ||
| const { name: Tag, classes, styles, attributes } = normalizeEditorElementDefinition( definition ?? { | ||
| name: 'div' | ||
| } ); | ||
|
|
||
| return ( | ||
| <Tag | ||
| ref={ref} | ||
| {...attributes} | ||
| style={normalizeStylesMap( styles ?? {} )} | ||
| className={normalizeClassList( classes )} | ||
| /> | ||
| ); | ||
| } ) ); | ||
|
|
||
| EditorElement.displayName = 'EditorElement'; | ||
|
|
||
| /** | ||
| * Properties for the {@link EditorElement} component. | ||
| */ | ||
| type Props = { | ||
|
|
||
| /** | ||
| * The definition of the element to be rendered. Defaults to a `div` element if not provided or null. | ||
| */ | ||
| definition?: EditorElementDefinition | null; | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.