Sfoglia il codice sorgente

Tests: Added very basic block toolbar manual test.

Oskar Wróbel 7 anni fa
parent
commit
a36675d66f

+ 12 - 0
packages/ckeditor5-ui/tests/manual/blocktoolbar/blocktoolbar.html

@@ -0,0 +1,12 @@
+<div id="editor">
+	<p><em>This</em> is a <strong>first line</strong> of text.</p>
+	<p><em>This</em> is a <strong>second line</strong> of text.</p>
+	<p><em>This</em> is the <strong>end</strong> of text.</p>
+</div>
+
+<style>
+	.ck-editor {
+		margin: 5em auto;
+		max-width: 70%;
+	}
+</style>

+ 36 - 0
packages/ckeditor5-ui/tests/manual/blocktoolbar/blocktoolbar.js

@@ -0,0 +1,36 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals window, document, console:false */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import HeadingButtonsUI from '@ckeditor/ckeditor5-heading/src/headingbuttonsui';
+import ParagraphButtonUI from '@ckeditor/ckeditor5-paragraph/src/paragraphbuttonui';
+import BlockToolbar from '../../../src/toolbar/block/blocktoolbar';
+import Range from '@ckeditor/ckeditor5-engine/src/model/range';
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePluginSet, HeadingButtonsUI, ParagraphButtonUI, BlockToolbar ],
+		blockToolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3', 'bulletedList', 'numberedList', 'blockQuote' ]
+	} )
+	.then( editor => {
+		window.editor = editor;
+
+		const balloonToolbar = editor.plugins.get( 'BalloonToolbar' );
+
+		balloonToolbar.on( 'show', evt => {
+			const selectionRange = editor.model.document.selection.getFirstRange();
+			const blockRange = Range.createOn( editor.model.document.getRoot().getChild( 0 ) );
+
+			if ( selectionRange.containsRange( blockRange ) || selectionRange.isIntersecting( blockRange ) ) {
+				evt.stop();
+			}
+		}, { priority: 'high' } );
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 1 - 0
packages/ckeditor5-ui/tests/manual/blocktoolbar/blocktoolbar.md

@@ -0,0 +1 @@
+## Block toolbar demo