Jelajahi Sumber

Merge pull request #5959 from ckeditor/i/5955

Docs: Add button to command binding in inline widget sample. Closes #5955.
Piotrek Koszuliński 6 tahun lalu
induk
melakukan
380dc95456

+ 4 - 0
docs/_snippets/framework/tutorials/inline-widget.js

@@ -75,6 +75,10 @@ class PlaceholderUI extends Plugin {
 				withText: true
 			} );
 
+			// Disable the placeholder button when the command is disabled.
+			const command = editor.commands.get( 'placeholder' );
+			dropdownView.bind( 'isEnabled' ).to( command );
+
 			// Execute the command when the dropdown item is clicked (executed).
 			this.listenTo( dropdownView, 'execute', evt => {
 				editor.execute( 'placeholder', { value: evt.source.commandParam } );

+ 8 - 0
docs/framework/guides/tutorials/implementing-an-inline-widget.md

@@ -581,6 +581,10 @@ export default class PlaceholderUI extends Plugin {
 				withText: true
 			} );
 
+			// Disable the placeholder button when the command is disabled.
+			const command = editor.commands.get( 'placeholder' );
+			dropdownView.bind( 'isEnabled' ).to( command );
+
 			// Execute the command when the dropdown item is clicked (executed).
 			this.listenTo( dropdownView, 'execute', evt => {
 				editor.execute( 'placeholder', { value: evt.source.commandParam } );
@@ -805,6 +809,10 @@ class PlaceholderUI extends Plugin {
 				withText: true
 			} );
 
+			// Disable the placeholder button when the command is disabled.
+			const command = editor.commands.get( 'placeholder' );
+			dropdownView.bind( 'isEnabled' ).to( command );
+
 			// Execute the command when the dropdown item is clicked (executed).
 			this.listenTo( dropdownView, 'execute', evt => {
 				editor.execute( 'placeholder', { value: evt.source.commandParam } );