Skip to content

Commit

Permalink
fix: 修复插件划词问题 & 快捷键唤起问题
Browse files Browse the repository at this point in the history
  • Loading branch information
moshangqi committed Oct 30, 2023
1 parent d0c85d1 commit 6afe2bf
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/components/AntdLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function AntdLayout(props: IAntdLayoutProps) {
Select: {
optionSelectedBg: '#EFF0F0',
},
Tooltip: {
colorBgSpotlight: 'rgba(0, 0, 0, 0.75)',
fontSize: 12,
},
},
}}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SelectSavePosition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function SelectSavePosition(props: ISelectSavePositionProps) {
const positionList = useMemo(() => {
return [
{ value: 'note', label: __i18n('保存小记') },
{ value: 'book', label: __i18n('存到文档') },
{ value: 'book', label: __i18n('存为文档') },
];
}, []);

Expand Down
4 changes: 2 additions & 2 deletions src/components/SuperSideBar/container/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function SuperSidebarHeader() {
</div>
<div className={styles.right}>
<div className={styles.infoWrapper}>
<Tooltip title={__i18n('访问语雀')} mouseEnterDelay={0.5}>
<Tooltip title={__i18n('访问语雀')}>
<div className={styles.itemWrapper} onClick={openHome}>
<Icon component={HomeSvg} />
</div>
Expand All @@ -78,7 +78,7 @@ function SuperSidebarHeader() {
<Icon component={SettingSvg} />
</div>
) : (
<Tooltip title={__i18n('设置')} mouseEnterDelay={0.5}>
<Tooltip title={__i18n('设置')}>
<div className={styles.itemWrapper} onClick={openSetting}>
<Icon component={SettingSvg} />
</div>
Expand Down
10 changes: 7 additions & 3 deletions src/components/SuperSideBar/impl/ClipAssistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function ClipContent() {
{renderLoading()}
<div className={styles.headerWrapper}>
<Tooltip
title={shortcutMap.selectArea}
title={isRunningInjectPage ? shortcutMap.selectArea : ''}
getPopupContainer={node => node}
>
<div
Expand All @@ -313,7 +313,10 @@ function ClipContent() {
<span>{__i18n('选取剪藏')}</span>
</div>
</Tooltip>
<Tooltip title={shortcutMap.startOcr} getPopupContainer={node => node}>
<Tooltip
title={isRunningInjectPage ? shortcutMap.startOcr : ''}
getPopupContainer={node => node}
>
<div
className={styles.headerItem}
onClick={onScreenOcr}
Expand All @@ -325,7 +328,7 @@ function ClipContent() {
</Tooltip>

<Tooltip
title={shortcutMap.collectLink}
title={isRunningInjectPage ? shortcutMap.collectLink : ''}
placement="top"
getPopupContainer={node => node}
>
Expand Down Expand Up @@ -358,6 +361,7 @@ function ClipContent() {
value=""
onLoad={onLoad}
uploadImage={onUploadImage as any}
onSave={onSave}
/>
</div>
{selectSavePosition?.id === DefaultSavePosition.id && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/lake-editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default forwardRef<IEditorRef, EditorProps>((props, ref) => {
},
],
},
placeholder: __i18n('输入正文'),
placeholder: __i18n('输入内容...'),
defaultFontsize: 14,
});
newEditor.on('visitLink', (url: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/components/lake-editor/template-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const templateHtml = `
display: flex;
flex-direction: column;
overflow: hidden;
-webkit-font-smoothing: antialiased;
}
.toolbar-container {
display: none;
Expand Down
2 changes: 0 additions & 2 deletions src/pages/inject/WordMark/Panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ function WordMarkPanel(props: WordMarkPanelProps) {
trigger="hover"
placement="bottom"
getPopupContainer={node => node as HTMLElement}
mouseEnterDelay={0.5}
>
<div className={styles.saveOperateItem} onClick={onSave}>
<Icon component={NoteLogoSvg} />
Expand All @@ -137,7 +136,6 @@ function WordMarkPanel(props: WordMarkPanelProps) {
trigger="hover"
placement="bottom"
getPopupContainer={node => node.parentElement as HTMLElement}
mouseEnterDelay={0.5}
>
<div className={styles.saveOperateItem} onClick={onCopyText}>
<Icon component={CopySvg} />
Expand Down
11 changes: 9 additions & 2 deletions src/pages/inject/WordMark/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function WordMarkApp() {
// 展开侧边栏
window._yuque_ext_app.showSidePanel();
// 发送消息在编辑器内加入内容
window._yuque_ext_app?.sendMessageToSidePanel(
window._yuque_ext_app?.sendMessageToClipAssistant(
ClipAssistantMessageActions.addContent,
text,
);
Expand Down Expand Up @@ -208,7 +208,14 @@ function WordMarkApp() {
useEffect(() => {
const onkeydown = (e: KeyboardEvent) => {
e.preventDefault();
setVisible(v => !v);
setVisible(v => {
message.success(
!v
? __i18n('本次访问已开启划词工具栏')
: __i18n('本次访问已关闭划词工具栏'),
);
return !v;
});
};
keymaster(wordMarkContext.evokeWordMarkShortKey, onkeydown);

Expand Down
10 changes: 7 additions & 3 deletions src/pages/inject/content-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,19 @@ export class App {
this._sidePanelStatus = SidePanelStatus.Hidden;
}

async showSidePanel() {
await this.initSidePanel();

private arouseSidePanel() {
this.sidePanelIframe?.contentWindow?.postMessage(
{
key: SidePanelMessageKey,
action: SidePanelMessageActions.arouse,
},
'*',
);
}

async showSidePanel() {
await this.initSidePanel();
this.arouseSidePanel();
this.sidePanelIframe?.classList.add('show');
this._sidePanelStatus = SidePanelStatus.Visible;
}
Expand Down Expand Up @@ -231,6 +234,7 @@ export class App {
action: ClipAssistantMessageActions,
data?: any,
) {
this.arouseSidePanel();
await this.initSidePanel();
await this.addListenClipAssistantReady();
this.sidePanelIframe?.contentWindow?.postMessage(
Expand Down
4 changes: 4 additions & 0 deletions src/styles/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
margin: 0;
}

body {
-webkit-font-smoothing: antialiased;
}

.yuque-chrome-extension-tooltip > .yuque-chrome-extension-tooltip-arrow {
display: none;
}

0 comments on commit 6afe2bf

Please sign in to comment.