mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
feat(admonitions): allow changing admonition type
This commit is contained in:
parent
fb7e310224
commit
504879b11c
@ -162,6 +162,10 @@ export default class AdmonitionCommand extends Command {
|
||||
quote = writer.createElement( 'aside', { type });
|
||||
|
||||
writer.wrap( groupRange, quote );
|
||||
} else if (quote.is("element")) {
|
||||
this.editor.model.change((writer) => {
|
||||
writer.setAttribute("type", type, quote as Element);
|
||||
});
|
||||
}
|
||||
|
||||
quotesToMerge.push( quote );
|
||||
|
@ -70,16 +70,24 @@ export default class AdmonitionEditing extends Plugin {
|
||||
}
|
||||
});
|
||||
|
||||
editor.conversion.for("downcast").elementToElement( {
|
||||
model: 'aside',
|
||||
view: (modelElement, { writer }) => {
|
||||
return writer.createContainerElement(
|
||||
"aside", {
|
||||
class: [ "admonition", modelElement.getAttribute("type") ].join(" ")
|
||||
}
|
||||
)
|
||||
}
|
||||
});
|
||||
editor.conversion.for("downcast")
|
||||
.elementToElement( {
|
||||
model: 'aside',
|
||||
view: (modelElement, { writer }) => {
|
||||
return writer.createContainerElement(
|
||||
"aside", {
|
||||
class: [ "admonition", modelElement.getAttribute("type") ].join(" ")
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
.attributeToAttribute({
|
||||
model: "type",
|
||||
view: (value) => ({
|
||||
key: "class",
|
||||
value: [ "admonition", value as string ]
|
||||
})
|
||||
});
|
||||
|
||||
// Postfixer which cleans incorrect model states connected with block quotes.
|
||||
editor.model.document.registerPostFixer( writer => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user