udpate: 增加 sub sup 解析规则
This commit is contained in:
parent
9a2bdf0c6b
commit
c12a1f4d19
|
@ -1,4 +1,10 @@
|
|||
import { MarkPlugin, PluginOptions } from '@aomao/engine';
|
||||
import {
|
||||
$,
|
||||
ConversionFromValue,
|
||||
ConversionToValue,
|
||||
MarkPlugin,
|
||||
PluginOptions,
|
||||
} from '@aomao/engine';
|
||||
|
||||
export interface SubOptions extends PluginOptions {
|
||||
hotkey?: string | Array<string>;
|
||||
|
@ -11,6 +17,26 @@ export default class<T extends SubOptions = SubOptions> extends MarkPlugin<T> {
|
|||
return 'sub';
|
||||
}
|
||||
|
||||
conversion(): { from: ConversionFromValue; to: ConversionToValue }[] {
|
||||
return [
|
||||
{
|
||||
from: (name, style) => {
|
||||
return (
|
||||
name === 'span' &&
|
||||
(style['vertical-align'] || '') === 'sub'
|
||||
);
|
||||
},
|
||||
to: (_, style, attrs) => {
|
||||
const newNode = $(`<${this.tagName} />`);
|
||||
delete style['vertical-align'];
|
||||
newNode.css(style);
|
||||
newNode.attributes(attrs);
|
||||
return newNode;
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
hotkey() {
|
||||
return this.options.hotkey || 'mod+,';
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import { MarkPlugin, PluginOptions } from '@aomao/engine';
|
||||
import {
|
||||
$,
|
||||
ConversionFromValue,
|
||||
ConversionToValue,
|
||||
MarkPlugin,
|
||||
PluginOptions,
|
||||
} from '@aomao/engine';
|
||||
|
||||
export interface SupOptions extends PluginOptions {
|
||||
hotkey?: string | Array<string>;
|
||||
|
@ -11,6 +17,26 @@ export default class<T extends SupOptions = SupOptions> extends MarkPlugin<T> {
|
|||
return 'sup';
|
||||
}
|
||||
|
||||
conversion(): { from: ConversionFromValue; to: ConversionToValue }[] {
|
||||
return [
|
||||
{
|
||||
from: (name, style) => {
|
||||
return (
|
||||
name === 'span' &&
|
||||
(style['vertical-align'] || '') === 'super'
|
||||
);
|
||||
},
|
||||
to: (_, style, attrs) => {
|
||||
const newNode = $(`<${this.tagName} />`);
|
||||
delete style['vertical-align'];
|
||||
newNode.css(style);
|
||||
newNode.attributes(attrs);
|
||||
return newNode;
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
markdown =
|
||||
this.options.markdown === undefined ? '^' : this.options.markdown;
|
||||
|
||||
|
|
Loading…
Reference in New Issue