@retor/react-native 0.4.4 → 0.4.5
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/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +44 -8
- package/dist/index.mjs +46 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,8 @@ interface RetorTag {
|
|
|
23
23
|
avatarUrl?: string;
|
|
24
24
|
/** Display name of the note's author. Used for the initial-letter fallback when `avatarUrl` is absent. */
|
|
25
25
|
authorName?: string;
|
|
26
|
+
/** ID of the user who created this note. Compared against `Viewer.userId` to show the delete button. */
|
|
27
|
+
userId?: string;
|
|
26
28
|
}
|
|
27
29
|
interface RetorLine {
|
|
28
30
|
_id: string;
|
|
@@ -103,12 +105,16 @@ interface RetorBridgeContextValue {
|
|
|
103
105
|
lineNotes: RetorTag[];
|
|
104
106
|
/** Notes injected by the consumer via the <Notes> sentinel. */
|
|
105
107
|
externalNotes: RetorTag[];
|
|
108
|
+
/** The current user's ID — notes with a matching `userId` show a delete button. */
|
|
109
|
+
userId: string | null;
|
|
106
110
|
isAddNoteOpen: boolean;
|
|
107
111
|
addNoteTagId: string | null;
|
|
108
112
|
controls: ViewerHandle;
|
|
109
113
|
openAddNote: (tagId?: string) => void;
|
|
110
114
|
closeAddNote: () => void;
|
|
111
115
|
submitNote: (text: string, isPrivate?: boolean) => void;
|
|
116
|
+
/** Optimistically remove a note and fire the consumer's onNoteDelete callback. */
|
|
117
|
+
deleteNote: (noteId: string) => void;
|
|
112
118
|
}
|
|
113
119
|
declare function useRetorBridge(): RetorBridgeContextValue;
|
|
114
120
|
/** Returns the array of all lines in the current project. */
|
|
@@ -187,8 +193,12 @@ interface ViewerProps {
|
|
|
187
193
|
id?: string;
|
|
188
194
|
/** Base URL where Retor is hosted. Defaults to https://retor.app */
|
|
189
195
|
baseUrl?: string;
|
|
196
|
+
/** The current user's ID. When set, notes with a matching `userId` field show a delete button. */
|
|
197
|
+
userId?: string;
|
|
190
198
|
/** Called when a note is submitted via `<AddNoteSheet>`. Receives the text + position. */
|
|
191
199
|
onNoteSubmit?: (note: NoteSubmitPayload) => void;
|
|
200
|
+
/** Called when the user deletes a note. The note is optimistically removed from the list. */
|
|
201
|
+
onNoteDelete?: (noteId: string) => void;
|
|
192
202
|
onInit?: (data: InitPayload) => void;
|
|
193
203
|
onLineOpen?: (data: {
|
|
194
204
|
lineId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ interface RetorTag {
|
|
|
23
23
|
avatarUrl?: string;
|
|
24
24
|
/** Display name of the note's author. Used for the initial-letter fallback when `avatarUrl` is absent. */
|
|
25
25
|
authorName?: string;
|
|
26
|
+
/** ID of the user who created this note. Compared against `Viewer.userId` to show the delete button. */
|
|
27
|
+
userId?: string;
|
|
26
28
|
}
|
|
27
29
|
interface RetorLine {
|
|
28
30
|
_id: string;
|
|
@@ -103,12 +105,16 @@ interface RetorBridgeContextValue {
|
|
|
103
105
|
lineNotes: RetorTag[];
|
|
104
106
|
/** Notes injected by the consumer via the <Notes> sentinel. */
|
|
105
107
|
externalNotes: RetorTag[];
|
|
108
|
+
/** The current user's ID — notes with a matching `userId` show a delete button. */
|
|
109
|
+
userId: string | null;
|
|
106
110
|
isAddNoteOpen: boolean;
|
|
107
111
|
addNoteTagId: string | null;
|
|
108
112
|
controls: ViewerHandle;
|
|
109
113
|
openAddNote: (tagId?: string) => void;
|
|
110
114
|
closeAddNote: () => void;
|
|
111
115
|
submitNote: (text: string, isPrivate?: boolean) => void;
|
|
116
|
+
/** Optimistically remove a note and fire the consumer's onNoteDelete callback. */
|
|
117
|
+
deleteNote: (noteId: string) => void;
|
|
112
118
|
}
|
|
113
119
|
declare function useRetorBridge(): RetorBridgeContextValue;
|
|
114
120
|
/** Returns the array of all lines in the current project. */
|
|
@@ -187,8 +193,12 @@ interface ViewerProps {
|
|
|
187
193
|
id?: string;
|
|
188
194
|
/** Base URL where Retor is hosted. Defaults to https://retor.app */
|
|
189
195
|
baseUrl?: string;
|
|
196
|
+
/** The current user's ID. When set, notes with a matching `userId` field show a delete button. */
|
|
197
|
+
userId?: string;
|
|
190
198
|
/** Called when a note is submitted via `<AddNoteSheet>`. Receives the text + position. */
|
|
191
199
|
onNoteSubmit?: (note: NoteSubmitPayload) => void;
|
|
200
|
+
/** Called when the user deletes a note. The note is optimistically removed from the list. */
|
|
201
|
+
onNoteDelete?: (noteId: string) => void;
|
|
192
202
|
onInit?: (data: InitPayload) => void;
|
|
193
203
|
onLineOpen?: (data: {
|
|
194
204
|
lineId: string;
|
package/dist/index.js
CHANGED
|
@@ -78,12 +78,14 @@ var fallback = {
|
|
|
78
78
|
activeLine: null,
|
|
79
79
|
lineNotes: [],
|
|
80
80
|
externalNotes: [],
|
|
81
|
+
userId: null,
|
|
81
82
|
isAddNoteOpen: false,
|
|
82
83
|
addNoteTagId: null,
|
|
83
84
|
controls: noopHandle,
|
|
84
85
|
openAddNote: noop,
|
|
85
86
|
closeAddNote: noop,
|
|
86
|
-
submitNote: noop
|
|
87
|
+
submitNote: noop,
|
|
88
|
+
deleteNote: noop
|
|
87
89
|
};
|
|
88
90
|
function useRetorBridge() {
|
|
89
91
|
return (0, import_react.useContext)(RetorBridgeContext) ?? fallback;
|
|
@@ -205,7 +207,7 @@ function extractNotes(children) {
|
|
|
205
207
|
});
|
|
206
208
|
return notes;
|
|
207
209
|
}
|
|
208
|
-
var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "default", baseUrl = "https://retor.app", onNoteSubmit, onInit, onLineOpen, onLineClose, onLineProgress, onMessage, style, children }, ref) {
|
|
210
|
+
var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "default", baseUrl = "https://retor.app", userId = null, onNoteSubmit, onNoteDelete, onInit, onLineOpen, onLineClose, onLineProgress, onMessage, style, children }, ref) {
|
|
209
211
|
const webviewRef = (0, import_react2.useRef)(null);
|
|
210
212
|
const notes = extractNotes(children);
|
|
211
213
|
const readyRef = (0, import_react2.useRef)(false);
|
|
@@ -260,6 +262,7 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
|
|
|
260
262
|
const addNoteTagIdRef = (0, import_react2.useRef)(addNoteTagId);
|
|
261
263
|
const activeLineIdRef = (0, import_react2.useRef)(activeLineId);
|
|
262
264
|
const onNoteSubmitRef = (0, import_react2.useRef)(onNoteSubmit);
|
|
265
|
+
const onNoteDeleteRef = (0, import_react2.useRef)(onNoteDelete);
|
|
263
266
|
const noteSnapshotRef = (0, import_react2.useRef)({ progress: 0, targetPosition: null, distanceFromStart: null });
|
|
264
267
|
const progressRef = (0, import_react2.useRef)(progress);
|
|
265
268
|
const targetPositionRef = (0, import_react2.useRef)(targetPosition);
|
|
@@ -276,6 +279,9 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
|
|
|
276
279
|
(0, import_react2.useEffect)(() => {
|
|
277
280
|
onNoteSubmitRef.current = onNoteSubmit;
|
|
278
281
|
}, [onNoteSubmit]);
|
|
282
|
+
(0, import_react2.useEffect)(() => {
|
|
283
|
+
onNoteDeleteRef.current = onNoteDelete;
|
|
284
|
+
}, [onNoteDelete]);
|
|
279
285
|
(0, import_react2.useEffect)(() => {
|
|
280
286
|
progressRef.current = progress;
|
|
281
287
|
}, [progress]);
|
|
@@ -317,6 +323,10 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
|
|
|
317
323
|
}
|
|
318
324
|
setIsAddNoteOpen(false);
|
|
319
325
|
}, [send]);
|
|
326
|
+
const deleteNote = (0, import_react2.useCallback)((noteId) => {
|
|
327
|
+
setLineNotes((prev) => prev.filter((n) => n._id !== noteId));
|
|
328
|
+
onNoteDeleteRef.current?.(noteId);
|
|
329
|
+
}, []);
|
|
320
330
|
const handleMessage = (0, import_react2.useCallback)(
|
|
321
331
|
(event) => {
|
|
322
332
|
let data = null;
|
|
@@ -391,14 +401,16 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
|
|
|
391
401
|
activeLine,
|
|
392
402
|
lineNotes,
|
|
393
403
|
externalNotes,
|
|
404
|
+
userId,
|
|
394
405
|
isAddNoteOpen,
|
|
395
406
|
addNoteTagId,
|
|
396
407
|
controls,
|
|
397
408
|
openAddNote,
|
|
398
409
|
closeAddNote,
|
|
399
|
-
submitNote
|
|
410
|
+
submitNote,
|
|
411
|
+
deleteNote
|
|
400
412
|
}),
|
|
401
|
-
[project, lines, activeLineId, activeLine, lineNotes, externalNotes, isAddNoteOpen, addNoteTagId, controls, openAddNote, closeAddNote, submitNote]
|
|
413
|
+
[project, lines, activeLineId, activeLine, lineNotes, externalNotes, userId, isAddNoteOpen, addNoteTagId, controls, openAddNote, closeAddNote, submitNote, deleteNote]
|
|
402
414
|
);
|
|
403
415
|
const progressCtx = (0, import_react2.useMemo)(
|
|
404
416
|
() => ({ progress, closestTagId, targetPosition, distanceFromStart, isPlaying }),
|
|
@@ -727,14 +739,22 @@ function LineTagList({ children, listHeader }) {
|
|
|
727
739
|
contentContainerStyle: styles3.list
|
|
728
740
|
},
|
|
729
741
|
listHeader,
|
|
730
|
-
tags.map((tag
|
|
742
|
+
tags.map((tag, i) => {
|
|
743
|
+
const isNote = !!tag._isNote;
|
|
744
|
+
const prevIsNote = i > 0 && !!tags[i - 1]._isNote;
|
|
745
|
+
const showSep = isNote && !prevIsNote && i > 0 || !isNote && i > 0 && prevIsNote;
|
|
746
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.Fragment, { key: tag._id }, showSep && /* @__PURE__ */ import_react6.default.createElement(import_react_native5.View, { style: styles3.separator }), /* @__PURE__ */ import_react6.default.createElement(import_react_native5.View, { onLayout: (e) => handleItemLayout(tag._id, e) }, children(tag, tag._id === closestTagId)));
|
|
747
|
+
})
|
|
731
748
|
);
|
|
732
749
|
}
|
|
733
750
|
function DefaultLineTagList({ listHeader }) {
|
|
734
751
|
return /* @__PURE__ */ import_react6.default.createElement(LineTagList, { listHeader }, (tag, isActive) => /* @__PURE__ */ import_react6.default.createElement(DefaultTagItem, { tag, isActive }));
|
|
735
752
|
}
|
|
736
753
|
function DefaultTagItem({ tag, isActive }) {
|
|
737
|
-
const { controls, openAddNote } = useRetorBridge();
|
|
754
|
+
const { controls, openAddNote, userId, deleteNote } = useRetorBridge();
|
|
755
|
+
const isNote = !!tag._isNote;
|
|
756
|
+
const tagUserId = tag.userId;
|
|
757
|
+
const isOwn = !!userId && !!tagUserId && tagUserId === userId;
|
|
738
758
|
const initial = tag.authorName?.trim().charAt(0).toUpperCase();
|
|
739
759
|
const handlePress = () => {
|
|
740
760
|
if (typeof tag.progress === "number") controls.scrollToProgress(tag.progress);
|
|
@@ -747,9 +767,17 @@ function DefaultTagItem({ tag, isActive }) {
|
|
|
747
767
|
style: [styles3.tagItem, isActive && styles3.tagItemActive]
|
|
748
768
|
},
|
|
749
769
|
tag.avatarUrl ? /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Image, { source: { uri: tag.avatarUrl }, style: styles3.tagAvatar }) : initial ? /* @__PURE__ */ import_react6.default.createElement(import_react_native5.View, { style: styles3.tagInitial }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Text, { style: styles3.tagInitialText }, initial)) : null,
|
|
750
|
-
/* @__PURE__ */ import_react6.default.createElement(import_react_native5.View, { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Text, { style: [styles3.tagText, isActive && styles3.tagTextActive], numberOfLines: 1 }, tag.name), isActive && tag.description && /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Text, { style: styles3.tagDescription, numberOfLines: 2 }, tag.description)),
|
|
770
|
+
/* @__PURE__ */ import_react6.default.createElement(import_react_native5.View, { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Text, { style: [styles3.tagText, isActive && styles3.tagTextActive], numberOfLines: isNote ? 3 : 1 }, tag.name), isActive && tag.description && /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Text, { style: styles3.tagDescription, numberOfLines: 2 }, tag.description)),
|
|
751
771
|
tag.subtitle && /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Text, { style: styles3.tagSubtitle, numberOfLines: 1 }, tag.subtitle),
|
|
752
|
-
|
|
772
|
+
isNote && isOwn && /* @__PURE__ */ import_react6.default.createElement(
|
|
773
|
+
import_react_native5.Pressable,
|
|
774
|
+
{
|
|
775
|
+
onPress: () => deleteNote(tag._id),
|
|
776
|
+
style: styles3.deleteBtn
|
|
777
|
+
},
|
|
778
|
+
/* @__PURE__ */ import_react6.default.createElement(import_lucide_react_native2.Trash2, { size: 12, color: "rgba(255,255,255,0.4)" })
|
|
779
|
+
),
|
|
780
|
+
isActive && !isNote && /* @__PURE__ */ import_react6.default.createElement(
|
|
753
781
|
import_react_native5.Pressable,
|
|
754
782
|
{
|
|
755
783
|
onPress: (e) => {
|
|
@@ -806,10 +834,18 @@ var styles3 = import_react_native5.StyleSheet.create({
|
|
|
806
834
|
justifyContent: "center"
|
|
807
835
|
},
|
|
808
836
|
tagInitialText: { color: "white", fontSize: 11, fontWeight: "700" },
|
|
837
|
+
separator: { height: 1, backgroundColor: "rgba(255,255,255,0.1)", marginHorizontal: 20, marginVertical: 4 },
|
|
809
838
|
tagText: { color: "rgba(255,255,255,0.6)", fontSize: 13 },
|
|
810
839
|
tagTextActive: { color: "white", fontWeight: "600" },
|
|
811
840
|
tagDescription: { color: "rgba(255,255,255,0.4)", fontSize: 11, marginTop: 2, lineHeight: 14 },
|
|
812
841
|
tagSubtitle: { color: "rgba(255,255,255,0.4)", fontSize: 10 },
|
|
842
|
+
deleteBtn: {
|
|
843
|
+
width: 24,
|
|
844
|
+
height: 24,
|
|
845
|
+
borderRadius: 12,
|
|
846
|
+
alignItems: "center",
|
|
847
|
+
justifyContent: "center"
|
|
848
|
+
},
|
|
813
849
|
plusBtn: {
|
|
814
850
|
width: 24,
|
|
815
851
|
height: 24,
|
package/dist/index.mjs
CHANGED
|
@@ -25,12 +25,14 @@ var fallback = {
|
|
|
25
25
|
activeLine: null,
|
|
26
26
|
lineNotes: [],
|
|
27
27
|
externalNotes: [],
|
|
28
|
+
userId: null,
|
|
28
29
|
isAddNoteOpen: false,
|
|
29
30
|
addNoteTagId: null,
|
|
30
31
|
controls: noopHandle,
|
|
31
32
|
openAddNote: noop,
|
|
32
33
|
closeAddNote: noop,
|
|
33
|
-
submitNote: noop
|
|
34
|
+
submitNote: noop,
|
|
35
|
+
deleteNote: noop
|
|
34
36
|
};
|
|
35
37
|
function useRetorBridge() {
|
|
36
38
|
return useContext(RetorBridgeContext) ?? fallback;
|
|
@@ -161,7 +163,7 @@ function extractNotes(children) {
|
|
|
161
163
|
});
|
|
162
164
|
return notes;
|
|
163
165
|
}
|
|
164
|
-
var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl = "https://retor.app", onNoteSubmit, onInit, onLineOpen, onLineClose, onLineProgress, onMessage, style, children }, ref) {
|
|
166
|
+
var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl = "https://retor.app", userId = null, onNoteSubmit, onNoteDelete, onInit, onLineOpen, onLineClose, onLineProgress, onMessage, style, children }, ref) {
|
|
165
167
|
const webviewRef = useRef(null);
|
|
166
168
|
const notes = extractNotes(children);
|
|
167
169
|
const readyRef = useRef(false);
|
|
@@ -216,6 +218,7 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
|
|
|
216
218
|
const addNoteTagIdRef = useRef(addNoteTagId);
|
|
217
219
|
const activeLineIdRef = useRef(activeLineId);
|
|
218
220
|
const onNoteSubmitRef = useRef(onNoteSubmit);
|
|
221
|
+
const onNoteDeleteRef = useRef(onNoteDelete);
|
|
219
222
|
const noteSnapshotRef = useRef({ progress: 0, targetPosition: null, distanceFromStart: null });
|
|
220
223
|
const progressRef = useRef(progress);
|
|
221
224
|
const targetPositionRef = useRef(targetPosition);
|
|
@@ -232,6 +235,9 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
|
|
|
232
235
|
useEffect(() => {
|
|
233
236
|
onNoteSubmitRef.current = onNoteSubmit;
|
|
234
237
|
}, [onNoteSubmit]);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
onNoteDeleteRef.current = onNoteDelete;
|
|
240
|
+
}, [onNoteDelete]);
|
|
235
241
|
useEffect(() => {
|
|
236
242
|
progressRef.current = progress;
|
|
237
243
|
}, [progress]);
|
|
@@ -273,6 +279,10 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
|
|
|
273
279
|
}
|
|
274
280
|
setIsAddNoteOpen(false);
|
|
275
281
|
}, [send]);
|
|
282
|
+
const deleteNote = useCallback((noteId) => {
|
|
283
|
+
setLineNotes((prev) => prev.filter((n) => n._id !== noteId));
|
|
284
|
+
onNoteDeleteRef.current?.(noteId);
|
|
285
|
+
}, []);
|
|
276
286
|
const handleMessage = useCallback(
|
|
277
287
|
(event) => {
|
|
278
288
|
let data = null;
|
|
@@ -347,14 +357,16 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
|
|
|
347
357
|
activeLine,
|
|
348
358
|
lineNotes,
|
|
349
359
|
externalNotes,
|
|
360
|
+
userId,
|
|
350
361
|
isAddNoteOpen,
|
|
351
362
|
addNoteTagId,
|
|
352
363
|
controls,
|
|
353
364
|
openAddNote,
|
|
354
365
|
closeAddNote,
|
|
355
|
-
submitNote
|
|
366
|
+
submitNote,
|
|
367
|
+
deleteNote
|
|
356
368
|
}),
|
|
357
|
-
[project, lines, activeLineId, activeLine, lineNotes, externalNotes, isAddNoteOpen, addNoteTagId, controls, openAddNote, closeAddNote, submitNote]
|
|
369
|
+
[project, lines, activeLineId, activeLine, lineNotes, externalNotes, userId, isAddNoteOpen, addNoteTagId, controls, openAddNote, closeAddNote, submitNote, deleteNote]
|
|
358
370
|
);
|
|
359
371
|
const progressCtx = useMemo2(
|
|
360
372
|
() => ({ progress, closestTagId, targetPosition, distanceFromStart, isPlaying }),
|
|
@@ -532,7 +544,7 @@ var styles2 = StyleSheet4.create({
|
|
|
532
544
|
});
|
|
533
545
|
|
|
534
546
|
// src/LineDetailSheet.tsx
|
|
535
|
-
import React6, { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo4, useRef as useRef3, useState as useState3 } from "react";
|
|
547
|
+
import React6, { Fragment, useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo4, useRef as useRef3, useState as useState3 } from "react";
|
|
536
548
|
import { Image, Pressable as Pressable2, StyleSheet as StyleSheet5, Text as Text2, View as View5 } from "react-native";
|
|
537
549
|
import {
|
|
538
550
|
BottomSheetBackdrop as BottomSheetBackdrop2,
|
|
@@ -541,7 +553,7 @@ import {
|
|
|
541
553
|
BottomSheetScrollView
|
|
542
554
|
} from "@gorhom/bottom-sheet";
|
|
543
555
|
import Svg, { Circle } from "react-native-svg";
|
|
544
|
-
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, Pause, Play, Plus } from "lucide-react-native";
|
|
556
|
+
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, Pause, Play, Plus, Trash2 } from "lucide-react-native";
|
|
545
557
|
|
|
546
558
|
// src/lineProgress.ts
|
|
547
559
|
function mergeLineTagsByProgress(controls, notes) {
|
|
@@ -688,14 +700,22 @@ function LineTagList({ children, listHeader }) {
|
|
|
688
700
|
contentContainerStyle: styles3.list
|
|
689
701
|
},
|
|
690
702
|
listHeader,
|
|
691
|
-
tags.map((tag
|
|
703
|
+
tags.map((tag, i) => {
|
|
704
|
+
const isNote = !!tag._isNote;
|
|
705
|
+
const prevIsNote = i > 0 && !!tags[i - 1]._isNote;
|
|
706
|
+
const showSep = isNote && !prevIsNote && i > 0 || !isNote && i > 0 && prevIsNote;
|
|
707
|
+
return /* @__PURE__ */ React6.createElement(Fragment, { key: tag._id }, showSep && /* @__PURE__ */ React6.createElement(View5, { style: styles3.separator }), /* @__PURE__ */ React6.createElement(View5, { onLayout: (e) => handleItemLayout(tag._id, e) }, children(tag, tag._id === closestTagId)));
|
|
708
|
+
})
|
|
692
709
|
);
|
|
693
710
|
}
|
|
694
711
|
function DefaultLineTagList({ listHeader }) {
|
|
695
712
|
return /* @__PURE__ */ React6.createElement(LineTagList, { listHeader }, (tag, isActive) => /* @__PURE__ */ React6.createElement(DefaultTagItem, { tag, isActive }));
|
|
696
713
|
}
|
|
697
714
|
function DefaultTagItem({ tag, isActive }) {
|
|
698
|
-
const { controls, openAddNote } = useRetorBridge();
|
|
715
|
+
const { controls, openAddNote, userId, deleteNote } = useRetorBridge();
|
|
716
|
+
const isNote = !!tag._isNote;
|
|
717
|
+
const tagUserId = tag.userId;
|
|
718
|
+
const isOwn = !!userId && !!tagUserId && tagUserId === userId;
|
|
699
719
|
const initial = tag.authorName?.trim().charAt(0).toUpperCase();
|
|
700
720
|
const handlePress = () => {
|
|
701
721
|
if (typeof tag.progress === "number") controls.scrollToProgress(tag.progress);
|
|
@@ -708,9 +728,17 @@ function DefaultTagItem({ tag, isActive }) {
|
|
|
708
728
|
style: [styles3.tagItem, isActive && styles3.tagItemActive]
|
|
709
729
|
},
|
|
710
730
|
tag.avatarUrl ? /* @__PURE__ */ React6.createElement(Image, { source: { uri: tag.avatarUrl }, style: styles3.tagAvatar }) : initial ? /* @__PURE__ */ React6.createElement(View5, { style: styles3.tagInitial }, /* @__PURE__ */ React6.createElement(Text2, { style: styles3.tagInitialText }, initial)) : null,
|
|
711
|
-
/* @__PURE__ */ React6.createElement(View5, { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React6.createElement(Text2, { style: [styles3.tagText, isActive && styles3.tagTextActive], numberOfLines: 1 }, tag.name), isActive && tag.description && /* @__PURE__ */ React6.createElement(Text2, { style: styles3.tagDescription, numberOfLines: 2 }, tag.description)),
|
|
731
|
+
/* @__PURE__ */ React6.createElement(View5, { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React6.createElement(Text2, { style: [styles3.tagText, isActive && styles3.tagTextActive], numberOfLines: isNote ? 3 : 1 }, tag.name), isActive && tag.description && /* @__PURE__ */ React6.createElement(Text2, { style: styles3.tagDescription, numberOfLines: 2 }, tag.description)),
|
|
712
732
|
tag.subtitle && /* @__PURE__ */ React6.createElement(Text2, { style: styles3.tagSubtitle, numberOfLines: 1 }, tag.subtitle),
|
|
713
|
-
|
|
733
|
+
isNote && isOwn && /* @__PURE__ */ React6.createElement(
|
|
734
|
+
Pressable2,
|
|
735
|
+
{
|
|
736
|
+
onPress: () => deleteNote(tag._id),
|
|
737
|
+
style: styles3.deleteBtn
|
|
738
|
+
},
|
|
739
|
+
/* @__PURE__ */ React6.createElement(Trash2, { size: 12, color: "rgba(255,255,255,0.4)" })
|
|
740
|
+
),
|
|
741
|
+
isActive && !isNote && /* @__PURE__ */ React6.createElement(
|
|
714
742
|
Pressable2,
|
|
715
743
|
{
|
|
716
744
|
onPress: (e) => {
|
|
@@ -767,10 +795,18 @@ var styles3 = StyleSheet5.create({
|
|
|
767
795
|
justifyContent: "center"
|
|
768
796
|
},
|
|
769
797
|
tagInitialText: { color: "white", fontSize: 11, fontWeight: "700" },
|
|
798
|
+
separator: { height: 1, backgroundColor: "rgba(255,255,255,0.1)", marginHorizontal: 20, marginVertical: 4 },
|
|
770
799
|
tagText: { color: "rgba(255,255,255,0.6)", fontSize: 13 },
|
|
771
800
|
tagTextActive: { color: "white", fontWeight: "600" },
|
|
772
801
|
tagDescription: { color: "rgba(255,255,255,0.4)", fontSize: 11, marginTop: 2, lineHeight: 14 },
|
|
773
802
|
tagSubtitle: { color: "rgba(255,255,255,0.4)", fontSize: 10 },
|
|
803
|
+
deleteBtn: {
|
|
804
|
+
width: 24,
|
|
805
|
+
height: 24,
|
|
806
|
+
borderRadius: 12,
|
|
807
|
+
alignItems: "center",
|
|
808
|
+
justifyContent: "center"
|
|
809
|
+
},
|
|
774
810
|
plusBtn: {
|
|
775
811
|
width: 24,
|
|
776
812
|
height: 24,
|