When dropping an unsupported file onto a notebook entry, tell the user it isnt supported (#7115)
* handle unknown files and deal with copy/paste * add some nice errors if couch pukes * added how to adjust couchdb limits * throw error on anntotation change * keep blockquotes * add test for blockquotes * allow multi-file drop of images too * add test for big files * spell check * check for null * need to ignore console errors * reorder tests so we can ignore console errors * when creating new entry, ready it for editing * fix tests and empty embeds * fix tests * found similar issue from notebooks in plots
This commit is contained in:
@@ -125,30 +125,35 @@ export function createNewImageEmbed(image, openmct, imageName = '') {
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = async () => {
|
||||
const base64Data = reader.result;
|
||||
const blobUrl = URL.createObjectURL(image);
|
||||
const imageDomainObject = createNotebookImageDomainObject(base64Data);
|
||||
await saveNotebookImageDomainObject(openmct, imageDomainObject);
|
||||
const imageThumbnailURL = await getThumbnailURLFromImageUrl(blobUrl);
|
||||
try {
|
||||
const base64Data = reader.result;
|
||||
const blobUrl = URL.createObjectURL(image);
|
||||
const imageDomainObject = createNotebookImageDomainObject(base64Data);
|
||||
await saveNotebookImageDomainObject(openmct, imageDomainObject);
|
||||
const imageThumbnailURL = await getThumbnailURLFromImageUrl(blobUrl);
|
||||
|
||||
const snapshot = {
|
||||
fullSizeImageObjectIdentifier: imageDomainObject.identifier,
|
||||
thumbnailImage: {
|
||||
src: imageThumbnailURL
|
||||
}
|
||||
};
|
||||
const snapshot = {
|
||||
fullSizeImageObjectIdentifier: imageDomainObject.identifier,
|
||||
thumbnailImage: {
|
||||
src: imageThumbnailURL
|
||||
}
|
||||
};
|
||||
|
||||
const embedMetaData = {
|
||||
bounds: openmct.time.bounds(),
|
||||
link: null,
|
||||
objectPath: null,
|
||||
openmct,
|
||||
userImage: true,
|
||||
imageName
|
||||
};
|
||||
const embedMetaData = {
|
||||
bounds: openmct.time.bounds(),
|
||||
link: null,
|
||||
objectPath: null,
|
||||
openmct,
|
||||
userImage: true,
|
||||
imageName
|
||||
};
|
||||
|
||||
const createdEmbed = await createNewEmbed(embedMetaData, snapshot);
|
||||
resolve(createdEmbed);
|
||||
const createdEmbed = await createNewEmbed(embedMetaData, snapshot);
|
||||
resolve(createdEmbed);
|
||||
} catch (error) {
|
||||
console.error(`${error.message} - unable to embed image ${imageName}`, error);
|
||||
openmct.notifications.error(`${error.message} -- unable to embed image ${imageName}`);
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(image);
|
||||
@@ -202,7 +207,7 @@ export async function addNotebookEntry(
|
||||
openmct,
|
||||
domainObject,
|
||||
notebookStorage,
|
||||
embed = null,
|
||||
passedEmbeds = [],
|
||||
entryText = ''
|
||||
) {
|
||||
if (!openmct || !domainObject || !notebookStorage) {
|
||||
@@ -212,7 +217,9 @@ export async function addNotebookEntry(
|
||||
const date = openmct.time.now();
|
||||
const configuration = domainObject.configuration;
|
||||
const entries = configuration.entries || {};
|
||||
const embeds = embed ? [embed] : [];
|
||||
// if embeds isn't an array, make it one
|
||||
const embedsNormalized =
|
||||
passedEmbeds && !Array.isArray(passedEmbeds) ? [passedEmbeds] : passedEmbeds;
|
||||
|
||||
const id = `entry-${uuid()}`;
|
||||
const [createdBy, createdByRole] = await Promise.all([
|
||||
@@ -225,7 +232,7 @@ export async function addNotebookEntry(
|
||||
createdBy,
|
||||
createdByRole,
|
||||
text: entryText,
|
||||
embeds
|
||||
embeds: embedsNormalized
|
||||
};
|
||||
|
||||
const newEntries = addEntryIntoPage(notebookStorage, entries, entry);
|
||||
|
||||
Reference in New Issue
Block a user