1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

JS-4319: external image embed

This commit is contained in:
Andrew Simachev 2024-09-10 15:11:48 +02:00
parent 5d4cfa2cc6
commit 24e93e8efe
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
8 changed files with 17 additions and 2 deletions

View file

@ -62,6 +62,7 @@
Kroki: 19,
Graphviz: 20,
Sketchfab: 21,
Image: 22,
};
const win = $(window);

View file

@ -0,0 +1,6 @@
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="40" height="40" rx="8" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M29.4369 13.8382C29.4988 14.5967 29.5 15.5751 29.5 17V23C29.5 24.4249 29.4988 25.4033 29.4369 26.1618C29.3763 26.9028 29.2653 27.3009 29.1185 27.589C28.783 28.2475 28.2475 28.783 27.589 29.1185C27.3009 29.2653 26.9028 29.3763 26.1618 29.4369C25.4033 29.4988 24.4249 29.5 23 29.5H17C15.5751 29.5 14.5967 29.4988 13.8382 29.4369C13.0972 29.3763 12.6991 29.2653 12.411 29.1185C11.7525 28.783 11.217 28.2475 10.8815 27.589C10.7347 27.3009 10.6237 26.9028 10.5631 26.1618C10.5012 25.4033 10.5 24.4249 10.5 23V17C10.5 15.5751 10.5012 14.5967 10.5631 13.8382C10.6237 13.0972 10.7347 12.6991 10.8815 12.411C11.217 11.7525 11.7525 11.217 12.411 10.8815C12.6991 10.7347 13.0972 10.6237 13.8382 10.5631C14.5967 10.5012 15.5751 10.5 17 10.5H23C24.4249 10.5 25.4033 10.5012 26.1618 10.5631C26.9028 10.6237 27.3009 10.7347 27.589 10.8815C28.2475 11.217 28.783 11.7525 29.1185 12.411C29.2653 12.6991 29.3763 13.0972 29.4369 13.8382ZM31 17C31 14.1997 31 12.7996 30.455 11.73C29.9757 10.7892 29.2108 10.0243 28.27 9.54497C27.2004 9 25.8003 9 23 9H17C14.1997 9 12.7996 9 11.73 9.54497C10.7892 10.0243 10.0243 10.7892 9.54497 11.73C9 12.7996 9 14.1997 9 17V23C9 25.8003 9 27.2004 9.54497 28.27C10.0243 29.2108 10.7892 29.9757 11.73 30.455C12.7996 31 14.1997 31 17 31H23C25.8003 31 27.2004 31 28.27 30.455C29.2108 29.9757 29.9757 29.2108 30.455 28.27C31 27.2004 31 25.8003 31 23V17Z" fill="#8C9EA5"/>
<path d="M16.6562 18C15.5517 18 14.6562 17.1046 14.6562 16C14.6562 14.8954 15.5517 14 16.6562 14C17.7608 14 18.6562 14.8954 18.6562 16C18.6562 17.1046 17.7608 18 16.6562 18Z" fill="#8C9EA5"/>
<path d="M22.1562 18.5L29.6562 25.9576L28.6562 30H11.6562L9.65625 25.9888L14.6562 20.9963L17.1562 23.5L22.1562 18.5Z" fill="#8C9EA5"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -608,6 +608,7 @@
"blockEmbedEmpty": "%s embed block is empty. Click to edit.",
"blockEmbedSource": "Source",
"blockEmbedOffline": "You are not connected to the Internet",
"blockEmbedExternalImage": "External image",
"blockTableOfContentsAdd": "Add headings to create a table of contents",

View file

@ -73,6 +73,7 @@
.icon.embed-twitter { background-image: url('~img/icon/menu/action/block/embed/twitter.svg'); }
.icon.embed-excalidraw { background-image: url('~img/icon/menu/action/block/embed/excalidraw.svg'); }
.icon.embed-sketchfab { background-image: url('~img/icon/menu/action/block/embed/sketchfab.svg'); }
.icon.embed-image { background-image: url('~img/icon/menu/action/block/embed/image.svg'); }
.icon.existing { background-image: url('~img/icon/menu/action/block/existing1.svg'); }
.icon.bookmark { background-image: url('~img/icon/menu/action/block/bookmark1.svg'); }

View file

@ -11,7 +11,6 @@ import { I, C, S, U, J, keyboard, focus, Action, translate } from 'Lib';
const katex = require('katex');
const pako = require('pako');
const mermaid = require('mermaid').default;
require('katex/dist/contrib/mhchem');

View file

@ -743,7 +743,6 @@ class UtilData {
collectionId: ''
}, param);
const { subId, idField, filters, sorts, sources, offset, limit, ignoreWorkspace, ignoreHidden, ignoreDeleted, afterId, beforeId, noDeps, withArchived, collectionId } = param;
const keys: string[] = [ ...new Set(param.keys as string[]) ];

View file

@ -79,6 +79,10 @@ class UtilEmbed {
return `<iframe src="${content}" ${IFRAME_PARAM}></iframe>`;
};
getImageHtml (content: string): string {
return `<img src="${content}" />`;
};
getProcessorByUrl (url: string): I.EmbedProcessor {
let p = null;
for (const i in DOMAINS) {
@ -323,6 +327,7 @@ class UtilEmbed {
I.EmbedProcessor.Bilibili,
I.EmbedProcessor.Kroki,
I.EmbedProcessor.Sketchfab,
I.EmbedProcessor.Image,
].includes(p);
};
@ -357,6 +362,7 @@ class UtilEmbed {
I.EmbedProcessor.Codepen,
I.EmbedProcessor.Kroki,
I.EmbedProcessor.Chart,
I.EmbedProcessor.Image,
].includes(p);
};
@ -374,6 +380,7 @@ class UtilEmbed {
I.EmbedProcessor.Bilibili,
I.EmbedProcessor.Graphviz,
I.EmbedProcessor.Kroki,
I.EmbedProcessor.Image,
].includes(p);
};

View file

@ -90,6 +90,7 @@ class UtilMenu {
{ id: I.EmbedProcessor.Kroki, name: 'Kroki' },
{ id: I.EmbedProcessor.Graphviz, name: 'Graphviz' },
{ id: I.EmbedProcessor.Sketchfab, name: 'Sketchfab' },
{ id: I.EmbedProcessor.Image, name: translate('blockEmbedExternalImage') },
];
if (config.experimental) {