@markput/react 0.5.0 → 0.7.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/index.css +2 -1
- package/index.d.ts +17 -19
- package/index.js +2681 -2183
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
.
|
|
1
|
+
._Container_1526r_1{min-height:1.4em}._Icon_1526r_5{background-color:currentColor;flex-shrink:0;width:14px;height:14px;display:inline-block;-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}._IconGrip_1526r_16{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='5' cy='3' r='1.5'/%3E%3Ccircle cx='11' cy='3' r='1.5'/%3E%3Ccircle cx='5' cy='8' r='1.5'/%3E%3Ccircle cx='11' cy='8' r='1.5'/%3E%3Ccircle cx='5' cy='13' r='1.5'/%3E%3Ccircle cx='11' cy='13' r='1.5'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='5' cy='3' r='1.5'/%3E%3Ccircle cx='11' cy='3' r='1.5'/%3E%3Ccircle cx='5' cy='8' r='1.5'/%3E%3Ccircle cx='11' cy='8' r='1.5'/%3E%3Ccircle cx='5' cy='13' r='1.5'/%3E%3Ccircle cx='11' cy='13' r='1.5'/%3E%3C/svg%3E")}._IconAdd_1526r_20,._IconDuplicate_1526r_21,._IconTrash_1526r_22{opacity:.75}._IconAdd_1526r_20{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2a.75.75 0 0 1 .75.75v4.5h4.5a.75.75 0 0 1 0 1.5h-4.5v4.5a.75.75 0 0 1-1.5 0v-4.5h-4.5a.75.75 0 0 1 0-1.5h4.5v-4.5A.75.75 0 0 1 8 2Z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2a.75.75 0 0 1 .75.75v4.5h4.5a.75.75 0 0 1 0 1.5h-4.5v4.5a.75.75 0 0 1-1.5 0v-4.5h-4.5a.75.75 0 0 1 0-1.5h4.5v-4.5A.75.75 0 0 1 8 2Z'/%3E%3C/svg%3E")}._IconDuplicate_1526r_21{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z'/%3E%3C/svg%3E")}._IconTrash_1526r_22{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z'/%3E%3C/svg%3E")}._Container_1526r_1 span{white-space:pre-wrap;outline:none}._Suggestions_1526r_43{filter:blur();opacity:1;visibility:visible;color:#000;background:#fff;border:1px solid #ccc;border-radius:4%;width:fit-content;min-width:100px;max-height:186px;margin-top:0;margin-bottom:0;padding-left:0;transition:all 1.1s ease-out;position:fixed;overflow-y:auto;transform:scale(1);box-shadow:0 3px 6px -2px #0009}._Suggestions_1526r_43 li{padding:.5rem}._Suggestions_1526r_43 li:hover,._suggestionActive_1526r_71{color:#2589f5;cursor:pointer;background-color:#cce9ff}
|
|
2
|
+
/*$vite$:1*/
|
package/index.d.ts
CHANGED
|
@@ -18,8 +18,6 @@ import type { OverlayTrigger } from '@markput/core';
|
|
|
18
18
|
import type { ReactNode } from 'react';
|
|
19
19
|
import type { Ref } from 'react';
|
|
20
20
|
import type { RefObject } from 'react';
|
|
21
|
-
import { reorderBlocks } from '@markput/core';
|
|
22
|
-
import { splitTokensIntoBlocks } from '@markput/core';
|
|
23
21
|
import { TextToken } from '@markput/core';
|
|
24
22
|
import { Token } from '@markput/core';
|
|
25
23
|
|
|
@@ -51,13 +49,15 @@ export declare function MarkedInput<TMarkProps = MarkProps, TOverlayProps = Over
|
|
|
51
49
|
export declare interface MarkedInputProps<TMarkProps = MarkProps, TOverlayProps = OverlayProps> {
|
|
52
50
|
/** Ref to handler */
|
|
53
51
|
ref?: Ref<MarkputHandler>;
|
|
54
|
-
/** Global component used for rendering
|
|
52
|
+
/** Global component used for rendering text tokens (default: built-in Span) */
|
|
53
|
+
Span?: ComponentType<MarkProps>;
|
|
54
|
+
/** Global component used for rendering markups (fallback for option.Mark) */
|
|
55
55
|
Mark?: ComponentType<TMarkProps>;
|
|
56
|
-
/** Global component used for rendering overlays (fallback for option.
|
|
56
|
+
/** Global component used for rendering overlays (fallback for option.Overlay) */
|
|
57
57
|
Overlay?: ComponentType<TOverlayProps>;
|
|
58
58
|
/**
|
|
59
59
|
* Configuration options for markups and overlays.
|
|
60
|
-
* Each option can specify its own
|
|
60
|
+
* Each option can specify its own component via option.Mark or option.Overlay.
|
|
61
61
|
* Falls back to global Mark/Overlay components when not specified.
|
|
62
62
|
*/
|
|
63
63
|
options?: Option_2<TMarkProps, TOverlayProps>[];
|
|
@@ -88,8 +88,13 @@ export declare interface MarkedInputProps<TMarkProps = MarkProps, TOverlayProps
|
|
|
88
88
|
onChange?: (value: string) => void;
|
|
89
89
|
/** Read-only mode */
|
|
90
90
|
readOnly?: boolean;
|
|
91
|
-
/** Enable
|
|
92
|
-
|
|
91
|
+
/** Enable drag mode: each individual token (mark or text) becomes its own draggable row.
|
|
92
|
+
* One mark per row, one text fragment per row.
|
|
93
|
+
* Adjacent marks need no separator; adjacent text rows are separated by `\n\n`.
|
|
94
|
+
*/
|
|
95
|
+
drag?: boolean | {
|
|
96
|
+
alwaysShowHandle: boolean;
|
|
97
|
+
};
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
export { MarkHandler }
|
|
@@ -98,14 +103,10 @@ export { MarkHandler }
|
|
|
98
103
|
* Props passed to Mark components.
|
|
99
104
|
*/
|
|
100
105
|
export declare interface MarkProps {
|
|
101
|
-
/** Custom component to render this mark */
|
|
102
|
-
slot?: ComponentType<MarkProps>;
|
|
103
106
|
/** Main content value of the mark */
|
|
104
107
|
value?: string;
|
|
105
108
|
/** Additional metadata for the mark */
|
|
106
109
|
meta?: string;
|
|
107
|
-
/** Nested content as string (raw, unparsed) */
|
|
108
|
-
nested?: string;
|
|
109
110
|
/** Rendered children content (ReactNode) for nested marks */
|
|
110
111
|
children?: ReactNode;
|
|
111
112
|
}
|
|
@@ -129,11 +130,15 @@ export { Markup }
|
|
|
129
130
|
* }
|
|
130
131
|
*/
|
|
131
132
|
declare interface Option_2<TMarkProps = MarkProps, TOverlayProps = OverlayProps> extends CoreOption {
|
|
133
|
+
/** Per-option component for rendering this mark */
|
|
134
|
+
Mark?: ComponentType<TMarkProps>;
|
|
132
135
|
/**
|
|
133
136
|
* Props for the mark component.
|
|
134
137
|
* Can be a static object or a function that transforms MarkProps.
|
|
135
138
|
*/
|
|
136
139
|
mark?: TMarkProps | ((props: MarkProps) => TMarkProps);
|
|
140
|
+
/** Per-option component for rendering this overlay */
|
|
141
|
+
Overlay?: ComponentType<TOverlayProps>;
|
|
137
142
|
/**
|
|
138
143
|
* Props for the overlay component.
|
|
139
144
|
*/
|
|
@@ -159,19 +164,14 @@ export declare interface OverlayHandler {
|
|
|
159
164
|
* Props for Overlay components.
|
|
160
165
|
*/
|
|
161
166
|
export declare interface OverlayProps {
|
|
162
|
-
/** Custom component to render this overlay */
|
|
163
|
-
slot?: ComponentType<OverlayProps>;
|
|
164
167
|
/** Trigger character(s) that activate the overlay */
|
|
165
168
|
trigger?: string;
|
|
166
169
|
/** Data array for suggestions/autocomplete */
|
|
167
170
|
data?: string[];
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
export { reorderBlocks }
|
|
171
|
-
|
|
172
173
|
declare interface SlotProps {
|
|
173
174
|
container?: HTMLAttributes<HTMLDivElement> & DataAttributes;
|
|
174
|
-
span?: HTMLAttributes<HTMLSpanElement> & DataAttributes;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/**
|
|
@@ -180,11 +180,9 @@ declare interface SlotProps {
|
|
|
180
180
|
declare interface Slots {
|
|
181
181
|
/** Root container component */
|
|
182
182
|
container?: ElementType<HTMLAttributes<HTMLDivElement>>;
|
|
183
|
-
/** Text span component for rendering text tokens */
|
|
184
|
-
span?: ElementType<HTMLAttributes<HTMLSpanElement>>;
|
|
185
183
|
}
|
|
186
184
|
|
|
187
|
-
export
|
|
185
|
+
export declare const Span: (_props: MarkProps) => JSX.Element;
|
|
188
186
|
|
|
189
187
|
export { TextToken }
|
|
190
188
|
|