This commit is contained in:
ammarahm-ed
2022-01-08 11:34:16 +05:00
parent c28a6187e3
commit 3d8e1ff4e9
3 changed files with 66 additions and 52 deletions

View File

@@ -10,6 +10,10 @@ import SheetWrapper from '../Sheet';
import {Button} from '../Button';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
import tiny from '../../views/Editor/tiny/tiny';
import {EditorWebView} from '../../views/Editor/Functions';
import {editing} from '../../utils';
import {reFocusEditor} from '../../views/Editor/tiny/toolbar/constants';
const GeneralSheet = ({context}) => {
const [state] = useTracked();
@@ -17,6 +21,10 @@ const GeneralSheet = ({context}) => {
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState(null);
const actionSheetRef = useRef();
const editor = useRef({
refocus: false
});
useEffect(() => {
eSubscribeEvent(eOpenProgressDialog, open);
eSubscribeEvent(eCloseProgressDialog, close);
@@ -35,10 +43,35 @@ const GeneralSheet = ({context}) => {
}
setDialogData(data);
setVisible(true);
await sleep(1);
actionSheetRef.current?.setModalVisible(true);
if (data.editor) {
editor.current.refocus = false;
if (editing.keyboardState) {
tiny.call(EditorWebView, tiny.cacheRange);
tiny.call(EditorWebView, tiny.blur);
console.log('here');
editor.current.refocus = true;
}
}
};
useEffect(() => {
(async () => {
if (visible) {
if (dialogData.editor) await sleep(100);
actionSheetRef.current?.setModalVisible(true);
return;
} else {
if (editor.current.refocus) {
editing.isFocused = true;
await reFocusEditor();
tiny.call(EditorWebView, tiny.restoreRange);
tiny.call(EditorWebView, tiny.clearRange);
editor.current.refocus = false;
}
}
})();
}, [visible]);
const close = ctx => {
if ((ctx && !context) || (ctx && ctx !== context)) {
return;

View File

@@ -1,26 +1,23 @@
import React, {useEffect, useState} from 'react';
import {View} from 'react-native';
import {ScrollView} from 'react-native-gesture-handler';
import {ActionIcon} from '../../components/ActionIcon';
import {Button} from '../../components/Button';
import {PressableButton} from '../../components/PressableButton';
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { ActionIcon } from '../../components/ActionIcon';
import { Button } from '../../components/Button';
import Heading from '../../components/Typography/Heading';
import Paragraph from '../../components/Typography/Paragraph';
import {useTracked} from '../../provider';
import { useTracked } from '../../provider';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
} from '../../services/EventManager';
import { editing } from '../../utils';
import layoutmanager from '../../utils/layout-manager';
import {SIZE} from '../../utils/SizeUtils';
import { sleep } from '../../utils/TimeUtils';
import {EditorWebView} from './Functions';
import { SIZE } from '../../utils/SizeUtils';
import { EditorWebView } from './Functions';
import tiny from './tiny/tiny';
import ColorItem from './tiny/toolbar/coloritem';
import {editor_colors, rgbToHex} from './tiny/toolbar/constants';
import { editor_colors, rgbToHex } from './tiny/toolbar/constants';
export const TableCellProperties = ({data}) => {
const [state] = useTracked();
@@ -256,24 +253,14 @@ export const TableCellProperties = ({data}) => {
};
TableCellProperties.isPresented = false;
TableCellProperties.present = async 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;
}
await sleep(100)
eSendEvent('updatecell', data);
if (TableCellProperties.isPresented) return;
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);
}
},
editor:true
});
};

View File

@@ -1,18 +1,21 @@
import React, {useEffect, useState} from 'react';
import {View} from 'react-native';
import {ScrollView} from 'react-native-gesture-handler';
import {Button} from '../../components/Button';
import React, { useEffect, useState } from 'react';
import { View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { Button } from '../../components/Button';
import Heading from '../../components/Typography/Heading';
import {useTracked} from '../../provider';
import {eSendEvent, eSubscribeEvent, eUnSubscribeEvent, presentSheet} from '../../services/EventManager';
import { editing } from '../../utils';
import { useTracked } from '../../provider';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
} from '../../services/EventManager';
import layoutmanager from '../../utils/layout-manager';
import {SIZE} from '../../utils/SizeUtils';
import { sleep } from '../../utils/TimeUtils';
import {EditorWebView} from './Functions';
import { SIZE } from '../../utils/SizeUtils';
import { EditorWebView } from './Functions';
import tiny from './tiny/tiny';
import ColorItem from './tiny/toolbar/coloritem';
import {editor_colors, rgbToHex} from './tiny/toolbar/constants';
import { editor_colors, rgbToHex } from './tiny/toolbar/constants';
export const TableRowProperties = ({data}) => {
const [state] = useTracked();
@@ -172,24 +175,15 @@ export const TableRowProperties = ({data}) => {
};
TableRowProperties.isPresented = false;
TableRowProperties.present = async data => {
eSendEvent('updatecell', data);
eSendEvent('updaterow', data);
if (TableRowProperties.isPresented) return;
let refocus = false;
if (editing.keyboardState) {
tiny.call(EditorWebView,tiny.cacheRange);
tiny.call(EditorWebView,tiny.blur);
refocus = true;
}
await sleep(100)
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);
}
},
editor: true
});
};