mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
refactor(admonitions): more references to blockquote
This commit is contained in:
parent
e028f88821
commit
137c5c27cd
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@ckeditor/ckeditor5-block-quote",
|
||||
"name": "@ckeditor/ckeditor5-admonition",
|
||||
"version": "43.2.0",
|
||||
"description": "Block quote feature for CKEditor 5.",
|
||||
"keywords": [
|
||||
@ -42,7 +42,7 @@
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ckeditor/ckeditor5.git",
|
||||
"directory": "packages/ckeditor5-block-quote"
|
||||
"directory": "packages/ckeditor5-admonition"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module block-quote/blockquote
|
||||
* @module admonition/admonition
|
||||
*/
|
||||
|
||||
import { Plugin } from 'ckeditor5/src/core.js';
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module block-quote/blockquotecommand
|
||||
* @module admonition/admonitioncommand
|
||||
*/
|
||||
|
||||
import { Command } from 'ckeditor5/src/core.js';
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module block-quote/blockquoteediting
|
||||
* @module admonition/admonitionediting
|
||||
*/
|
||||
|
||||
import { Plugin } from 'ckeditor5/src/core.js';
|
||||
@ -42,13 +42,13 @@ export default class AdmonitionEditing extends Plugin {
|
||||
const editor = this.editor;
|
||||
const schema = editor.model.schema;
|
||||
|
||||
editor.commands.add( 'blockQuote', new AdmonitionCommand( editor ) );
|
||||
editor.commands.add( 'admonition', new AdmonitionCommand( editor ) );
|
||||
|
||||
schema.register( 'blockQuote', {
|
||||
schema.register( 'admonition', {
|
||||
inheritAllFrom: '$container'
|
||||
} );
|
||||
|
||||
editor.conversion.elementToElement( { model: 'blockQuote', view: 'blockquote' } );
|
||||
editor.conversion.elementToElement( { model: 'blockQuote', view: 'admonition' } );
|
||||
|
||||
// Postfixer which cleans incorrect model states connected with block quotes.
|
||||
editor.model.document.registerPostFixer( writer => {
|
||||
@ -105,19 +105,19 @@ export default class AdmonitionEditing extends Plugin {
|
||||
|
||||
const viewDocument = this.editor.editing.view.document;
|
||||
const selection = editor.model.document.selection;
|
||||
const blockQuoteCommand: AdmonitionCommand = editor.commands.get( 'blockQuote' )!;
|
||||
const admonitionCommand: AdmonitionCommand = editor.commands.get( 'admonition' )!;
|
||||
|
||||
// Overwrite default Enter key behavior.
|
||||
// If Enter key is pressed with selection collapsed in empty block inside a quote, break the quote.
|
||||
this.listenTo<ViewDocumentEnterEvent>( viewDocument, 'enter', ( evt, data ) => {
|
||||
if ( !selection.isCollapsed || !blockQuoteCommand.value ) {
|
||||
if ( !selection.isCollapsed || !admonitionCommand.value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const positionParent = selection.getLastPosition()!.parent;
|
||||
|
||||
if ( positionParent.isEmpty ) {
|
||||
editor.execute( 'blockQuote' );
|
||||
editor.execute( 'admonition' );
|
||||
editor.editing.view.scrollToTheSelection();
|
||||
|
||||
data.preventDefault();
|
||||
@ -128,14 +128,14 @@ export default class AdmonitionEditing extends Plugin {
|
||||
// Overwrite default Backspace key behavior.
|
||||
// If Backspace key is pressed with selection collapsed in first empty block inside a quote, break the quote.
|
||||
this.listenTo<ViewDocumentDeleteEvent>( viewDocument, 'delete', ( evt, data ) => {
|
||||
if ( data.direction != 'backward' || !selection.isCollapsed || !blockQuoteCommand!.value ) {
|
||||
if ( data.direction != 'backward' || !selection.isCollapsed || !admonitionCommand!.value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const positionParent = selection.getLastPosition()!.parent;
|
||||
|
||||
if ( positionParent.isEmpty && !positionParent.previousSibling ) {
|
||||
editor.execute( 'blockQuote' );
|
||||
editor.execute( 'admonition' );
|
||||
editor.editing.view.scrollToTheSelection();
|
||||
|
||||
data.preventDefault();
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module block-quote/blockquoteui
|
||||
* @module admonition/admonitionui
|
||||
*/
|
||||
|
||||
import { Plugin, icons } from 'ckeditor5/src/core.js';
|
||||
@ -15,7 +15,7 @@ import '../theme/blockquote.css';
|
||||
/**
|
||||
* The block quote UI plugin.
|
||||
*
|
||||
* It introduces the `'blockQuote'` button.
|
||||
* It introduces the `'admonition'` button.
|
||||
*
|
||||
* @extends module:core/plugin~Plugin
|
||||
*/
|
||||
@ -33,7 +33,7 @@ export default class AdmonitionUI extends Plugin {
|
||||
public init(): void {
|
||||
const editor = this.editor;
|
||||
|
||||
editor.ui.componentFactory.add( 'blockQuote', () => {
|
||||
editor.ui.componentFactory.add( 'admonition', () => {
|
||||
const buttonView = this._createButton( ButtonView );
|
||||
|
||||
buttonView.set( {
|
||||
@ -43,7 +43,7 @@ export default class AdmonitionUI extends Plugin {
|
||||
return buttonView;
|
||||
} );
|
||||
|
||||
editor.ui.componentFactory.add( 'menuBar:blockQuote', () => {
|
||||
editor.ui.componentFactory.add( 'menuBar:admonition', () => {
|
||||
const buttonView = this._createButton( MenuBarMenuListItemButtonView );
|
||||
|
||||
buttonView.set( {
|
||||
@ -60,7 +60,7 @@ export default class AdmonitionUI extends Plugin {
|
||||
private _createButton<T extends typeof ButtonView | typeof MenuBarMenuListItemButtonView>( ButtonClass: T ): InstanceType<T> {
|
||||
const editor = this.editor;
|
||||
const locale = editor.locale;
|
||||
const command = editor.commands.get( 'blockQuote' )!;
|
||||
const command = editor.commands.get( 'admonition' )!;
|
||||
const view = new ButtonClass( editor.locale ) as InstanceType<T>;
|
||||
const t = locale.t;
|
||||
|
||||
@ -75,7 +75,7 @@ export default class AdmonitionUI extends Plugin {
|
||||
|
||||
// Execute the command.
|
||||
this.listenTo( view, 'execute', () => {
|
||||
editor.execute( 'blockQuote' );
|
||||
editor.execute( 'admonition' );
|
||||
editor.editing.view.focus();
|
||||
} );
|
||||
|
||||
|
@ -18,6 +18,6 @@ declare module '@ckeditor/ckeditor5-core' {
|
||||
}
|
||||
|
||||
interface CommandsMap {
|
||||
blockQuote: AdmonitionCommand;
|
||||
admonition: AdmonitionCommand;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module block-quote
|
||||
* @module admonition
|
||||
*/
|
||||
|
||||
export { default as Admonition } from './admonition.js';
|
||||
|
Loading…
x
Reference in New Issue
Block a user