Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image suggestion feature to iMatrics widget #4175

Merged
merged 23 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9127e84
add image suggestion feature to iMatrics widget
hanstchou Jan 9, 2023
d628828
fix lint issues
hanstchou Jan 13, 2023
8f0eb8e
remove trailing white space
hanstchou Jan 17, 2023
de3e097
modify functional to class component
hanstchou Jan 18, 2023
7ab1716
fix lint issue
tomaskikutis Jan 23, 2023
98e276a
adjusted payload and fix more lint issues
hanstchou Jan 25, 2023
35fff03
fix issues from feedback
hanstchou Jan 27, 2023
342af02
add grab indicator on image
hanstchou Jan 27, 2023
053a8cd
fix timeout type
hanstchou Jan 30, 2023
ff5e4fd
fix init timeout
hanstchou Jan 30, 2023
abd0249
replace timeout with debounce, add error alert, fix gettext
hanstchou Jan 31, 2023
4bb1310
replace ToggleBoxNext with ToggleBox
hanstchou Feb 2, 2023
bab4850
use an API method to prepare an external image for dropping to the ed…
tomaskikutis Feb 8, 2023
b726559
improve translations
tomaskikutis Feb 8, 2023
95232c3
don't stringify error object
tomaskikutis Feb 8, 2023
abf6166
fix lint
tomaskikutis Feb 8, 2023
f9b676e
fix api path
tomaskikutis Feb 8, 2023
82fe8cc
code style improvements
tomaskikutis Feb 8, 2023
b3d4a6f
revert package-lock changes
tomaskikutis Feb 8, 2023
2d86f28
add filter images with no imageUrl and ensure selectedImage is not re…
hanstchou Feb 13, 2023
f583062
fix figcaption to only render if there is caption and removed unneces…
hanstchou Feb 20, 2023
8d971ca
remove unnecessary filter of images without src in client
hanstchou Feb 28, 2023
7aff308
fix unit tests
tomaskikutis Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions scripts/core/get-superdesk-api-implementation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ export const dispatchCustomEvent = <T extends keyof IEvents>(eventName: T, paylo
);
};

export function prepareExternalImageForDroppingToEditor(
event: DragEvent,
renditions: IArticle['renditions'],
additionalData?: Partial<IArticle>,
) {
const item: Partial<IArticle> = {
_fetchable: false,
_type: 'externalsource',
...(additionalData ?? {}),
type: 'picture',
renditions: renditions,
};

event.dataTransfer.setData(
'application/superdesk.item.picture',
JSON.stringify(item),
);
}

export let applicationState: Writeable<ISuperdesk['state']> = {
articleInEditMode: undefined,
};
Expand Down Expand Up @@ -302,6 +321,7 @@ export function getSuperdeskApiImplementation(
save: () => {
dispatchInternalEvent('saveArticleInEditMode', null);
},
prepareExternalImageForDroppingToEditor,
},
alert: (message: string) => modal.alert({bodyText: message}),
confirm: (message: string, title?: string) => new Promise((resolve) => {
Expand Down
8 changes: 7 additions & 1 deletion scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1682,10 +1682,16 @@ declare module 'superdesk-api' {
addImage(field: string, image: IArticle): void;

/**
* Programatically triggers saving of an article in edit mode.
* Programmatically triggers saving of an article in edit mode.
* Runs the same code as if "save" button was clicked manually.
*/
save(): void;

prepareExternalImageForDroppingToEditor(
event: DragEvent,
renditions: IArticle['renditions'],
additionalData?: Partial<IArticle>,
): void;
};
alert(message: string): Promise<void>;
confirm(message: string, title?: string): Promise<boolean>;
Expand Down
Loading