Skip to content
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

Update Placeholder after initialization #9925

Closed
mugnap opened this issue Jun 19, 2021 · 3 comments · Fixed by #14627
Closed

Update Placeholder after initialization #9925

mugnap opened this issue Jun 19, 2021 · 3 comments · Fixed by #14627
Assignees
Labels
package:core squad:features Issue to be handled by the Features team. support:1 An issue reported by a commercially licensed client. type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@mugnap
Copy link

mugnap commented Jun 19, 2021

Hello,

I'd like to have the ability, for an Inline editor, to update the placeholder at runtime (i.e. after the editor has been created). Is there any way to do that? Currently the placeholder is set in the configuration options, so I can't change it later. I found this thread #7383 but I think nothing has changed yet.
Thanks!


If you'd like to see this feature implemented, add a 👍 reaction to this post.

@mugnap mugnap added the type:feature This issue reports a feature request (an idea for a new functionality or a missing option). label Jun 19, 2021
@urbanspr1nter
Copy link
Contributor

I'd really like to know if there's any ability to do this yet.. Is there an easy way in v37+?

@Witoso something probably worth thinking about. CKE5 can be used for a variety of scenarios such as chat apps. For example, in Slack, the placeholder will change depending on which channel or chat you are in.

image image

Having a convenient way to update the root editable placeholder would be really nice..

@Witoso Witoso added package:core squad:core Issue to be handled by the Core team. labels Jun 2, 2023
@Witoso
Copy link
Member

Witoso commented Jun 2, 2023

@urbanspr1nter thanks for bringing this to my attention! I haven't found an easy way to do that, unfortunately :/ I will keep it in my mind in our future API discussion.

@mlewand mlewand added squad:features Issue to be handled by the Features team. and removed squad:core Issue to be handled by the Core team. labels Jul 17, 2023
@mlewand
Copy link
Contributor

mlewand commented Jul 19, 2023

Some precedence is with viewportOffset config. At runtime it is reflected in EditorUI#viewportOffset property.

Currently the enablePlaceholder method is called in EditorUI implementation (e.g. in ClassicEditorUI). It passes the placeholder text, editingRoot and couple of auxillary properties.

Logically, the placeholder is a property of a specific RootEditableElement instance, so it make sense to set the placeholder value there.

By doing so we could remove the need of passing placeholder text all along, as enablePlaceholder should start listen to the placeholder property of a passed RootEditableElement instance.

If the integrator wants to change the placeholder value at a runtime would need to execute editor.editing.view.document.getRoot( 'main' ).placeholder = 'new placeholder' to make a change.

Remarks

  • Remember there's multiroot configuration and it must be possible to specify a distinct placeholder for a given root.
  • There's a guide related to placeholoders. We should add an example on how to change the placeholder at a runtime.

@CKEditorBot CKEditorBot added status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. and removed status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. labels Jul 19, 2023
@lslowikowska lslowikowska added support:2 An issue reported by a commercially licensed client. support:1 An issue reported by a commercially licensed client. and removed support:2 An issue reported by a commercially licensed client. labels Jul 24, 2023
@mlewand mlewand self-assigned this Jul 26, 2023
mlewand added a commit that referenced this issue Jul 26, 2023
…ter-initialization

Feature (engine): Placeholders can now be changed after the initialization. This can be done by changing `placeholder` property of the `element` passed to `enablePlaceholder()` helper. Closes #9925.

MINOR BREAKING CHANGE (engine): The `enablePlaceholder()` helper now uses a `placeholder` property of passed `element`. It no longer takes the placeholder text as a `text` argument.
@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Jul 26, 2023
@CKEditorBot CKEditorBot added this to the iteration 66 milestone Jul 26, 2023
@pomek pomek modified the milestones: iteration 66, iteration 65 Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:core squad:features Issue to be handled by the Features team. support:1 An issue reported by a commercially licensed client. type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants