| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { BasicInterceptor } from 'crowi-pluginkit';
- import * as codemirror from 'codemirror';
- import mlu from './MarkdownListUtil';
- export default class MarkdownListInterceptor extends BasicInterceptor {
- constructor() {
- super();
- }
- /**
- * @inheritdoc
- */
- isInterceptWhen(contextName) {
- return (
- contextName === 'preHandleEnter'
- );
- }
- /**
- * return boolean value whether processable parallel
- */
- isProcessableParallel() {
- return false;
- }
- /**
- * @inheritdoc
- */
- process(contextName, ...args) {
- const context = Object.assign(args[0]); // clone
- const editor = context.editor;
- // get strings from current position to EOL(end of line) before break the line
- const strToEol = mlu.getStrToEol(editor);
- if (mlu.indentAndMarkRE.test(strToEol)) {
- mlu.newlineWithoutIndent(editor, strToEol);
- // report to manager that handling was done
- context.handlers.push(this.className);
- }
- // resolve
- return Promise.resolve(context);
- }
- }
|