-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
127 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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 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
16 changes: 16 additions & 0 deletions
16
.../Resources/public/js/CKEditor/custom-tags/block-custom-tag/custom-tag-settings-command.js
This file contains 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,16 @@ | ||
import Command from '@ckeditor/ckeditor5-core/src/command'; | ||
|
||
const { ibexa } = window; | ||
|
||
class IbexaCustomTagSettingsCommand extends Command { | ||
refresh() { | ||
const modelElement = this.editor.model.document.selection.getSelectedElement(); | ||
const isCustomTag = modelElement?.name === 'customTag'; | ||
const isEnabled = | ||
isCustomTag && !!Object.keys(ibexa.richText.customTags[modelElement.getAttribute('customTagName')].attributes).length; | ||
|
||
this.isEnabled = isEnabled; | ||
} | ||
} | ||
|
||
export default IbexaCustomTagSettingsCommand; |
42 changes: 42 additions & 0 deletions
42
...undle/Resources/public/js/CKEditor/custom-tags/block-custom-tag/custom-tag-settings-ui.js
This file contains 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,42 @@ | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import IbexaButtonView from '../../common/button-view/button-view'; | ||
|
||
import IbexaCustomTagSettingsCommand from './custom-tag-settings-command'; | ||
|
||
const { ibexa, Translator } = window; | ||
|
||
class IbexaCustomTagSettingsUI extends Plugin { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.showSettings = this.showSettings.bind(this); | ||
} | ||
|
||
showSettings() { | ||
this.editor.editing.view.document.fire('ibexa-show-custom-tag-settings'); | ||
} | ||
|
||
init() { | ||
const ibexaCustomTagSettingsCommand = new IbexaCustomTagSettingsCommand(this.editor); | ||
|
||
this.editor.ui.componentFactory.add('ibexaCustomTagSettings', (locale) => { | ||
const buttonView = new IbexaButtonView(locale); | ||
|
||
buttonView.set({ | ||
label: Translator.trans(/*@Desc("Settings")*/ 'custom_tag.settings.label', {}, 'ck_editor'), | ||
icon: ibexa.helpers.icon.getIconPath('settings-block'), | ||
tooltip: true, | ||
}); | ||
|
||
this.listenTo(buttonView, 'execute', this.showSettings); | ||
|
||
buttonView.bind('isEnabled').to(ibexaCustomTagSettingsCommand); | ||
|
||
return buttonView; | ||
}); | ||
|
||
this.editor.commands.add('ibexaCustomTagSettings', ibexaCustomTagSettingsCommand); | ||
} | ||
} | ||
|
||
export default IbexaCustomTagSettingsUI; |
30 changes: 30 additions & 0 deletions
30
src/bundle/Resources/public/js/CKEditor/custom-tags/block-custom-tag/custom-tag-toolbar.js
This file contains 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,30 @@ | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import WidgetToolbarRepository from '@ckeditor/ckeditor5-widget/src/widgettoolbarrepository'; | ||
|
||
const { Translator } = window; | ||
|
||
class IbexaCustomTagsToolbar extends Plugin { | ||
static get requires() { | ||
return [WidgetToolbarRepository]; | ||
} | ||
|
||
getSelectedCustomTagWidget(selection) { | ||
const viewElement = selection.getSelectedElement(); | ||
const isCustomTag = viewElement?.hasClass('ibexa-custom-tag') && viewElement?.getAttribute('data-ezelement') === 'eztemplate'; | ||
|
||
return isCustomTag ? viewElement : null; | ||
} | ||
|
||
afterInit() { | ||
const { editor } = this; | ||
const widgetToolbarRepository = editor.plugins.get(WidgetToolbarRepository); | ||
|
||
widgetToolbarRepository.register('customTags', { | ||
ariaLabel: Translator.trans(/*@Desc("Custom tag toolbar")*/ 'custom_tag.toolbar.label', {}, 'ck_editor'), | ||
items: editor.config.get('customTag.toolbar') || [], | ||
getRelatedElement: this.getSelectedCustomTagWidget, | ||
}); | ||
} | ||
} | ||
|
||
export default IbexaCustomTagsToolbar; |
This file contains 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 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 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 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