mirror of
https://github.com/outline/outline.git
synced 2026-11-22 14:01:41 +03:00
stash
This commit is contained in:
1 parent
08efb34c29
commit
a77b24cf01
2 files changed
+42
-7
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import * as React from "react";
|
||||
import { ComponentProps } from "../types";
|
||||
|
||||
export function MentionUser(props: ComponentProps) {
|
||||
const { isSelected, node, isEditable, children, onChangeSize } = props;
|
||||
|
||||
return (
|
||||
<span className={isSelected ? `ProseMirror-selectednode` : undefined}>
|
||||
@{node.attrs.label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function MentionDocument(props: ComponentProps) {
|
||||
const { isSelected, node, isEditable, children, onChangeSize } = props;
|
||||
|
||||
return (
|
||||
<a
|
||||
className={isSelected ? `ProseMirror-selectednode` : undefined}
|
||||
href={`/doc/${node.attrs.modelId}`}
|
||||
>
|
||||
+{node.attrs.label}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
@@ -6,11 +6,14 @@ import {
|
||||
Schema,
|
||||
} from "prosemirror-model";
|
||||
import { Command, TextSelection } from "prosemirror-state";
|
||||
import * as React from "react";
|
||||
import { Primitive } from "utility-types";
|
||||
import { MentionType } from "@shared/types";
|
||||
import { MentionType } from "../../types";
|
||||
import { MentionDocument, MentionUser } from "../components/Mentions";
|
||||
import Extension from "../lib/Extension";
|
||||
import { MarkdownSerializerState } from "../lib/markdown/serializer";
|
||||
import mentionRule from "../rules/mention";
|
||||
import { ComponentProps } from "../types";
|
||||
|
||||
export default class Mention extends Extension {
|
||||
get type() {
|
||||
@@ -51,14 +54,10 @@ export default class Mention extends Extension {
|
||||
},
|
||||
],
|
||||
toDOM: (node) => [
|
||||
"a",
|
||||
"span",
|
||||
{
|
||||
class: `${node.type.name} mention-${node.attrs.type} use-hover-preview`,
|
||||
class: `${node.type.name} use-hover-preview`,
|
||||
id: node.attrs.id,
|
||||
href:
|
||||
node.attrs.type === MentionType.User
|
||||
? undefined
|
||||
: `/doc/${node.attrs.modelId}`,
|
||||
"data-type": node.attrs.type,
|
||||
"data-id": node.attrs.modelId,
|
||||
"data-actorId": node.attrs.actorId,
|
||||
@@ -70,6 +69,17 @@ export default class Mention extends Extension {
|
||||
};
|
||||
}
|
||||
|
||||
component = (props: ComponentProps) => {
|
||||
switch (props.node.attrs.type) {
|
||||
case MentionType.User:
|
||||
return <MentionUser {...props} />;
|
||||
case MentionType.Document:
|
||||
return <MentionDocument {...props} />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
get rulePlugins() {
|
||||
return [mentionRule];
|
||||
}
|
||||
Reference in new issue
Block a user