mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
Merge to master (#445)
* Fix/venus spanish (#423) fix: update venus spanish language Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> * fix: can not convert url text to link after paste * fix: double link icon size error * feat(code): enhance markdown parse code * fix(code): add robust * fix: remove special menu * chore: clean code * fix: ime with command menu * fix(code): langs[lang] is not a function * fix: can't add image and delete more action button (#430) * feat: add zh_Hant for venus (#431) * fix: lang select in code block is insanity * GitHub Doc Updates (#421) * Update types-of-contributions.md * Update README.md Tidy up links section * fix: inline menu position (#433) * Master (#436) * Fix/venus spanish (#423) (#425) fix: update venus spanish language Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> * Merge to master (#435) * Fix/venus spanish (#423) fix: update venus spanish language Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> * fix: can not convert url text to link after paste * fix: double link icon size error * feat(code): enhance markdown parse code * fix(code): add robust * fix: remove special menu * chore: clean code * fix: ime with command menu * fix(code): langs[lang] is not a function * fix: can't add image and delete more action button (#430) * feat: add zh_Hant for venus (#431) * fix: lang select in code block is insanity * GitHub Doc Updates (#421) * Update types-of-contributions.md * Update README.md Tidy up links section * fix: inline menu position (#433) Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: QiShaoXuan <qishaoxuan777@gmail.com> Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com> Co-authored-by: DiamondThree <diamond.shx@gmail.com> Co-authored-by: CJSS <CJSS@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: QiShaoXuan <qishaoxuan777@gmail.com> Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com> Co-authored-by: DiamondThree <diamond.shx@gmail.com> Co-authored-by: CJSS <CJSS@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com> * fix: close select popover after mouse leave code block * docs: add jobs * docs: update job docs structure * fix: typo * Update affine.pro.md * Update affine.pro.md * Update affine.pro.md * feat: add Serbian language to venus (#441) * refactor: redesign loading workspace db * chore: remove unuse site logic * feat: affine-embed-header * Update affine.pro.md * feat: add German language to venus (#443) * fix: connection state * refactor: jd Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: QiShaoXuan <qishaoxuan777@gmail.com> Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com> Co-authored-by: DiamondThree <diamond.shx@gmail.com> Co-authored-by: CJSS <CJSS@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com> Co-authored-by: DarkSky <darksky2048@gmail.com> Co-authored-by: HeJiachen-PM <79301703+HeJiachen-PM@users.noreply.github.com>
This commit is contained in:
@@ -153,6 +153,7 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {
|
||||
const langType: string = block.getProperty('lang');
|
||||
const [extensions, setExtensions] = useState<Extension[]>();
|
||||
const [showOperationPanel, setShowOperationPanel] = useState(false);
|
||||
const [selectOpen, setSelectOpen] = useState(false);
|
||||
const isSelecting = useRef(false);
|
||||
const codeMirror = useRef<ReactCodeMirrorRef>();
|
||||
const focusCode = () => {
|
||||
@@ -197,6 +198,7 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {
|
||||
setShowOperationPanel(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setSelectOpen(false);
|
||||
!isSelecting.current && setShowOperationPanel(false);
|
||||
}}
|
||||
>
|
||||
@@ -210,9 +212,11 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {
|
||||
onChange={(selectedValue: string) => {
|
||||
handleLangChange(selectedValue);
|
||||
}}
|
||||
onListboxOpenChange={() => {
|
||||
onListboxOpenChange={open => {
|
||||
setSelectOpen(open);
|
||||
isSelecting.current = true;
|
||||
}}
|
||||
open={selectOpen}
|
||||
>
|
||||
{Object.keys(langs).map(item => {
|
||||
return (
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
type ForwardedRef,
|
||||
type ReactNode,
|
||||
type RefAttributes,
|
||||
useEffect,
|
||||
} from 'react';
|
||||
/* eslint-disable no-restricted-imports */
|
||||
import SelectUnstyled, {
|
||||
@@ -15,13 +16,13 @@ import SelectUnstyled, {
|
||||
import PopperUnstyled from '@mui/base/PopperUnstyled';
|
||||
import { ArrowDropDownIcon } from '@toeverything/components/icons';
|
||||
import { styled } from '../styled';
|
||||
|
||||
type ExtendSelectProps = {
|
||||
// Width is always used custom, it will be set to root button and popover
|
||||
width?: number | string;
|
||||
style?: CSSProperties;
|
||||
listboxStyle?: CSSProperties;
|
||||
placeholder?: ReactNode;
|
||||
open?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,6 @@ export const Select = forwardRef(function CustomSelect<TValue>(
|
||||
props: ExtendSelectProps & SelectUnstyledProps<TValue>,
|
||||
ref: ForwardedRef<HTMLUListElement>
|
||||
) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const {
|
||||
width = '100%',
|
||||
style,
|
||||
@@ -48,7 +48,11 @@ export const Select = forwardRef(function CustomSelect<TValue>(
|
||||
placeholder,
|
||||
onListboxOpenChange,
|
||||
onChange,
|
||||
open: propsOpen,
|
||||
} = props;
|
||||
const openControlledByProps = propsOpen !== undefined;
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const components: SelectUnstyledProps<TValue>['components'] = {
|
||||
// Root: generateStyledRoot({ width, ...style }),
|
||||
Root: forwardRef((rootProps, rootRef) => {
|
||||
@@ -88,13 +92,13 @@ export const Select = forwardRef(function CustomSelect<TValue>(
|
||||
return (
|
||||
<SelectUnstyled
|
||||
{...props}
|
||||
listboxOpen={isOpen}
|
||||
listboxOpen={openControlledByProps ? propsOpen : isOpen}
|
||||
onListboxOpenChange={open => {
|
||||
setIsOpen(open);
|
||||
!openControlledByProps && setIsOpen(open);
|
||||
onListboxOpenChange?.(open);
|
||||
}}
|
||||
onChange={v => {
|
||||
setIsOpen(false);
|
||||
!openControlledByProps && setIsOpen(false);
|
||||
onChange?.(v);
|
||||
}}
|
||||
ref={ref}
|
||||
|
||||
@@ -8,21 +8,12 @@ import {
|
||||
BlockMatcher,
|
||||
Connectivity,
|
||||
} from '@toeverything/datasource/jwt';
|
||||
import { sleep } from '@toeverything/utils';
|
||||
|
||||
import type { ObserveCallback, ReturnUnobserve } from './observer';
|
||||
import { getObserverName, ObserverManager } from './observer';
|
||||
export type { ObserveCallback, ReturnUnobserve } from './observer';
|
||||
|
||||
const workspaces: Record<string, BlockClientInstance> = {};
|
||||
|
||||
const loading = new Set();
|
||||
|
||||
const waitLoading = async (key: string) => {
|
||||
while (loading.has(key)) {
|
||||
await sleep(50);
|
||||
}
|
||||
};
|
||||
const workspaces: Record<string, Promise<BlockClientInstance>> = {};
|
||||
|
||||
async function _getCurrentToken() {
|
||||
if (!process.env['NX_LOCAL']) {
|
||||
@@ -48,20 +39,15 @@ async function _getBlockDatabase(
|
||||
workspace: string,
|
||||
options?: BlockInitOptions
|
||||
) {
|
||||
if (loading.has(workspace)) {
|
||||
await waitLoading(workspace);
|
||||
}
|
||||
|
||||
if (!workspaces[workspace]) {
|
||||
loading.add(workspace);
|
||||
workspaces[workspace] = await BlockClient.init(workspace, {
|
||||
enabled: _enabled[workspace] || ['idb'],
|
||||
...options,
|
||||
token: await _getCurrentToken(),
|
||||
});
|
||||
workspaces[workspace] = _getCurrentToken().then(token =>
|
||||
BlockClient.init(workspace, {
|
||||
enabled: _enabled[workspace] || ['idb'],
|
||||
...options,
|
||||
token,
|
||||
})
|
||||
);
|
||||
(window as any).client = workspaces[workspace];
|
||||
await workspaces[workspace].buildIndex();
|
||||
loading.delete(workspace);
|
||||
}
|
||||
return workspaces[workspace];
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ export class BlockClient<
|
||||
const { importData, exportData, hasExporter, installExporter } =
|
||||
getDataExporter();
|
||||
|
||||
const instance = await YjsAdapter.init(workspace, {
|
||||
const yjsAdapter = await YjsAdapter.init(workspace, {
|
||||
provider: getYjsProviders({
|
||||
enabled: [],
|
||||
backend: BucketBackend.YjsWebSocketAffine,
|
||||
@@ -652,10 +652,17 @@ export class BlockClient<
|
||||
}),
|
||||
...options,
|
||||
});
|
||||
return new BlockClient(instance, workspace, {
|
||||
...options,
|
||||
installExporter,
|
||||
});
|
||||
|
||||
const blockClient: BlockClientInstance = new BlockClient(
|
||||
yjsAdapter,
|
||||
workspace,
|
||||
{
|
||||
...options,
|
||||
installExporter,
|
||||
}
|
||||
);
|
||||
await blockClient.buildIndex();
|
||||
return blockClient;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@ function getLocation() {
|
||||
function getCollaborationPoint() {
|
||||
const { protocol, host } = getLocation();
|
||||
const ws = protocol.startsWith('https') ? 'wss' : 'ws';
|
||||
const isOnline = host.endsWith('affine.pro');
|
||||
const site = isOnline ? host : 'localhost:3000';
|
||||
return `${ws}://${site}/collaboration/`;
|
||||
return `${ws}://${host}/collaboration/`;
|
||||
}
|
||||
|
||||
export const BucketBackend = {
|
||||
|
||||
@@ -118,7 +118,7 @@ export const getYjsProviders = (
|
||||
// TODO: synced will also be triggered on reconnection after losing sync
|
||||
// There needs to be an event mechanism to emit the synchronization state to the upper layer
|
||||
ws.once('synced', () => resolve());
|
||||
ws.once('lost-connection', () => resolve());
|
||||
ws.once('lost-connection', () => reject());
|
||||
ws.once('connection-error', () => reject());
|
||||
ws.on('synced', () => instances.emitState('connected'));
|
||||
ws.on('lost-connection', () =>
|
||||
|
||||
Reference in New Issue
Block a user