@peers-app/peers-ui 0.34.6 → 0.34.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/markdown-editor/editor.d.ts +5 -4
- package/dist/components/markdown-editor/editor.js +10 -145
- package/dist/components/markdown-editor/lexical-editor.d.ts +3 -0
- package/dist/components/markdown-editor/lexical-editor.js +153 -0
- package/dist/components/markdown-render.d.ts +8 -0
- package/dist/components/markdown-render.js +143 -0
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +7 -129
- package/dist/components/trust-level-dropdown.d.ts +6 -1
- package/dist/components/trust-level-dropdown.js +43 -14
- package/dist/isolated-screens/focus-relay.d.ts +24 -0
- package/dist/isolated-screens/focus-relay.js +104 -0
- package/dist/isolated-screens/frame-document.d.ts +7 -0
- package/dist/isolated-screens/frame-document.js +11 -1
- package/dist/isolated-screens/frame-protocol.d.ts +26 -0
- package/dist/isolated-screens/frame-protocol.js +21 -0
- package/dist/isolated-screens/frame-runtime.js +47 -14
- package/dist/isolated-screens/isolated-screen.d.ts +6 -0
- package/dist/isolated-screens/isolated-screen.js +40 -3
- package/dist/isolated-screens/piece-frames.js +57 -5
- package/dist/isolated-screens/piece-reach.js +17 -6
- package/dist/lazy-module.d.ts +17 -0
- package/dist/lazy-module.js +26 -0
- package/dist/operator-console/console-session.js +1 -9
- package/dist/screens/groups/group-members.js +7 -17
- package/dist/screens/invites/accept-invite.js +15 -4
- package/dist/ui-contracts/piece-height.d.ts +8 -2
- package/dist/ui-contracts/piece-height.js +6 -1
- package/dist/ui-contracts/piece.js +1 -1
- package/package.json +4 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {
|
|
1
|
+
import type { IMentionLink, Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { IToolbarControl } from "./toolbar";
|
|
4
|
+
import "prismjs";
|
|
4
5
|
/**
|
|
5
6
|
* Hooks for working with the editor imperatively. The caller sets `onKeyDown`, which sees keys
|
|
6
7
|
* first (return true to handle one; skipped while the mention picker is open). The editor sets
|
|
@@ -71,4 +72,4 @@ export interface IMarkdownEditorProps {
|
|
|
71
72
|
*
|
|
72
73
|
* Edits are written back to `value`.
|
|
73
74
|
*/
|
|
74
|
-
export declare function MarkdownEditor(props: IMarkdownEditorProps):
|
|
75
|
+
export declare function MarkdownEditor(props: IMarkdownEditorProps): React.FunctionComponentElement<IMarkdownEditorProps>;
|
|
@@ -1,99 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.MarkdownEditor = MarkdownEditor;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const LexicalContentEditable_1 = require("@lexical/react/LexicalContentEditable");
|
|
50
|
-
const LexicalErrorBoundary_1 = require("@lexical/react/LexicalErrorBoundary");
|
|
51
|
-
const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
|
|
52
|
-
const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
|
|
53
|
-
const LexicalMarkdownShortcutPlugin_1 = require("@lexical/react/LexicalMarkdownShortcutPlugin");
|
|
54
|
-
const LexicalRichTextPlugin_1 = require("@lexical/react/LexicalRichTextPlugin");
|
|
55
|
-
const LexicalTabIndentationPlugin_1 = require("@lexical/react/LexicalTabIndentationPlugin");
|
|
56
|
-
const rich_text_1 = require("@lexical/rich-text");
|
|
57
|
-
const utils_1 = require("@lexical/utils");
|
|
58
|
-
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
59
|
-
const lexical_1 = require("lexical");
|
|
60
|
-
const react_1 = __importStar(require("react"));
|
|
61
|
-
const mention_chip_1 = require("../../mentions/mention-chip");
|
|
62
|
-
const autolink_plugin_1 = require("./autolink-plugin");
|
|
63
|
-
const blocks_1 = require("./blocks");
|
|
64
|
-
const code_plugin_1 = require("./code-plugin");
|
|
65
|
-
const link_plugin_1 = require("./link-plugin");
|
|
66
|
-
const markdown_plugin_1 = require("./markdown-plugin");
|
|
67
|
-
const mention_node_1 = require("./mention-node");
|
|
68
|
-
const mentions_plugin_1 = require("./mentions-plugin");
|
|
69
|
-
const move_line_plugin_1 = require("./move-line-plugin");
|
|
70
|
-
const select_line_boundary_plugin_1 = require("./select-line-boundary-plugin");
|
|
71
|
-
const selection_effects_plugin_1 = require("./selection-effects-plugin");
|
|
72
|
-
const theme_1 = __importDefault(require("./theme"));
|
|
73
|
-
const toolbar_1 = require("./toolbar");
|
|
74
|
-
const editorConfig = {
|
|
75
|
-
namespace: "PeersEditor",
|
|
76
|
-
nodes: [
|
|
77
|
-
rich_text_1.HeadingNode,
|
|
78
|
-
rich_text_1.QuoteNode,
|
|
79
|
-
blocks_1.CalloutNode,
|
|
80
|
-
code_1.CodeNode,
|
|
81
|
-
code_1.CodeHighlightNode,
|
|
82
|
-
extension_1.HorizontalRuleNode,
|
|
83
|
-
list_1.ListNode,
|
|
84
|
-
list_1.ListItemNode,
|
|
85
|
-
mention_node_1.MentionNode,
|
|
86
|
-
// Lexical node registry typing is narrower than runtime; AutoLinkNode is required for links.
|
|
87
|
-
link_1.AutoLinkNode,
|
|
88
|
-
link_1.LinkNode,
|
|
89
|
-
],
|
|
90
|
-
// Handling of errors during update
|
|
91
|
-
onError(error) {
|
|
92
|
-
throw error;
|
|
93
|
-
},
|
|
94
|
-
// The editor theme
|
|
95
|
-
theme: theme_1.default,
|
|
96
|
-
};
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const lazy_module_1 = require("../../lazy-module");
|
|
6
|
+
// Prism, which colors the editor's code blocks, still loads with peers-ui. When Prism first loads
|
|
7
|
+
// it colors every `language-*` code block on the page, and it becomes the page's `Prism`. Loaded
|
|
8
|
+
// at the first editor instead, it would rewrite code blocks React had already drawn, which then
|
|
9
|
+
// stop updating, and it would take the place of a package's own copy of Prism.
|
|
10
|
+
require("prismjs");
|
|
11
|
+
/** Lexical and the editor's plugins, loaded the first time an editor draws. */
|
|
12
|
+
const lexicalEditor = (0, lazy_module_1.lazyModule)(() => require("./lexical-editor"));
|
|
97
13
|
/**
|
|
98
14
|
* A rich-text editor whose value is markdown. It has:
|
|
99
15
|
* - headings (unless `headings` is false), lists and checklists, quotes, and `==highlight==`;
|
|
@@ -109,56 +25,5 @@ const editorConfig = {
|
|
|
109
25
|
* Edits are written back to `value`.
|
|
110
26
|
*/
|
|
111
27
|
function MarkdownEditor(props) {
|
|
112
|
-
|
|
113
|
-
const editorRef = react_1.default.useRef(null);
|
|
114
|
-
const [mentionsOpen] = (0, react_1.useState)(() => {
|
|
115
|
-
const obs = (0, peers_sdk_1.observable)(false);
|
|
116
|
-
return obs;
|
|
117
|
-
});
|
|
118
|
-
if (effects) {
|
|
119
|
-
effects.focus = () => {
|
|
120
|
-
if (editorRef.current?.children[0]) {
|
|
121
|
-
const div = editorRef.current.children[0];
|
|
122
|
-
setTimeout(() => {
|
|
123
|
-
div.focus();
|
|
124
|
-
// Set the selection to the end of the div content
|
|
125
|
-
const range = document.createRange();
|
|
126
|
-
range.selectNodeContents(div);
|
|
127
|
-
range.collapse(false);
|
|
128
|
-
const selection = window.getSelection();
|
|
129
|
-
if (selection) {
|
|
130
|
-
selection.removeAllRanges();
|
|
131
|
-
selection.addRange(range);
|
|
132
|
-
}
|
|
133
|
-
}, 10);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
const transformers = props.headings === false ? markdown_plugin_1.inlineMarkdownTransformers : markdown_plugin_1.documentMarkdownTransformers;
|
|
138
|
-
return ((0, jsx_runtime_1.jsx)(mention_chip_1.MentionGroupContext.Provider, { value: props.groupId, children: (0, jsx_runtime_1.jsx)(LexicalComposer_1.LexicalComposer, { initialConfig: { ...editorConfig }, children: (0, jsx_runtime_1.jsxs)("div", { className: "editor-container", children: [props.hideToolbar ? null : (0, jsx_runtime_1.jsx)(toolbar_1.ToolbarPlugin, { topRightControls: props.topRightControls }), (0, jsx_runtime_1.jsxs)("div", { className: "editor-inner", ref: editorRef, style: { maxHeight: props.maxHeight, overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "editor-input p-2" }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), props.autoFocus && (0, jsx_runtime_1.jsx)(LexicalAutoFocusPlugin_1.AutoFocusPlugin, { defaultSelection: "rootEnd" }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), props.mentions !== false && ((0, jsx_runtime_1.jsx)(mentions_plugin_1.MentionsPlugin, { mentionsOpen: mentionsOpen, groupId: props.groupId })), (0, jsx_runtime_1.jsx)(autolink_plugin_1.LexicalAutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(link_plugin_1.LinksPlugin, {}), (0, jsx_runtime_1.jsx)(code_plugin_1.CodePlugin, {}), (0, jsx_runtime_1.jsx)(BlocksPlugin, {}), (0, jsx_runtime_1.jsx)(markdown_plugin_1.MarkdownPlugin, { markdownObs: props.value, transformers: transformers }), (0, jsx_runtime_1.jsx)(LexicalMarkdownShortcutPlugin_1.MarkdownShortcutPlugin, { transformers: transformers }), (0, jsx_runtime_1.jsx)(LexicalCheckListPlugin_1.CheckListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalTabIndentationPlugin_1.TabIndentationPlugin, {}), (0, jsx_runtime_1.jsx)(move_line_plugin_1.MoveLineWithAltArrowsPlugin, { mentionsOpen: mentionsOpen }), (0, jsx_runtime_1.jsx)(select_line_boundary_plugin_1.SelectToLineBoundaryPlugin, {}), (0, jsx_runtime_1.jsx)(OnKeyDownPlugin, { effects: props.effects, mentionsOpen: mentionsOpen }), effects ? (0, jsx_runtime_1.jsx)(selection_effects_plugin_1.SelectionEffectsPlugin, { effects: effects }) : null] })] }) }) }));
|
|
28
|
+
return (0, react_1.createElement)(lexicalEditor().LexicalMarkdownEditor, props);
|
|
139
29
|
}
|
|
140
|
-
const OnKeyDownPlugin = (props) => {
|
|
141
|
-
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
142
|
-
// Intentionally `[editor]` only: `props.effects` is a stable object ref whose `onKeyDown` is
|
|
143
|
-
// imperatively reassigned by callers each render; the closure reads the latest value at event time.
|
|
144
|
-
(0, react_1.useEffect)(() => {
|
|
145
|
-
const removeListener = editor.registerCommand(lexical_1.KEY_DOWN_COMMAND, (event) => {
|
|
146
|
-
if (props.mentionsOpen()) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
if (props.effects?.onKeyDown) {
|
|
150
|
-
const result = props.effects.onKeyDown(event);
|
|
151
|
-
return !!result;
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
}, lexical_1.COMMAND_PRIORITY_LOW);
|
|
155
|
-
return removeListener;
|
|
156
|
-
}, [editor]);
|
|
157
|
-
return null;
|
|
158
|
-
};
|
|
159
|
-
/** Dividers that can be selected, and tidy callouts (see `blocks.ts`). */
|
|
160
|
-
const BlocksPlugin = () => {
|
|
161
|
-
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
162
|
-
(0, react_1.useEffect)(() => (0, utils_1.mergeRegister)((0, blocks_1.registerHorizontalRules)(editor), (0, blocks_1.registerCallouts)(editor)), [editor]);
|
|
163
|
-
return null;
|
|
164
|
-
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.LexicalMarkdownEditor = LexicalMarkdownEditor;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
// The markdown editor itself, built on Lexical. It loads the first time an editor draws
|
|
42
|
+
// (`MarkdownEditor` in editor.tsx), not when peers-ui loads: see `lazyModule`.
|
|
43
|
+
const code_1 = require("@lexical/code");
|
|
44
|
+
const extension_1 = require("@lexical/extension");
|
|
45
|
+
const link_1 = require("@lexical/link");
|
|
46
|
+
const list_1 = require("@lexical/list");
|
|
47
|
+
const LexicalAutoFocusPlugin_1 = require("@lexical/react/LexicalAutoFocusPlugin");
|
|
48
|
+
const LexicalCheckListPlugin_1 = require("@lexical/react/LexicalCheckListPlugin");
|
|
49
|
+
const LexicalComposer_1 = require("@lexical/react/LexicalComposer");
|
|
50
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
51
|
+
const LexicalContentEditable_1 = require("@lexical/react/LexicalContentEditable");
|
|
52
|
+
const LexicalErrorBoundary_1 = require("@lexical/react/LexicalErrorBoundary");
|
|
53
|
+
const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
|
|
54
|
+
const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
|
|
55
|
+
const LexicalMarkdownShortcutPlugin_1 = require("@lexical/react/LexicalMarkdownShortcutPlugin");
|
|
56
|
+
const LexicalRichTextPlugin_1 = require("@lexical/react/LexicalRichTextPlugin");
|
|
57
|
+
const LexicalTabIndentationPlugin_1 = require("@lexical/react/LexicalTabIndentationPlugin");
|
|
58
|
+
const rich_text_1 = require("@lexical/rich-text");
|
|
59
|
+
const utils_1 = require("@lexical/utils");
|
|
60
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
61
|
+
const lexical_1 = require("lexical");
|
|
62
|
+
const react_1 = __importStar(require("react"));
|
|
63
|
+
const mention_chip_1 = require("../../mentions/mention-chip");
|
|
64
|
+
const autolink_plugin_1 = require("./autolink-plugin");
|
|
65
|
+
const blocks_1 = require("./blocks");
|
|
66
|
+
const code_plugin_1 = require("./code-plugin");
|
|
67
|
+
const link_plugin_1 = require("./link-plugin");
|
|
68
|
+
const markdown_plugin_1 = require("./markdown-plugin");
|
|
69
|
+
const mention_node_1 = require("./mention-node");
|
|
70
|
+
const mentions_plugin_1 = require("./mentions-plugin");
|
|
71
|
+
const move_line_plugin_1 = require("./move-line-plugin");
|
|
72
|
+
const select_line_boundary_plugin_1 = require("./select-line-boundary-plugin");
|
|
73
|
+
const selection_effects_plugin_1 = require("./selection-effects-plugin");
|
|
74
|
+
const theme_1 = __importDefault(require("./theme"));
|
|
75
|
+
const toolbar_1 = require("./toolbar");
|
|
76
|
+
const editorConfig = {
|
|
77
|
+
namespace: "PeersEditor",
|
|
78
|
+
nodes: [
|
|
79
|
+
rich_text_1.HeadingNode,
|
|
80
|
+
rich_text_1.QuoteNode,
|
|
81
|
+
blocks_1.CalloutNode,
|
|
82
|
+
code_1.CodeNode,
|
|
83
|
+
code_1.CodeHighlightNode,
|
|
84
|
+
extension_1.HorizontalRuleNode,
|
|
85
|
+
list_1.ListNode,
|
|
86
|
+
list_1.ListItemNode,
|
|
87
|
+
mention_node_1.MentionNode,
|
|
88
|
+
// Lexical node registry typing is narrower than runtime; AutoLinkNode is required for links.
|
|
89
|
+
link_1.AutoLinkNode,
|
|
90
|
+
link_1.LinkNode,
|
|
91
|
+
],
|
|
92
|
+
// Handling of errors during update
|
|
93
|
+
onError(error) {
|
|
94
|
+
throw error;
|
|
95
|
+
},
|
|
96
|
+
// The editor theme
|
|
97
|
+
theme: theme_1.default,
|
|
98
|
+
};
|
|
99
|
+
/** {@link MarkdownEditor}'s implementation. */
|
|
100
|
+
function LexicalMarkdownEditor(props) {
|
|
101
|
+
const { effects } = props;
|
|
102
|
+
const editorRef = react_1.default.useRef(null);
|
|
103
|
+
const [mentionsOpen] = (0, react_1.useState)(() => {
|
|
104
|
+
const obs = (0, peers_sdk_1.observable)(false);
|
|
105
|
+
return obs;
|
|
106
|
+
});
|
|
107
|
+
if (effects) {
|
|
108
|
+
effects.focus = () => {
|
|
109
|
+
if (editorRef.current?.children[0]) {
|
|
110
|
+
const div = editorRef.current.children[0];
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
div.focus();
|
|
113
|
+
// Set the selection to the end of the div content
|
|
114
|
+
const range = document.createRange();
|
|
115
|
+
range.selectNodeContents(div);
|
|
116
|
+
range.collapse(false);
|
|
117
|
+
const selection = window.getSelection();
|
|
118
|
+
if (selection) {
|
|
119
|
+
selection.removeAllRanges();
|
|
120
|
+
selection.addRange(range);
|
|
121
|
+
}
|
|
122
|
+
}, 10);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const transformers = props.headings === false ? markdown_plugin_1.inlineMarkdownTransformers : markdown_plugin_1.documentMarkdownTransformers;
|
|
127
|
+
return ((0, jsx_runtime_1.jsx)(mention_chip_1.MentionGroupContext.Provider, { value: props.groupId, children: (0, jsx_runtime_1.jsx)(LexicalComposer_1.LexicalComposer, { initialConfig: { ...editorConfig }, children: (0, jsx_runtime_1.jsxs)("div", { className: "editor-container", children: [props.hideToolbar ? null : (0, jsx_runtime_1.jsx)(toolbar_1.ToolbarPlugin, { topRightControls: props.topRightControls }), (0, jsx_runtime_1.jsxs)("div", { className: "editor-inner", ref: editorRef, style: { maxHeight: props.maxHeight, overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "editor-input p-2" }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), props.autoFocus && (0, jsx_runtime_1.jsx)(LexicalAutoFocusPlugin_1.AutoFocusPlugin, { defaultSelection: "rootEnd" }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), props.mentions !== false && ((0, jsx_runtime_1.jsx)(mentions_plugin_1.MentionsPlugin, { mentionsOpen: mentionsOpen, groupId: props.groupId })), (0, jsx_runtime_1.jsx)(autolink_plugin_1.LexicalAutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(link_plugin_1.LinksPlugin, {}), (0, jsx_runtime_1.jsx)(code_plugin_1.CodePlugin, {}), (0, jsx_runtime_1.jsx)(BlocksPlugin, {}), (0, jsx_runtime_1.jsx)(markdown_plugin_1.MarkdownPlugin, { markdownObs: props.value, transformers: transformers }), (0, jsx_runtime_1.jsx)(LexicalMarkdownShortcutPlugin_1.MarkdownShortcutPlugin, { transformers: transformers }), (0, jsx_runtime_1.jsx)(LexicalCheckListPlugin_1.CheckListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalTabIndentationPlugin_1.TabIndentationPlugin, {}), (0, jsx_runtime_1.jsx)(move_line_plugin_1.MoveLineWithAltArrowsPlugin, { mentionsOpen: mentionsOpen }), (0, jsx_runtime_1.jsx)(select_line_boundary_plugin_1.SelectToLineBoundaryPlugin, {}), (0, jsx_runtime_1.jsx)(OnKeyDownPlugin, { effects: props.effects, mentionsOpen: mentionsOpen }), effects ? (0, jsx_runtime_1.jsx)(selection_effects_plugin_1.SelectionEffectsPlugin, { effects: effects }) : null] })] }) }) }));
|
|
128
|
+
}
|
|
129
|
+
const OnKeyDownPlugin = (props) => {
|
|
130
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
131
|
+
// Intentionally `[editor]` only: `props.effects` is a stable object ref whose `onKeyDown` is
|
|
132
|
+
// imperatively reassigned by callers each render; the closure reads the latest value at event time.
|
|
133
|
+
(0, react_1.useEffect)(() => {
|
|
134
|
+
const removeListener = editor.registerCommand(lexical_1.KEY_DOWN_COMMAND, (event) => {
|
|
135
|
+
if (props.mentionsOpen()) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if (props.effects?.onKeyDown) {
|
|
139
|
+
const result = props.effects.onKeyDown(event);
|
|
140
|
+
return !!result;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}, lexical_1.COMMAND_PRIORITY_LOW);
|
|
144
|
+
return removeListener;
|
|
145
|
+
}, [editor]);
|
|
146
|
+
return null;
|
|
147
|
+
};
|
|
148
|
+
/** Dividers that can be selected, and tidy callouts (see `blocks.ts`). */
|
|
149
|
+
const BlocksPlugin = () => {
|
|
150
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
151
|
+
(0, react_1.useEffect)(() => (0, utils_1.mergeRegister)((0, blocks_1.registerHorizontalRules)(editor), (0, blocks_1.registerCallouts)(editor)), [editor]);
|
|
152
|
+
return null;
|
|
153
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** {@link mentionUrlTransform}'s implementation. */
|
|
3
|
+
export declare function mentionUrlTransform(url: string): string;
|
|
4
|
+
/** {@link MarkdownWithMentions}'s implementation. */
|
|
5
|
+
export declare const MarkdownRender: React.FC<{
|
|
6
|
+
content: string;
|
|
7
|
+
groupId?: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.MarkdownRender = void 0;
|
|
40
|
+
exports.mentionUrlTransform = mentionUrlTransform;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
// Markdown rendered with react-markdown and remark-gfm. It loads the first time markdown is
|
|
43
|
+
// drawn (`MarkdownWithMentions` in markdown-with-mentions.tsx) or `mentionUrlTransform` is
|
|
44
|
+
// called, not when peers-ui loads: see `lazyModule`.
|
|
45
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
46
|
+
const react_1 = __importDefault(require("react"));
|
|
47
|
+
const react_markdown_1 = __importStar(require("react-markdown"));
|
|
48
|
+
const remark_gfm_1 = __importDefault(require("remark-gfm"));
|
|
49
|
+
const host_shell_consumer_1 = require("../host-shell/host-shell-consumer");
|
|
50
|
+
const mention_chip_1 = require("../mentions/mention-chip");
|
|
51
|
+
/** The text in some rendered markdown children. */
|
|
52
|
+
function textOf(children) {
|
|
53
|
+
return react_1.default.Children.toArray(children)
|
|
54
|
+
.map((child) => {
|
|
55
|
+
if (typeof child === "string" || typeof child === "number")
|
|
56
|
+
return String(child);
|
|
57
|
+
if (react_1.default.isValidElement(child)) {
|
|
58
|
+
return textOf(child.props.children);
|
|
59
|
+
}
|
|
60
|
+
return "";
|
|
61
|
+
})
|
|
62
|
+
.join("");
|
|
63
|
+
}
|
|
64
|
+
/** A link: a mention becomes a chip, and a web link opens in the system browser. */
|
|
65
|
+
const LinkRenderer = (props) => {
|
|
66
|
+
const { href } = props;
|
|
67
|
+
const mention = href ? (0, peers_sdk_1.parseMentionUrl)(href) : undefined;
|
|
68
|
+
if (mention)
|
|
69
|
+
return (0, jsx_runtime_1.jsx)(mention_chip_1.MentionChip, { ...mention, label: textOf(props.children) });
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)("a", { href: href, onClick: (e) => {
|
|
71
|
+
if (href?.startsWith("http")) {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
void (0, host_shell_consumer_1.openOnHost)(href);
|
|
74
|
+
}
|
|
75
|
+
}, children: props.children }));
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* An image. `` is a mention typed right after a `!` ("Thanks"),
|
|
79
|
+
* which the editor shows as `!` and a chip, so it renders the same here.
|
|
80
|
+
*/
|
|
81
|
+
const ImageRenderer = ({ node: _node, src, alt, ...props }) => {
|
|
82
|
+
const mention = typeof src === "string" ? (0, peers_sdk_1.parseMentionUrl)(src) : undefined;
|
|
83
|
+
if (mention) {
|
|
84
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["!", (0, jsx_runtime_1.jsx)(mention_chip_1.MentionChip, { ...mention, label: alt ?? "" })] }));
|
|
85
|
+
}
|
|
86
|
+
return (0, jsx_runtime_1.jsx)("img", { src: src, alt: alt, ...props });
|
|
87
|
+
};
|
|
88
|
+
/** Text with the older `<$kind:Name:id>` mentions turned into chips (a name alone without an id). */
|
|
89
|
+
const processTextWithMentions = (text) => {
|
|
90
|
+
const parts = [];
|
|
91
|
+
const regex = new RegExp((0, peers_sdk_1.mentionRegex)().source, "g");
|
|
92
|
+
let lastIndex = 0;
|
|
93
|
+
for (const match of text.matchAll(regex)) {
|
|
94
|
+
const at = match.index ?? 0;
|
|
95
|
+
if (at > lastIndex)
|
|
96
|
+
parts.push(text.slice(lastIndex, at));
|
|
97
|
+
const [, , kind, name, id] = match;
|
|
98
|
+
const label = name.replace(/_/g, " ");
|
|
99
|
+
const ref = id ? (0, peers_sdk_1.parseMentionUrl)(`peers://${kind.toLowerCase()}/${id}`) : undefined;
|
|
100
|
+
parts.push(ref ? (0, jsx_runtime_1.jsx)(mention_chip_1.MentionChip, { ...ref, label: label }, at) : label);
|
|
101
|
+
lastIndex = at + match[0].length;
|
|
102
|
+
}
|
|
103
|
+
if (lastIndex < text.length)
|
|
104
|
+
parts.push(text.slice(lastIndex));
|
|
105
|
+
return parts;
|
|
106
|
+
};
|
|
107
|
+
const createElementWithMentions = (Element) => {
|
|
108
|
+
return ({ node: _node, ...props }) => {
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)(Element, { ...props, children: react_1.default.Children.map(props.children, (child) => {
|
|
110
|
+
if (typeof child === "string") {
|
|
111
|
+
return processTextWithMentions(child);
|
|
112
|
+
}
|
|
113
|
+
return child;
|
|
114
|
+
}) }));
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const components = {
|
|
118
|
+
p: createElementWithMentions("p"),
|
|
119
|
+
h1: createElementWithMentions("h1"),
|
|
120
|
+
h2: createElementWithMentions("h2"),
|
|
121
|
+
h3: createElementWithMentions("h3"),
|
|
122
|
+
h4: createElementWithMentions("h4"),
|
|
123
|
+
h5: createElementWithMentions("h5"),
|
|
124
|
+
h6: createElementWithMentions("h6"),
|
|
125
|
+
li: createElementWithMentions("li"),
|
|
126
|
+
a: LinkRenderer,
|
|
127
|
+
img: ImageRenderer,
|
|
128
|
+
strong: createElementWithMentions("strong"),
|
|
129
|
+
em: createElementWithMentions("em"),
|
|
130
|
+
blockquote: createElementWithMentions("blockquote"),
|
|
131
|
+
code: createElementWithMentions("code"),
|
|
132
|
+
td: createElementWithMentions("td"),
|
|
133
|
+
th: createElementWithMentions("th"),
|
|
134
|
+
};
|
|
135
|
+
/** {@link mentionUrlTransform}'s implementation. */
|
|
136
|
+
function mentionUrlTransform(url) {
|
|
137
|
+
return (0, peers_sdk_1.parseMentionUrl)(url) ? url : (0, react_markdown_1.defaultUrlTransform)(url);
|
|
138
|
+
}
|
|
139
|
+
/** {@link MarkdownWithMentions}'s implementation. */
|
|
140
|
+
const MarkdownRender = ({ content, groupId, }) => ((0, jsx_runtime_1.jsx)(mention_chip_1.MentionGroupContext.Provider, { value: groupId, children: (0, jsx_runtime_1.jsx)("div", { className: "markdown", children: (0, jsx_runtime_1.jsx)(react_markdown_1.default, { remarkPlugins: [remark_gfm_1.default], urlTransform: mentionUrlTransform,
|
|
141
|
+
// @ts-expect-error react-markdown's component props are narrower than these wrappers
|
|
142
|
+
components: components, children: content }) }) }));
|
|
143
|
+
exports.MarkdownRender = MarkdownRender;
|
|
@@ -1,140 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.MarkdownWithMentions = void 0;
|
|
40
4
|
exports.mentionUrlTransform = mentionUrlTransform;
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const react_1 = __importDefault(require("react"));
|
|
44
|
-
const react_markdown_1 = __importStar(require("react-markdown"));
|
|
45
|
-
const remark_gfm_1 = __importDefault(require("remark-gfm"));
|
|
46
|
-
const host_shell_consumer_1 = require("../host-shell/host-shell-consumer");
|
|
47
|
-
const mention_chip_1 = require("../mentions/mention-chip");
|
|
48
|
-
/** The text in some rendered markdown children. */
|
|
49
|
-
function textOf(children) {
|
|
50
|
-
return react_1.default.Children.toArray(children)
|
|
51
|
-
.map((child) => {
|
|
52
|
-
if (typeof child === "string" || typeof child === "number")
|
|
53
|
-
return String(child);
|
|
54
|
-
if (react_1.default.isValidElement(child)) {
|
|
55
|
-
return textOf(child.props.children);
|
|
56
|
-
}
|
|
57
|
-
return "";
|
|
58
|
-
})
|
|
59
|
-
.join("");
|
|
60
|
-
}
|
|
61
|
-
/** A link: a mention becomes a chip, and a web link opens in the system browser. */
|
|
62
|
-
const LinkRenderer = (props) => {
|
|
63
|
-
const { href } = props;
|
|
64
|
-
const mention = href ? (0, peers_sdk_1.parseMentionUrl)(href) : undefined;
|
|
65
|
-
if (mention)
|
|
66
|
-
return (0, jsx_runtime_1.jsx)(mention_chip_1.MentionChip, { ...mention, label: textOf(props.children) });
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)("a", { href: href, onClick: (e) => {
|
|
68
|
-
if (href?.startsWith("http")) {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
void (0, host_shell_consumer_1.openOnHost)(href);
|
|
71
|
-
}
|
|
72
|
-
}, children: props.children }));
|
|
73
|
-
};
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const lazy_module_1 = require("../lazy-module");
|
|
74
7
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
8
|
+
* react-markdown, remark-gfm and the renderers, loaded the first time markdown is drawn (or
|
|
9
|
+
* `mentionUrlTransform` is called).
|
|
77
10
|
*/
|
|
78
|
-
const
|
|
79
|
-
const mention = typeof src === "string" ? (0, peers_sdk_1.parseMentionUrl)(src) : undefined;
|
|
80
|
-
if (mention) {
|
|
81
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["!", (0, jsx_runtime_1.jsx)(mention_chip_1.MentionChip, { ...mention, label: alt ?? "" })] }));
|
|
82
|
-
}
|
|
83
|
-
return (0, jsx_runtime_1.jsx)("img", { src: src, alt: alt, ...props });
|
|
84
|
-
};
|
|
85
|
-
/** Text with the older `<$kind:Name:id>` mentions turned into chips (a name alone without an id). */
|
|
86
|
-
const processTextWithMentions = (text) => {
|
|
87
|
-
const parts = [];
|
|
88
|
-
const regex = new RegExp((0, peers_sdk_1.mentionRegex)().source, "g");
|
|
89
|
-
let lastIndex = 0;
|
|
90
|
-
for (const match of text.matchAll(regex)) {
|
|
91
|
-
const at = match.index ?? 0;
|
|
92
|
-
if (at > lastIndex)
|
|
93
|
-
parts.push(text.slice(lastIndex, at));
|
|
94
|
-
const [, , kind, name, id] = match;
|
|
95
|
-
const label = name.replace(/_/g, " ");
|
|
96
|
-
const ref = id ? (0, peers_sdk_1.parseMentionUrl)(`peers://${kind.toLowerCase()}/${id}`) : undefined;
|
|
97
|
-
parts.push(ref ? (0, jsx_runtime_1.jsx)(mention_chip_1.MentionChip, { ...ref, label: label }, at) : label);
|
|
98
|
-
lastIndex = at + match[0].length;
|
|
99
|
-
}
|
|
100
|
-
if (lastIndex < text.length)
|
|
101
|
-
parts.push(text.slice(lastIndex));
|
|
102
|
-
return parts;
|
|
103
|
-
};
|
|
104
|
-
const createElementWithMentions = (Element) => {
|
|
105
|
-
return ({ node: _node, ...props }) => {
|
|
106
|
-
return ((0, jsx_runtime_1.jsx)(Element, { ...props, children: react_1.default.Children.map(props.children, (child) => {
|
|
107
|
-
if (typeof child === "string") {
|
|
108
|
-
return processTextWithMentions(child);
|
|
109
|
-
}
|
|
110
|
-
return child;
|
|
111
|
-
}) }));
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
const components = {
|
|
115
|
-
p: createElementWithMentions("p"),
|
|
116
|
-
h1: createElementWithMentions("h1"),
|
|
117
|
-
h2: createElementWithMentions("h2"),
|
|
118
|
-
h3: createElementWithMentions("h3"),
|
|
119
|
-
h4: createElementWithMentions("h4"),
|
|
120
|
-
h5: createElementWithMentions("h5"),
|
|
121
|
-
h6: createElementWithMentions("h6"),
|
|
122
|
-
li: createElementWithMentions("li"),
|
|
123
|
-
a: LinkRenderer,
|
|
124
|
-
img: ImageRenderer,
|
|
125
|
-
strong: createElementWithMentions("strong"),
|
|
126
|
-
em: createElementWithMentions("em"),
|
|
127
|
-
blockquote: createElementWithMentions("blockquote"),
|
|
128
|
-
code: createElementWithMentions("code"),
|
|
129
|
-
td: createElementWithMentions("td"),
|
|
130
|
-
th: createElementWithMentions("th"),
|
|
131
|
-
};
|
|
11
|
+
const markdownRender = (0, lazy_module_1.lazyModule)(() => require("./markdown-render"));
|
|
132
12
|
/**
|
|
133
13
|
* Keep `peers://` mention links; every other URL gets react-markdown's default treatment, which
|
|
134
14
|
* blanks `javascript:` and other unsafe schemes in text other members wrote.
|
|
135
15
|
*/
|
|
136
16
|
function mentionUrlTransform(url) {
|
|
137
|
-
return (
|
|
17
|
+
return markdownRender().mentionUrlTransform(url);
|
|
138
18
|
}
|
|
139
19
|
/**
|
|
140
20
|
* Render markdown (GitHub-flavored) with mentions (`[label](peers://<kind>/<id>)`, and the
|
|
@@ -144,7 +24,5 @@ function mentionUrlTransform(url) {
|
|
|
144
24
|
* @param props.content - The markdown.
|
|
145
25
|
* @param props.groupId - The group the text belongs to: mentions resolve there first.
|
|
146
26
|
*/
|
|
147
|
-
const MarkdownWithMentions = (
|
|
148
|
-
// @ts-expect-error react-markdown's component props are narrower than these wrappers
|
|
149
|
-
components: components, children: content }) }) }));
|
|
27
|
+
const MarkdownWithMentions = (props) => (0, react_1.createElement)(markdownRender().MarkdownRender, props);
|
|
150
28
|
exports.MarkdownWithMentions = MarkdownWithMentions;
|