Skip to content

Commit

Permalink
feat: update version
Browse files Browse the repository at this point in the history
  • Loading branch information
杨国璇 authored and 杨国璇 committed Oct 12, 2024
1 parent d1dcbf4 commit 604755e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seafile/seafile-editor",
"version": "1.0.119",
"version": "1.0.120",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/constants/event-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const INTERNAL_EVENTS = {
ON_SELECT_ALL_CELL: 'on_select_all_cell',
ON_TOGGLE_IMAGE_POPOVER: 'on_toggle_image_popover',
OUTLINE_STATE_CHANGED: 'outline_state_changed',
RESIZE_ARTICLE: 'resize_article',
};

export const EXTERNAL_EVENTS = {
Expand Down
9 changes: 8 additions & 1 deletion src/containers/article-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback, useState, useMemo, useEffect } from 'react';
import PropTypes from 'prop-types';
import ResizeWidth from './resize-width';
import EventBus from '../../utils/event-bus';
import { EXTERNAL_EVENTS } from '../../constants/event-types';
import { EXTERNAL_EVENTS, INTERNAL_EVENTS } from '../../constants/event-types';

import './style.css';

Expand Down Expand Up @@ -30,6 +30,8 @@ const ArticleInfo = ({ isVisible }) => {
const resizeWidth = useCallback((width) => {
if (width >= MIN_PANEL_WIDTH && width <= MAX_PANEL_WIDTH) {
setWidth(width);
const eventBus = EventBus.getInstance();
eventBus.dispatch(INTERNAL_EVENTS.RESIZE_ARTICLE);
}
}, []);

Expand Down Expand Up @@ -58,6 +60,11 @@ const ArticleInfo = ({ isVisible }) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
const eventBus = EventBus.getInstance();
eventBus.dispatch(INTERNAL_EVENTS.RESIZE_ARTICLE);
}, [isVisible, fileDetails]);

const { component: fileDetailsComponent, props: fileDetailsProps } = fileDetails || {};
return (
<div className="sf-article-info-container-wrapper" style={containerWrapperStyle}>
Expand Down
4 changes: 3 additions & 1 deletion src/editors/slate-editor/editor-help/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import classNames from 'classnames';
import EventBus from '../../../utils/event-bus';
import { EXTERNAL_EVENTS } from '../../../constants/event-types';
import { EXTERNAL_EVENTS, INTERNAL_EVENTS } from '../../../constants/event-types';
import HotKeysHelper from '../../../containers/hotkeys-helper';
import ArticleInfo from '../../../containers/article-info';

Expand All @@ -20,6 +20,8 @@ export default function EditorHelp({ children }) {
const updateHelpInfoState = useCallback((state) => {
setIsShowHelpInfo(state);
setIsShowArticleInfo(false);
const eventBus = EventBus.getInstance();
eventBus.dispatch(INTERNAL_EVENTS.RESIZE_ARTICLE);
}, []);

useEffect(() => {
Expand Down
11 changes: 5 additions & 6 deletions src/editors/slate-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ export default function SlateEditor({ value, editorApi, onSave, onContentChanged
}
}, []);

useEffect(() => {
const eventBus = EventBus.getInstance();
const unsubscribeOutline = eventBus.subscribe(INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, handleWindowResize);
return unsubscribeOutline;
}, [handleWindowResize]);

useEffect(() => {
handleWindowResize();
window.addEventListener('resize', handleWindowResize);
const eventBus = EventBus.getInstance();
const unsubscribeOutline = eventBus.subscribe(INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, handleWindowResize);
const unsubscribeResizeArticle = eventBus.subscribe(INTERNAL_EVENTS.RESIZE_ARTICLE, handleWindowResize);
return () => {
window.removeEventListener('resize', handleWindowResize);
unsubscribeOutline();
unsubscribeResizeArticle();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down

0 comments on commit 604755e

Please sign in to comment.