Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into authoring-react-po…
Browse files Browse the repository at this point in the history
…st-broadcasting
  • Loading branch information
petrjasek committed Oct 31, 2023
2 parents b19b89b + 8dd0036 commit 087f8c2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ export function ItemCarouselDirective(notify, relationsService) {
carousel.trigger('to.owl.carousel', [index]);
};

const addDragOverClass = () => {
elem.find('figure').addClass('dragover');
elem.find('button.item-association').addClass('dragover');
};

const removeDragOverClass = () => {
elem.find('figure').removeClass('dragover');
elem.find('button.item-association').removeClass('dragover');
};

function canUploadItems(uploadsCount: number = 0): boolean {
const mediaItemsForCurrentField = getAssociationsByFieldId(scope.item.associations, scope.field._id);
const currentUploads = mediaItemsForCurrentField.length;
Expand All @@ -208,6 +218,11 @@ export function ItemCarouselDirective(notify, relationsService) {
elem.on('dragover', (event) => {
event.preventDefault();
event.stopPropagation();
addDragOverClass();
});

elem.on('dragleave', () => {
removeDragOverClass();
});

elem.on('drop dragdrop', (event) => {
Expand All @@ -219,9 +234,13 @@ export function ItemCarouselDirective(notify, relationsService) {
event.stopPropagation();

const type: string = getSuperdeskType(event, false);
const item: IArticle = angular.fromJson(event.originalEvent.dataTransfer.getData(type));

const jsonData = event.originalEvent.dataTransfer.getData(type);
const item: IArticle = angular.fromJson(jsonData !== '' ? jsonData : '{}');

const isWorkflowAllowed: boolean = relationsService.itemHasAllowedStatus(item, scope.field);

removeDragOverClass();
if (!isWorkflowAllowed) {
notify.error(gettext(
'The following status is not allowed in this field: {{status}}',
Expand Down
5 changes: 4 additions & 1 deletion scripts/apps/authoring/views/item-carousel.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<button tabindex="{{tabindex}}" class="item-association" ng-if="!carouselItems.length"
<button
tabindex="{{tabindex}}"
class="item-association"
ng-if="!carouselItems.length"
ng-class="{'item-association--preview': item[item.fieldId], 'item-association--loading': loading}"
ng-click="associations.isMediaEditable() && !item[item.fieldId] && upload()"
ng-disabled="!editable"
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/contacts/components/Form/ProfileDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export class ProfileDetail extends React.PureComponent<IProps, IState> {
field="organisation"
label={gettext('Organisation')}
value={this.state.orgValue}
initValue
onChange={this.handleOrgChange}
querySearch={true}
onQuerySearch={((text) => this.getSearchResult('organisation', text))}
Expand Down
6 changes: 4 additions & 2 deletions scripts/core/editor3/components/Editor3Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {CharacterLimitUiBehavior} from 'apps/authoring/authoring/components/Char
import {Editor3Autocomplete} from './Editor3Autocomplete';
import {querySelectorParent} from 'core/helpers/dom/querySelectorParent';
import {MEDIA_TYPES_TRIGGER_DROP_ZONE} from 'core/constants';
import {isMacOS} from 'core/utils';

const EVENT_TYPES_TRIGGER_DROP_ZONE = [
...MEDIA_TYPES_TRIGGER_DROP_ZONE,
Expand Down Expand Up @@ -274,12 +275,13 @@ export class Editor3Component extends React.Component<IProps, IState> {
}

keyBindingFn(e) {
const {key, shiftKey, ctrlKey} = e;
const {key, shiftKey, ctrlKey, metaKey} = e;
const selectionState = this.props.editorState.getSelection();
const modifierKey = isMacOS() ? metaKey : ctrlKey;

if (
key === 'k'
&& ctrlKey
&& modifierKey
&& this.props.editorFormat.includes('link')
&& selectionState.isCollapsed() !== true
) {
Expand Down
5 changes: 5 additions & 0 deletions scripts/core/editor3/components/links/LinkInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ export class LinkInputComponent extends React.Component<IProps, any> {
>
<div style={{padding: '3.2rem 1.6rem'}}>
<input
onKeyDown={(e) => {
if (e.key === 'Enter') {
this.onSubmit(linkTypes.href);
}
}}
type="url"
ref={(el) => {
this.inputElement = el;
Expand Down
11 changes: 11 additions & 0 deletions scripts/core/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ function applyTranslations(translations) {
window.translations = translations;
}

export function isMacOS() {
if (
navigator.userAgent.toLowerCase().includes('macintosh')
|| navigator.userAgent.toLowerCase().includes('mac os')
) {
return true;
}

return false;
}

function requestListener() {
const translations = JSON.parse(this.responseText);

Expand Down

0 comments on commit 087f8c2

Please sign in to comment.