@astryxdesign/richtext 0.6.5-canary.4b7cb3a → 0.6.5-canary.4cdaedc
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/CodeBlockHeaderPlugin.d.ts.map +1 -1
- package/dist/MarkdownExtensionsPlugin.d.ts +17 -0
- package/dist/MarkdownExtensionsPlugin.d.ts.map +1 -0
- package/dist/MarkdownExtensionsPlugin.js +185 -0
- package/dist/RichTextEditor.d.ts +10 -0
- package/dist/RichTextEditor.d.ts.map +1 -1
- package/dist/RichTextEditor.js +7 -2
- package/dist/RichTextEditorToolbar.d.ts.map +1 -1
- package/dist/RichTextEditorToolbar.js +11 -3
- package/dist/RichTextView.d.ts +11 -1
- package/dist/RichTextView.d.ts.map +1 -1
- package/dist/RichTextView.js +9 -1
- package/dist/TaskCheckboxPlugin.d.ts.map +1 -1
- package/dist/editorNodes.d.ts.map +1 -1
- package/dist/editorNodes.js +6 -1
- package/dist/editorTheme.d.ts.map +1 -1
- package/dist/editorTheme.js +8 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/markdown.d.ts +17 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +17 -0
- package/dist/markdownCharacterReferences.d.ts +87 -3
- package/dist/markdownCharacterReferences.d.ts.map +1 -1
- package/dist/markdownCharacterReferences.js +673 -12
- package/dist/markdownCodeFence.d.ts +4 -0
- package/dist/markdownCodeFence.d.ts.map +1 -0
- package/dist/markdownCodeFence.js +167 -0
- package/dist/markdownExtensionNode.d.ts +88 -0
- package/dist/markdownExtensionNode.d.ts.map +1 -0
- package/dist/markdownExtensionNode.js +244 -0
- package/dist/markdownExtensions.d.ts +115 -0
- package/dist/markdownExtensions.d.ts.map +1 -0
- package/dist/markdownExtensions.js +392 -0
- package/dist/markdownHeading.d.ts +20 -0
- package/dist/markdownHeading.d.ts.map +1 -0
- package/dist/markdownHeading.js +30 -0
- package/dist/markdownLink.d.ts +5 -0
- package/dist/markdownLink.d.ts.map +1 -0
- package/dist/markdownLink.js +88 -0
- package/dist/markdownListIndentation.d.ts.map +1 -1
- package/dist/markdownListIndentation.js +17 -1
- package/dist/markdownQuote.d.ts +22 -0
- package/dist/markdownQuote.d.ts.map +1 -0
- package/dist/markdownQuote.js +32 -0
- package/dist/markdownSerializers.d.ts +8 -0
- package/dist/markdownSerializers.d.ts.map +1 -1
- package/dist/markdownSerializers.js +7 -4
- package/dist/markdownSource.d.ts +4 -10
- package/dist/markdownSource.d.ts.map +1 -1
- package/dist/markdownSource.js +150 -33
- package/dist/markdownSpaceRuns.d.ts +24 -0
- package/dist/markdownSpaceRuns.d.ts.map +1 -0
- package/dist/markdownSpaceRuns.js +147 -0
- package/dist/markdownTable.d.ts +4 -1
- package/dist/markdownTable.d.ts.map +1 -1
- package/dist/markdownTable.js +45 -10
- package/dist/richtext.css +2 -1
- package/package.json +9 -4
- package/src/CodeBlockHeaderPlugin.tsx +1 -0
- package/src/MarkdownExtensionsPlugin.test.tsx +279 -0
- package/src/MarkdownExtensionsPlugin.tsx +289 -0
- package/src/RichTextEditor.doc.mjs +12 -1
- package/src/RichTextEditor.tsx +26 -1
- package/src/RichTextEditorToolbar.tsx +15 -2
- package/src/RichTextView.tsx +21 -0
- package/src/TaskCheckboxPlugin.tsx +5 -1
- package/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.ts +123 -10
- package/src/__tests__/MarkdownPlugins.a11y.chromium.spec.ts +482 -0
- package/src/__tests__/MarkdownPluginsImportExport.a11y.chromium.spec.ts +117 -0
- package/src/editorNodes.ts +4 -0
- package/src/editorTheme.ts +11 -3
- package/src/index.ts +5 -0
- package/src/markdown.ts +25 -0
- package/src/markdownAngleCodeSpans.test.ts +92 -0
- package/src/markdownAngleDestinations.test.ts +303 -0
- package/src/markdownCharacterReferences.ts +668 -17
- package/src/markdownCodeFence.test.ts +195 -0
- package/src/markdownCodeFence.ts +216 -0
- package/src/markdownCodeSpans.test.ts +399 -0
- package/src/markdownEscapes.test.ts +234 -0
- package/src/markdownExtensionNode.ts +332 -0
- package/src/markdownExtensionSelection.test.ts +102 -0
- package/src/markdownExtensions.test.ts +765 -0
- package/src/markdownExtensions.ts +496 -0
- package/src/markdownHeading.ts +33 -0
- package/src/markdownHeadingMarkers.test.ts +132 -0
- package/src/markdownIndentedFences.test.ts +43 -0
- package/src/markdownIndentedTables.test.ts +43 -0
- package/src/markdownLink.ts +92 -0
- package/src/markdownListContinuation.test.ts +34 -0
- package/src/markdownListIndentation.ts +17 -1
- package/src/markdownListThematicBreak.test.ts +31 -0
- package/src/markdownListThematicBreakInside.test.ts +64 -0
- package/src/markdownOpenFence.test.ts +35 -0
- package/src/markdownQuote.ts +35 -0
- package/src/markdownQuoteMarkers.test.ts +206 -0
- package/src/markdownRefusedLinks.test.tsx +193 -0
- package/src/markdownSerializers.ts +13 -4
- package/src/markdownSource.test.tsx +11 -5
- package/src/markdownSource.ts +200 -38
- package/src/markdownSpaceRuns.test.ts +204 -0
- package/src/markdownSpaceRuns.ts +164 -0
- package/src/markdownSpacedBlockStarts.test.ts +96 -0
- package/src/markdownTabRuns.test.ts +75 -0
- package/src/markdownTable.ts +61 -11
- package/src/markdownTableLinks.test.ts +69 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockHeaderPlugin.d.ts","sourceRoot":"","sources":["../src/CodeBlockHeaderPlugin.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeBlockHeaderPlugin.d.ts","sourceRoot":"","sources":["../src/CodeBlockHeaderPlugin.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;AA+JpD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,GAAG,CAAC,OAAO,CA+EnD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Transformer } from '@lexical/markdown';
|
|
2
|
+
import type { MarkdownExtensionNode, MarkdownPluginEntry } from '@astryxdesign/core/Markdown/plugins';
|
|
3
|
+
import { type RichTextMarkdownExtension } from './markdownExtensions';
|
|
4
|
+
import { type RichTextExtensionNodeFacts } from './markdownExtensionNode';
|
|
5
|
+
/**
|
|
6
|
+
* The node core derives from a stored node's source with `plugins`, or null
|
|
7
|
+
* when no adopted plugin of the same protocol version reads that exact source
|
|
8
|
+
* as that node.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deriveExtensionNode(facts: RichTextExtensionNodeFacts, plugins: ReadonlyArray<MarkdownPluginEntry>): MarkdownExtensionNode | null;
|
|
11
|
+
export interface MarkdownExtensionsPluginProps {
|
|
12
|
+
extensions: ReadonlyArray<RichTextMarkdownExtension>;
|
|
13
|
+
/** The surface's Markdown transformers, checked against the extensions. */
|
|
14
|
+
transformers: ReadonlyArray<Transformer>;
|
|
15
|
+
}
|
|
16
|
+
export declare function MarkdownExtensionsPlugin({ extensions, transformers, }: MarkdownExtensionsPluginProps): null;
|
|
17
|
+
//# sourceMappingURL=MarkdownExtensionsPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownExtensionsPlugin.d.ts","sourceRoot":"","sources":["../src/MarkdownExtensionsPlugin.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAwBnD,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAY,KAAK,yBAAyB,EAAC,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAKL,KAAK,0BAA0B,EAChC,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,0BAA0B,EACjC,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAC1C,qBAAqB,GAAG,IAAI,CAoB9B;AAyHD,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACrD,2EAA2E;IAC3E,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED,wBAAgB,wBAAwB,CAAC,EACvC,UAAU,EACV,YAAY,GACb,EAAE,6BAA6B,GAAG,IAAI,CAoEtC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file MarkdownExtensionsPlugin.tsx
|
|
7
|
+
* @input Uses @lexical/react (composer context), @lexical/utils ($dfs),
|
|
8
|
+
* lexical, core's client-only MarkdownPluginNodeRenderer and server-safe
|
|
9
|
+
* parser, and the RichText adapter and extension node.
|
|
10
|
+
* @output Exports MarkdownExtensionsPlugin, which draws every Markdown plugin
|
|
11
|
+
* node in an editor with its plugin's renderer, and deriveExtensionNode.
|
|
12
|
+
* @position Rendered by RichTextEditor and RichTextView when they are given
|
|
13
|
+
* `markdownExtensions` (spec:AST-064 FR2). It checks the configuration
|
|
14
|
+
* first (FR6), so a conflicting one throws a RichTextExtensionError while
|
|
15
|
+
* the surface renders. Each node is derived again from its source with the
|
|
16
|
+
* adopted plugins and drawn by core's MarkdownPluginNodeRenderer, so it
|
|
17
|
+
* renders, falls back, and reports failures exactly as Markdown does (FR8,
|
|
18
|
+
* FR9); stored data is never drawn on its own, and a node its plugin no
|
|
19
|
+
* longer recognizes — or whose plugin is not adopted — shows its source
|
|
20
|
+
* (FR11). Without this plugin a node shows its source.
|
|
21
|
+
*/
|
|
22
|
+
import { useEffect, useMemo } from 'react';
|
|
23
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
24
|
+
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
25
|
+
import { $dfs, addClassNamesToElement, removeClassNamesFromElement } from '@lexical/utils';
|
|
26
|
+
import { $getSelection, $isRangeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, HISTORY_MERGE_TAG, TEXT_TYPE_TO_FORMAT } from 'lexical';
|
|
27
|
+
import { MarkdownPluginNodeRenderer } from '@astryxdesign/core/Markdown/plugin-renderer';
|
|
28
|
+
import { parseInlineAst, parseMarkdownAst } from '@astryxdesign/core/Markdown/parser';
|
|
29
|
+
import { pluginsOf } from "./markdownExtensions.js";
|
|
30
|
+
import { $firstSelectedText, $isRichTextExtensionNode, setRichTextExtensionNodeDecorator } from "./markdownExtensionNode.js";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The node core derives from a stored node's source with `plugins`, or null
|
|
34
|
+
* when no adopted plugin of the same protocol version reads that exact source
|
|
35
|
+
* as that node.
|
|
36
|
+
*/
|
|
37
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
+
export function deriveExtensionNode(facts, plugins) {
|
|
39
|
+
const plugin = plugins.find(entry => entry.name === facts.plugin);
|
|
40
|
+
if (plugin == null || plugin.apiVersion !== facts.apiVersion) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const nodes = facts.display === 'inline' ? parseInlineAst(facts.source, {
|
|
44
|
+
plugins: [plugin]
|
|
45
|
+
}) : parseMarkdownAst(facts.source, {
|
|
46
|
+
plugins: [plugin]
|
|
47
|
+
}).children;
|
|
48
|
+
const [node] = nodes;
|
|
49
|
+
if (nodes.length !== 1 || node?.type !== 'extension') {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const extension = node;
|
|
53
|
+
return extension.plugin === facts.plugin && extension.name === facts.name && extension.display === facts.display && extension.source === facts.source ? extension : null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The formats a plugin node can sit inside, outermost first, as RichText draws
|
|
58
|
+
* them around text (textSemantics.ts): a deletion, then emphasis, then strong.
|
|
59
|
+
*/
|
|
60
|
+
const MARKS = [['strikethrough', 'del'], ['italic', 'em'], ['bold', 'strong']];
|
|
61
|
+
|
|
62
|
+
/** The formats a toggle can put a plugin node inside. */
|
|
63
|
+
const NODE_FORMATS = new Set(MARKS.map(([format]) => format));
|
|
64
|
+
function ExtensionNodeView({
|
|
65
|
+
facts,
|
|
66
|
+
format,
|
|
67
|
+
nodeKey,
|
|
68
|
+
plugins
|
|
69
|
+
}) {
|
|
70
|
+
const [editor] = useLexicalComposerContext();
|
|
71
|
+
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
72
|
+
// A click on the node selects it whole, as a click on a rule does, so a
|
|
73
|
+
// pointer user can format or delete it like a keyboard user.
|
|
74
|
+
useEffect(() => editor.registerCommand(CLICK_COMMAND, event => {
|
|
75
|
+
const element = editor.getElementByKey(nodeKey);
|
|
76
|
+
if (!editor.isEditable() || element == null || !(event.target instanceof Node) || !element.contains(event.target)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
clearSelection();
|
|
80
|
+
setSelected(true);
|
|
81
|
+
return true;
|
|
82
|
+
}, COMMAND_PRIORITY_LOW), [clearSelection, editor, nodeKey, setSelected]);
|
|
83
|
+
// A selected node shows the focus ring a selected rule shows.
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const element = editor.getElementByKey(nodeKey);
|
|
86
|
+
const className = editor._config.theme.markdownExtensionSelected;
|
|
87
|
+
if (element == null || typeof className !== 'string' || className === '') {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (isSelected) {
|
|
91
|
+
addClassNamesToElement(element, className);
|
|
92
|
+
} else {
|
|
93
|
+
removeClassNamesFromElement(element, className);
|
|
94
|
+
}
|
|
95
|
+
}, [editor, isSelected, nodeKey]);
|
|
96
|
+
const node = useMemo(() => deriveExtensionNode(facts, plugins), [facts, plugins]);
|
|
97
|
+
let content = node == null ? facts.source : /*#__PURE__*/_jsx(MarkdownPluginNodeRenderer, {
|
|
98
|
+
plugins: plugins,
|
|
99
|
+
node: node
|
|
100
|
+
});
|
|
101
|
+
// Inside emphasis, strong, or strikethrough, the node is drawn inside the
|
|
102
|
+
// same elements, as core Markdown draws it inside the text's.
|
|
103
|
+
for (const [type, Tag] of [...MARKS].reverse()) {
|
|
104
|
+
if ((format & TEXT_TYPE_TO_FORMAT[type]) !== 0) {
|
|
105
|
+
content = /*#__PURE__*/_jsx(Tag, {
|
|
106
|
+
children: content
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return content;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Marks every plugin node so Lexical draws it again with the decorator the
|
|
115
|
+
* editor has now. Not an edit, so it adds nothing to undo history.
|
|
116
|
+
*/
|
|
117
|
+
function redrawExtensionNodes(editor) {
|
|
118
|
+
editor.update(() => {
|
|
119
|
+
for (const {
|
|
120
|
+
node
|
|
121
|
+
} of $dfs()) {
|
|
122
|
+
if ($isRichTextExtensionNode(node)) {
|
|
123
|
+
node.markDirty();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
tag: HISTORY_MERGE_TAG
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Whether `format` will be on for the text a range selects once it is
|
|
133
|
+
* toggled, as Lexical's formatText decides it from the first selected
|
|
134
|
+
* character; null when the range selects no text, only nodes.
|
|
135
|
+
*/
|
|
136
|
+
function $nextTextFormat(selection, format) {
|
|
137
|
+
const first = $firstSelectedText(selection);
|
|
138
|
+
return first == null ? null : (first.getFormatFlags(format, null) & TEXT_TYPE_TO_FORMAT[format]) !== 0;
|
|
139
|
+
}
|
|
140
|
+
export function MarkdownExtensionsPlugin({
|
|
141
|
+
extensions,
|
|
142
|
+
transformers
|
|
143
|
+
}) {
|
|
144
|
+
const [editor] = useLexicalComposerContext();
|
|
145
|
+
const plugins = useMemo(() => pluginsOf(extensions, transformers), [extensions, transformers]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const unset = setRichTextExtensionNodeDecorator(editor, (facts, format, nodeKey) => /*#__PURE__*/_jsx(ExtensionNodeView, {
|
|
148
|
+
facts: facts,
|
|
149
|
+
format: format,
|
|
150
|
+
nodeKey: nodeKey,
|
|
151
|
+
plugins: plugins
|
|
152
|
+
}));
|
|
153
|
+
redrawExtensionNodes(editor);
|
|
154
|
+
return () => {
|
|
155
|
+
unset();
|
|
156
|
+
redrawExtensionNodes(editor);
|
|
157
|
+
};
|
|
158
|
+
}, [editor, plugins]);
|
|
159
|
+
|
|
160
|
+
// Bold, italic, or strikethrough toggled on a selection takes the plugin
|
|
161
|
+
// nodes in it along, so they stay inside the marks the text around them
|
|
162
|
+
// gets — and a selection of nodes alone toggles them by themselves.
|
|
163
|
+
useEffect(() => editor.registerCommand(FORMAT_TEXT_COMMAND, format => {
|
|
164
|
+
const selection = $getSelection();
|
|
165
|
+
if (!NODE_FORMATS.has(format) || selection == null) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const nodes = selection.getNodes().filter(node => $isRichTextExtensionNode(node) && node.isInline());
|
|
169
|
+
if (nodes.length === 0) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
// The state Lexical gives the selected text, read before it does;
|
|
173
|
+
// null when no text is selected, only nodes.
|
|
174
|
+
const textState = $isRangeSelection(selection) ? $nextTextFormat(selection, format) : null;
|
|
175
|
+
if ($isRangeSelection(selection)) {
|
|
176
|
+
selection.formatText(format);
|
|
177
|
+
}
|
|
178
|
+
const isOn = textState ?? !nodes.every(node => node.hasFormat(format));
|
|
179
|
+
for (const node of nodes) {
|
|
180
|
+
node.setFormatFlag(format, isOn);
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}, COMMAND_PRIORITY_LOW), [editor]);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
package/dist/RichTextEditor.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { type ReactNode } from 'react';
|
|
|
26
26
|
import { type FieldStatusVariant } from '@astryxdesign/core/Field';
|
|
27
27
|
import type { BaseProps } from '@astryxdesign/core';
|
|
28
28
|
import { type SizeValue } from '@astryxdesign/core/utils';
|
|
29
|
+
import type { RichTextMarkdownExtension } from './markdownExtensions';
|
|
29
30
|
import { type Transformer } from '@lexical/markdown';
|
|
30
31
|
export type { Transformer } from '@lexical/markdown';
|
|
31
32
|
import { type EditorState, type Klass, type LexicalEditor, type LexicalNode } from 'lexical';
|
|
@@ -201,6 +202,15 @@ export interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defau
|
|
|
201
202
|
* the serialization APIs added in later phases.
|
|
202
203
|
*/
|
|
203
204
|
transformers?: ReadonlyArray<Transformer>;
|
|
205
|
+
/**
|
|
206
|
+
* Markdown plugins whose nodes this surface draws, each adopted with
|
|
207
|
+
* `createRichTextExtension` (spec:AST-064). A plugin node renders exactly as
|
|
208
|
+
* core `Markdown` renders it, and one whose plugin is not given here shows
|
|
209
|
+
* its source. Pass the extensions the content was converted with. Create
|
|
210
|
+
* them in a client module: they hold the plugins' functions, so they are not
|
|
211
|
+
* serializable props.
|
|
212
|
+
*/
|
|
213
|
+
markdownExtensions?: ReadonlyArray<RichTextMarkdownExtension>;
|
|
204
214
|
/** Whether to automatically focus the editor on mount. @default false */
|
|
205
215
|
hasAutoFocus?: boolean;
|
|
206
216
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AASf,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAA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AE,kBAAkB,CAAC;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC9D,yEAAyE;IACzE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,cAAc,mHAkRzB,CAAC"}
|
package/dist/RichTextEditor.js
CHANGED
|
@@ -53,6 +53,7 @@ import { TextSemanticsExtension } from "./textSemantics.js";
|
|
|
53
53
|
import { TableColumnFloorPlugin } from "./TableColumnFloorPlugin.js";
|
|
54
54
|
import { CodeBlockHeaderPlugin } from "./CodeBlockHeaderPlugin.js";
|
|
55
55
|
import { CodeSyntaxPlugin } from "./CodeSyntaxPlugin.js";
|
|
56
|
+
import { MarkdownExtensionsPlugin } from "./MarkdownExtensionsPlugin.js";
|
|
56
57
|
import { TaskCheckboxPlugin } from "./TaskCheckboxPlugin.js";
|
|
57
58
|
import { $generateHtmlFromNodes } from '@lexical/html';
|
|
58
59
|
import { DEFAULT_NODES } from "./editorNodes.js";
|
|
@@ -135,7 +136,7 @@ const styles = {
|
|
|
135
136
|
$$css: true
|
|
136
137
|
},
|
|
137
138
|
disabled: {
|
|
138
|
-
kkrTdU: "
|
|
139
|
+
kkrTdU: "xt0e3qv x16khyan",
|
|
139
140
|
$$css: true
|
|
140
141
|
}
|
|
141
142
|
};
|
|
@@ -224,6 +225,7 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
|
|
|
224
225
|
plugins,
|
|
225
226
|
hasMarkdownShortcuts = true,
|
|
226
227
|
transformers = DEFAULT_TRANSFORMERS,
|
|
228
|
+
markdownExtensions,
|
|
227
229
|
hasAutoFocus = false,
|
|
228
230
|
tabEscapeHint = DEFAULT_TAB_ESCAPE_HINT,
|
|
229
231
|
maxLength,
|
|
@@ -363,7 +365,10 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
|
|
|
363
365
|
hasCellBackgroundColor: false,
|
|
364
366
|
hasTabHandler: false,
|
|
365
367
|
hasHorizontalScroll: true
|
|
366
|
-
}), /*#__PURE__*/_jsx(TableColumnFloorPlugin, {}), /*#__PURE__*/_jsx(CodeBlockHeaderPlugin, {}), /*#__PURE__*/_jsx(CodeSyntaxPlugin, {}),
|
|
368
|
+
}), /*#__PURE__*/_jsx(TableColumnFloorPlugin, {}), /*#__PURE__*/_jsx(CodeBlockHeaderPlugin, {}), /*#__PURE__*/_jsx(CodeSyntaxPlugin, {}), markdownExtensions != null && markdownExtensions.length > 0 ? /*#__PURE__*/_jsx(MarkdownExtensionsPlugin, {
|
|
369
|
+
extensions: markdownExtensions,
|
|
370
|
+
transformers: markdownTransformers
|
|
371
|
+
}) : null, /*#__PURE__*/_jsx(TabIndentationPlugin, {}), /*#__PURE__*/_jsx(TabFocusEscapePlugin, {}), hasMarkdownShortcuts && /*#__PURE__*/_jsx(MarkdownShortcutPlugin, {
|
|
367
372
|
transformers: markdownTransformers
|
|
368
373
|
}), hasAutoFocus && /*#__PURE__*/_jsx(AutoFocusOnMount, {}), onChange && /*#__PURE__*/_jsx(OnChangePlugin, {
|
|
369
374
|
onChange: onChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditorToolbar.d.ts","sourceRoot":"","sources":["../src/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RichTextEditorToolbar.d.ts","sourceRoot":"","sources":["../src/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAkHf;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAwOX,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IAClD;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnE;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAyB,EACzB,aAAkC,EAClC,IAAW,EACX,OAAc,EACd,YAAY,EACZ,iBAAwB,EACxB,UAAU,GACX,EAAE,0BAA0B,+BAwe5B;yBAhfe,qBAAqB"}
|
|
@@ -51,8 +51,9 @@ import { Button } from '@astryxdesign/core/Button';
|
|
|
51
51
|
import { Stack } from '@astryxdesign/core/Stack';
|
|
52
52
|
import { HStack, Layout, LayoutContent, LayoutFooter } from '@astryxdesign/core/Layout';
|
|
53
53
|
import { getExtendedIcon } from '@astryxdesign/core/Icon';
|
|
54
|
-
import { FORMAT_TEXT_COMMAND, UNDO_COMMAND, REDO_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, SELECTION_CHANGE_COMMAND, KEY_DOWN_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_NORMAL, IS_APPLE, isExactShortcutMatch, $getSelection, $isRangeSelection, $setSelection, $createParagraphNode, $createTextNode } from 'lexical';
|
|
54
|
+
import { FORMAT_TEXT_COMMAND, UNDO_COMMAND, REDO_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, SELECTION_CHANGE_COMMAND, KEY_DOWN_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_NORMAL, IS_APPLE, isExactShortcutMatch, $getSelection, $isNodeSelection, $isRangeSelection, $setSelection, $createParagraphNode, $createTextNode } from 'lexical';
|
|
55
55
|
import { sanitizeUrl } from "./linkUtils.js";
|
|
56
|
+
import { $selectedExtensionNodesOnly } from "./markdownExtensionNode.js";
|
|
56
57
|
|
|
57
58
|
/** Block types exposed by the toolbar's format selector. */
|
|
58
59
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -419,16 +420,23 @@ export function RichTextEditorToolbar({
|
|
|
419
420
|
const [linkError, setLinkError] = useState('');
|
|
420
421
|
const $syncToolbar = useCallback(() => {
|
|
421
422
|
const selection = $getSelection();
|
|
422
|
-
if (!$isRangeSelection(selection)) {
|
|
423
|
+
if (!$isRangeSelection(selection) && !$isNodeSelection(selection)) {
|
|
423
424
|
return;
|
|
424
425
|
}
|
|
425
426
|
const formats = new Set();
|
|
427
|
+
// A selection of Markdown plugin nodes alone — a range around them, or
|
|
428
|
+
// a node selection from a click — shows their formats. Any other node
|
|
429
|
+
// selection, such as a rule, has none.
|
|
430
|
+
const nodesOnly = $selectedExtensionNodesOnly(selection);
|
|
426
431
|
for (const fmt of ['bold', 'italic', 'underline', 'strikethrough', 'code']) {
|
|
427
|
-
if (selection.hasFormat(fmt)) {
|
|
432
|
+
if (nodesOnly != null ? nodesOnly.every(node => node.hasFormat(fmt)) : $isRangeSelection(selection) && selection.hasFormat(fmt)) {
|
|
428
433
|
formats.add(fmt);
|
|
429
434
|
}
|
|
430
435
|
}
|
|
431
436
|
setActiveFormats(formats);
|
|
437
|
+
if (!$isRangeSelection(selection)) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
432
440
|
|
|
433
441
|
// Link active state — a link is "active" when the caret/selection anchor
|
|
434
442
|
// sits inside a LinkNode (or its immediate parent is one):
|
package/dist/RichTextView.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { type ReactNode } from 'react';
|
|
17
17
|
import type { BaseProps } from '@astryxdesign/core';
|
|
18
|
+
import type { RichTextMarkdownExtension } from './markdownExtensions';
|
|
18
19
|
import type { Klass, LexicalNode } from 'lexical';
|
|
19
20
|
export interface RichTextViewProps extends BaseProps {
|
|
20
21
|
/**
|
|
@@ -27,6 +28,15 @@ export interface RichTextViewProps extends BaseProps {
|
|
|
27
28
|
* the nodes used to author `value` so custom node types deserialize.
|
|
28
29
|
*/
|
|
29
30
|
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
31
|
+
/**
|
|
32
|
+
* Markdown plugins whose nodes this surface draws, each adopted with
|
|
33
|
+
* `createRichTextExtension` (spec:AST-064). A plugin node renders exactly as
|
|
34
|
+
* core `Markdown` renders it, and one whose plugin is not given here shows
|
|
35
|
+
* its source. Pass the extensions the content was converted with. Create
|
|
36
|
+
* them in a client module: they hold the plugins' functions, so they are not
|
|
37
|
+
* serializable props.
|
|
38
|
+
*/
|
|
39
|
+
markdownExtensions?: ReadonlyArray<RichTextMarkdownExtension>;
|
|
30
40
|
/**
|
|
31
41
|
* Additional read-only plugins to render inside the composer (e.g. hover
|
|
32
42
|
* cards, decorators).
|
|
@@ -66,7 +76,7 @@ export interface RichTextViewProps extends BaseProps {
|
|
|
66
76
|
* <RichTextView value={storedEditorStateJSON} />
|
|
67
77
|
* ```
|
|
68
78
|
*/
|
|
69
|
-
export declare function RichTextView({ value, nodes, plugins, namespace, onParseError, errorFallback, xstyle, className, style, ...rest }: RichTextViewProps): import("react").JSX.Element;
|
|
79
|
+
export declare function RichTextView({ value, nodes, markdownExtensions, plugins, namespace, onParseError, errorFallback, xstyle, className, style, ...rest }: RichTextViewProps): import("react").JSX.Element;
|
|
70
80
|
export declare namespace RichTextView {
|
|
71
81
|
var displayName: string;
|
|
72
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextView.d.ts","sourceRoot":"","sources":["../src/RichTextView.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA8B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAGlE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAclD,OAAO,KAAK,EAEV,KAAK,EACL,WAAW,EAEZ,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"RichTextView.d.ts","sourceRoot":"","sources":["../src/RichTextView.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA8B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAGlE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAclD,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,sBAAsB,CAAC;AAEpE,OAAO,KAAK,EAEV,KAAK,EACL,WAAW,EAEZ,MAAM,SAAS,CAAC;AA6CjB,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1C;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC9D;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAyCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,kBAAkB,EAClB,OAAO,EACP,SAAyB,EACzB,YAAY,EACZ,aAAoB,EACpB,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,iBAAiB,+BA8HnB;yBA1Ie,YAAY"}
|
package/dist/RichTextView.js
CHANGED
|
@@ -31,6 +31,7 @@ import { TableScrollRegionPlugin } from "./TableScrollRegionPlugin.js";
|
|
|
31
31
|
import { TableColumnFloorPlugin } from "./TableColumnFloorPlugin.js";
|
|
32
32
|
import { CodeBlockHeaderPlugin } from "./CodeBlockHeaderPlugin.js";
|
|
33
33
|
import { CodeSyntaxPlugin } from "./CodeSyntaxPlugin.js";
|
|
34
|
+
import { MarkdownExtensionsPlugin } from "./MarkdownExtensionsPlugin.js";
|
|
34
35
|
import { TaskCheckboxPlugin } from "./TaskCheckboxPlugin.js";
|
|
35
36
|
import { defineExtension } from 'lexical';
|
|
36
37
|
import { TextSemanticsExtension } from "./textSemantics.js";
|
|
@@ -71,6 +72,9 @@ const VIEW_CONTENT_EDITABLE_PROPS = {
|
|
|
71
72
|
'aria-readonly': undefined,
|
|
72
73
|
role: null
|
|
73
74
|
};
|
|
75
|
+
|
|
76
|
+
/** The view imports and exports no Markdown, so it uses no transformers. */
|
|
77
|
+
const NO_TRANSFORMERS = [];
|
|
74
78
|
/**
|
|
75
79
|
* Keeps the rendered content in sync with the `value` prop after mount.
|
|
76
80
|
*
|
|
@@ -131,6 +135,7 @@ function SyncValuePlugin({
|
|
|
131
135
|
export function RichTextView({
|
|
132
136
|
value,
|
|
133
137
|
nodes,
|
|
138
|
+
markdownExtensions,
|
|
134
139
|
plugins,
|
|
135
140
|
namespace = 'astryx-view',
|
|
136
141
|
onParseError,
|
|
@@ -239,7 +244,10 @@ export function RichTextView({
|
|
|
239
244
|
}),
|
|
240
245
|
placeholder: null,
|
|
241
246
|
ErrorBoundary: LexicalErrorBoundary
|
|
242
|
-
}), /*#__PURE__*/_jsx(CodeBlockHeaderPlugin, {}), /*#__PURE__*/_jsx(CodeSyntaxPlugin, {}), /*#__PURE__*/_jsx(
|
|
247
|
+
}), /*#__PURE__*/_jsx(CodeBlockHeaderPlugin, {}), /*#__PURE__*/_jsx(CodeSyntaxPlugin, {}), markdownExtensions != null && markdownExtensions.length > 0 ? /*#__PURE__*/_jsx(MarkdownExtensionsPlugin, {
|
|
248
|
+
extensions: markdownExtensions,
|
|
249
|
+
transformers: NO_TRANSFORMERS
|
|
250
|
+
}) : null, /*#__PURE__*/_jsx(TaskCheckboxPlugin, {
|
|
243
251
|
isReadOnly: true
|
|
244
252
|
}), plugins]
|
|
245
253
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskCheckboxPlugin.d.ts","sourceRoot":"","sources":["../src/TaskCheckboxPlugin.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAA6B,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TaskCheckboxPlugin.d.ts","sourceRoot":"","sources":["../src/TaskCheckboxPlugin.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAA6B,KAAK,GAAG,EAAC,MAAM,OAAO,CAAC;AAmC3D,wDAAwD;AACxD,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAgDnD,wBAAgB,kBAAkB,CAAC,EACjC,UAAU,GACX,EAAE;IACD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B,GAAG,GAAG,CAAC,OAAO,CAmId"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorNodes.d.ts","sourceRoot":"","sources":["../src/editorNodes.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"editorNodes.d.ts","sourceRoot":"","sources":["../src/editorNodes.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAGhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAgB3D,CAAC"}
|
package/dist/editorNodes.js
CHANGED
|
@@ -17,9 +17,14 @@ import { LinkNode, AutoLinkNode } from '@lexical/link';
|
|
|
17
17
|
import { CodeNode, CodeHighlightNode } from '@lexical/code';
|
|
18
18
|
import { TableNode, TableRowNode, TableCellNode } from '@lexical/table';
|
|
19
19
|
import { HorizontalRuleNode } from '@lexical/extension';
|
|
20
|
+
import { RichTextExtensionNode } from "./markdownExtensionNode.js";
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* The default OSS node set registered with the editor: headings, quotes,
|
|
22
24
|
* lists, links, code, and tables. Extend via the `nodes` prop / option rather
|
|
23
25
|
* than editing this list.
|
|
24
26
|
*/
|
|
25
|
-
export const DEFAULT_NODES = [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode, TableNode, TableRowNode, TableCellNode, HorizontalRuleNode
|
|
27
|
+
export const DEFAULT_NODES = [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode, TableNode, TableRowNode, TableCellNode, HorizontalRuleNode,
|
|
28
|
+
// Markdown plugin nodes (spec:AST-064): registered everywhere so stored
|
|
29
|
+
// state that holds them always loads.
|
|
30
|
+
RichTextExtensionNode];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAyXhD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CA6DtD"}
|
package/dist/editorTheme.js
CHANGED
|
@@ -236,6 +236,9 @@ export function sharedEditorTheme() {
|
|
|
236
236
|
const className = style => stylex.props(style).className ?? '';
|
|
237
237
|
return {
|
|
238
238
|
paragraph: block(editorTheme.paragraph),
|
|
239
|
+
// A Markdown plugin's block node is spaced and measured as a paragraph,
|
|
240
|
+
// as core Markdown spaces its block (RichTextExtensionNode reads it).
|
|
241
|
+
markdownExtensionBlock: block(editorTheme.paragraph),
|
|
239
242
|
heading: {
|
|
240
243
|
h1: block(editorTheme.h1),
|
|
241
244
|
h2: block(editorTheme.h2),
|
|
@@ -261,7 +264,7 @@ export function sharedEditorTheme() {
|
|
|
261
264
|
olDepth: [className(editorTheme.olMarker0), className(editorTheme.olMarker1), className(editorTheme.olMarker2)]
|
|
262
265
|
},
|
|
263
266
|
link: {
|
|
264
|
-
className: "xjse4m1 x1bvjpef x1ypdohk"
|
|
267
|
+
className: "xjse4m1 x1bvjpef x1ypdohk x16khyan"
|
|
265
268
|
}.className,
|
|
266
269
|
text: {
|
|
267
270
|
bold: {
|
|
@@ -288,6 +291,10 @@ export function sharedEditorTheme() {
|
|
|
288
291
|
hrSelected: {
|
|
289
292
|
className: "xak0ai5 x9ssot5 x19bwoy8 x1eqjuhu"
|
|
290
293
|
}.className,
|
|
294
|
+
// MarkdownExtensionsPlugin puts it on a selected plugin node.
|
|
295
|
+
markdownExtensionSelected: {
|
|
296
|
+
className: "xak0ai5 x9ssot5 x19bwoy8 x1eqjuhu"
|
|
297
|
+
}.className,
|
|
291
298
|
table: block(editorTheme.table),
|
|
292
299
|
// Lexical stamps rows and cells `dir="auto"` too, which would set a cell
|
|
293
300
|
// of English text left-to-right inside a right-to-left document.
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type { RichTextViewProps } from './RichTextView';
|
|
|
16
16
|
export { sharedEditorTheme } from './editorTheme';
|
|
17
17
|
export { markdownToEditorStateJSON, editorStateJSONToMarkdown, } from './markdownSerializers';
|
|
18
18
|
export type { MarkdownSerializerOptions } from './markdownSerializers';
|
|
19
|
+
export { createRichTextExtension, RichTextExtensionError, } from './markdownExtensions';
|
|
20
|
+
export type { RichTextMarkdownExtension } from './markdownExtensions';
|
|
19
21
|
export { RichTextEditorToolbar, RICHTEXT_ICON_KEYS, } from './RichTextEditorToolbar';
|
|
20
22
|
export type { RichTextEditorToolbarProps } from './RichTextEditorToolbar';
|
|
21
23
|
export { RichTextEditorAutoLinkPlugin, DEFAULT_LINK_MATCHERS, NEW_TAB_LINK_ATTRIBUTES, } from './RichTextEditorAutoLinkPlugin';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB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,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { RichTextEditor } from "./RichTextEditor.js";
|
|
|
17
17
|
export { RichTextView } from "./RichTextView.js";
|
|
18
18
|
export { sharedEditorTheme } from "./editorTheme.js";
|
|
19
19
|
export { markdownToEditorStateJSON, editorStateJSONToMarkdown } from "./markdownSerializers.js";
|
|
20
|
+
export { createRichTextExtension, RichTextExtensionError } from "./markdownExtensions.js";
|
|
20
21
|
export { RichTextEditorToolbar, RICHTEXT_ICON_KEYS } from "./RichTextEditorToolbar.js";
|
|
21
22
|
export { RichTextEditorAutoLinkPlugin, DEFAULT_LINK_MATCHERS, NEW_TAB_LINK_ATTRIBUTES } from "./RichTextEditorAutoLinkPlugin.js";
|
|
22
23
|
export { sanitizeUrl, validateUrl, URL_MATCHER, EMAIL_MATCHER } from "./linkUtils.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file markdown.ts
|
|
3
|
+
* @output Server-safe entry `@astryxdesign/richtext/markdown`: the Markdown
|
|
4
|
+
* serializers, createRichTextExtension, RichTextExtensionError, and their
|
|
5
|
+
* types.
|
|
6
|
+
* @position Imports no React, DOM, or client-only module, so server and Node
|
|
7
|
+
* code converts Markdown and adopts plugins here (spec:AST-064 FR3, FR12).
|
|
8
|
+
* The package's main entry is a client module and re-exports all of this
|
|
9
|
+
* for client code. An extension holds its plugin's functions, so it is not
|
|
10
|
+
* serializable: create the extensions a page passes to the surfaces in a
|
|
11
|
+
* client module, and create your own for headless use.
|
|
12
|
+
*/
|
|
13
|
+
export { markdownToEditorStateJSON, editorStateJSONToMarkdown, } from './markdownSerializers';
|
|
14
|
+
export type { MarkdownSerializerOptions } from './markdownSerializers';
|
|
15
|
+
export { createRichTextExtension, RichTextExtensionError, } from './markdownExtensions';
|
|
16
|
+
export type { RichTextMarkdownExtension } from './markdownExtensions';
|
|
17
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAC,yBAAyB,EAAC,MAAM,sBAAsB,CAAC"}
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file markdown.ts
|
|
5
|
+
* @output Server-safe entry `@astryxdesign/richtext/markdown`: the Markdown
|
|
6
|
+
* serializers, createRichTextExtension, RichTextExtensionError, and their
|
|
7
|
+
* types.
|
|
8
|
+
* @position Imports no React, DOM, or client-only module, so server and Node
|
|
9
|
+
* code converts Markdown and adopts plugins here (spec:AST-064 FR3, FR12).
|
|
10
|
+
* The package's main entry is a client module and re-exports all of this
|
|
11
|
+
* for client code. An extension holds its plugin's functions, so it is not
|
|
12
|
+
* serializable: create the extensions a page passes to the surfaces in a
|
|
13
|
+
* client module, and create your own for headless use.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export { markdownToEditorStateJSON, editorStateJSONToMarkdown } from "./markdownSerializers.js";
|
|
17
|
+
export { createRichTextExtension, RichTextExtensionError } from "./markdownExtensions.js";
|