import React, {Fragment, useState} from 'react'; import {observer, inject} from "mobx-react"; import {List, ListItem, Icon, Row, Page, Navbar, NavRight, BlockTitle, Toggle, Range, ListButton, Link, Tabs, Tab} from 'framework7-react'; import { f7 } from 'framework7-react'; import { useTranslation } from 'react-i18next'; import {Device} from '../../../../../common/mobile/utils/device'; import {CustomColorPicker, ThemeColorPalette} from "../../../../../common/mobile/lib/component/ThemeColorPalette.jsx"; const PageCustomFillColor = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); let fillColor = props.storeShapeSettings.fillColor; if (typeof fillColor === 'object') { fillColor = fillColor.color; } const onAddNewColor = (colors, color) => { props.storePalette.changeCustomColors(colors); props.onFillColor(color); props.storeShapeSettings.setFillColor(color); props.f7router.back(); }; return( {Device.phone && } ) }; const PaletteFill = inject("storeFocusObjects", "storeShapeSettings", "storePalette")(observer(props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const storeShapeSettings = props.storeShapeSettings; const shapeObject = props.storeFocusObjects.shapeObject; const curFillColor = storeShapeSettings.fillColor ? storeShapeSettings.fillColor : storeShapeSettings.getFillColor(shapeObject); const customColors = props.storePalette.customColors; const changeColor = (color, effectId, effectValue) => { if (color !== 'empty') { if (effectId !==undefined ) { const newColor = {color: color, effectId: effectId, effectValue: effectValue}; props.onFillColor(newColor); storeShapeSettings.setFillColor(newColor); } else { props.onFillColor(color); storeShapeSettings.setFillColor(color); } } else { // open custom color menu props.f7router.navigate('/edit-shape-custom-fill-color/', {props: {onFillColor: props.onFillColor}}); } }; return( ) })); const PageCustomBorderColor = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); let borderColor = props.storeShapeSettings.borderColorView; if (typeof borderColor === 'object') { borderColor = borderColor.color; } const onAddNewColor = (colors, color) => { props.storePalette.changeCustomColors(colors); props.onBorderColor(color); props.storeShapeSettings.setBorderColor(color); props.f7router.back(); }; return( {Device.phone && } ) }; const PageBorderColor = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const borderColor = props.storeShapeSettings.borderColorView; const customColors = props.storePalette.customColors; const changeColor = (color, effectId, effectValue) => { if (color !== 'empty') { if (effectId !==undefined ) { const newColor = {color: color, effectId: effectId, effectValue: effectValue}; props.onBorderColor(newColor); props.storeShapeSettings.setBorderColor(newColor); } else { props.onBorderColor(color); props.storeShapeSettings.setBorderColor(color); } } else { // open custom color menu props.f7router.navigate('/edit-shape-custom-border-color/', {props: {onBorderColor: props.onBorderColor}}); } }; return( {Device.phone && } ) }; const PageStyle = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const storeShapeSettings = props.storeShapeSettings; const shapeObject = props.storeFocusObjects.shapeObject; const isAndroid = Device.android; let borderSize, borderType, transparent; if (shapeObject) { const stroke = shapeObject.get_ShapeProperties().get_stroke(); borderSize = stroke.get_width() * 72.0 / 25.4; borderType = stroke.get_type(); transparent = shapeObject.get_ShapeProperties().get_fill().asc_getTransparent(); } // Init border size const borderSizeTransform = storeShapeSettings.borderSizeTransform(); const displayBorderSize = (borderType == Asc.c_oAscStrokeType.STROKE_NONE || borderType === undefined) ? 0 : borderSizeTransform.indexSizeByValue(borderSize); const displayTextBorderSize = (borderType == Asc.c_oAscStrokeType.STROKE_NONE || borderType === undefined) ? 0 : borderSizeTransform.sizeByValue(borderSize); const [stateBorderSize, setBorderSize] = useState(displayBorderSize); const [stateTextBorderSize, setTextBorderSize] = useState(displayTextBorderSize); // Init border color const borderColor = !storeShapeSettings.borderColorView ? storeShapeSettings.initBorderColorView(shapeObject) : storeShapeSettings.borderColorView; const displayBorderColor = borderColor !== 'transparent' ? `#${(typeof borderColor === "object" ? borderColor.color : borderColor)}` : borderColor; // Init opacity const opacity = transparent !== null && transparent !== undefined ? transparent / 2.55 : 100; const [stateOpacity, setOpacity] = useState(Math.round(opacity)); if (!shapeObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; } return (
{_t.textFill} {_t.textBorder} {_t.textEffects} {isAndroid && }
{Device.phone && }
{_t.textSize}
{setBorderSize(value); setTextBorderSize(borderSizeTransform.sizeByIndex(value));}} onRangeChanged={(value) => {props.onBorderSize(borderSizeTransform.sizeByIndex(value))}} >
{stateTextBorderSize + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)}
{_t.textOpacity}
{setOpacity(value)}} onRangeChanged={(value) => {props.onOpacity(value)}} >
{stateOpacity + ' %'}
) }; const PageStyleNoFill = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const storeShapeSettings = props.storeShapeSettings; const shapeObject = props.storeFocusObjects.shapeObject; let borderSize, borderType; if (shapeObject) { const stroke = shapeObject.get_ShapeProperties().get_stroke(); borderSize = stroke.get_width() * 72.0 / 25.4; borderType = stroke.get_type(); } // Init border size const borderSizeTransform = storeShapeSettings.borderSizeTransform(); const displayBorderSize = (borderType == Asc.c_oAscStrokeType.STROKE_NONE || borderType === undefined) ? 0 : borderSizeTransform.indexSizeByValue(borderSize); const displayTextBorderSize = (borderType == Asc.c_oAscStrokeType.STROKE_NONE || borderType === undefined) ? 0 : borderSizeTransform.sizeByValue(borderSize); const [stateBorderSize, setBorderSize] = useState(displayBorderSize); const [stateTextBorderSize, setTextBorderSize] = useState(displayTextBorderSize); // Init border color const borderColor = !storeShapeSettings.borderColorView ? storeShapeSettings.initBorderColorView(shapeObject) : storeShapeSettings.borderColorView; const displayBorderColor = borderColor !== 'transparent' ? `#${(typeof borderColor === "object" ? borderColor.color : borderColor)}` : borderColor; if (!shapeObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; } return ( {Device.phone && }
{_t.textSize}
{setBorderSize(value); setTextBorderSize(borderSizeTransform.sizeByIndex(value));}} onRangeChanged={(value) => {props.onBorderSize(borderSizeTransform.sizeByIndex(value))}} >
{stateTextBorderSize + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)}
) }; const PageWrap = props => { const isAndroid = Device.android; const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const storeShapeSettings = props.storeShapeSettings; const shapeObject = props.storeFocusObjects.shapeObject; let wrapType, align, moveText, overlap, distance; if (shapeObject) { wrapType = storeShapeSettings.getWrapType(shapeObject); align = storeShapeSettings.getAlign(shapeObject); moveText = storeShapeSettings.getMoveText(shapeObject); overlap = storeShapeSettings.getOverlap(shapeObject); distance = Common.Utils.Metric.fnRecalcFromMM(storeShapeSettings.getWrapDistance(shapeObject)); } const metricText = Common.Utils.Metric.getCurrentMetricName(); const [stateDistance, setDistance] = useState(distance); if (!shapeObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; } return ( {Device.phone && } {props.onWrapType('inline')}}> {!isAndroid && } {props.onWrapType('square')}}> {!isAndroid && } {props.onWrapType('tight')}}> {!isAndroid && } {props.onWrapType('through')}}> {!isAndroid && } {props.onWrapType('top-bottom')}}> {!isAndroid && } {props.onWrapType('infront')}}> {!isAndroid && } {props.onWrapType('behind')}}> {!isAndroid && } {('behind' !== wrapType && 'infront' !== wrapType) && {_t.textDistanceFromText}
{setDistance(value)}} onRangeChanged={(value) => {props.onWrapDistance(value)}} >
{stateDistance + ' ' + metricText}
} {wrapType !== 'inline' && {_t.textAlign} { props.onShapeAlign(Asc.c_oAscAlignH.Left) }}> { props.onShapeAlign(Asc.c_oAscAlignH.Center) }}> { props.onShapeAlign(Asc.c_oAscAlignH.Right) }}> } {props.onMoveText(!moveText)}}/> {props.onOverlap(!overlap)}}/>
) }; const PageReplace = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const storeShapeSettings = props.storeShapeSettings; let shapes = storeShapeSettings.getStyleGroups(); shapes.splice(0, 1); // Remove line shapes const shapeObject = props.storeFocusObjects.shapeObject; if (!shapeObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; } return ( {Device.phone && } {shapes.map((row, indexRow) => { return ( ) })} ) }; const PageReorder = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const shapeObject = props.storeFocusObjects.shapeObject; if (!shapeObject && Device.phone) { $$('.sheet-modal.modal-in').length > 0 && f7.sheet.close(); return null; } return ( {Device.phone && } {props.onReorder('all-up')}} className='no-indicator'> {props.onReorder('all-down')}} className='no-indicator'> {props.onReorder('move-up')}} className='no-indicator'> {props.onReorder('move-down')}} className='no-indicator'> ) }; const EditShape = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const api = Common.EditorApi.get(); const canFill = props.storeFocusObjects.shapeObject.get_ShapeProperties().get_CanFill(); const shapeObject = props.storeFocusObjects.shapeObject; const wrapType = props.storeShapeSettings.getWrapType(shapeObject); const settings = props.storeFocusObjects.settings; const shapeType = shapeObject.get_ShapeProperties().asc_getType(); const hideChangeType = shapeObject.get_ShapeProperties().get_FromChart() || shapeObject.get_ShapeProperties().get_FromSmartArt() || shapeType=='line' || shapeType=='bentConnector2' || shapeType=='bentConnector3' || shapeType=='bentConnector4' || shapeType=='bentConnector5' || shapeType=='curvedConnector2' || shapeType=='curvedConnector3' || shapeType=='curvedConnector4' || shapeType=='curvedConnector5' || shapeType=='straightConnector1'; const isSmartArtInternal = shapeObject.get_ShapeProperties().get_FromSmartArtInternal(); const isFromGroup = shapeObject.get_ShapeProperties().get_FromGroup(); const inControl = api.asc_IsContentControl(); const controlProps = (api && inControl) ? api.asc_GetContentControlProperties() : null; const lockType = controlProps ? controlProps.get_Lock() : Asc.c_oAscSdtLockType.Unlocked; let fixedSize = false; if (controlProps) { let spectype = controlProps.get_SpecificType(); fixedSize = (spectype == Asc.c_oAscContentControlSpecificType.CheckBox || spectype == Asc. c_oAscContentControlSpecificType.ComboBox || spectype == Asc.c_oAscContentControlSpecificType.DropDownList || spectype == Asc.c_oAscContentControlSpecificType.None || spectype == Asc.c_oAscContentControlSpecificType.Picture || spectype == Asc.c_oAscContentControlSpecificType.Complex) && controlProps.get_FormPr() && controlProps.get_FormPr().get_Fixed(); } let disableRemove = !!props.storeFocusObjects.paragraphObject || (lockType == Asc.c_oAscSdtLockType.SdtContentLocked || lockType == Asc.c_oAscSdtLockType.SdtLocked); return ( {!fixedSize ? canFill ? : : null} {(!isFromGroup && settings.indexOf('image') === -1) && } {(!hideChangeType && !fixedSize) && } {(wrapType !== 'inline' && !isSmartArtInternal && settings.indexOf('image') === -1) && } {settings.indexOf('image') === -1 && {props.onRemoveShape()}} className={`button-red button-fill button-raised${disableRemove ? ' disabled' : ''}`} /> } ) }; const EditShapeContainer = inject("storeFocusObjects","storeShapeSettings")(observer(EditShape)); const PageShapeStyle = inject("storeFocusObjects", "storeShapeSettings")(observer(PageStyle)); const PageShapeStyleNoFill = inject("storeFocusObjects", "storeShapeSettings")(observer(PageStyleNoFill)); const PageShapeCustomFillColor = inject("storeFocusObjects", "storeShapeSettings", "storePalette")(observer(PageCustomFillColor)); const PageShapeBorderColor = inject("storeShapeSettings", "storePalette")(observer(PageBorderColor)); const PageShapeCustomBorderColor = inject("storeShapeSettings", "storePalette")(observer(PageCustomBorderColor)); const PageWrapContainer = inject("storeShapeSettings", "storeFocusObjects")(observer(PageWrap)); const PageReplaceContainer = inject("storeShapeSettings","storeFocusObjects")(observer(PageReplace)); const PageReorderContainer = inject("storeFocusObjects")(observer(PageReorder)); export {EditShapeContainer as EditShape, PageShapeStyle, PageShapeStyleNoFill, PageShapeCustomFillColor, PageShapeBorderColor, PageShapeCustomBorderColor, PageWrapContainer as PageWrap, PageReplaceContainer as PageReplace, PageReorderContainer as PageReorder}