[DE mobile] Add cut, copy, paste handler in context menu
This commit is contained in:
parent
fd561f3687
commit
c5ef8766d6
|
@ -29,7 +29,7 @@ class ContextMenuView extends Component {
|
||||||
{buttons.map((b, index) =>
|
{buttons.map((b, index) =>
|
||||||
!b.icon ?
|
!b.icon ?
|
||||||
<ListButton title={b.caption} key={index} onClick={e => this.props.onMenuItemClick(b.event)} /> :
|
<ListButton title={b.caption} key={index} onClick={e => this.props.onMenuItemClick(b.event)} /> :
|
||||||
<ListButton key={index}>
|
<ListButton key={index} onClick={e => this.props.onMenuItemClick(b.event)}>
|
||||||
<Icon slot="media" icon={`icon_mask ${b.icon}`} />
|
<Icon slot="media" icon={`icon_mask ${b.icon}`} />
|
||||||
</ListButton>
|
</ListButton>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -660,6 +660,15 @@ input[type="number"]::-webkit-inner-spin-button {
|
||||||
background-position: -16px -192px;
|
background-position: -16px -192px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.checkbox-in-modal {
|
||||||
|
margin-top: 10px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
.right-text {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,10 @@
|
||||||
"menuReview": "Review",
|
"menuReview": "Review",
|
||||||
"menuOpenLink": "Open Link",
|
"menuOpenLink": "Open Link",
|
||||||
"menuMore": "More",
|
"menuMore": "More",
|
||||||
"menuCancel": "Cancel"
|
"menuCancel": "Cancel",
|
||||||
|
"textCopyCutPasteActions": "Copy, Cut and Paste Actions",
|
||||||
|
"errorCopyCutPaste": "Copy, cut and paste actions using the context menu will be performed within the current file only.",
|
||||||
|
"textDoNotShowAgain": "Don't show again"
|
||||||
},
|
},
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"textCancel": "Cancel",
|
"textCancel": "Cancel",
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { f7 } from 'framework7-react';
|
import { f7 } from 'framework7-react';
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
|
import { withTranslation} from 'react-i18next';
|
||||||
|
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
|
||||||
|
|
||||||
import ContextMenuController from '../../../../common/mobile/lib/controller/ContextMenu';
|
import ContextMenuController from '../../../../common/mobile/lib/controller/ContextMenu';
|
||||||
import { idContextMenuElement } from '../../../../common/mobile/lib/view/ContextMenu';
|
import { idContextMenuElement } from '../../../../common/mobile/lib/view/ContextMenu';
|
||||||
import { Device } from '../../../../common/mobile/utils/device';
|
import { Device } from '../../../../common/mobile/utils/device';
|
||||||
import { withTranslation} from 'react-i18next';
|
|
||||||
|
|
||||||
@inject ( stores => ({
|
@inject ( stores => ({
|
||||||
isEdit: stores.storeAppOptions.isEdit,
|
isEdit: stores.storeAppOptions.isEdit,
|
||||||
|
@ -48,7 +50,23 @@ class ContextMenu extends ContextMenuController {
|
||||||
onMenuItemClick(action) {
|
onMenuItemClick(action) {
|
||||||
super.onMenuItemClick(action);
|
super.onMenuItemClick(action);
|
||||||
|
|
||||||
|
const api = Common.EditorApi.get();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case 'cut':
|
||||||
|
if (!api.Cut() && !LocalStorage.getBool("de-hide-copy-cut-paste-warning")) {
|
||||||
|
this.showCopyCutPasteModal();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'copy':
|
||||||
|
if (!api.Copy() && !LocalStorage.getBool("de-hide-copy-cut-paste-warning")) {
|
||||||
|
this.showCopyCutPasteModal();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'paste':
|
||||||
|
if (!api.Paste() && !LocalStorage.getBool("de-hide-copy-cut-paste-warning")) {
|
||||||
|
this.showCopyCutPasteModal();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'addcomment':
|
case 'addcomment':
|
||||||
Common.Notifications.trigger('addcomment');
|
Common.Notifications.trigger('addcomment');
|
||||||
break;
|
break;
|
||||||
|
@ -60,6 +78,29 @@ class ContextMenu extends ContextMenuController {
|
||||||
console.log("click context menu item: " + action);
|
console.log("click context menu item: " + action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showCopyCutPasteModal() {
|
||||||
|
const { t } = this.props;
|
||||||
|
const _t = t("ContextMenu", { returnObjects: true });
|
||||||
|
f7.dialog.create({
|
||||||
|
title: _t.textCopyCutPasteActions,
|
||||||
|
text: _t.errorCopyCutPaste,
|
||||||
|
content: `<div class="checkbox-in-modal">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" name="checkbox-show" />
|
||||||
|
<i class="icon-checkbox"></i>
|
||||||
|
</label>
|
||||||
|
<span class="right-text">${_t.textDoNotShowAgain}</span>
|
||||||
|
</div>`,
|
||||||
|
buttons: [{
|
||||||
|
text: 'OK',
|
||||||
|
onClick: () => {
|
||||||
|
const dontShow = $$('input[name="checkbox-show"]').prop('checked');
|
||||||
|
if (dontShow) LocalStorage.setItem("de-hide-copy-cut-paste-warning", 1);
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}).open();
|
||||||
|
}
|
||||||
|
|
||||||
onDocumentReady() {
|
onDocumentReady() {
|
||||||
super.onDocumentReady();
|
super.onDocumentReady();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue