fix table cell and row properties not showing properly

This commit is contained in:
ammarahm-ed
2022-01-08 10:17:05 +05:00
parent 7506ff0d4b
commit 3f9bc53dd3
4 changed files with 61 additions and 16 deletions

View File

@@ -52,6 +52,7 @@ const GeneralSheet = ({context}) => {
gestureEnabled={!dialogData.progress}
closeOnTouchBackdrop={!dialogData.progress}
onClose={() => {
dialogData.onClose && dialogData.onClose();
if (!dialogData.progress) {
setVisible(false);
setDialogData(null);

View File

@@ -36,6 +36,7 @@ import {
IMAGE_TOOLTIP_CONFIG,
TABLE_TOOLTIP_CONFIG
} from './tiny/toolbar/config';
import { focusEditor, reFocusEditor } from './tiny/toolbar/constants';
export let EditorWebView = createRef();
export const editorTitleInput = createRef();
@@ -482,20 +483,10 @@ export const _onMessage = async evt => {
showTableOptionsTooltip();
break;
case 'tablecelloptions':
eSendEvent('updatecell', message.value);
safeKeyboardDismiss();
await sleep(100);
presentSheet({
component: <TableCellProperties data={message.value} />
});
TableCellProperties.present(message.value);
break;
case 'tablerowoptions':
eSendEvent('updaterow', message.value);
safeKeyboardDismiss();
await sleep(100);
presentSheet({
component: <TableRowProperties data={message.value} />
});
TableRowProperties.present(message.value);
break;
case 'selectionvalue':
eSendEvent('selectionvalue', message.value);

View File

@@ -7,7 +7,13 @@ import {PressableButton} from '../../components/PressableButton';
import Heading from '../../components/Typography/Heading';
import Paragraph from '../../components/Typography/Paragraph';
import {useTracked} from '../../provider';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
} from '../../services/EventManager';
import { editing } from '../../utils';
import layoutmanager from '../../utils/layout-manager';
import {SIZE} from '../../utils/SizeUtils';
import {EditorWebView} from './Functions';
@@ -215,7 +221,9 @@ export const TableCellProperties = ({data}) => {
title="Body"
/>
</View>
<Heading size={SIZE.md}>Cell background color(${cellOptions.backgroundColor})</Heading>
<Heading size={SIZE.md}>
Cell background color(${cellOptions.backgroundColor})
</Heading>
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
@@ -227,7 +235,7 @@ export const TableCellProperties = ({data}) => {
<ColorItem
value={item}
key={item}
checked={item === (rgbToHex(cellOptions.backgroundColor))}
checked={item === rgbToHex(cellOptions.backgroundColor)}
onCustomPress={color => {
tiny.call(
EditorWebView,
@@ -245,3 +253,25 @@ export const TableCellProperties = ({data}) => {
</View>
);
};
TableCellProperties.isPresented = false;
TableCellProperties.present = data => {
eSendEvent('updaterow', data);
if (TableCellProperties.isPresented) return;
let refocus = false;
if (editing.keyboardState) {
tiny.call(EditorWebView, tiny.cacheRange);
tiny.call(EditorWebView, tiny.blur);
refocus = true;
}
TableCellProperties.isPresented = true;
presentSheet({
component: <TableCellProperties data={data} />,
onClose: () => {
TableCellProperties.isPresented = false;
if (!refocus) return;
tiny.call(EditorWebView, tiny.focusEditor);
tiny.call(EditorWebView, tiny.restoreRange);
tiny.call(EditorWebView, tiny.clearRange);
}
});
};

View File

@@ -4,7 +4,8 @@ import {ScrollView} from 'react-native-gesture-handler';
import {Button} from '../../components/Button';
import Heading from '../../components/Typography/Heading';
import {useTracked} from '../../provider';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
import {eSendEvent, eSubscribeEvent, eUnSubscribeEvent, presentSheet} from '../../services/EventManager';
import { editing } from '../../utils';
import layoutmanager from '../../utils/layout-manager';
import {SIZE} from '../../utils/SizeUtils';
import {EditorWebView} from './Functions';
@@ -168,3 +169,25 @@ export const TableRowProperties = ({data}) => {
</View>
);
};
TableRowProperties.isPresented = false;
TableRowProperties.present = data => {
eSendEvent('updatecell', data);
if (TableRowProperties.isPresented) return;
let refocus = false;
if (editing.keyboardState) {
tiny.call(EditorWebView,tiny.cacheRange);
tiny.call(EditorWebView,tiny.blur);
refocus = true;
}
TableRowProperties.isPresented = true;
presentSheet({
component: <TableRowProperties data={data} />,
onClose: () => {
TableRowProperties.isPresented = false;
if (!refocus) return;
tiny.call(EditorWebView,tiny.focusEditor);
tiny.call(EditorWebView,tiny.restoreRange);
tiny.call(EditorWebView,tiny.clearRange);
}
});
};