-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kévin Commaille
committed
Jan 18, 2021
1 parent
f3fbe13
commit b429435
Showing
9 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import * as Etebase from "etebase"; | ||
import { Share } from "react-native"; | ||
import { getItemData } from "./utils"; | ||
|
||
export function canExport() { | ||
return false; | ||
return true; | ||
} | ||
|
||
export async function exportItem(item: Etebase.Item) { | ||
const { name } = item.getMeta(); | ||
throw Error(`Cannot export item "${name}". Exporting is not implemented on this Platform`); | ||
const { name, content } = await getItemData(item, "export"); | ||
|
||
await Share.share({ | ||
message: content, | ||
title: name, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./export"; | ||
export * from "./share"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
import * as Etebase from "etebase"; | ||
import YAML from "js-yaml"; | ||
|
||
export async function getItemData(item: Etebase.Item) { | ||
const { name } = item.getMeta(); | ||
const content = await item.getContent(Etebase.OutputFormat.String); | ||
return { | ||
name, | ||
content, | ||
export async function getItemData(item: Etebase.Item, format = "") { | ||
const data = { | ||
name: item.getMeta().name, | ||
content: "", | ||
}; | ||
const content = await item.getContent(Etebase.OutputFormat.String); | ||
|
||
switch (format) { | ||
case "export": { | ||
const frontmatter = YAML.dump({ title: data.name }); | ||
data.content = `---\n${frontmatter}---\n\n${content}`; | ||
break; | ||
} | ||
default: { | ||
data.content = `# ${data.name}\n\n${content}`; | ||
} | ||
} | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters