diff --git a/apps/common/mobile/resources/icons/common/icon-image-storage.svg b/apps/common/mobile/resources/icons/common/icon-image-storage.svg new file mode 100644 index 0000000000..69fcba0b1f --- /dev/null +++ b/apps/common/mobile/resources/icons/common/icon-image-storage.svg @@ -0,0 +1 @@ + diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 68b2bc5b5f..0de33ed0ab 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -50,6 +50,7 @@ "textPageNumber": "Page Number", "textPasteImageUrl": "Paste an image URL", "textPictureFromLibrary": "Picture from Library", + "textPictureFromStorage": "Picture from Storage", "textPictureFromURL": "Picture from URL", "textPosition": "Position", "textRecommended": "Recommended", @@ -361,6 +362,7 @@ "textParagraph": "Paragraph", "textParagraphStyle": "Paragraph Style", "textPictureFromLibrary": "Picture from Library", + "textPictureFromStorage": "Picture from Storage", "textPictureFromURL": "Picture from URL", "textPlaceholder": "Placeholder", "textPt": "pt", diff --git a/apps/documenteditor/mobile/locale/fr.json b/apps/documenteditor/mobile/locale/fr.json index 6cc94ed6e2..8840f45f30 100644 --- a/apps/documenteditor/mobile/locale/fr.json +++ b/apps/documenteditor/mobile/locale/fr.json @@ -50,6 +50,7 @@ "textPageNumber": "Numéro de page", "textPasteImageUrl": "Coller l'URL de l'image", "textPictureFromLibrary": "Image depuis la bibliothèque", + "textPictureFromStorage": "Image de stockage", "textPictureFromURL": "Image à partir d'une URL", "textPosition": "Position", "textRecommended": "Recommandations", @@ -361,6 +362,7 @@ "textParagraph": "Paragraphe", "textParagraphStyle": "Style de paragraphe", "textPictureFromLibrary": "Image depuis la bibliothèque", + "textPictureFromStorage": "Image de stockage", "textPictureFromURL": "Image à partir d'une URL", "textPlaceholder": "Espace réservé", "textPt": "pt", diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 9a2d6e9a1e..fe1d03db4b 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -589,7 +589,12 @@ class MainController extends Component { data._urls = arr; } - this.insertImageFromStorage(data); + if(data.c === 'add') { + this.insertImageFromStorage(data); + } + else if(data.c === 'change') { + this.replaceImageFromStorage(data); + } } loadDefaultMetricSettings() { @@ -1045,6 +1050,14 @@ class MainController extends Component { } } + replaceImageFromStorage (data) { + if (data && data._urls && (!data.c || data.c === 'change') && data._urls.length > 0) { + const image = new Asc.asc_CImgProperty(); + image.put_ImageUrl(data._urls[0], data.token); + this.api.ImgApply(image); + } + } + markFavorite(favorite) { Common.Gateway.metaChange({ favorite }); } diff --git a/apps/documenteditor/mobile/src/controller/add/AddImage.jsx b/apps/documenteditor/mobile/src/controller/add/AddImage.jsx index 73145f992a..af70a7a3e8 100644 --- a/apps/documenteditor/mobile/src/controller/add/AddImage.jsx +++ b/apps/documenteditor/mobile/src/controller/add/AddImage.jsx @@ -10,6 +10,7 @@ class AddImageController extends Component { super(props); this.onInsertByFile = this.onInsertByFile.bind(this); this.onInsertByUrl = this.onInsertByUrl.bind(this); + this.onInsertByStorage = this.onInsertByStorage.bind(this); } closeModal () { @@ -45,10 +46,16 @@ class AddImageController extends Component { } } + onInsertByStorage () { + Common.Gateway.requestInsertImage('add'); + this.closeModal(); + } + render () { return ( ) } @@ -56,4 +63,4 @@ class AddImageController extends Component { const AddImageWithTranslation = withTranslation()(AddImageController); -export {AddImageWithTranslation as AddImageController}; \ No newline at end of file +export {AddImageWithTranslation as AddImageController}; diff --git a/apps/documenteditor/mobile/src/controller/edit/EditImage.jsx b/apps/documenteditor/mobile/src/controller/edit/EditImage.jsx index cad355f2a4..650e0d2a6a 100644 --- a/apps/documenteditor/mobile/src/controller/edit/EditImage.jsx +++ b/apps/documenteditor/mobile/src/controller/edit/EditImage.jsx @@ -12,6 +12,7 @@ class EditImageController extends Component { this.onRemoveImage = this.onRemoveImage.bind(this); this.onReplaceByFile = this.onReplaceByFile.bind(this); this.onReplaceByUrl = this.onReplaceByUrl.bind(this); + this.onReplaceByStorage = this.onReplaceByStorage.bind(this); } closeModal () { @@ -117,6 +118,11 @@ class EditImageController extends Component { } } + onReplaceByStorage () { + Common.Gateway.requestInsertImage('change'); + this.closeModal(); + } + onReorder (type) { const api = Common.EditorApi.get(); if (api) { @@ -145,10 +151,11 @@ class EditImageController extends Component { onWrapDistance={this.onWrapDistance} onReplaceByFile={this.onReplaceByFile} onReplaceByUrl={this.onReplaceByUrl} + onReplaceByStorage={this.onReplaceByStorage} onReorder={this.onReorder} /> ) } } -export default inject("storeImageSettings")(observer(EditImageController)); \ No newline at end of file +export default inject("storeImageSettings")(observer(EditImageController)); diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index 39fc562443..a12fddf704 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -22,6 +22,10 @@ export class storeAppOptions { canBrandingExt: observable, canBranding: observable, + + canRequestInsertImage: observable, + changeCanRequestInsertImage: action, + isDocReady: observable, changeDocReady: action, @@ -110,6 +114,11 @@ export class storeAppOptions { this.isDocReady = value; } + canRequestInsertImage = false; + changeCanRequestInsertImage(value) { + this.canRequestInsertImage = value; + } + config = {}; customization; @@ -142,6 +151,7 @@ export class storeAppOptions { this.saveAsUrl = config.saveAsUrl; this.canAnalytics = false; this.canRequestClose = config.canRequestClose; + this.canRequestInsertImage = config.canRequestInsertImage === true; this.canCloseEditor = false; let canBack = false; @@ -226,7 +236,7 @@ export class storeAppOptions { this.trialMode = params.asc_getLicenseMode(); const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType); - + this.canDownloadOrigin = false; this.canDownload = permissions.download !== false; this.canReader = (!type || typeof type[1] !== 'string'); @@ -240,12 +250,12 @@ export class storeAppOptions { if ( this.isLightVersion ) { this.canUseHistory = this.canReview = this.isReviewOnly = false; } - this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization + this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object')); this.canUseCommentPermissions = this.canLicense && !!permissions.commentGroups; this.canUseUserInfoPermissions = this.canLicense && !!permissions.userInfoGroups; this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions); - this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); + this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); this.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(permissions.userInfoGroups); this.canLiveView = !!params.asc_getLiveViewerSupport() && (this.config.mode === 'view') && !(type && typeof type[1] === 'string') && isSupportEditFeature; diff --git a/apps/documenteditor/mobile/src/view/add/AddImage.jsx b/apps/documenteditor/mobile/src/view/add/AddImage.jsx index e5b0580385..b00c63e143 100644 --- a/apps/documenteditor/mobile/src/view/add/AddImage.jsx +++ b/apps/documenteditor/mobile/src/view/add/AddImage.jsx @@ -8,6 +8,7 @@ import IconImageLibraryIos from '@common-ios-icons/icon-image-library.svg?ios'; import IconImageLibraryAndroid from '@common-android-icons/icon-image-library.svg'; import IconLinkIos from '@common-ios-icons/icon-link.svg?ios'; import IconLinkAndroid from '@common-android-icons/icon-link.svg'; +import IconImageStorage from '@common-icons/icon-image-storage.svg'; const PageLinkSettings = props => { @@ -36,9 +37,11 @@ const PageLinkSettings = props => { ) }; -const AddImage = props => { +const AddImage = inject('storeAppOptions')(observer(props => { const { t } = useTranslation(); const _t = t('Add', {returnObjects: true}); + const canRequestInsertImage = props.storeAppOptions.canRequestInsertImage; + return ( @@ -57,9 +60,15 @@ const AddImage = props => { } + { + canRequestInsertImage && + {props.onInsertByStorage()}}> + + + } ) -}; +})); export {AddImage, PageLinkSettings as PageImageLinkSettings}; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/edit/EditImage.jsx b/apps/documenteditor/mobile/src/view/edit/EditImage.jsx index 004a8fff66..df18c5b26a 100644 --- a/apps/documenteditor/mobile/src/view/edit/EditImage.jsx +++ b/apps/documenteditor/mobile/src/view/edit/EditImage.jsx @@ -25,6 +25,7 @@ import IconMoveForeground from '@common-icons/icon-move-foreground.svg'; import IconMoveBackground from '@common-icons/icon-move-background.svg'; import IconMoveForward from '@common-icons/icon-move-forward.svg'; import IconMoveBackward from '@common-icons/icon-move-backward.svg'; +import IconImageStorage from '@common-icons/icon-image-storage.svg'; const PageWrap = props => { @@ -287,6 +288,8 @@ const PageReplace = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const imageObject = props.storeFocusObjects.imageObject; + const canRequestInsertImage = props.storeAppOptions.canRequestInsertImage; + if (!imageObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; @@ -320,6 +323,12 @@ const PageReplace = props => { } + { + canRequestInsertImage && + {props.onReplaceByStorage()}}> + + + } ) @@ -385,7 +394,8 @@ const EditImage = props => { }}> { wrapType !== 'inline' && { const EditImageContainer = inject("storeFocusObjects", "storeImageSettings")(observer(EditImage)); const PageWrapContainer = inject("storeFocusObjects", "storeImageSettings")(observer(PageWrap)); -const PageReplaceContainer = inject("storeFocusObjects")(observer(PageReplace)); +const PageReplaceContainer = inject("storeAppOptions","storeFocusObjects")(observer(PageReplace)); const PageReorderContainer = inject("storeFocusObjects")(observer(PageReorder)); const PageLinkSettingsContainer = inject("storeFocusObjects")(observer(PageLinkSettings)); const PageWrappingStyleContainer = inject("storeFocusObjects")(observer(PageWrappingStyle)); diff --git a/apps/presentationeditor/mobile/locale/en.json b/apps/presentationeditor/mobile/locale/en.json index 3678da70ca..b82700d114 100644 --- a/apps/presentationeditor/mobile/locale/en.json +++ b/apps/presentationeditor/mobile/locale/en.json @@ -323,6 +323,7 @@ "textPasteImageUrl": "Paste an image URL", "textPictureFromLibrary": "Picture from Library", "textPictureFromURL": "Picture from URL", + "textPictureFromStorage": "Picture from Storage", "textPreviousSlide": "Previous Slide", "textRecommended": "Recommended", "textRequired": "Required", @@ -453,6 +454,7 @@ "textOptions": "Options", "textPictureFromLibrary": "Picture from Library", "textPictureFromURL": "Picture from URL", + "textPictureFromStorage": "Picture from Storage", "textPreviousSlide": "Previous Slide", "textPt": "pt", "textPush": "Push", diff --git a/apps/presentationeditor/mobile/locale/fr.json b/apps/presentationeditor/mobile/locale/fr.json index 7c649d4778..6ee768a111 100644 --- a/apps/presentationeditor/mobile/locale/fr.json +++ b/apps/presentationeditor/mobile/locale/fr.json @@ -321,6 +321,7 @@ "textPasteImageUrl": "Coller l'URL de l'image", "textPictureFromLibrary": "Image depuis la bibliothèque", "textPictureFromURL": "Image à partir d'une URL", + "textPictureFromStorage": "Image de stockage", "textPreviousSlide": "Diapositive précédente", "textRecommended": "Recommandations", "textRequired": "Obligatoire", @@ -451,6 +452,7 @@ "textOptions": "Options", "textPictureFromLibrary": "Image depuis la bibliothèque", "textPictureFromURL": "Image à partir d'une URL", + "textPictureFromStorage": "Image de stockage", "textPreviousSlide": "Diapositive précédente", "textPt": "pt", "textPush": "Expulsion", diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index 17929691ca..b552d61e11 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -550,6 +550,14 @@ class MainController extends Component { } } + replaceImageFromStorage (data) { + if (data && data._urls && (!data.c || data.c === 'change') && data._urls.length > 0) { + const image = new Asc.asc_CImgProperty(); + image.put_ImageUrl(data._urls[0], data.token); + this.api.ImgApply(image); + } + } + onApiTextReplaced(found, replaced) { const { t } = this.props; @@ -647,7 +655,12 @@ class MainController extends Component { data._urls = arr; } - this.insertImageFromStorage(data); + if(data.c === 'add') { + this.insertImageFromStorage(data); + } + else if(data.c === 'change') { + this.replaceImageFromStorage(data); + } } onLicenseChanged (params) { diff --git a/apps/presentationeditor/mobile/src/controller/add/AddImage.jsx b/apps/presentationeditor/mobile/src/controller/add/AddImage.jsx index ad68b85b0b..35976f3394 100644 --- a/apps/presentationeditor/mobile/src/controller/add/AddImage.jsx +++ b/apps/presentationeditor/mobile/src/controller/add/AddImage.jsx @@ -10,6 +10,7 @@ class AddImageController extends Component { super(props); this.onInsertByFile = this.onInsertByFile.bind(this); this.onInsertByUrl = this.onInsertByUrl.bind(this); + this.onInsertByStorage = this.onInsertByStorage.bind(this); } closeModal () { @@ -45,10 +46,17 @@ class AddImageController extends Component { } } + onInsertByStorage () { + Common.Gateway.requestInsertImage('add'); + this.closeModal(); + } + + render () { return ( ) } @@ -56,4 +64,4 @@ class AddImageController extends Component { const AddImageWithTranslation = withTranslation()(AddImageController); -export {AddImageWithTranslation as AddImageController}; \ No newline at end of file +export {AddImageWithTranslation as AddImageController}; diff --git a/apps/presentationeditor/mobile/src/controller/edit/EditImage.jsx b/apps/presentationeditor/mobile/src/controller/edit/EditImage.jsx index ea7c335477..ee95f4eb92 100644 --- a/apps/presentationeditor/mobile/src/controller/edit/EditImage.jsx +++ b/apps/presentationeditor/mobile/src/controller/edit/EditImage.jsx @@ -11,6 +11,7 @@ class EditImageController extends Component { this.onRemoveImage = this.onRemoveImage.bind(this); this.onReplaceByFile = this.onReplaceByFile.bind(this); this.onReplaceByUrl = this.onReplaceByUrl.bind(this); + this.onReplaceByStorage = this.onReplaceByStorage.bind(this); } onReorder(type) { @@ -102,6 +103,10 @@ class EditImageController extends Component { this.closeModal(); } + onReplaceByStorage () { + Common.Gateway.requestInsertImage('change'); + this.closeModal(); + } render () { return ( @@ -112,9 +117,10 @@ class EditImageController extends Component { onReplaceByFile={this.onReplaceByFile} onDefaultSize={this.onDefaultSize} onReplaceByUrl={this.onReplaceByUrl} + onReplaceByStorage={this.onReplaceByStorage} /> ) } } -export default EditImageController; \ No newline at end of file +export default EditImageController; diff --git a/apps/presentationeditor/mobile/src/store/appOptions.js b/apps/presentationeditor/mobile/src/store/appOptions.js index e77564c534..442c0d9679 100644 --- a/apps/presentationeditor/mobile/src/store/appOptions.js +++ b/apps/presentationeditor/mobile/src/store/appOptions.js @@ -20,6 +20,9 @@ export class storeAppOptions { isDocReady: observable, changeDocReady: action, + canRequestInsertImage: observable, + changeCanRequestInsertImage: action, + customization: observable, }); } @@ -46,6 +49,11 @@ export class storeAppOptions { this.isDocReady = value; } + canRequestInsertImage = false; + changeCanRequestInsertImage(value) { + this.canRequestInsertImage = value; + } + setConfigOptions (config, _t) { this.config = config; this.customization = config.customization; @@ -74,6 +82,7 @@ export class storeAppOptions { this.mergeFolderUrl = config.mergeFolderUrl; this.canAnalytics = false; this.canRequestClose = config.canRequestClose; + this.canRequestInsertImage = config.canRequestInsertImage === true; this.canCloseEditor = false; let canBack = false; @@ -151,7 +160,7 @@ export class storeAppOptions { this.canBranding = params.asc_getCustomization(); this.canBrandingExt = params.asc_getCanBranding() && (typeof this.customization == 'object' || this.config.plugins); - this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization + this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object')); this.canUseCommentPermissions = this.canLicense && !!permissions.commentGroups; this.canUseUserInfoPermissions = this.canLicense && !!permissions.userInfoGroups; diff --git a/apps/presentationeditor/mobile/src/view/add/AddImage.jsx b/apps/presentationeditor/mobile/src/view/add/AddImage.jsx index 3e56f01924..bcfd966c00 100644 --- a/apps/presentationeditor/mobile/src/view/add/AddImage.jsx +++ b/apps/presentationeditor/mobile/src/view/add/AddImage.jsx @@ -8,6 +8,7 @@ import IconImageLibraryIos from '@common-ios-icons/icon-image-library.svg?ios'; import IconImageLibraryAndroid from '@common-android-icons/icon-image-library.svg'; import IconLinkIos from '@common-ios-icons/icon-link.svg?ios'; import IconLinkAndroid from '@common-android-icons/icon-link.svg'; +import IconImageStorage from '@common-icons/icon-image-storage.svg'; const PageLinkSettings = props => { const { t } = useTranslation(); @@ -35,9 +36,11 @@ const PageLinkSettings = props => { ) }; -const AddImage = props => { +const AddImage = inject('storeAppOptions')(observer(props => { const { t } = useTranslation(); const _t = t('View.Add', {returnObjects: true}); + const canRequestInsertImage = props.storeAppOptions.canRequestInsertImage; + return ( @@ -56,9 +59,15 @@ const AddImage = props => { } - + { + canRequestInsertImage && + {props.onInsertByStorage()}}> + + + } + ) -}; +})); export {AddImage, PageLinkSettings as PageImageLinkSettings}; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/edit/EditImage.jsx b/apps/presentationeditor/mobile/src/view/edit/EditImage.jsx index 8afcc4f6ed..6a7eaca796 100644 --- a/apps/presentationeditor/mobile/src/view/edit/EditImage.jsx +++ b/apps/presentationeditor/mobile/src/view/edit/EditImage.jsx @@ -23,6 +23,7 @@ import IconImageLibraryIos from '@common-ios-icons/icon-image-library.svg?ios'; import IconImageLibraryAndroid from '@common-android-icons/icon-image-library.svg'; import IconLinkIos from '@common-ios-icons/icon-link.svg?ios'; import IconLinkAndroid from '@common-android-icons/icon-link.svg'; +import IconImageStorage from '@common-icons/icon-image-storage.svg'; const EditImage = props => { const { t } = useTranslation(); @@ -36,7 +37,8 @@ const EditImage = props => { { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); const imageObject = props.storeFocusObjects.imageObject; - + const canRequestInsertImage = props.storeAppOptions.canRequestInsertImage; + if (!imageObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; @@ -190,6 +193,12 @@ const PageReplace = props => { } + { + canRequestInsertImage && + {props.onReplaceByStorage()}}> + + + } ) @@ -244,7 +253,7 @@ const PageLinkSettings = props => { }; const EditImageContainer = inject("storeFocusObjects")(observer(EditImage)); -const PageReplaceContainer = inject("storeFocusObjects")(observer(PageReplace)); +const PageReplaceContainer = inject("storeAppOptions","storeFocusObjects")(observer(PageReplace)); const PageReorderContainer = inject("storeFocusObjects")(observer(PageReorder)); const PageAlignContainer = inject("storeFocusObjects")(observer(PageAlign)); const PageLinkSettingsContainer = inject("storeFocusObjects")(observer(PageLinkSettings)); diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index c9d18d810f..26ec17c412 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -514,6 +514,7 @@ "textPasteImageUrl": "Paste an image URL", "textPictureFromLibrary": "Picture from library", "textPictureFromURL": "Picture from URL", + "textPictureFromStorage": "Picture from Storage", "textRange": "Range", "textRecommended": "Recommended", "textRequired": "Required", @@ -682,6 +683,7 @@ "textPercentage": "Percentage", "textPictureFromLibrary": "Picture from Library", "textPictureFromURL": "Picture from URL", + "textPictureFromStorage": "Picture from Storage", "textPound": "Pound", "textPt": "pt", "textRange": "Range", diff --git a/apps/spreadsheeteditor/mobile/locale/fr.json b/apps/spreadsheeteditor/mobile/locale/fr.json index 7bb2c18ab7..142cc67bde 100644 --- a/apps/spreadsheeteditor/mobile/locale/fr.json +++ b/apps/spreadsheeteditor/mobile/locale/fr.json @@ -512,6 +512,7 @@ "textPasteImageUrl": "Coller l'URL de l'image", "textPictureFromLibrary": "Image depuis la bibliothèque", "textPictureFromURL": "Image à partir d'une URL", + "textPictureFromStorage": "Image de stockage", "textRange": "Plage", "textRecommended": "Recommandations", "textRequired": "Obligatoire", @@ -680,6 +681,7 @@ "textPercentage": "Pourcentage", "textPictureFromLibrary": "Image depuis la bibliothèque", "textPictureFromURL": "Image à partir d'une URL", + "textPictureFromStorage": "Image de stockage", "textPound": "Livre", "textPt": "pt", "textRange": "Plage", diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index db5f8f2f71..d3fde3ca39 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -613,6 +613,14 @@ class MainController extends Component { } } + replaceImageFromStorage (data) { + if (data && data._urls && (!data.c || data.c === 'change') && data._urls.length > 0) { + const image = new Asc.asc_CImgProperty(); + image.put_ImageUrl(data._urls[0], data.token); + this.api.asc_setGraphicObjectProps(image); + } + } + onNeedUpdateExternalReference() { const { t } = this.props; @@ -795,7 +803,12 @@ class MainController extends Component { data._urls = arr; } - this.insertImageFromStorage(data); + if(data.c === 'add') { + this.insertImageFromStorage(data); + } + else if(data.c === 'change') { + this.replaceImageFromStorage(data); + } } applyMode (appOptions) { diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddImage.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddImage.jsx index 8939dc6abd..c63e6371cd 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddImage.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddImage.jsx @@ -10,6 +10,7 @@ class AddImageController extends Component { super(props); this.onInsertByFile = this.onInsertByFile.bind(this); this.onInsertByUrl = this.onInsertByUrl.bind(this); + this.onInsertByStorage = this.onInsertByStorage.bind(this); } closeModal () { @@ -45,11 +46,17 @@ class AddImageController extends Component { } } + onInsertByStorage () { + Common.Gateway.requestInsertImage('add'); + this.closeModal(); + } + render () { return ( ) } @@ -57,4 +64,4 @@ class AddImageController extends Component { const AddImageWithTranslation = withTranslation()(AddImageController); -export {AddImageWithTranslation as AddImageController}; \ No newline at end of file +export {AddImageWithTranslation as AddImageController}; diff --git a/apps/spreadsheeteditor/mobile/src/controller/edit/EditImage.jsx b/apps/spreadsheeteditor/mobile/src/controller/edit/EditImage.jsx index 298d82c4ca..2f086d0109 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/edit/EditImage.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/edit/EditImage.jsx @@ -11,6 +11,7 @@ class EditImageController extends Component { this.onRemoveImage = this.onRemoveImage.bind(this); this.onReplaceByFile = this.onReplaceByFile.bind(this); this.onReplaceByUrl = this.onReplaceByUrl.bind(this); + this.onReplaceByStorage = this.onReplaceByStorage.bind(this); } onReorder(type) { @@ -74,6 +75,10 @@ class EditImageController extends Component { this.closeModal(); } + onReplaceByStorage () { + Common.Gateway.requestInsertImage('change'); + this.closeModal(); + } render () { return ( @@ -83,9 +88,10 @@ class EditImageController extends Component { onReplaceByFile={this.onReplaceByFile} onDefaultSize={this.onDefaultSize} onReplaceByUrl={this.onReplaceByUrl} + onReplaceByStorage={this.onReplaceByStorage} /> ) } } -export default EditImageController; \ No newline at end of file +export default EditImageController; diff --git a/apps/spreadsheeteditor/mobile/src/store/appOptions.js b/apps/spreadsheeteditor/mobile/src/store/appOptions.js index 497d8ff286..94039b3ea3 100644 --- a/apps/spreadsheeteditor/mobile/src/store/appOptions.js +++ b/apps/spreadsheeteditor/mobile/src/store/appOptions.js @@ -14,13 +14,17 @@ export class storeAppOptions { lostEditingRights: observable, changeEditingRights: action, - + canBranding: observable, canBrandingExt: observable, isDocReady: observable, changeDocReady: action, + + canRequestInsertImage: observable, + changeCanRequestInsertImage: action, + customization: observable, }); } @@ -52,6 +56,11 @@ export class storeAppOptions { this.isDocReady = value; } + canRequestInsertImage = false; + changeCanRequestInsertImage(value) { + this.canRequestInsertImage = value; + } + setConfigOptions (config, _t) { this.config = config; this.customization = config.customization; @@ -64,7 +73,7 @@ export class storeAppOptions { this.canRename = this.config.canRename; this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now())); this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id); - + config.user = this.user; this.isDesktopApp = config.targetApp == 'desktop'; this.canCreateNew = !!config.createUrl && !this.isDesktopApp; @@ -82,6 +91,7 @@ export class storeAppOptions { this.mergeFolderUrl = config.mergeFolderUrl; this.canAnalytics = false; this.canRequestClose = config.canRequestClose; + this.canRequestInsertImage = config.canRequestInsertImage === true; this.canCloseEditor = false; let canBack = false; @@ -149,12 +159,12 @@ export class storeAppOptions { const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType); this.canDownloadOrigin = permissions.download !== false && (type && typeof type[1] === 'string'); this.canDownload = permissions.download !== false && (!type || typeof type[1] !== 'string'); - this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization + this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object')); this.canUseCommentPermissions = this.canLicense && !!permissions.commentGroups; this.canUseUserInfoPermissions = this.canLicense && !!permissions.userInfoGroups; this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions); - this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); + this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups); this.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(permissions.userInfoGroups); this.canUseHistory = this.canLicense && this.config.canUseHistory && this.canCoAuthoring && !this.isDesktopApp && !this.isOffline; diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddImage.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddImage.jsx index 6005b2cc4e..8b6ebcf261 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddImage.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddImage.jsx @@ -1,4 +1,5 @@ import React, {Fragment, useState} from 'react'; +import {observer, inject} from "mobx-react"; import {Page, Navbar, BlockTitle, List, ListItem, ListInput, ListButton, Icon} from 'framework7-react'; import { useTranslation } from 'react-i18next'; import { Device } from '../../../../../common/mobile/utils/device'; @@ -7,10 +8,13 @@ import IconImageLibraryIos from '@common-ios-icons/icon-image-library.svg?ios'; import IconImageLibraryAndroid from '@common-android-icons/icon-image-library.svg'; import IconLinkIos from '@common-ios-icons/icon-link.svg?ios'; import IconLinkAndroid from '@common-android-icons/icon-link.svg'; +import IconImageStorage from '@common-icons/icon-image-storage.svg'; -const AddImageList = props => { +const AddImageList = inject('storeAppOptions')(observer(props => { const { t } = useTranslation(); const _t = t('View.Add', {returnObjects: true}); + const canRequestInsertImage = props.storeAppOptions.canRequestInsertImage; + return ( {props.onInsertByFile()}}> @@ -27,9 +31,15 @@ const AddImageList = props => { } + { + canRequestInsertImage && + {props.onInsertByStorage()}}> + + + } ) -}; +})); const PageLinkSettings = props => { const { t } = useTranslation(); @@ -62,10 +72,10 @@ const AddImage = props => { const _t = t('View.Add', {returnObjects: true}); return ( props.inTabs ? - : + : - + ) }; diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/EditImage.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/EditImage.jsx index 973f54cc02..c24b406f10 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/EditImage.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/EditImage.jsx @@ -14,6 +14,7 @@ import IconImageLibraryIos from '@common-ios-icons/icon-image-library.svg?ios'; import IconImageLibraryAndroid from '@common-android-icons/icon-image-library.svg'; import IconLinkIos from '@common-ios-icons/icon-link.svg?ios'; import IconLinkAndroid from '@common-android-icons/icon-link.svg'; +import IconImageStorage from '@common-icons/icon-image-storage.svg'; const EditImage = props => { const { t } = useTranslation(); @@ -27,7 +28,8 @@ const EditImage = props => { { const PageReplace = props => { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); + const canRequestInsertImage = props.storeAppOptions.canRequestInsertImage; const storeFocusObjects = props.storeFocusObjects; if ((!storeFocusObjects.imageObject || storeFocusObjects.focusOn === 'cell') && Device.phone) { @@ -120,6 +123,12 @@ const PageReplace = props => { } + { + canRequestInsertImage && + {props.onReplaceByStorage()}}> + + + } ) @@ -172,7 +181,7 @@ const PageLinkSettings = props => { }; const EditImageContainer = inject("storeFocusObjects")(observer(EditImage)); -const PageReplaceContainer = inject("storeFocusObjects")(observer(PageReplace)); +const PageReplaceContainer = inject("storeAppOptions","storeFocusObjects")(observer(PageReplace)); const PageReorderContainer = inject("storeFocusObjects")(observer(PageReorder)); const PageLinkSettingsContainer = inject("storeFocusObjects")(observer(PageLinkSettings));