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

How to override LinkFormView? #4786

Closed
oskarwrobel opened this issue Apr 20, 2017 · 10 comments
Closed

How to override LinkFormView? #4786

oskarwrobel opened this issue Apr 20, 2017 · 10 comments
Labels
package:link resolution:wontfix This issue will not be fixed because the team decided that for given reasons it does not make sense. type:question This issue asks a question (how to...).

Comments

@oskarwrobel
Copy link
Contributor

I need to use Link plugin with a custom form view. Everything should work the same but View has to have a different markup. That's it. I see 2 ways to do it:

  1. Create a copy of Link class and change import of LinkFormView and also create a copy of LinkFormView and change template. Easy but produces a lot of duplicated code to maintenance. Eventually, we can split Link and LinkformView into small helpers to reduce duplicated code.
  2. Try to change Link and LinkFormView classes to be available to extend and override. Makes Link#_createFormView @protected instead of @private and move LinkFormView template definition from constructor to @protected method.

Option 2 seems to be the easiest from my perspective.

@oleq
Copy link
Member

oleq commented Apr 20, 2017

Well, we're back to the roots of the UI library here. The initial assumption was that views are interchangeable but we dropped the idea after a while because it meant a very complex architecture.

I'd try to create a CustomLinkFormView which inherits from LinkFormView but with a different template. Then I'd create a CustomLink inheriting from Link with a custom _createForm implementation that uses CustomLinkFormView.

Perhaps it's possible to do it on the build-level? Like silently replace LinkFormView with CustomLinkFormView?

/cc @Reinmar

@oleq
Copy link
Member

oleq commented Apr 20, 2017

It also depends on to what extent the new LinkFormView will customize the basic one. If this is something simple maybe there's no need to create CustomLinkFormView but manipulate the template somehow directly from the CustomLink?

@oskarwrobel
Copy link
Contributor Author

I need to change an order of child views and remove one container. So I'm afraid that I need a new template definition.

@oskarwrobel
Copy link
Contributor Author

Theoretically, I can try to hack this view by a CSS but I'm not sure if it is a right way.

@oleq
Copy link
Member

oleq commented Apr 20, 2017

I need to change an order of child views

They're in collection so remove() + add( view, index ) should do the trick, even after template was rendered.

They're not in collections :(

remove one container

Which one? Maybe this can be hacked with CSS.

@oskarwrobel
Copy link
Contributor Author

oskarwrobel commented Apr 20, 2017

Now is:

this.template = new Template( {
	tag: 'form',

	attributes: {
		class: [
			'ck-link-form',
		]
	},

	children: [
		this.urlInputView,
		{
			tag: 'div',

			attributes: {
				class: [
					'ck-link-form__actions'
				]
			},

			children: [
				this.saveButtonView,
				this.cancelButtonView,
				this.unlinkButtonView
			]
		}
	]
} );

I need:

this.template = new Template( {
	tag: 'form',

	attributes: {
		class: [
			'ck-link-form',
		]
	},

	children: [
		this.unlinkButtonView
		this.urlInputView,
		this.saveButtonView,
		this.cancelButtonView,
	]
} );

@oskarwrobel
Copy link
Contributor Author

I don't even need to change order of child for the FocysCycler.

@Reinmar
Copy link
Member

Reinmar commented Apr 21, 2017

I replied regarding some aspects of this ticket in #425.

@oskarwrobel
Copy link
Contributor Author

I'll use webpack to replace this View.

@Reinmar
Copy link
Member

Reinmar commented Apr 24, 2017

Could you post some example how you configured this under #425?

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-link Oct 9, 2019
@mlewand mlewand added resolution:wontfix This issue will not be fixed because the team decided that for given reasons it does not make sense. type:question This issue asks a question (how to...). package:link labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:link resolution:wontfix This issue will not be fixed because the team decided that for given reasons it does not make sense. type:question This issue asks a question (how to...).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants