Skip to content

Build your personal knowledge base with Trilium Notes

feat(admonitions): use aside instead of blockquote

Elian Doranc49b30cf53aa
diff --git a/packages/ckeditor5-admonition/ckeditor5-metadata.json b/packages/ckeditor5-admonition/ckeditor5-metadata.json
index 1061d38e24..3218dff501 100644
--- a/packages/ckeditor5-admonition/ckeditor5-metadata.json
+++ b/packages/ckeditor5-admonition/ckeditor5-metadata.json
@@ -15,7 +15,7 @@
],
"htmlOutput": [
{
- "elements": "blockquote"
+ "elements": "aside"
}
]
}
diff --git a/packages/ckeditor5-admonition/src/admonitioncommand.ts b/packages/ckeditor5-admonition/src/admonitioncommand.ts
index 5431617309..cf91e49f31 100644
--- a/packages/ckeditor5-admonition/src/admonitioncommand.ts
+++ b/packages/ckeditor5-admonition/src/admonitioncommand.ts
@@ -151,7 +151,7 @@ export default class AdmonitionCommand extends Command {
let quote = findQuote( groupRange.start );
if ( !quote ) {
- quote = writer.createElement( 'blockQuote' );
+ quote = writer.createElement( 'aside' );
writer.wrap( groupRange, quote );
}
@@ -176,7 +176,7 @@ export default class AdmonitionCommand extends Command {
}
function findQuote( elementOrPosition: Element | Position ): Element | DocumentFragment | null {
- return elementOrPosition.parent!.name == 'blockQuote' ? elementOrPosition.parent : null;
+ return elementOrPosition.parent!.name == 'aside' ? elementOrPosition.parent : null;
}
/**
@@ -215,8 +215,8 @@ function getRangesOfBlockGroups( writer: Writer, blocks: Array<Element> ): Array
*/
function checkCanBeQuoted( schema: Schema, block: Element ): boolean {
// TMP will be replaced with schema.checkWrap().
- const isBQAllowed = schema.checkChild( block.parent as Element, 'blockQuote' );
- const isBlockAllowedInBQ = schema.checkChild( [ '$root', 'blockQuote' ], block );
+ const isBQAllowed = schema.checkChild( block.parent as Element, 'aside' );
+ const isBlockAllowedInBQ = schema.checkChild( [ '$root', 'aside' ], block );
return isBQAllowed && isBlockAllowedInBQ;
}
diff --git a/packages/ckeditor5-admonition/src/admonitionediting.ts b/packages/ckeditor5-admonition/src/admonitionediting.ts
index 7f8c16077c..29e2352abd 100644
--- a/packages/ckeditor5-admonition/src/admonitionediting.ts
+++ b/packages/ckeditor5-admonition/src/admonitionediting.ts
@@ -16,7 +16,7 @@ import AdmonitionCommand from './admonitioncommand.js';
/**
* The block quote editing.
*
- * Introduces the `'blockQuote'` command and the `'blockQuote'` model element.
+ * Introduces the `'admonition'` command and the `'aside'` model element.
*
* @extends module:core/plugin~Plugin
*/
@@ -44,11 +44,11 @@ export default class AdmonitionEditing extends Plugin {
editor.commands.add( 'admonition', new AdmonitionCommand( editor ) );
- schema.register( 'admonition', {
+ schema.register( 'aside', {
inheritAllFrom: '$container'
} );
- editor.conversion.elementToElement( { model: 'blockQuote', view: 'admonition' } );
+ editor.conversion.elementToElement( { model: 'aside', view: 'aside' } );
// Postfixer which cleans incorrect model states connected with block quotes.
editor.model.document.registerPostFixer( writer => {
@@ -63,13 +63,13 @@ export default class AdmonitionEditing extends Plugin {
continue;
}
- if ( element.is( 'element', 'blockQuote' ) && element.isEmpty ) {
- // Added an empty blockQuote - remove it.
+ if ( element.is( 'element', 'aside' ) && element.isEmpty ) {
+ // Added an empty aside - remove it.
writer.remove( element );
return true;
- } else if ( element.is( 'element', 'blockQuote' ) && !schema.checkChild( entry.position, element ) ) {
- // Added a blockQuote in incorrect place. Unwrap it so the content inside is not lost.
+ } else if ( element.is( 'element', 'aside' ) && !schema.checkChild( entry.position, element ) ) {
+ // Added a aside in incorrect place. Unwrap it so the content inside is not lost.
writer.unwrap( element );
return true;
@@ -79,7 +79,7 @@ export default class AdmonitionEditing extends Plugin {
for ( const child of range.getItems() ) {
if (
- child.is( 'element', 'blockQuote' ) &&
+ child.is( 'element', 'aside' ) &&
!schema.checkChild( writer.createPositionBefore( child ), child )
) {
writer.unwrap( child );
@@ -91,8 +91,8 @@ export default class AdmonitionEditing extends Plugin {
} else if ( entry.type == 'remove' ) {
const parent = entry.position.parent;
- if ( parent.is( 'element', 'blockQuote' ) && parent.isEmpty ) {
- // Something got removed and now blockQuote is empty. Remove the blockQuote as well.
+ if ( parent.is( 'element', 'aside' ) && parent.isEmpty ) {
+ // Something got removed and now aside is empty. Remove the aside as well.
writer.remove( parent );
return true;