@tensor_1/react 2.18.0 → 2.19.0
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/README.md +102 -1
- package/dist/components/Comments.d.ts +18 -2
- package/dist/components/Comments.js +37 -12
- package/dist/components/EditorIcons.d.ts +39 -0
- package/dist/components/EditorIcons.js +51 -0
- package/dist/components/EmojiGlyph.d.ts +10 -0
- package/dist/components/EmojiGlyph.js +18 -0
- package/dist/components/EmojiPicker.d.ts +60 -0
- package/dist/components/EmojiPicker.js +277 -0
- package/dist/components/Markdown.d.ts +36 -0
- package/dist/components/Markdown.js +104 -0
- package/dist/components/ReactionBar.d.ts +57 -0
- package/dist/components/ReactionBar.js +81 -0
- package/dist/components/RelationshipGraph.js +23 -4
- package/dist/components/RichTextEditor.d.ts +128 -0
- package/dist/components/RichTextEditor.js +954 -0
- package/dist/components/SaveStatus.d.ts +32 -0
- package/dist/components/SaveStatus.js +21 -0
- package/dist/components/Tabs.d.ts +10 -3
- package/dist/components/Tabs.js +5 -3
- package/dist/emoji-image-WQLh8ZQP.d.cts +128 -0
- package/dist/emoji-image.d.ts +25 -0
- package/dist/emoji-image.js +80 -0
- package/dist/emoji-model.d.ts +66 -0
- package/dist/emoji-model.js +108 -0
- package/dist/emoji.cjs +871 -0
- package/dist/emoji.d.cts +57 -0
- package/dist/emoji.d.ts +6 -0
- package/dist/emoji.js +18 -0
- package/dist/index.cjs +587 -519
- package/dist/index.d.cts +59 -64
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/markdown-model.d.ts +75 -0
- package/dist/markdown-model.js +438 -0
- package/dist/markdown.cjs +585 -0
- package/dist/markdown.d.cts +115 -0
- package/dist/markdown.d.ts +4 -0
- package/dist/markdown.js +9 -0
- package/dist/overlay-position-CEGSz6Z2.d.cts +59 -0
- package/dist/rich-text/emoji-items.d.ts +14 -0
- package/dist/rich-text/emoji-items.js +7 -0
- package/dist/rich-text/pipeline.d.ts +91 -0
- package/dist/rich-text/pipeline.js +379 -0
- package/dist/rich-text/round-trip.d.ts +24 -0
- package/dist/rich-text/round-trip.js +11 -0
- package/dist/rich-text.cjs +2578 -0
- package/dist/rich-text.d.cts +148 -0
- package/dist/rich-text.d.ts +8 -0
- package/dist/rich-text.js +10 -0
- package/dist/url-policy.d.ts +9 -0
- package/dist/url-policy.js +11 -0
- package/package.json +82 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { E as EmojiPickerLabels, a as EmojiLocale } from './emoji-image-WQLh8ZQP.cjs';
|
|
4
|
+
export { l as emojiImageFileName } from './emoji-image-WQLh8ZQP.cjs';
|
|
5
|
+
import './overlay-position-CEGSz6Z2.cjs';
|
|
6
|
+
|
|
7
|
+
type RichTextFeatures = 'full' | 'comment' | 'template';
|
|
8
|
+
type RichTextHeadingLevel = 1 | 2 | 3;
|
|
9
|
+
/** Every visible and accessible string of the editor. Placeholders are filled by the editor. */
|
|
10
|
+
interface RichTextLabels {
|
|
11
|
+
toolbar: string;
|
|
12
|
+
heading1: string;
|
|
13
|
+
heading2: string;
|
|
14
|
+
heading3: string;
|
|
15
|
+
bold: string;
|
|
16
|
+
italic: string;
|
|
17
|
+
strike: string;
|
|
18
|
+
code: string;
|
|
19
|
+
bulletList: string;
|
|
20
|
+
orderedList: string;
|
|
21
|
+
taskList: string;
|
|
22
|
+
blockquote: string;
|
|
23
|
+
codeBlock: string;
|
|
24
|
+
horizontalRule: string;
|
|
25
|
+
link: string;
|
|
26
|
+
/** Label of the link address field. */
|
|
27
|
+
linkUrl: string;
|
|
28
|
+
linkApply: string;
|
|
29
|
+
linkRemove: string;
|
|
30
|
+
/** Shown when the link address is refused by `isSafeUrl`. */
|
|
31
|
+
linkInvalid: string;
|
|
32
|
+
table: string;
|
|
33
|
+
tableAddRow: string;
|
|
34
|
+
tableAddColumn: string;
|
|
35
|
+
tableDeleteRow: string;
|
|
36
|
+
tableDeleteColumn: string;
|
|
37
|
+
tableDelete: string;
|
|
38
|
+
image: string;
|
|
39
|
+
imageUploading: string;
|
|
40
|
+
imageFailed: string;
|
|
41
|
+
emoji: string;
|
|
42
|
+
/** Accessible name of the `:shortcode` suggestion list. */
|
|
43
|
+
emojiSuggestions: string;
|
|
44
|
+
undo: string;
|
|
45
|
+
redo: string;
|
|
46
|
+
/** Toggle to markdown source. */
|
|
47
|
+
sourceMode: string;
|
|
48
|
+
/** Toggle back to formatted editing. */
|
|
49
|
+
richMode: string;
|
|
50
|
+
/** Character counter. Placeholders: `{count}`, `{max}`. */
|
|
51
|
+
characterCount: string;
|
|
52
|
+
}
|
|
53
|
+
declare const DEFAULT_RICH_TEXT_LABELS: RichTextLabels;
|
|
54
|
+
interface RichTextEditorProps {
|
|
55
|
+
/** Markdown. */
|
|
56
|
+
value: string;
|
|
57
|
+
/**
|
|
58
|
+
* Fired only for user edits — never on mount or when `value` changes from outside.
|
|
59
|
+
* Pass the emitted markdown back as `value` in the same update (as React state does):
|
|
60
|
+
* a different `value` is treated as an outside change and replaces the content.
|
|
61
|
+
*/
|
|
62
|
+
onChange: (markdown: string) => void;
|
|
63
|
+
/** Toolbar preset. Default `'full'`. */
|
|
64
|
+
features?: RichTextFeatures;
|
|
65
|
+
/** Heading levels the toolbar and input rules offer. Default `[1, 2, 3]`. */
|
|
66
|
+
headingLevels?: ReadonlyArray<RichTextHeadingLevel>;
|
|
67
|
+
/** Enables the image button (preset `full`), and image paste/drop. */
|
|
68
|
+
onUploadImage?: (file: File) => Promise<{
|
|
69
|
+
src: string;
|
|
70
|
+
alt: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** Link policy. Default: http(s), mailto and same-app paths. */
|
|
73
|
+
isSafeUrl?: (url: string) => boolean;
|
|
74
|
+
/** Image policy: the URL to display, or `null` to show the image as a link chip. */
|
|
75
|
+
resolveImageSrc?: (src: string) => string | null;
|
|
76
|
+
/** Ctrl/Cmd+Enter. */
|
|
77
|
+
onSubmitShortcut?: () => void;
|
|
78
|
+
/** Emoji button and `:shortcode` suggestions. Default `true`. */
|
|
79
|
+
emoji?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Same-origin folder of fallback emoji PNGs for devices without a colour emoji font
|
|
82
|
+
* (e.g. `/static/emoji`). Emoji the device cannot draw show as
|
|
83
|
+
* `<img src="{base}/{codepoints}.png">`; see `emojiImageFileName`. Values with a scheme or
|
|
84
|
+
* `//` are ignored. Unset = native emoji only; UIx ships no image set.
|
|
85
|
+
*/
|
|
86
|
+
emojiImageBaseUrl?: string;
|
|
87
|
+
/** Shows a character counter (markdown characters); over the limit sets `aria-invalid`. */
|
|
88
|
+
maxLength?: number;
|
|
89
|
+
placeholder?: string;
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
readOnly?: boolean;
|
|
92
|
+
labels?: Partial<RichTextLabels>;
|
|
93
|
+
/** Labels of the emoji picker opened from the toolbar. */
|
|
94
|
+
emojiPickerLabels?: Partial<EmojiPickerLabels>;
|
|
95
|
+
/** Language of emoji names in the picker. Default `'en'`. */
|
|
96
|
+
emojiLocale?: EmojiLocale;
|
|
97
|
+
id?: string;
|
|
98
|
+
/** Renders a hidden input with the markdown, for native form posts. */
|
|
99
|
+
name?: string;
|
|
100
|
+
'aria-label'?: string;
|
|
101
|
+
'aria-labelledby'?: string;
|
|
102
|
+
'aria-describedby'?: string;
|
|
103
|
+
'aria-invalid'?: boolean;
|
|
104
|
+
'aria-required'?: boolean;
|
|
105
|
+
/** `'composer'` renders inside Composer with the toolbar in ComposerBar. Default `'field'`. */
|
|
106
|
+
variant?: 'field' | 'composer';
|
|
107
|
+
/** Composer actions (visibility, send), placed at the end of the bar. */
|
|
108
|
+
toolbarEnd?: ReactNode;
|
|
109
|
+
/** Minimum visible lines. Default 4 (field) / 3 (composer). */
|
|
110
|
+
minRows?: number;
|
|
111
|
+
className?: string;
|
|
112
|
+
onBlur?: () => void;
|
|
113
|
+
}
|
|
114
|
+
/** The loading/error stand-in: a plain Textarea with the same value and ARIA, and the composer bar. */
|
|
115
|
+
declare function RichTextEditorFallback(props: RichTextEditorProps): react.JSX.Element;
|
|
116
|
+
/**
|
|
117
|
+
* Markdown rich-text editor on Tiptap v3 (RTE-01). Markdown in, markdown out:
|
|
118
|
+
* untouched blocks keep their exact source bytes, `onChange` fires only for user
|
|
119
|
+
* edits, emoji are stored as Unicode, raw HTML is never interpreted, and links and
|
|
120
|
+
* images pass the consumer's policy. The toolbar is one tab stop (arrow keys move
|
|
121
|
+
* within it) and scrolls horizontally on narrow screens.
|
|
122
|
+
*/
|
|
123
|
+
declare function RichTextEditor(props: RichTextEditorProps): react.JSX.Element;
|
|
124
|
+
|
|
125
|
+
/** Editor options that change how markdown is read. */
|
|
126
|
+
interface RoundTripOptions {
|
|
127
|
+
/** As on RichTextEditor. Does not affect round-trip bytes; accepted for parity. */
|
|
128
|
+
headingLevels?: ReadonlyArray<1 | 2 | 3>;
|
|
129
|
+
/** As on RichTextEditor. */
|
|
130
|
+
isSafeUrl?: (url: string) => boolean;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Load markdown into the RichTextEditor's document model and write it back, exactly as
|
|
134
|
+
* the editor does when a user opens a field and saves without editing it. Consumers
|
|
135
|
+
* use it to gate their own content corpus: every stored value should satisfy
|
|
136
|
+
* `await roundTripMarkdown(md) === md`.
|
|
137
|
+
*
|
|
138
|
+
* Runs without a DOM (Node, Vitest, Jest). Asynchronous so the pipeline can be loaded
|
|
139
|
+
* lazily in future versions without an API change.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* for (const article of corpus) {
|
|
143
|
+
* expect(await roundTripMarkdown(article.body)).toBe(article.body);
|
|
144
|
+
* }
|
|
145
|
+
*/
|
|
146
|
+
declare function roundTripMarkdown(markdown: string, options?: RoundTripOptions): Promise<string>;
|
|
147
|
+
|
|
148
|
+
export { DEFAULT_RICH_TEXT_LABELS, EmojiLocale, EmojiPickerLabels, RichTextEditor, RichTextEditorFallback, type RichTextEditorProps, type RichTextFeatures, type RichTextHeadingLevel, type RichTextLabels, type RoundTripOptions, roundTripMarkdown };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DEFAULT_RICH_TEXT_LABELS, RichTextEditor, RichTextEditorFallback, RichTextEditorProps, RichTextFeatures, RichTextHeadingLevel, RichTextLabels } from './components/RichTextEditor.js';
|
|
2
|
+
export { RoundTripOptions, roundTripMarkdown } from './rich-text/round-trip.js';
|
|
3
|
+
export { EmojiLocale } from './emoji-model.js';
|
|
4
|
+
export { EmojiPickerLabels } from './components/EmojiPicker.js';
|
|
5
|
+
export { emojiImageFileName } from './emoji-image.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '@tiptap/extension-emoji';
|
|
8
|
+
import './overlay-position.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RichTextEditor, RichTextEditorFallback, DEFAULT_RICH_TEXT_LABELS } from "./components/RichTextEditor.js";
|
|
2
|
+
import { roundTripMarkdown } from "./rich-text/round-trip.js";
|
|
3
|
+
import { emojiImageFileName } from "./emoji-image.js";
|
|
4
|
+
export {
|
|
5
|
+
DEFAULT_RICH_TEXT_LABELS,
|
|
6
|
+
RichTextEditor,
|
|
7
|
+
RichTextEditorFallback,
|
|
8
|
+
emojiImageFileName,
|
|
9
|
+
roundTripMarkdown
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allows http(s), mailto and same-app references (`/path`, `#anchor`, `./x`, `../x`).
|
|
3
|
+
* Browsers drop tabs and newlines inside URLs and read `\` as `/`, so those are removed
|
|
4
|
+
* or refused first: `//evil.test`, `/\evil.test` and `/<TAB>/evil.test` are not
|
|
5
|
+
* same-app paths.
|
|
6
|
+
*/
|
|
7
|
+
declare function defaultIsSafeUrl(url: string): boolean;
|
|
8
|
+
|
|
9
|
+
export { defaultIsSafeUrl };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const ALLOWED_START = /^(https?:|mailto:|\/|#|\.\/|\.\.\/)/i;
|
|
2
|
+
const CONTROL_OR_BACKSLASH = /[\x00-\x1f\x7f\\]/;
|
|
3
|
+
const PROTOCOL_RELATIVE = /^[/\\]{2}/;
|
|
4
|
+
function defaultIsSafeUrl(url) {
|
|
5
|
+
const candidate = url.replace(/[\t\n\r]/g, "").trim();
|
|
6
|
+
if (CONTROL_OR_BACKSLASH.test(candidate) || PROTOCOL_RELATIVE.test(candidate)) return false;
|
|
7
|
+
return ALLOWED_START.test(candidate);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
defaultIsSafeUrl
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tensor_1/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "Thin React wrappers over the UIx v2 CSS component library.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -31,6 +31,21 @@
|
|
|
31
31
|
"types": "./dist/chart-preset.d.ts",
|
|
32
32
|
"import": "./dist/chart-preset.js",
|
|
33
33
|
"require": "./dist/chart-preset.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./rich-text": {
|
|
36
|
+
"types": "./dist/rich-text.d.ts",
|
|
37
|
+
"import": "./dist/rich-text.js",
|
|
38
|
+
"require": "./dist/rich-text.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./markdown": {
|
|
41
|
+
"types": "./dist/markdown.d.ts",
|
|
42
|
+
"import": "./dist/markdown.js",
|
|
43
|
+
"require": "./dist/markdown.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./emoji": {
|
|
46
|
+
"types": "./dist/emoji.d.ts",
|
|
47
|
+
"import": "./dist/emoji.js",
|
|
48
|
+
"require": "./dist/emoji.cjs"
|
|
34
49
|
}
|
|
35
50
|
},
|
|
36
51
|
"scripts": {
|
|
@@ -42,20 +57,86 @@
|
|
|
42
57
|
"size": "node scripts/check-chart-preset-size.mjs"
|
|
43
58
|
},
|
|
44
59
|
"peerDependencies": {
|
|
60
|
+
"@tiptap/core": "3.31.3",
|
|
61
|
+
"@tiptap/extension-emoji": "3.31.3",
|
|
62
|
+
"@tiptap/extension-image": "3.31.3",
|
|
63
|
+
"@tiptap/extension-list": "3.31.3",
|
|
64
|
+
"@tiptap/extension-table": "3.31.3",
|
|
65
|
+
"@tiptap/extensions": "3.31.3",
|
|
66
|
+
"@tiptap/markdown": "3.31.3",
|
|
67
|
+
"@tiptap/pm": "3.31.3",
|
|
68
|
+
"@tiptap/react": "3.31.3",
|
|
69
|
+
"@tiptap/starter-kit": "3.31.3",
|
|
70
|
+
"@tiptap/suggestion": "3.31.3",
|
|
45
71
|
"echarts": "^5.6.0",
|
|
72
|
+
"emojibase-data": "17.0.0",
|
|
73
|
+
"marked": "17.0.6",
|
|
46
74
|
"react": "^18.0.0 || ^19.0.0",
|
|
47
75
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
48
76
|
},
|
|
49
77
|
"peerDependenciesMeta": {
|
|
78
|
+
"@tiptap/core": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@tiptap/extension-emoji": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"@tiptap/extension-image": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@tiptap/extension-list": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"@tiptap/extension-table": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"@tiptap/extensions": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@tiptap/markdown": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@tiptap/pm": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"@tiptap/react": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"@tiptap/starter-kit": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
"@tiptap/suggestion": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
50
111
|
"echarts": {
|
|
51
112
|
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"emojibase-data": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"marked": {
|
|
118
|
+
"optional": true
|
|
52
119
|
}
|
|
53
120
|
},
|
|
54
121
|
"devDependencies": {
|
|
122
|
+
"@tiptap/core": "3.31.3",
|
|
123
|
+
"@tiptap/extension-emoji": "3.31.3",
|
|
124
|
+
"@tiptap/extension-image": "3.31.3",
|
|
125
|
+
"@tiptap/extension-list": "3.31.3",
|
|
126
|
+
"@tiptap/extension-table": "3.31.3",
|
|
127
|
+
"@tiptap/extensions": "3.31.3",
|
|
128
|
+
"@tiptap/markdown": "3.31.3",
|
|
129
|
+
"@tiptap/pm": "3.31.3",
|
|
130
|
+
"@tiptap/react": "3.31.3",
|
|
131
|
+
"@tiptap/starter-kit": "3.31.3",
|
|
132
|
+
"@tiptap/suggestion": "3.31.3",
|
|
55
133
|
"@types/react": "^18.0.0",
|
|
56
134
|
"@types/react-dom": "^18.0.0",
|
|
57
135
|
"echarts": "^5.6.0",
|
|
136
|
+
"emojibase-data": "17.0.0",
|
|
58
137
|
"esbuild": "^0.27.0",
|
|
138
|
+
"jsdom": "30.1.0",
|
|
139
|
+
"marked": "17.0.6",
|
|
59
140
|
"tsup": "^8.0.0",
|
|
60
141
|
"typescript": "^5.0.0"
|
|
61
142
|
}
|