Allow using / anywhere on a line or table (#7026)
This commit is contained in:
@@ -12,8 +12,9 @@ import BlockMenu from "../components/BlockMenu";
|
|||||||
export default class BlockMenuExtension extends Suggestion {
|
export default class BlockMenuExtension extends Suggestion {
|
||||||
get defaultOptions() {
|
get defaultOptions() {
|
||||||
return {
|
return {
|
||||||
openRegex: /^\/(\w+)?$/,
|
// ported from https://github.com/tc39/proposal-regexp-unicode-property-escapes#unicode-aware-version-of-w
|
||||||
closeRegex: /(^(?!\/(\w+)?)(.*)$|^\/(([\w\W]+)\s.*|\s)$|^\/((\W)+)$)/,
|
openRegex: /(?:^|\s|\()\/([\p{L}\p{M}\d]+)?$/u,
|
||||||
|
closeRegex: /(?:^|\s|\()\/(([\p{L}\p{M}\d]*\s+)|(\s+[\p{L}\p{M}\d]+))$/u,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ export default class EmojiMenuExtension extends Suggestion {
|
|||||||
),
|
),
|
||||||
closeRegex:
|
closeRegex:
|
||||||
/(?:^|\s|\():(([0-9a-zA-Z_+-]*\s+)|(\s+[0-9a-zA-Z_+-]+)|[^0-9a-zA-Z_+-]+)$/,
|
/(?:^|\s|\():(([0-9a-zA-Z_+-]*\s+)|(\s+[0-9a-zA-Z_+-]+)|[^0-9a-zA-Z_+-]+)$/,
|
||||||
enabledInTable: true,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export default class MentionMenuExtension extends Suggestion {
|
|||||||
// ported from https://github.com/tc39/proposal-regexp-unicode-property-escapes#unicode-aware-version-of-w
|
// ported from https://github.com/tc39/proposal-regexp-unicode-property-escapes#unicode-aware-version-of-w
|
||||||
openRegex: /(?:^|\s|\()@([\p{L}\p{M}\d]+)?$/u,
|
openRegex: /(?:^|\s|\()@([\p{L}\p{M}\d]+)?$/u,
|
||||||
closeRegex: /(?:^|\s|\()@(([\p{L}\p{M}\d]*\s+)|(\s+[\p{L}\p{M}\d]+))$/u,
|
closeRegex: /(?:^|\s|\()@(([\p{L}\p{M}\d]*\s+)|(\s+[\p{L}\p{M}\d]+))$/u,
|
||||||
enabledInTable: true,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { action, observable } from "mobx";
|
|||||||
import { InputRule } from "prosemirror-inputrules";
|
import { InputRule } from "prosemirror-inputrules";
|
||||||
import { NodeType, Schema } from "prosemirror-model";
|
import { NodeType, Schema } from "prosemirror-model";
|
||||||
import { EditorState, Plugin } from "prosemirror-state";
|
import { EditorState, Plugin } from "prosemirror-state";
|
||||||
import { isInTable } from "prosemirror-tables";
|
|
||||||
import Extension from "@shared/editor/lib/Extension";
|
import Extension from "@shared/editor/lib/Extension";
|
||||||
import { SuggestionsMenuPlugin } from "@shared/editor/plugins/Suggestions";
|
import { SuggestionsMenuPlugin } from "@shared/editor/plugins/Suggestions";
|
||||||
import { isInCode } from "@shared/editor/queries/isInCode";
|
import { isInCode } from "@shared/editor/queries/isInCode";
|
||||||
@@ -50,8 +49,7 @@ export default class Suggestion extends Extension {
|
|||||||
match &&
|
match &&
|
||||||
(parent.type.name === "paragraph" ||
|
(parent.type.name === "paragraph" ||
|
||||||
parent.type.name === "heading") &&
|
parent.type.name === "heading") &&
|
||||||
(!isInCode(state) || this.options.enabledInCode) &&
|
(!isInCode(state) || this.options.enabledInCode)
|
||||||
(!isInTable(state) || this.options.enabledInTable)
|
|
||||||
) {
|
) {
|
||||||
this.state.open = true;
|
this.state.open = true;
|
||||||
this.state.query = match[1];
|
this.state.query = match[1];
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ type Options = {
|
|||||||
openRegex: RegExp;
|
openRegex: RegExp;
|
||||||
closeRegex: RegExp;
|
closeRegex: RegExp;
|
||||||
enabledInCode: true;
|
enabledInCode: true;
|
||||||
enabledInTable: true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type ExtensionState = {
|
type ExtensionState = {
|
||||||
|
|||||||
Reference in New Issue
Block a user