@adminide-stack/yantra-mobile 12.0.141-alpha.1 → 12.0.141
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/lib/features/agent-chat/NativeAgentChat.js +21 -4
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/chat/ApprovalCard.js +353 -0
- package/lib/features/chat/ApprovalCard.js.map +1 -0
- package/lib/features/chat/AskUserCard.js +9 -2
- package/lib/features/chat/AskUserCard.js.map +1 -1
- package/lib/features/chat/askUser.js +25 -3
- package/lib/features/chat/askUser.js.map +1 -1
- package/lib/features/chat/queuedFollowUpRows.js +13 -0
- package/lib/features/chat/queuedFollowUpRows.js.map +1 -0
- package/lib/features/devices/bodyComposition.js +116 -0
- package/lib/features/devices/bodyComposition.js.map +1 -0
- package/lib/features/devices/readings.js.map +1 -1
- package/lib/features/devices/session.js +22 -2
- package/lib/features/devices/session.js.map +1 -1
- package/lib/features/discover/DiscoverArticle.js +105 -92
- package/lib/features/discover/DiscoverArticle.js.map +1 -1
- package/lib/features/discover/DiscoverFeed.js +97 -48
- package/lib/features/discover/DiscoverFeed.js.map +1 -1
- package/lib/features/discover/DiscoverFollowUp.js +135 -0
- package/lib/features/discover/DiscoverFollowUp.js.map +1 -0
- package/lib/features/discover/DiscoverSidebar.js +555 -0
- package/lib/features/discover/DiscoverSidebar.js.map +1 -0
- package/lib/features/discover/DiscoverSkeletons.js +123 -0
- package/lib/features/discover/DiscoverSkeletons.js.map +1 -0
- package/lib/features/discover/DiscoverStoryCards.js +193 -87
- package/lib/features/discover/DiscoverStoryCards.js.map +1 -1
- package/lib/features/discover/followUpQuery.js +42 -0
- package/lib/features/discover/followUpQuery.js.map +1 -0
- package/lib/features/discover/markets.js +37 -0
- package/lib/features/discover/markets.js.map +1 -0
- package/lib/features/discover/useDiscoverSidebar.js +148 -0
- package/lib/features/discover/useDiscoverSidebar.js.map +1 -0
- package/lib/features/discover/weather.js +42 -0
- package/lib/features/discover/weather.js.map +1 -0
- package/lib/features/expenses/ExpensesAgentChatPane.js +1 -1
- package/lib/features/expenses/ExpensesAgentChatPane.js.map +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js.map +1 -1
- package/lib/features/job-search/JobSearchAgentChatPane.js +1 -0
- package/lib/features/job-search/JobSearchAgentChatPane.js.map +1 -1
- package/lib/features/local-services/LocalServicesAgentChatPane.js +1 -1
- package/lib/features/local-services/LocalServicesAgentChatPane.js.map +1 -1
- package/lib/features/movies/MoviesAgentChatPane.js +1 -1
- package/lib/features/movies/MoviesAgentChatPane.js.map +1 -1
- package/lib/features/notion/NotionBlockSheets.js +206 -0
- package/lib/features/notion/NotionBlockSheets.js.map +1 -0
- package/lib/features/notion/NotionBlockView.js +36 -0
- package/lib/features/notion/NotionBlockView.js.map +1 -0
- package/lib/features/notion/NotionCommentsSheet.js +461 -0
- package/lib/features/notion/NotionCommentsSheet.js.map +1 -0
- package/lib/features/notion/NotionConnectionsSheet.js +244 -0
- package/lib/features/notion/NotionConnectionsSheet.js.map +1 -0
- package/lib/features/notion/NotionHistorySheet.js +439 -0
- package/lib/features/notion/NotionHistorySheet.js.map +1 -0
- package/lib/features/notion/NotionMediaBlocks.js +803 -0
- package/lib/features/notion/NotionMediaBlocks.js.map +1 -0
- package/lib/features/notion/NotionMentionSheet.js +279 -0
- package/lib/features/notion/NotionMentionSheet.js.map +1 -0
- package/lib/features/notion/NotionPageMenu.js +585 -0
- package/lib/features/notion/NotionPageMenu.js.map +1 -0
- package/lib/features/notion/NotionPageTree.js +220 -0
- package/lib/features/notion/NotionPageTree.js.map +1 -0
- package/lib/features/notion/NotionPageView.js +1253 -152
- package/lib/features/notion/NotionPageView.js.map +1 -1
- package/lib/features/notion/NotionShareSheet.js +606 -0
- package/lib/features/notion/NotionShareSheet.js.map +1 -0
- package/lib/features/notion/NotionSheets.js +87 -15
- package/lib/features/notion/NotionSheets.js.map +1 -1
- package/lib/features/notion/NotionSidebarSections.js +492 -0
- package/lib/features/notion/NotionSidebarSections.js.map +1 -0
- package/lib/features/notion/NotionWorkspaceAdmin.js +659 -0
- package/lib/features/notion/NotionWorkspaceAdmin.js.map +1 -0
- package/lib/features/notion/NotionWorkspaceView.js +257 -45
- package/lib/features/notion/NotionWorkspaceView.js.map +1 -1
- package/lib/features/notion/database/DatabaseCells.js +554 -0
- package/lib/features/notion/database/DatabaseCells.js.map +1 -0
- package/lib/features/notion/database/DatabaseDateLayouts.js +792 -0
- package/lib/features/notion/database/DatabaseDateLayouts.js.map +1 -0
- package/lib/features/notion/database/DatabaseLayouts.js +461 -0
- package/lib/features/notion/database/DatabaseLayouts.js.map +1 -0
- package/lib/features/notion/database/DatabaseSheets.js +791 -0
- package/lib/features/notion/database/DatabaseSheets.js.map +1 -0
- package/lib/features/notion/database/NotionDatabaseView.js +817 -0
- package/lib/features/notion/database/NotionDatabaseView.js.map +1 -0
- package/lib/features/notion/database/RowPropertiesPanel.js +162 -0
- package/lib/features/notion/database/RowPropertiesPanel.js.map +1 -0
- package/lib/features/notion/database/chartData.js +89 -0
- package/lib/features/notion/database/chartData.js.map +1 -0
- package/lib/features/notion/database/chartView.js +112 -0
- package/lib/features/notion/database/chartView.js.map +1 -0
- package/lib/features/notion/database/connectorButton.js +33 -0
- package/lib/features/notion/database/connectorButton.js.map +1 -0
- package/lib/features/notion/database/databaseCalc.js +208 -0
- package/lib/features/notion/database/databaseCalc.js.map +1 -0
- package/lib/features/notion/database/databaseCalendar.js +157 -0
- package/lib/features/notion/database/databaseCalendar.js.map +1 -0
- package/lib/features/notion/database/databaseCsv.js +98 -0
- package/lib/features/notion/database/databaseCsv.js.map +1 -0
- package/lib/features/notion/database/databaseCsvActions.js +58 -0
- package/lib/features/notion/database/databaseCsvActions.js.map +1 -0
- package/lib/features/notion/database/databaseFilter.js +473 -0
- package/lib/features/notion/database/databaseFilter.js.map +1 -0
- package/lib/features/notion/database/databaseFormula.js +1072 -0
- package/lib/features/notion/database/databaseFormula.js.map +1 -0
- package/lib/features/notion/database/databaseGroup.js +151 -0
- package/lib/features/notion/database/databaseGroup.js.map +1 -0
- package/lib/features/notion/database/databaseRollup.js +58 -0
- package/lib/features/notion/database/databaseRollup.js.map +1 -0
- package/lib/features/notion/database/databaseTimeline.js +156 -0
- package/lib/features/notion/database/databaseTimeline.js.map +1 -0
- package/lib/features/notion/database/databaseView.js +1188 -0
- package/lib/features/notion/database/databaseView.js.map +1 -0
- package/lib/features/notion/database/databaseViews.js +310 -0
- package/lib/features/notion/database/databaseViews.js.map +1 -0
- package/lib/features/notion/database/relationSource.js +92 -0
- package/lib/features/notion/database/relationSource.js.map +1 -0
- package/lib/features/notion/database/uniqueId.js +17 -0
- package/lib/features/notion/database/uniqueId.js.map +1 -0
- package/lib/features/notion/database/useNotionDatabase.js +617 -0
- package/lib/features/notion/database/useNotionDatabase.js.map +1 -0
- package/lib/features/notion/notionAgentRunStatus.js +39 -0
- package/lib/features/notion/notionAgentRunStatus.js.map +1 -0
- package/lib/features/notion/notionCodeLanguages.js +112 -0
- package/lib/features/notion/notionCodeLanguages.js.map +1 -0
- package/lib/features/notion/notionComments.js +86 -0
- package/lib/features/notion/notionComments.js.map +1 -0
- package/lib/features/notion/notionConnections.js +74 -0
- package/lib/features/notion/notionConnections.js.map +1 -0
- package/lib/features/notion/notionDocuments.js +453 -1
- package/lib/features/notion/notionDocuments.js.map +1 -1
- package/lib/features/notion/notionEditorModel.js +142 -7
- package/lib/features/notion/notionEditorModel.js.map +1 -1
- package/lib/features/notion/notionMarkdownShortcuts.js +51 -0
- package/lib/features/notion/notionMarkdownShortcuts.js.map +1 -0
- package/lib/features/notion/notionMedia.js +119 -0
- package/lib/features/notion/notionMedia.js.map +1 -0
- package/lib/features/notion/notionMentionDate.js +32 -0
- package/lib/features/notion/notionMentionDate.js.map +1 -0
- package/lib/features/notion/notionMentionOptions.js +162 -0
- package/lib/features/notion/notionMentionOptions.js.map +1 -0
- package/lib/features/notion/notionNotesAgent.js +445 -0
- package/lib/features/notion/notionNotesAgent.js.map +1 -0
- package/lib/features/notion/notionPageAccess.js +168 -0
- package/lib/features/notion/notionPageAccess.js.map +1 -0
- package/lib/features/notion/notionPageActions.js +138 -0
- package/lib/features/notion/notionPageActions.js.map +1 -0
- package/lib/features/notion/notionPageHistory.js +154 -0
- package/lib/features/notion/notionPageHistory.js.map +1 -0
- package/lib/features/notion/notionPageKinds.js +200 -0
- package/lib/features/notion/notionPageKinds.js.map +1 -0
- package/lib/features/notion/notionRecents.js +48 -0
- package/lib/features/notion/notionRecents.js.map +1 -0
- package/lib/features/notion/notionRichText.js +177 -0
- package/lib/features/notion/notionRichText.js.map +1 -0
- package/lib/features/notion/notionRichTitle.js +336 -0
- package/lib/features/notion/notionRichTitle.js.map +1 -0
- package/lib/features/notion/useNotionWorkspace.js +272 -13
- package/lib/features/notion/useNotionWorkspace.js.map +1 -1
- package/lib/features/notion/usePageActions.js +155 -0
- package/lib/features/notion/usePageActions.js.map +1 -0
- package/lib/features/resume/ResumeAgentChatPane.js +1 -1
- package/lib/features/resume/ResumeAgentChatPane.js.map +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
- package/lib/features/study/StudyAgentChatPane.js +1 -1
- package/lib/features/study/StudyAgentChatPane.js.map +1 -1
- package/lib/features/travel/TravelAgentChatPane.js +1 -1
- package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +40 -8
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +1 -1
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/codeFiles.js +302 -0
- package/lib/features/webbuilder/codeFiles.js.map +1 -0
- package/lib/features/webbuilder/codeHighlight.js +209 -0
- package/lib/features/webbuilder/codeHighlight.js.map +1 -0
- package/lib/features/webbuilder/components/CodeView.js +682 -52
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +59 -38
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +3 -3
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/stepLabels.js +68 -0
- package/lib/features/webbuilder/stepLabels.js.map +1 -0
- package/lib/hooks/useHostChatSteering.js +45 -0
- package/lib/hooks/useHostChatSteering.js.map +1 -0
- package/lib/screens/Chat/index.js +2 -12
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Devices/index.js +205 -3
- package/lib/screens/Devices/index.js.map +1 -1
- package/lib/screens/ExpensesNative/useExpensesHostChat.js +25 -5
- package/lib/screens/ExpensesNative/useExpensesHostChat.js.map +1 -1
- package/lib/screens/InboxNative/useInboxHostChat.js +25 -5
- package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -1
- package/lib/screens/JobSearchNative/useJobSearchHostChat.js +25 -5
- package/lib/screens/JobSearchNative/useJobSearchHostChat.js.map +1 -1
- package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js +25 -5
- package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js.map +1 -1
- package/lib/screens/MoviesNative/useMoviesHostChat.js +25 -5
- package/lib/screens/MoviesNative/useMoviesHostChat.js.map +1 -1
- package/lib/screens/NotionPage/index.js +2 -2
- package/lib/screens/NotionPage/index.js.map +1 -1
- package/lib/screens/ResumeNative/useResumeHostChat.js +25 -5
- package/lib/screens/ResumeNative/useResumeHostChat.js.map +1 -1
- package/lib/screens/ShoppingNative/useShoppingHostChat.js +25 -5
- package/lib/screens/ShoppingNative/useShoppingHostChat.js.map +1 -1
- package/lib/screens/StudyNative/useStudyHostChat.js +25 -5
- package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -1
- package/lib/screens/TravelNative/useTravelHostChat.js +25 -5
- package/lib/screens/TravelNative/useTravelHostChat.js.map +1 -1
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +222 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -0
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js +126 -4
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +120 -11
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import {useMemo,useState,useEffect,useCallback}from'react';import {View,ScrollView,StyleSheet,Pressable,TextInput,Text,ActivityIndicator,Alert}from'react-native';import {Ionicons}from'@expo/vector-icons';import {Image}from'expo-image';import {useApolloClient}from'@apollo/client/index.js';import {NATIVE_NOTION_OPEN_GRAPH,NATIVE_NOTION_CREATE_UPLOAD_LINK,NATIVE_NOTION_SAVE_UPLOADED_FILE,NATIVE_NOTION_RESOLVE_FILE_URL}from'./notionDocuments.js';import {tableRowsOf,setCell,addRow,addColumn,hostOf,mediaSourceOf,isStreamingSiteUrl,fileNameOf,sizeLabel,removeRow,removeColumn,contentTypeForS3Put,managedFileProps,externalProps}from'./notionMedia.js';const MEDIA_TYPES = ["image", "video", "audio", "file", "bookmark", "embed", "equation", "table"];
|
|
2
|
+
const REF_TYPE = {
|
|
3
|
+
image: "NotionImageBlock",
|
|
4
|
+
video: "NotionVideoBlock",
|
|
5
|
+
file: "NotionFileBlock",
|
|
6
|
+
audio: "NotionAudioBlock"
|
|
7
|
+
};
|
|
8
|
+
const MONO = "Menlo";
|
|
9
|
+
function useNotionUpload() {
|
|
10
|
+
const client = useApolloClient();
|
|
11
|
+
return useCallback(async (file, blockId, blockType) => {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
13
|
+
const refType = (_a = REF_TYPE[blockType]) != null ? _a : "NotionFileBlock";
|
|
14
|
+
const link = await client.mutate({
|
|
15
|
+
mutation: NATIVE_NOTION_CREATE_UPLOAD_LINK,
|
|
16
|
+
variables: {
|
|
17
|
+
input: {
|
|
18
|
+
filename: file.name,
|
|
19
|
+
ref: blockId,
|
|
20
|
+
refType
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
errorPolicy: "none"
|
|
24
|
+
});
|
|
25
|
+
const uploadUrl = (_c = (_b = link.data) == null ? void 0 : _b.createNotionUploadLink) == null ? void 0 : _c.uploadUrl;
|
|
26
|
+
if (!((_e = (_d = link.data) == null ? void 0 : _d.createNotionUploadLink) == null ? void 0 : _e.success) || !uploadUrl) {
|
|
27
|
+
throw new Error(((_g = (_f = link.data) == null ? void 0 : _f.createNotionUploadLink) == null ? void 0 : _g.message) || "Could not get an upload link");
|
|
28
|
+
}
|
|
29
|
+
const body = await (await fetch(file.uri)).blob();
|
|
30
|
+
const putType = contentTypeForS3Put(file.mimeType || "application/octet-stream", file.name);
|
|
31
|
+
const put = await fetch(uploadUrl, {
|
|
32
|
+
method: "PUT",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": putType
|
|
35
|
+
},
|
|
36
|
+
body
|
|
37
|
+
});
|
|
38
|
+
if (!put.ok) throw new Error(`Upload failed (${put.status})`);
|
|
39
|
+
const saved = await client.mutate({
|
|
40
|
+
mutation: NATIVE_NOTION_SAVE_UPLOADED_FILE,
|
|
41
|
+
variables: {
|
|
42
|
+
input: {
|
|
43
|
+
file: {
|
|
44
|
+
name: file.name,
|
|
45
|
+
url: uploadUrl.split("?")[0],
|
|
46
|
+
mimeType: putType.split(";")[0].trim(),
|
|
47
|
+
size: (_h = file.size) != null ? _h : body.size
|
|
48
|
+
},
|
|
49
|
+
ref: blockId,
|
|
50
|
+
refType
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
errorPolicy: "none"
|
|
54
|
+
});
|
|
55
|
+
const info = (_j = (_i = saved.data) == null ? void 0 : _i.saveNotionUploadedFile) == null ? void 0 : _j.fileInfo;
|
|
56
|
+
if (!((_l = (_k = saved.data) == null ? void 0 : _k.saveNotionUploadedFile) == null ? void 0 : _l.success) || !info) {
|
|
57
|
+
throw new Error(((_n = (_m = saved.data) == null ? void 0 : _m.saveNotionUploadedFile) == null ? void 0 : _n.message) || "Upload failed");
|
|
58
|
+
}
|
|
59
|
+
return managedFileProps(info);
|
|
60
|
+
}, [client]);
|
|
61
|
+
}
|
|
62
|
+
function useMediaUrl(props) {
|
|
63
|
+
const client = useApolloClient();
|
|
64
|
+
const source = mediaSourceOf(props);
|
|
65
|
+
const key = (source == null ? void 0 : source.kind) === "managed" ? source.key : null;
|
|
66
|
+
const [resolved, setResolved] = useState(null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!key) return void 0;
|
|
69
|
+
let alive = true;
|
|
70
|
+
client.query({
|
|
71
|
+
query: NATIVE_NOTION_RESOLVE_FILE_URL,
|
|
72
|
+
variables: {
|
|
73
|
+
s3KeyOrUrl: key,
|
|
74
|
+
expiresIn: 3600
|
|
75
|
+
},
|
|
76
|
+
fetchPolicy: "no-cache"
|
|
77
|
+
}).then((res) => {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
return alive && setResolved({
|
|
80
|
+
key,
|
|
81
|
+
url: (_b = (_a = res.data) == null ? void 0 : _a.resolveNotionFileUrl) != null ? _b : null
|
|
82
|
+
});
|
|
83
|
+
}).catch(() => alive && setResolved({
|
|
84
|
+
key,
|
|
85
|
+
url: null
|
|
86
|
+
}));
|
|
87
|
+
return () => {
|
|
88
|
+
alive = false;
|
|
89
|
+
};
|
|
90
|
+
}, [client, key]);
|
|
91
|
+
if (!source) return {
|
|
92
|
+
url: null,
|
|
93
|
+
loading: false
|
|
94
|
+
};
|
|
95
|
+
if (source.kind === "external") return {
|
|
96
|
+
url: source.url,
|
|
97
|
+
loading: false
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
url: (resolved == null ? void 0 : resolved.key) === key ? resolved.url : null,
|
|
101
|
+
loading: (resolved == null ? void 0 : resolved.key) !== key
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function pickMedia(kind) {
|
|
105
|
+
var _a;
|
|
106
|
+
const ImagePicker = require("expo-image-picker");
|
|
107
|
+
const permission = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
|
108
|
+
if (!permission.granted) throw new Error("Allow photo access in Settings to add media.");
|
|
109
|
+
const result = await ImagePicker.launchImageLibraryAsync({
|
|
110
|
+
mediaTypes: [kind === "image" ? "images" : "videos"],
|
|
111
|
+
quality: 0.85,
|
|
112
|
+
exif: false
|
|
113
|
+
});
|
|
114
|
+
const asset = result.canceled ? null : (_a = result.assets) == null ? void 0 : _a[0];
|
|
115
|
+
if (!(asset == null ? void 0 : asset.uri)) return null;
|
|
116
|
+
const ext = kind === "image" ? "jpg" : "mp4";
|
|
117
|
+
return {
|
|
118
|
+
uri: asset.uri,
|
|
119
|
+
name: asset.fileName || `${kind}-${Date.now()}.${ext}`,
|
|
120
|
+
mimeType: asset.mimeType || (kind === "image" ? "image/jpeg" : "video/mp4"),
|
|
121
|
+
size: asset.fileSize
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async function pickDocument(kind) {
|
|
125
|
+
var _a;
|
|
126
|
+
const DocumentPicker = require("expo-document-picker");
|
|
127
|
+
const result = await DocumentPicker.getDocumentAsync({
|
|
128
|
+
type: kind === "audio" ? "audio/*" : "*/*",
|
|
129
|
+
copyToCacheDirectory: true,
|
|
130
|
+
multiple: false
|
|
131
|
+
});
|
|
132
|
+
const asset = result.canceled ? null : (_a = result.assets) == null ? void 0 : _a[0];
|
|
133
|
+
if (!(asset == null ? void 0 : asset.uri)) return null;
|
|
134
|
+
return {
|
|
135
|
+
uri: asset.uri,
|
|
136
|
+
name: asset.name,
|
|
137
|
+
mimeType: asset.mimeType || "application/octet-stream",
|
|
138
|
+
size: asset.size
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function openInBrowser(url) {
|
|
142
|
+
const WebBrowser = require("expo-web-browser");
|
|
143
|
+
WebBrowser.openBrowserAsync(url).catch(() => void 0);
|
|
144
|
+
}
|
|
145
|
+
function MediaBlock({
|
|
146
|
+
block,
|
|
147
|
+
palette,
|
|
148
|
+
locked,
|
|
149
|
+
onPatch,
|
|
150
|
+
onCaption,
|
|
151
|
+
onMenu
|
|
152
|
+
}) {
|
|
153
|
+
const props = block.properties;
|
|
154
|
+
switch (block.type) {
|
|
155
|
+
case "image":
|
|
156
|
+
case "video":
|
|
157
|
+
case "audio":
|
|
158
|
+
case "file":
|
|
159
|
+
return /* @__PURE__ */ jsx(FileLikeBlock, { block, palette, locked, onPatch, onCaption, onMenu });
|
|
160
|
+
case "bookmark":
|
|
161
|
+
return /* @__PURE__ */ jsx(BookmarkBlock, { props, palette, locked, onPatch, onMenu });
|
|
162
|
+
case "embed":
|
|
163
|
+
return /* @__PURE__ */ jsx(EmbedBlock, { props, palette, locked, onPatch, onMenu });
|
|
164
|
+
case "equation":
|
|
165
|
+
return /* @__PURE__ */ jsx(EquationBlock, { props, palette, locked, onPatch, onMenu });
|
|
166
|
+
case "table":
|
|
167
|
+
return /* @__PURE__ */ jsx(TableBlock, { props, palette, locked, onPatch, onMenu });
|
|
168
|
+
default:
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const KIND_COPY = {
|
|
173
|
+
image: {
|
|
174
|
+
icon: "image-outline",
|
|
175
|
+
empty: "Add an image",
|
|
176
|
+
upload: "Upload photo"
|
|
177
|
+
},
|
|
178
|
+
video: {
|
|
179
|
+
icon: "videocam-outline",
|
|
180
|
+
empty: "Add a video",
|
|
181
|
+
upload: "Upload video"
|
|
182
|
+
},
|
|
183
|
+
audio: {
|
|
184
|
+
icon: "musical-notes-outline",
|
|
185
|
+
empty: "Add audio",
|
|
186
|
+
upload: "Upload audio"
|
|
187
|
+
},
|
|
188
|
+
file: {
|
|
189
|
+
icon: "document-attach-outline",
|
|
190
|
+
empty: "Add a file",
|
|
191
|
+
upload: "Upload file"
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
function FileLikeBlock({
|
|
195
|
+
block,
|
|
196
|
+
palette,
|
|
197
|
+
locked,
|
|
198
|
+
onPatch,
|
|
199
|
+
onCaption,
|
|
200
|
+
onMenu
|
|
201
|
+
}) {
|
|
202
|
+
var _a, _b, _c;
|
|
203
|
+
const upload = useNotionUpload();
|
|
204
|
+
const {
|
|
205
|
+
url,
|
|
206
|
+
loading
|
|
207
|
+
} = useMediaUrl(block.properties);
|
|
208
|
+
const [busy, setBusy] = useState(false);
|
|
209
|
+
const [linking, setLinking] = useState(false);
|
|
210
|
+
const [link, setLink] = useState("");
|
|
211
|
+
const [error, setError] = useState(null);
|
|
212
|
+
const copy = (_a = KIND_COPY[block.type]) != null ? _a : KIND_COPY.file;
|
|
213
|
+
const hasSource = Boolean(mediaSourceOf(block.properties));
|
|
214
|
+
const doUpload = async () => {
|
|
215
|
+
setError(null);
|
|
216
|
+
try {
|
|
217
|
+
const picked = block.type === "image" || block.type === "video" ? await pickMedia(block.type) : await pickDocument(block.type === "audio" ? "audio" : "file");
|
|
218
|
+
if (!picked) return;
|
|
219
|
+
setBusy(true);
|
|
220
|
+
onPatch(await upload(picked, block.id, block.type));
|
|
221
|
+
} catch (err) {
|
|
222
|
+
setError(err instanceof Error ? err.message : "Upload failed");
|
|
223
|
+
} finally {
|
|
224
|
+
setBusy(false);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const saveLink = () => {
|
|
228
|
+
const u = link.trim();
|
|
229
|
+
if (!/^https?:\/\//i.test(u)) {
|
|
230
|
+
setError("Enter a link that starts with http:// or https://");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
setLinking(false);
|
|
234
|
+
setError(null);
|
|
235
|
+
onPatch(externalProps(u));
|
|
236
|
+
};
|
|
237
|
+
if (!hasSource) {
|
|
238
|
+
return /* @__PURE__ */ jsxs(Pressable, { onLongPress: onMenu, style: [styles.emptyCard, {
|
|
239
|
+
backgroundColor: palette.fill
|
|
240
|
+
}], children: [
|
|
241
|
+
/* @__PURE__ */ jsxs(View, { style: styles.emptyHead, children: [
|
|
242
|
+
/* @__PURE__ */ jsx(Ionicons, { name: copy.icon, size: 20, color: palette.textMuted }),
|
|
243
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.emptyTitle, {
|
|
244
|
+
color: palette.textMuted
|
|
245
|
+
}], children: copy.empty })
|
|
246
|
+
] }),
|
|
247
|
+
locked ? null : linking ? /* @__PURE__ */ jsxs(View, { style: styles.linkRow, children: [
|
|
248
|
+
/* @__PURE__ */ jsx(TextInput, { value: link, onChangeText: setLink, placeholder: "Paste a link", placeholderTextColor: palette.textFaint, autoCapitalize: "none", autoCorrect: false, keyboardType: "url", autoFocus: true, onSubmitEditing: saveLink, style: [styles.linkInput, {
|
|
249
|
+
color: palette.text,
|
|
250
|
+
backgroundColor: palette.card
|
|
251
|
+
}] }),
|
|
252
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: saveLink, style: [styles.smallBtn, {
|
|
253
|
+
backgroundColor: palette.primary
|
|
254
|
+
}], children: /* @__PURE__ */ jsx(Text, { style: [styles.smallBtnLabel, {
|
|
255
|
+
color: palette.onPrimary
|
|
256
|
+
}], children: "Add" }) })
|
|
257
|
+
] }) : /* @__PURE__ */ jsxs(View, { style: styles.actionsRow, children: [
|
|
258
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: doUpload, disabled: busy, style: [styles.smallBtn, {
|
|
259
|
+
backgroundColor: palette.primary
|
|
260
|
+
}], children: busy ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: palette.onPrimary }) : /* @__PURE__ */ jsx(Text, { style: [styles.smallBtnLabel, {
|
|
261
|
+
color: palette.onPrimary
|
|
262
|
+
}], children: copy.upload }) }),
|
|
263
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => setLinking(true), style: [styles.smallBtn, {
|
|
264
|
+
backgroundColor: palette.card
|
|
265
|
+
}], children: /* @__PURE__ */ jsx(Text, { style: [styles.smallBtnLabel, {
|
|
266
|
+
color: palette.text
|
|
267
|
+
}], children: "Paste a link" }) })
|
|
268
|
+
] }),
|
|
269
|
+
error ? /* @__PURE__ */ jsx(Text, { style: [styles.error, {
|
|
270
|
+
color: palette.danger
|
|
271
|
+
}], children: error }) : null
|
|
272
|
+
] });
|
|
273
|
+
}
|
|
274
|
+
const caption = block.text.trim();
|
|
275
|
+
let body = null;
|
|
276
|
+
if (loading) {
|
|
277
|
+
body = /* @__PURE__ */ jsx(View, { style: [styles.loadingBox, {
|
|
278
|
+
backgroundColor: palette.fill
|
|
279
|
+
}], children: /* @__PURE__ */ jsx(ActivityIndicator, { color: palette.textMuted }) });
|
|
280
|
+
} else if (!url) {
|
|
281
|
+
body = /* @__PURE__ */ jsx(View, { style: [styles.loadingBox, {
|
|
282
|
+
backgroundColor: palette.fill
|
|
283
|
+
}], children: /* @__PURE__ */ jsxs(Text, { style: [styles.error, {
|
|
284
|
+
color: palette.textMuted
|
|
285
|
+
}], children: [
|
|
286
|
+
"Couldn't load this ",
|
|
287
|
+
block.type,
|
|
288
|
+
"."
|
|
289
|
+
] }) });
|
|
290
|
+
} else if (block.type === "image") {
|
|
291
|
+
body = /* @__PURE__ */ jsx(ImageView, { url });
|
|
292
|
+
} else if (block.type === "video") {
|
|
293
|
+
body = isStreamingSiteUrl(url) ? /* @__PURE__ */ jsx(LinkCard, { palette, icon: "play-circle-outline", title: hostOf(url), subtitle: "Opens in the browser", onPress: () => openInBrowser(url) }) : /* @__PURE__ */ jsx(VideoView, { url });
|
|
294
|
+
} else if (block.type === "audio") {
|
|
295
|
+
body = /* @__PURE__ */ jsx(AudioView, { url, palette, title: fileNameOf(block.properties) });
|
|
296
|
+
} else {
|
|
297
|
+
body = /* @__PURE__ */ jsx(LinkCard, { palette, icon: "document-attach-outline", title: fileNameOf(block.properties), subtitle: sizeLabel((_c = block.properties.size) != null ? _c : (_b = block.properties.file) == null ? void 0 : _b.size) || hostOf(url), onPress: () => openInBrowser(url) });
|
|
298
|
+
}
|
|
299
|
+
return /* @__PURE__ */ jsxs(Pressable, { onLongPress: onMenu, delayLongPress: 350, children: [
|
|
300
|
+
body,
|
|
301
|
+
caption || !locked ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: locked ? void 0 : onCaption, hitSlop: 4, children: /* @__PURE__ */ jsx(Text, { style: [styles.caption, {
|
|
302
|
+
color: caption ? palette.textMuted : palette.textFaint
|
|
303
|
+
}], children: caption || (block.type === "image" || block.type === "video" ? "Add a caption" : "") }) }) : null
|
|
304
|
+
] });
|
|
305
|
+
}
|
|
306
|
+
function ImageView({
|
|
307
|
+
url
|
|
308
|
+
}) {
|
|
309
|
+
const [ratio, setRatio] = useState(4 / 3);
|
|
310
|
+
return /* @__PURE__ */ jsx(Image, { source: {
|
|
311
|
+
uri: url
|
|
312
|
+
}, style: [styles.image, {
|
|
313
|
+
aspectRatio: ratio
|
|
314
|
+
}], contentFit: "contain", transition: 150, onLoad: (e) => {
|
|
315
|
+
const {
|
|
316
|
+
width,
|
|
317
|
+
height
|
|
318
|
+
} = e.source;
|
|
319
|
+
if (width && height) setRatio(width / height);
|
|
320
|
+
} });
|
|
321
|
+
}
|
|
322
|
+
function VideoView({
|
|
323
|
+
url
|
|
324
|
+
}) {
|
|
325
|
+
const ExpoVideo = require("expo-video");
|
|
326
|
+
const player = ExpoVideo.useVideoPlayer(url, (p) => {
|
|
327
|
+
p.loop = false;
|
|
328
|
+
});
|
|
329
|
+
return /* @__PURE__ */ jsx(ExpoVideo.VideoView, { player, style: styles.video, nativeControls: true, allowsFullscreen: true, contentFit: "contain" });
|
|
330
|
+
}
|
|
331
|
+
function AudioView({
|
|
332
|
+
url,
|
|
333
|
+
palette,
|
|
334
|
+
title
|
|
335
|
+
}) {
|
|
336
|
+
const ExpoAudio = require("expo-audio");
|
|
337
|
+
const player = ExpoAudio.useAudioPlayer(url);
|
|
338
|
+
const status = ExpoAudio.useAudioPlayerStatus(player);
|
|
339
|
+
const progress = status.duration ? Math.min(1, status.currentTime / status.duration) : 0;
|
|
340
|
+
const fmt = (s) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, "0")}`;
|
|
341
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles.audio, {
|
|
342
|
+
backgroundColor: palette.fill
|
|
343
|
+
}], children: [
|
|
344
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: status.playing ? "Pause" : "Play", onPress: () => {
|
|
345
|
+
if (status.playing) player.pause();
|
|
346
|
+
else {
|
|
347
|
+
if (status.duration && status.currentTime >= status.duration) player.seekTo(0);
|
|
348
|
+
player.play();
|
|
349
|
+
}
|
|
350
|
+
}, style: [styles.playBtn, {
|
|
351
|
+
backgroundColor: palette.primary
|
|
352
|
+
}], children: /* @__PURE__ */ jsx(Ionicons, { name: status.playing ? "pause" : "play", size: 18, color: palette.onPrimary }) }),
|
|
353
|
+
/* @__PURE__ */ jsxs(View, { style: styles.audioBody, children: [
|
|
354
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.audioTitle, {
|
|
355
|
+
color: palette.text
|
|
356
|
+
}], children: title }),
|
|
357
|
+
/* @__PURE__ */ jsx(View, { style: [styles.track, {
|
|
358
|
+
backgroundColor: palette.hairline
|
|
359
|
+
}], children: /* @__PURE__ */ jsx(View, { style: [styles.trackFill, {
|
|
360
|
+
width: `${progress * 100}%`,
|
|
361
|
+
backgroundColor: palette.primary
|
|
362
|
+
}] }) }),
|
|
363
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.audioTime, {
|
|
364
|
+
color: palette.textMuted
|
|
365
|
+
}], children: `${fmt(status.currentTime || 0)} / ${fmt(status.duration || 0)}` })
|
|
366
|
+
] })
|
|
367
|
+
] });
|
|
368
|
+
}
|
|
369
|
+
function LinkCard({
|
|
370
|
+
palette,
|
|
371
|
+
icon,
|
|
372
|
+
title,
|
|
373
|
+
subtitle,
|
|
374
|
+
image,
|
|
375
|
+
description,
|
|
376
|
+
onPress
|
|
377
|
+
}) {
|
|
378
|
+
return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "link", onPress, style: ({
|
|
379
|
+
pressed
|
|
380
|
+
}) => [styles.linkCard, {
|
|
381
|
+
borderColor: palette.hairline,
|
|
382
|
+
backgroundColor: pressed ? palette.pressed : palette.card
|
|
383
|
+
}], children: [
|
|
384
|
+
/* @__PURE__ */ jsxs(View, { style: styles.linkCardBody, children: [
|
|
385
|
+
/* @__PURE__ */ jsxs(View, { style: styles.linkCardHead, children: [
|
|
386
|
+
/* @__PURE__ */ jsx(Ionicons, { name: icon, size: 18, color: palette.textMuted }),
|
|
387
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: [styles.linkCardTitle, {
|
|
388
|
+
color: palette.text
|
|
389
|
+
}], children: title })
|
|
390
|
+
] }),
|
|
391
|
+
description ? /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: [styles.linkCardDesc, {
|
|
392
|
+
color: palette.textMuted
|
|
393
|
+
}], children: description }) : null,
|
|
394
|
+
subtitle ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.linkCardSub, {
|
|
395
|
+
color: palette.textFaint
|
|
396
|
+
}], children: subtitle }) : null
|
|
397
|
+
] }),
|
|
398
|
+
image ? /* @__PURE__ */ jsx(Image, { source: {
|
|
399
|
+
uri: image
|
|
400
|
+
}, style: styles.linkCardImage, contentFit: "cover" }) : null
|
|
401
|
+
] });
|
|
402
|
+
}
|
|
403
|
+
function UrlEntry({
|
|
404
|
+
palette,
|
|
405
|
+
placeholder,
|
|
406
|
+
onSave,
|
|
407
|
+
busy
|
|
408
|
+
}) {
|
|
409
|
+
const [value, setValue] = useState("");
|
|
410
|
+
const [error, setError] = useState(null);
|
|
411
|
+
const save = () => {
|
|
412
|
+
const raw = value.trim();
|
|
413
|
+
if (!raw) return;
|
|
414
|
+
const url = /^[a-z]+:\/\//i.test(raw) ? raw : `https://${raw}`;
|
|
415
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
416
|
+
setError("Enter a web link");
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
setError(null);
|
|
420
|
+
onSave(url);
|
|
421
|
+
};
|
|
422
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles.emptyCard, {
|
|
423
|
+
backgroundColor: palette.fill
|
|
424
|
+
}], children: [
|
|
425
|
+
/* @__PURE__ */ jsxs(View, { style: styles.linkRow, children: [
|
|
426
|
+
/* @__PURE__ */ jsx(TextInput, { value, onChangeText: setValue, placeholder, placeholderTextColor: palette.textFaint, autoCapitalize: "none", autoCorrect: false, keyboardType: "url", onSubmitEditing: save, style: [styles.linkInput, {
|
|
427
|
+
color: palette.text,
|
|
428
|
+
backgroundColor: palette.card
|
|
429
|
+
}] }),
|
|
430
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: save, disabled: busy, style: [styles.smallBtn, {
|
|
431
|
+
backgroundColor: palette.primary
|
|
432
|
+
}], children: busy ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: palette.onPrimary }) : /* @__PURE__ */ jsx(Text, { style: [styles.smallBtnLabel, {
|
|
433
|
+
color: palette.onPrimary
|
|
434
|
+
}], children: "Add" }) })
|
|
435
|
+
] }),
|
|
436
|
+
error ? /* @__PURE__ */ jsx(Text, { style: [styles.error, {
|
|
437
|
+
color: palette.danger
|
|
438
|
+
}], children: error }) : null
|
|
439
|
+
] });
|
|
440
|
+
}
|
|
441
|
+
function plain(value) {
|
|
442
|
+
if (typeof value === "string") return value;
|
|
443
|
+
if (Array.isArray(value)) return value.map((v) => {
|
|
444
|
+
var _a, _b, _c;
|
|
445
|
+
return (_c = (_b = v == null ? void 0 : v.plainText) != null ? _b : (_a = v == null ? void 0 : v.text) == null ? void 0 : _a.content) != null ? _c : "";
|
|
446
|
+
}).join("");
|
|
447
|
+
return "";
|
|
448
|
+
}
|
|
449
|
+
function BookmarkBlock({
|
|
450
|
+
props,
|
|
451
|
+
palette,
|
|
452
|
+
locked,
|
|
453
|
+
onPatch,
|
|
454
|
+
onMenu
|
|
455
|
+
}) {
|
|
456
|
+
var _a, _b;
|
|
457
|
+
const client = useApolloClient();
|
|
458
|
+
const [busy, setBusy] = useState(false);
|
|
459
|
+
const url = typeof props.url === "string" ? props.url : "";
|
|
460
|
+
const add = async (target) => {
|
|
461
|
+
var _a2, _b2, _c, _d;
|
|
462
|
+
setBusy(true);
|
|
463
|
+
onPatch({
|
|
464
|
+
url: target
|
|
465
|
+
});
|
|
466
|
+
try {
|
|
467
|
+
const res = await client.query({
|
|
468
|
+
query: NATIVE_NOTION_OPEN_GRAPH,
|
|
469
|
+
variables: {
|
|
470
|
+
url: target
|
|
471
|
+
},
|
|
472
|
+
fetchPolicy: "network-only"
|
|
473
|
+
});
|
|
474
|
+
const og = (_a2 = res.data) == null ? void 0 : _a2.fetchOpenGraph;
|
|
475
|
+
if (og) onPatch({
|
|
476
|
+
url: target,
|
|
477
|
+
title: (_b2 = og.title) != null ? _b2 : "",
|
|
478
|
+
description: (_c = og.description) != null ? _c : "",
|
|
479
|
+
image: (_d = og.image) != null ? _d : ""
|
|
480
|
+
});
|
|
481
|
+
} catch (e) {
|
|
482
|
+
} finally {
|
|
483
|
+
setBusy(false);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
if (!url) {
|
|
487
|
+
return locked ? null : /* @__PURE__ */ jsx(UrlEntry, { palette, placeholder: "Paste a link to bookmark", onSave: add, busy });
|
|
488
|
+
}
|
|
489
|
+
const image = typeof props.image === "string" ? props.image : typeof props.ogImage === "string" ? props.ogImage : null;
|
|
490
|
+
return /* @__PURE__ */ jsx(Pressable, { onLongPress: onMenu, delayLongPress: 350, children: /* @__PURE__ */ jsx(LinkCard, { palette, icon: "bookmark-outline", title: plain((_a = props.title) != null ? _a : props.ogTitle) || hostOf(url), description: plain((_b = props.description) != null ? _b : props.ogDescription), subtitle: url, image, onPress: () => openInBrowser(url) }) });
|
|
491
|
+
}
|
|
492
|
+
function EmbedBlock({
|
|
493
|
+
props,
|
|
494
|
+
palette,
|
|
495
|
+
locked,
|
|
496
|
+
onPatch,
|
|
497
|
+
onMenu
|
|
498
|
+
}) {
|
|
499
|
+
var _a, _b;
|
|
500
|
+
const url = typeof props.url === "string" ? props.url : "";
|
|
501
|
+
if (!url) {
|
|
502
|
+
if (props.embedType && props.embedType !== "url") {
|
|
503
|
+
return /* @__PURE__ */ jsx(Pressable, { onLongPress: onMenu, style: [styles.emptyCard, {
|
|
504
|
+
backgroundColor: palette.fill
|
|
505
|
+
}], children: /* @__PURE__ */ jsxs(View, { style: styles.emptyHead, children: [
|
|
506
|
+
/* @__PURE__ */ jsx(Ionicons, { name: "apps-outline", size: 18, color: palette.textMuted }),
|
|
507
|
+
/* @__PURE__ */ jsxs(Text, { style: [styles.emptyTitle, {
|
|
508
|
+
color: palette.textMuted
|
|
509
|
+
}], children: [
|
|
510
|
+
String((_b = (_a = props.fieldSchema) == null ? void 0 : _a.title) != null ? _b : "Widget"),
|
|
511
|
+
" \xB7 open on the web"
|
|
512
|
+
] })
|
|
513
|
+
] }) });
|
|
514
|
+
}
|
|
515
|
+
return locked ? null : /* @__PURE__ */ jsx(UrlEntry, { palette, placeholder: "Paste a link to embed", onSave: (u) => onPatch({
|
|
516
|
+
embedType: "url",
|
|
517
|
+
url: u
|
|
518
|
+
}) });
|
|
519
|
+
}
|
|
520
|
+
return /* @__PURE__ */ jsx(Pressable, { onLongPress: onMenu, delayLongPress: 350, children: /* @__PURE__ */ jsx(LinkCard, { palette, icon: "globe-outline", title: hostOf(url), subtitle: "Embed \xB7 opens in the browser", onPress: () => openInBrowser(url) }) });
|
|
521
|
+
}
|
|
522
|
+
function EquationBlock({
|
|
523
|
+
props,
|
|
524
|
+
palette,
|
|
525
|
+
locked,
|
|
526
|
+
onPatch,
|
|
527
|
+
onMenu
|
|
528
|
+
}) {
|
|
529
|
+
var _a;
|
|
530
|
+
const expression = String((_a = props.expression) != null ? _a : "");
|
|
531
|
+
const [draft, setDraft] = useState(expression);
|
|
532
|
+
useEffect(() => setDraft(expression), [expression]);
|
|
533
|
+
return /* @__PURE__ */ jsxs(Pressable, { onLongPress: onMenu, delayLongPress: 350, style: [styles.equation, {
|
|
534
|
+
backgroundColor: palette.fill
|
|
535
|
+
}], children: [
|
|
536
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.equationLabel, {
|
|
537
|
+
color: palette.textMuted
|
|
538
|
+
}], children: "TeX" }),
|
|
539
|
+
/* @__PURE__ */ jsx(TextInput, { value: draft, onChangeText: setDraft, onBlur: () => draft !== expression && onPatch({
|
|
540
|
+
expression: draft
|
|
541
|
+
}), editable: !locked, multiline: true, placeholder: "E = mc^2", placeholderTextColor: palette.textFaint, autoCapitalize: "none", autoCorrect: false, style: [styles.equationInput, {
|
|
542
|
+
color: palette.text
|
|
543
|
+
}] })
|
|
544
|
+
] });
|
|
545
|
+
}
|
|
546
|
+
function TableBlock({
|
|
547
|
+
props,
|
|
548
|
+
palette,
|
|
549
|
+
locked,
|
|
550
|
+
onPatch,
|
|
551
|
+
onMenu
|
|
552
|
+
}) {
|
|
553
|
+
const saved = useMemo(() => tableRowsOf(props), [props]);
|
|
554
|
+
const [rows, setRows] = useState(saved);
|
|
555
|
+
useEffect(() => setRows(saved), [saved]);
|
|
556
|
+
const header = props.hasHeaderRow === true;
|
|
557
|
+
const commit = (next) => {
|
|
558
|
+
setRows(next);
|
|
559
|
+
onPatch({
|
|
560
|
+
rows: next
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
const cellMenu = (r, c) => {
|
|
564
|
+
if (locked) return;
|
|
565
|
+
Alert.alert("Table", void 0, [{
|
|
566
|
+
text: "Add row",
|
|
567
|
+
onPress: () => commit(addRow(rows))
|
|
568
|
+
}, {
|
|
569
|
+
text: "Add column",
|
|
570
|
+
onPress: () => commit(addColumn(rows))
|
|
571
|
+
}, {
|
|
572
|
+
text: header ? "Remove header row" : "Header row",
|
|
573
|
+
onPress: () => onPatch({
|
|
574
|
+
hasHeaderRow: !header
|
|
575
|
+
})
|
|
576
|
+
}, {
|
|
577
|
+
text: "Delete row",
|
|
578
|
+
style: "destructive",
|
|
579
|
+
onPress: () => commit(removeRow(rows, r))
|
|
580
|
+
}, {
|
|
581
|
+
text: "Delete column",
|
|
582
|
+
style: "destructive",
|
|
583
|
+
onPress: () => commit(removeColumn(rows, c))
|
|
584
|
+
}, ...onMenu ? [{
|
|
585
|
+
text: "Block actions\u2026",
|
|
586
|
+
onPress: onMenu
|
|
587
|
+
}] : [], {
|
|
588
|
+
text: "Cancel",
|
|
589
|
+
style: "cancel"
|
|
590
|
+
}]);
|
|
591
|
+
};
|
|
592
|
+
return /* @__PURE__ */ jsxs(View, { children: [
|
|
593
|
+
/* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsx(View, { style: [styles.table, {
|
|
594
|
+
borderColor: palette.hairline
|
|
595
|
+
}], children: rows.map((row, r) => (
|
|
596
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
597
|
+
/* @__PURE__ */ jsx(View, { style: [styles.tableRow, header && r === 0 && {
|
|
598
|
+
backgroundColor: palette.fill
|
|
599
|
+
}], children: row.map((cell, c) => (
|
|
600
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
601
|
+
/* @__PURE__ */ jsx(Pressable, { onLongPress: () => cellMenu(r, c), delayLongPress: 350, children: /* @__PURE__ */ jsx(TextInput, { value: cell, onChangeText: (v) => setRows((cur) => setCell(cur, r, c, v)), onBlur: () => {
|
|
602
|
+
if (rows !== saved) onPatch({
|
|
603
|
+
rows
|
|
604
|
+
});
|
|
605
|
+
}, editable: !locked, multiline: true, style: [styles.cell, {
|
|
606
|
+
color: palette.text,
|
|
607
|
+
borderColor: palette.hairline
|
|
608
|
+
}, header && r === 0 && styles.headerCell] }) }, c)
|
|
609
|
+
)) }, r)
|
|
610
|
+
)) }) }),
|
|
611
|
+
locked ? null : /* @__PURE__ */ jsxs(View, { style: styles.tableActions, children: [
|
|
612
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => commit(addRow(rows)), hitSlop: 6, children: /* @__PURE__ */ jsx(Text, { style: [styles.tableAction, {
|
|
613
|
+
color: palette.primary
|
|
614
|
+
}], children: "+ Row" }) }),
|
|
615
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => commit(addColumn(rows)), hitSlop: 6, children: /* @__PURE__ */ jsx(Text, { style: [styles.tableAction, {
|
|
616
|
+
color: palette.primary
|
|
617
|
+
}], children: "+ Column" }) }),
|
|
618
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.tableHint, {
|
|
619
|
+
color: palette.textFaint
|
|
620
|
+
}], children: "Long-press a cell for more" })
|
|
621
|
+
] })
|
|
622
|
+
] });
|
|
623
|
+
}
|
|
624
|
+
const styles = StyleSheet.create({
|
|
625
|
+
emptyCard: {
|
|
626
|
+
borderRadius: 12,
|
|
627
|
+
padding: 14,
|
|
628
|
+
gap: 10
|
|
629
|
+
},
|
|
630
|
+
emptyHead: {
|
|
631
|
+
flexDirection: "row",
|
|
632
|
+
alignItems: "center",
|
|
633
|
+
gap: 8
|
|
634
|
+
},
|
|
635
|
+
emptyTitle: {
|
|
636
|
+
fontSize: 15,
|
|
637
|
+
fontWeight: "600"
|
|
638
|
+
},
|
|
639
|
+
actionsRow: {
|
|
640
|
+
flexDirection: "row",
|
|
641
|
+
gap: 8,
|
|
642
|
+
flexWrap: "wrap"
|
|
643
|
+
},
|
|
644
|
+
linkRow: {
|
|
645
|
+
flexDirection: "row",
|
|
646
|
+
gap: 8,
|
|
647
|
+
alignItems: "center"
|
|
648
|
+
},
|
|
649
|
+
linkInput: {
|
|
650
|
+
flex: 1,
|
|
651
|
+
height: 40,
|
|
652
|
+
paddingHorizontal: 12,
|
|
653
|
+
borderRadius: 10,
|
|
654
|
+
fontSize: 15
|
|
655
|
+
},
|
|
656
|
+
smallBtn: {
|
|
657
|
+
minHeight: 38,
|
|
658
|
+
paddingHorizontal: 14,
|
|
659
|
+
borderRadius: 10,
|
|
660
|
+
alignItems: "center",
|
|
661
|
+
justifyContent: "center"
|
|
662
|
+
},
|
|
663
|
+
smallBtnLabel: {
|
|
664
|
+
fontSize: 14,
|
|
665
|
+
fontWeight: "700"
|
|
666
|
+
},
|
|
667
|
+
error: {
|
|
668
|
+
fontSize: 13
|
|
669
|
+
},
|
|
670
|
+
loadingBox: {
|
|
671
|
+
height: 160,
|
|
672
|
+
borderRadius: 12,
|
|
673
|
+
alignItems: "center",
|
|
674
|
+
justifyContent: "center"
|
|
675
|
+
},
|
|
676
|
+
image: {
|
|
677
|
+
width: "100%",
|
|
678
|
+
borderRadius: 10
|
|
679
|
+
},
|
|
680
|
+
video: {
|
|
681
|
+
width: "100%",
|
|
682
|
+
aspectRatio: 16 / 9,
|
|
683
|
+
borderRadius: 10,
|
|
684
|
+
backgroundColor: "#000"
|
|
685
|
+
},
|
|
686
|
+
caption: {
|
|
687
|
+
fontSize: 13,
|
|
688
|
+
marginTop: 6
|
|
689
|
+
},
|
|
690
|
+
audio: {
|
|
691
|
+
flexDirection: "row",
|
|
692
|
+
alignItems: "center",
|
|
693
|
+
gap: 12,
|
|
694
|
+
padding: 12,
|
|
695
|
+
borderRadius: 12
|
|
696
|
+
},
|
|
697
|
+
playBtn: {
|
|
698
|
+
width: 40,
|
|
699
|
+
height: 40,
|
|
700
|
+
borderRadius: 20,
|
|
701
|
+
alignItems: "center",
|
|
702
|
+
justifyContent: "center"
|
|
703
|
+
},
|
|
704
|
+
audioBody: {
|
|
705
|
+
flex: 1,
|
|
706
|
+
gap: 6
|
|
707
|
+
},
|
|
708
|
+
audioTitle: {
|
|
709
|
+
fontSize: 14,
|
|
710
|
+
fontWeight: "600"
|
|
711
|
+
},
|
|
712
|
+
track: {
|
|
713
|
+
height: 4,
|
|
714
|
+
borderRadius: 2,
|
|
715
|
+
overflow: "hidden"
|
|
716
|
+
},
|
|
717
|
+
trackFill: {
|
|
718
|
+
height: 4
|
|
719
|
+
},
|
|
720
|
+
audioTime: {
|
|
721
|
+
fontSize: 11
|
|
722
|
+
},
|
|
723
|
+
linkCard: {
|
|
724
|
+
flexDirection: "row",
|
|
725
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
726
|
+
borderRadius: 12,
|
|
727
|
+
overflow: "hidden"
|
|
728
|
+
},
|
|
729
|
+
linkCardBody: {
|
|
730
|
+
flex: 1,
|
|
731
|
+
padding: 12,
|
|
732
|
+
gap: 4
|
|
733
|
+
},
|
|
734
|
+
linkCardHead: {
|
|
735
|
+
flexDirection: "row",
|
|
736
|
+
alignItems: "center",
|
|
737
|
+
gap: 8
|
|
738
|
+
},
|
|
739
|
+
linkCardTitle: {
|
|
740
|
+
flex: 1,
|
|
741
|
+
fontSize: 15,
|
|
742
|
+
fontWeight: "600"
|
|
743
|
+
},
|
|
744
|
+
linkCardDesc: {
|
|
745
|
+
fontSize: 13,
|
|
746
|
+
lineHeight: 18
|
|
747
|
+
},
|
|
748
|
+
linkCardSub: {
|
|
749
|
+
fontSize: 12
|
|
750
|
+
},
|
|
751
|
+
linkCardImage: {
|
|
752
|
+
width: 96
|
|
753
|
+
},
|
|
754
|
+
equation: {
|
|
755
|
+
borderRadius: 10,
|
|
756
|
+
padding: 12,
|
|
757
|
+
gap: 4
|
|
758
|
+
},
|
|
759
|
+
equationLabel: {
|
|
760
|
+
fontSize: 10,
|
|
761
|
+
fontWeight: "800",
|
|
762
|
+
letterSpacing: 0.6
|
|
763
|
+
},
|
|
764
|
+
equationInput: {
|
|
765
|
+
fontFamily: MONO,
|
|
766
|
+
fontSize: 15,
|
|
767
|
+
padding: 0,
|
|
768
|
+
minHeight: 24
|
|
769
|
+
},
|
|
770
|
+
table: {
|
|
771
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
772
|
+
borderLeftWidth: StyleSheet.hairlineWidth
|
|
773
|
+
},
|
|
774
|
+
tableRow: {
|
|
775
|
+
flexDirection: "row"
|
|
776
|
+
},
|
|
777
|
+
cell: {
|
|
778
|
+
width: 140,
|
|
779
|
+
minHeight: 40,
|
|
780
|
+
paddingHorizontal: 8,
|
|
781
|
+
paddingVertical: 8,
|
|
782
|
+
fontSize: 14,
|
|
783
|
+
borderRightWidth: StyleSheet.hairlineWidth,
|
|
784
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
785
|
+
},
|
|
786
|
+
headerCell: {
|
|
787
|
+
fontWeight: "700"
|
|
788
|
+
},
|
|
789
|
+
tableActions: {
|
|
790
|
+
flexDirection: "row",
|
|
791
|
+
alignItems: "center",
|
|
792
|
+
gap: 16,
|
|
793
|
+
marginTop: 8
|
|
794
|
+
},
|
|
795
|
+
tableAction: {
|
|
796
|
+
fontSize: 14,
|
|
797
|
+
fontWeight: "700"
|
|
798
|
+
},
|
|
799
|
+
tableHint: {
|
|
800
|
+
fontSize: 12,
|
|
801
|
+
marginLeft: "auto"
|
|
802
|
+
}
|
|
803
|
+
});export{MEDIA_TYPES,MediaBlock,useNotionUpload};//# sourceMappingURL=NotionMediaBlocks.js.map
|