Skip to content

Commit

Permalink
daily commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Xheldon committed Feb 3, 2020
1 parent 083c4d9 commit c37b93c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
}
} else if (selection instanceof NodeSelection || selection instanceof AllSelection) {
// 否则理论上应该会有其他模块处理选区, 当前选区应该是 nodeblock, 则在其下插入一个 paragraph
tr.insert($to.pos +2, _nodes.p.create(null, _nodes.textBlock.create(null, _nodes.text.create(null, ''))));
tr.insert($to.pos + 2, _nodes.p.create(null, _nodes.textBlock.create(null, _nodes.text.create(null, ''))));
return true;
}
}
Expand Down
8 changes: 1 addition & 7 deletions app/modules/slash/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const slashPopupPlugin: () => Plugin = () => new Plugin({
if (newState.selection.from - old.start > 9 || newState.selection.from - old.start <= 0) {
return null;
} else {
// 此处 rdxDispatch 一个 action
return {
start: old.start,
end: newState.selection.from,
Expand All @@ -42,12 +43,5 @@ export const slashPopupPlugin: () => Plugin = () => new Plugin({
}
}
}
},
view(view): ViewReturn {
return new View({
type: SHOW_SLASH_POPUP,
component: SlashPopupView,
view
});
}
});
2 changes: 2 additions & 0 deletions app/modules/slash/typebehinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { EditorState, Transaction } from 'prosemirror-state';
import { slashPopupPluginKey } from '@modules/slash/plugin';

export default () => new InputRule(/\/{1}$/, (state: EditorState, match: [string], start: number, end: number): Transaction => {
// 其实 inputrule 不是这么用的, 其作用是将一个输入转换成另一个输入
// 此处的用法是检测到 / 输入就 setMeta 然后 rdxDispatch 一个 action
let tr = state.tr.setMeta(slashPopupPluginKey, {
start,
end
Expand Down

0 comments on commit c37b93c

Please sign in to comment.