mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
JS-3345: Soundcloud + refactoring
This commit is contained in:
parent
c756c10d4b
commit
3d636b42e4
8 changed files with 117 additions and 38 deletions
17
electron.js
17
electron.js
|
@ -21,17 +21,12 @@ const WindowManager = require('./electron/js/window.js');
|
|||
const Server = require('./electron/js/server.js');
|
||||
const Util = require('./electron/js/util.js');
|
||||
|
||||
const csp = [
|
||||
`default-src 'self' 'unsafe-eval' blob: http://localhost:*`,
|
||||
`img-src 'self' http://*:* https://*:* data: blob: file://*`,
|
||||
`media-src 'self' http://*:* https://*:* data: blob: file://* https://*.googlevideo.com`,
|
||||
`style-src 'unsafe-inline' http://localhost:* file://* https://*.youtube.com/ https://*.vimeocdn.com`,
|
||||
`font-src data: file://* http://localhost:* https://*.youtube.com/ https://*.vimeocdn.com`,
|
||||
`connect-src file://* http://localhost:* http://127.0.0.1:* ws://localhost:* https://*.anytype.io https://api.amplitude.com/ devtools://devtools data: https://*.youtube.com/ https://*.vimeocdn.com/ https://*.vimeo.com/ https://*.googlevideo.com https://*.akamaized.net`,
|
||||
`script-src-elem file: http://localhost:* https://sentry.io devtools://devtools 'unsafe-inline' https://*.youtube.com/ https://*.vimeocdn.com https://*.gstatic.com/`,
|
||||
`frame-src chrome-extension://react-developer-tools http://localhost:*/embed/iframe.html https://*.youtube.com/ https://*.vimeo.com/`,
|
||||
`worker-src 'self' 'unsafe-eval' blob: http://localhost:*`,
|
||||
];
|
||||
const Cors = require('./electron/json/cors.json');
|
||||
const csp = [];
|
||||
|
||||
for (let i in Cors) {
|
||||
csp.push([ i ].concat(Cors[i]).join(' '));
|
||||
};
|
||||
|
||||
app.commandLine.appendSwitch('ignore-connections-limit', 'localhost, 127.0.0.1');
|
||||
app.removeAsDefaultProtocolClient(protocol);
|
||||
|
|
89
electron/json/cors.json
Normal file
89
electron/json/cors.json
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"default-src": [
|
||||
"'self'",
|
||||
"'unsafe-eval'",
|
||||
"blob:",
|
||||
"http://localhost:*"
|
||||
],
|
||||
|
||||
"img-src": [
|
||||
"'self'",
|
||||
"http://*:*",
|
||||
"https://*:*",
|
||||
"data:",
|
||||
"blob:",
|
||||
"file://*",
|
||||
"https://*.sndcdn.com"
|
||||
],
|
||||
|
||||
"media-src": [
|
||||
"'self'",
|
||||
"http://*:*",
|
||||
"https://*:*",
|
||||
"data:",
|
||||
"blob:",
|
||||
"file://*",
|
||||
"https://*.googlevideo.com"
|
||||
],
|
||||
|
||||
"style-src": [
|
||||
"'unsafe-inline'",
|
||||
"http://localhost:*",
|
||||
"file://*",
|
||||
"https://*.youtube.com",
|
||||
"https://*.vimeocdn.com"
|
||||
],
|
||||
|
||||
"font-src": [
|
||||
"data:",
|
||||
"file://*",
|
||||
"http://localhost:*",
|
||||
"https://*.youtube.com",
|
||||
"https://*.vimeocdn.com"
|
||||
],
|
||||
|
||||
"connect-src": [
|
||||
"file://*",
|
||||
"data:",
|
||||
"http://localhost:*",
|
||||
"http://127.0.0.1:*",
|
||||
"ws://localhost:*",
|
||||
"https://*.anytype.io",
|
||||
"https://api.amplitude.com",
|
||||
"devtools://devtools",
|
||||
"https://*.youtube.com",
|
||||
"https://*.vimeocdn.com",
|
||||
"https://*.vimeo.com",
|
||||
"https://*.googlevideo.com",
|
||||
"https://*.akamaized.net",
|
||||
"https://*.soundcloud.com",
|
||||
"https://*.sndcdn.com"
|
||||
],
|
||||
|
||||
"script-src-elem": [
|
||||
"file:",
|
||||
"'unsafe-inline'",
|
||||
"http://localhost:*",
|
||||
"https://sentry.io",
|
||||
"devtools://devtools",
|
||||
"https://*.youtube.com",
|
||||
"https://*.vimeocdn.com",
|
||||
"https://*.gstatic.com",
|
||||
"https://*.sndcdn.com"
|
||||
],
|
||||
|
||||
"frame-src": [
|
||||
"chrome-extension://react-developer-tools",
|
||||
"http://localhost:*/embed/iframe.html",
|
||||
"https://*.youtube.com",
|
||||
"https://*.vimeo.com",
|
||||
"https://w.soundcloud.com"
|
||||
],
|
||||
|
||||
"worker-src": [
|
||||
"'self'",
|
||||
"'unsafe-eval'",
|
||||
"blob:",
|
||||
"http://localhost:*"
|
||||
]
|
||||
}
|
|
@ -416,11 +416,6 @@
|
|||
"blockNameEmbed": "Show as embed",
|
||||
"blockNameRelation": "Relation",
|
||||
"blockNameNewRelation": "New Relation",
|
||||
"blockNameLatex": "LaTeX",
|
||||
"blockNameMermaid": "Mermaid",
|
||||
"blockNameYoutube": "Youtube",
|
||||
"blockNameVimeo": "Vimeo",
|
||||
"blockNameChart": "Chart",
|
||||
"blockNameSimpleTable": "Table 3x3",
|
||||
"blockNameTableOfContents": "Table of Contents",
|
||||
"blockNameSet": "Inline set",
|
||||
|
@ -450,11 +445,6 @@
|
|||
"blockTextEmbed": "Embed file into the Object",
|
||||
"blockTextRelation": "Meaningful connection between Objects",
|
||||
"blockTextNewRelation": "Meaningful connection between Objects",
|
||||
"blockTextLatex": "Display a math equations",
|
||||
"blockTextMermaid": "...",
|
||||
"blockTextYoutube": "...",
|
||||
"blockTextVimeo": "...",
|
||||
"blockTextChart": "...",
|
||||
"blockTextSimpleTable": "Create a Simple Table",
|
||||
"blockTextTableOfContents": "Create a Table of Contents",
|
||||
"blockTextSet": "Add existing or create new Inline Set to this Object",
|
||||
|
@ -463,6 +453,13 @@
|
|||
"blockTextWrap": "Wrap",
|
||||
"blockTextUnwrap": "Unwrap",
|
||||
|
||||
"blockTextLatex": "Display a math equations",
|
||||
"blockTextMermaid": "...",
|
||||
"blockTextYoutube": "...",
|
||||
"blockTextVimeo": "...",
|
||||
"blockTextChart": "...",
|
||||
"blockTextSoundcloud": "...",
|
||||
|
||||
"blockLinkSyncing": "Syncing...",
|
||||
"blockLinkArchived": "Deleted",
|
||||
|
||||
|
|
|
@ -457,6 +457,12 @@ const BlockEmbed = observer(class BlockEmbedIndex extends React.Component<I.Bloc
|
|||
let text = this.text;
|
||||
|
||||
const sandbox = [ 'allow-scripts' ];
|
||||
const allowSameOrigin = [ I.EmbedProcessor.Youtube, I.EmbedProcessor.Vimeo, I.EmbedProcessor.Soundcloud ];
|
||||
|
||||
if (allowSameOrigin.includes(processor)) {
|
||||
sandbox.push('allow-same-origin');
|
||||
};
|
||||
|
||||
const onLoad = () => {
|
||||
const iw = (iframe[0] as HTMLIFrameElement).contentWindow;
|
||||
const env = this.getEnvironmentContent();
|
||||
|
@ -475,13 +481,7 @@ const BlockEmbed = observer(class BlockEmbedIndex extends React.Component<I.Bloc
|
|||
};
|
||||
|
||||
iw.postMessage(data, '*');
|
||||
|
||||
win.off(`message.${block.id}`).on(`message.${block.id}`, (e: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
if ([ I.EmbedProcessor.Youtube, I.EmbedProcessor.Vimeo].includes(processor)) {
|
||||
sandbox.push('allow-same-origin');
|
||||
win.off(`message.${block.id}`).on(`message.${block.id}`, () => {});
|
||||
};
|
||||
|
||||
if (!iframe.length) {
|
||||
|
|
|
@ -190,7 +190,6 @@ export interface Block {
|
|||
|
||||
isEmbed?(): boolean;
|
||||
isEmbedLatex?(): boolean;
|
||||
isEmbedMermaid?(): boolean;
|
||||
|
||||
isText?(): boolean;
|
||||
isTextTitle?(): boolean;
|
||||
|
|
|
@ -6,6 +6,7 @@ export enum EmbedProcessor {
|
|||
Chart = 2,
|
||||
Youtube = 3,
|
||||
Vimeo = 4,
|
||||
Soundcloud = 5,
|
||||
};
|
||||
|
||||
export interface ContentEmbed {
|
||||
|
|
|
@ -49,11 +49,13 @@ class UtilMenu {
|
|||
{ type: I.BlockType.File, id: I.FileType.Pdf, icon: 'pdf', lang: 'Pdf' },
|
||||
{ type: I.BlockType.Bookmark, id: 'bookmark', icon: 'bookmark', lang: 'Bookmark' },
|
||||
{ type: I.BlockType.Text, id: I.TextStyle.Code, icon: 'code', lang: 'Code' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Latex, icon: 'latex', lang: 'Latex' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Mermaid, icon: 'mermaid', lang: 'Mermaid' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Chart, icon: 'chart', lang: 'Chart' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Youtube, icon: 'youtube', lang: 'Youtube' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Vimeo, icon: 'vimeo', lang: 'Vimeo' },
|
||||
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Latex, icon: 'latex', name: 'LaTeX' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Mermaid, icon: 'mermaid', name: 'Mermaid' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Chart, icon: 'chart', name: 'Chart' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Youtube, icon: 'youtube', name: 'Youtube' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Vimeo, icon: 'vimeo', name: 'Vimeo' },
|
||||
{ type: I.BlockType.Embed, id: I.EmbedProcessor.Soundcloud, icon: 'soundcloud', name: 'Soundcloud' },
|
||||
].map(this.mapperBlock);
|
||||
};
|
||||
|
||||
|
|
|
@ -365,10 +365,6 @@ class Block implements I.Block {
|
|||
isEmbedLatex (): boolean {
|
||||
return this.isEmbed() && (this.content.processor == I.EmbedProcessor.Latex);
|
||||
};
|
||||
|
||||
isEmbedMermaid (): boolean {
|
||||
return this.isEmbed() && (this.content.processor == I.EmbedProcessor.Mermaid);
|
||||
};
|
||||
|
||||
isText (): boolean {
|
||||
return this.type == I.BlockType.Text;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue