diff --git a/src/background/context-menu.ts b/src/background/context-menu.ts
index c7ba1466..28c1426f 100644
--- a/src/background/context-menu.ts
+++ b/src/background/context-menu.ts
@@ -11,7 +11,7 @@ const menuList: MenuItem[] = [
{
id: 'save-to-yuque-notes',
get title() {
- return __i18n('保存到语雀小记');
+ return __i18n('剪藏到语雀');
},
contexts: ['selection'],
},
@@ -25,7 +25,7 @@ const menuList: MenuItem[] = [
{
id: 'save-to-yuque-image',
get title() {
- return __i18n('保存到语雀小记');
+ return __i18n('剪藏到语雀');
},
contexts: ['image'],
},
@@ -43,7 +43,7 @@ export function listenContextMenuEvents() {
const { selectionText } = info;
chromeExtension.scripting.executeScript({
target: { tabId: currentTab?.id as number },
- args: [{ html: `${selectionText}
` }],
+ args: [{ html: `${selectionText}` }],
func: args => {
window._yuque_ext_app.addContentToClipAssistant(args.html, true);
},
diff --git a/src/components/SuperSideBar/impl/ClipAssistant/index.tsx b/src/components/SuperSideBar/impl/ClipAssistant/index.tsx
index 93a4288c..0c91e69d 100644
--- a/src/components/SuperSideBar/impl/ClipAssistant/index.tsx
+++ b/src/components/SuperSideBar/impl/ClipAssistant/index.tsx
@@ -7,16 +7,10 @@ import { backgroundBridge } from '@/core/bridge/background';
import { IStartOcrResult, ocrManager } from '@/core/ocr-manager';
import { getBookmarkHTMLs, transformUrlToFile } from '@/isomorphic/util';
import SelectSavePosition from '@/components/SelectSavePosition';
-import {
- buildParamsForDoc,
- buildParamsForNote,
-} from '@/components/lake-editor/helper';
+import { buildParamsForDoc, buildParamsForNote } from '@/components/lake-editor/helper';
import LinkHelper from '@/isomorphic/link-helper';
import { STORAGE_KEYS } from '@/config';
-import {
- DefaultSavePosition,
- ISavePosition,
-} from '@/core/bridge/background/request/mine';
+import { DefaultSavePosition, ISavePosition } from '@/core/bridge/background/request/mine';
import { ITag } from '@/core/bridge/background/request/tag';
import useClipShortCut from '@/hooks/useClipShortCut';
import {
@@ -48,12 +42,9 @@ function ClipContent() {
const [selectTags, setSelectTags] = useState([]);
const [title, setTitle] = useState('');
- const onTitleChange = useCallback(
- (e: React.ChangeEvent) => {
- setTitle(e.target.value);
- },
- [],
- );
+ const onTitleChange = useCallback((e: React.ChangeEvent) => {
+ setTitle(e.target.value);
+ }, []);
const onLoad = useCallback(() => {
// iframe 加载完成后触发一个 message
@@ -74,10 +65,7 @@ function ClipContent() {
return;
}
- const showSuccessMessage = (
- text: string,
- link: { text: string; href: string },
- ) => {
+ const showSuccessMessage = (text: string, link: { text: string; href: string }) => {
if (Env.isRunningHostPage) {
backgroundBridge.tab.showMessage({
text,
@@ -105,8 +93,8 @@ function ClipContent() {
...(await buildParamsForNote(editor)),
tag_meta_ids: selectTags.map(item => item.id),
};
- await backgroundBridge.request.note.create(noteParams);
- const url = LinkHelper.goMyNote();
+ const result: any = await backgroundBridge.request.note.create(noteParams);
+ const url = LinkHelper.goMyNote(result.data.id);
showSuccessMessage(__i18n('保存成功!'), {
href: url,
text: __i18n('去小记查看'),
@@ -163,27 +151,30 @@ function ClipContent() {
const onClipPage = async () => {
const html = await backgroundBridge.clip.clipPage();
- await addLinkWhenEmpty();
+ const isAddLink = await addLinkWhenEmpty();
+ if (!isAddLink) {
+ editorRef.current?.insertBreakLine();
+ }
editorRef.current?.appendContent(html);
- editorRef.current?.insertBreakLine();
};
const addLinkWhenEmpty = async () => {
if (!editorRef.current?.isEmpty()) {
- return;
+ return false;
}
- const config: IClipConfig = await backgroundBridge.configManager.get(
- 'clip',
- );
- if (!config.addLink) return;
+ const config: IClipConfig = await backgroundBridge.configManager.get('clip');
+ if (!config.addLink) return false;
await onCollectLink();
+ return true;
};
const onSelectArea = async () => {
const html = await backgroundBridge.clip.selectArea();
- await addLinkWhenEmpty();
+ const isAddLink = await addLinkWhenEmpty();
+ if (!isAddLink) {
+ editorRef.current?.insertBreakLine();
+ }
editorRef.current?.appendContent(html);
- editorRef.current?.insertBreakLine();
};
const onScreenOcr = async () => {
@@ -210,10 +201,11 @@ function ClipContent() {
};
});
const text = textArray?.map(item => item.text)?.join('') || '';
- await addLinkWhenEmpty();
-
+ const isAddLink = await addLinkWhenEmpty();
+ if (!isAddLink) {
+ editorRef.current?.insertBreakLine();
+ }
editorRef.current?.appendContent(text);
- editorRef.current?.insertBreakLine();
}
} catch (error) {
console.log('ocr error:', error);
@@ -256,13 +248,16 @@ function ClipContent() {
(div as HTMLDivElement)?.click();
};
- const onMessage = (e: any) => {
+ const onMessage = async (e: any) => {
if (e.data.key !== ClipAssistantMessageKey) {
return;
}
switch (e.data.action) {
case ClipAssistantMessageActions.addContent: {
- addLinkWhenEmpty();
+ const isAddLink = await addLinkWhenEmpty();
+ if (!isAddLink) {
+ editorRef.current?.insertBreakLine();
+ }
editorRef.current?.appendContent(e.data?.data);
break;
}
diff --git a/src/components/lake-editor/editor.tsx b/src/components/lake-editor/editor.tsx
index 36e185c2..2035e35d 100644
--- a/src/components/lake-editor/editor.tsx
+++ b/src/components/lake-editor/editor.tsx
@@ -188,6 +188,10 @@ export default forwardRef((props, ref) => {
},
placeholder: __i18n('输入内容...'),
defaultFontsize: 14,
+ typography: {
+ typography: 'classic',
+ paragraphSpacing: 'relax',
+ },
});
newEditor.on('visitLink', (url: string) => {
window.open(url, '__blank');
diff --git a/src/components/lake-editor/template-html.ts b/src/components/lake-editor/template-html.ts
index aac85212..59027083 100644
--- a/src/components/lake-editor/template-html.ts
+++ b/src/components/lake-editor/template-html.ts
@@ -69,6 +69,9 @@ export const templateHtml = `
.ne-layout-mode-fixed .ne-editor-wrap-content, .ne-layout-mode-adapt .ne-editor-wrap-content {
min-width: 317px;
}
+ .ne-editor-wrap {
+ overscroll-behavior: contain;
+ }
diff --git a/src/core/bridge/background/index.ts b/src/core/bridge/background/index.ts
index 3c55f9dc..8945771c 100644
--- a/src/core/bridge/background/index.ts
+++ b/src/core/bridge/background/index.ts
@@ -24,7 +24,7 @@ export type ICallBridgeImpl = (bridgeName: string, params?: IBridgeParams, callb
export function callBackgroundBridge(bridgeName: string, data?: MapT, callback?: OneArgFunctionT) {
callback =
callback ||
- function () {
+ function() {
// ignore
};
chrome.runtime.sendMessage(
diff --git a/src/core/parseDom/parsePageConfig.ts b/src/core/parseDom/parsePageConfig.ts
index 76307633..6e77c2ba 100644
--- a/src/core/parseDom/parsePageConfig.ts
+++ b/src/core/parseDom/parsePageConfig.ts
@@ -1,6 +1,6 @@
export const parsePageConfig = [
{
- url: 'https?:\\\\/\\\\/www\\\\.toutiao\\\\.com\\\\/w\\\\/([a-zA-Z]\\\\/)?[a-zA-Z]\\\\d{10,}',
+ url: 'https?:\\/\\/www\\.toutiao\\.com\\/w\\/([a-zA-Z]\\/)?[a-zA-Z]\\d{10,}',
include: ['.wtt-content'],
exclude: [
'.xgplayer',
@@ -13,12 +13,12 @@ export const parsePageConfig = [
],
},
{
- url: 'https?:\\\\/\\\\/www\\\\.toutiao\\\\.com\\\\/article',
+ url: 'https?:\\/\\/www\\.toutiao\\.com\\/article',
include: ['.article-content'],
exclude: ['.xgplayer'],
},
{
- url: '^https?:\\\\/\\\\/www\\\\.toutiao\\\\.com\\\\/([a-zA-Z]\\\\/)?[a-zA-Z]\\\\d{10,}',
+ url: '^https?:\\/\\/www\\.toutiao\\.com\\/([a-zA-Z]\\/)?[a-zA-Z]\\d{10,}',
include: ['.article-content', '.weitoutiao-content'],
exclude: [
'#comment-area',
@@ -32,12 +32,12 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/zhuanlan\\\\.zhihu\\\\.com\\\\/p\\\\/',
+ url: '^https?:\\/\\/zhuanlan\\.zhihu\\.com\\/p\\/',
include: ['article.Post-Main'],
exclude: ['.Post-Author', '.Post-topicsAndReviewer', '.RichContent-actions', 'img.LinkCard-image', '.Post-Header'],
},
{
- url: '^https?:\\\\/\\\\/www\\\\.zhihu\\\\.com\\\\/question\\\\/\\\\d+',
+ url: '^https?:\\/\\/www\\.zhihu\\.com\\/question\\/\\d+',
include: ['.QuestionHeader-title', '.ContentItem.AnswerItem', '.List-item'],
exclude: [
'.ContentItem-time',
@@ -53,7 +53,7 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/mp\\\\.weixin\\\\.qq\\\\.com\\\\/s',
+ url: '^https?:\\/\\/mp\\.weixin\\.qq\\.com\\/s',
include: ['.rich_media_wrp', '.js_inner', '#js_common_share_desc'],
exclude: [
'.weapp_text_link',
@@ -71,7 +71,7 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/blog\\\\.csdn\\\\.net',
+ url: '^https?:\\/\\/blog\\.csdn\\.net',
include: ['.blog-content-box', '.hljs-comment'],
exclude: [
'.dp-highlighter.bg_cpp .bar',
@@ -83,20 +83,20 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/blog\\\\.csdn\\\\.net',
+ url: '^https?:\\/\\/blog\\.csdn\\.net',
include: ['.blog-content-box', '.hljs-comment'],
exclude: ['.dp-highlighter.bg_cpp .bar'],
},
- { url: '^https?:\\\\/\\\\/new\\\\.qq\\\\.com', include: ['.content-article'], exclude: ['.videoPlayerWrap'] },
- { url: '^https?:\\\\/\\\\/applet-data\\\\.web\\\\.bytedance\\\\.net', include: ['.app-main'], exclude: [] },
- { url: '^https?:\\\\/\\\\/blog\\\\.whatsapp\\\\.com', include: ['._9t2d'], exclude: [] },
+ { url: '^https?:\\/\\/new\\.qq\\.com', include: ['.content-article'], exclude: ['.videoPlayerWrap'] },
+ { url: '^https?:\\/\\/applet-data\\.web\\.bytedance\\.net', include: ['.app-main'], exclude: [] },
+ { url: '^https?:\\/\\/blog\\.whatsapp\\.com', include: ['._9t2d'], exclude: [] },
{
- url: '^https?:\\\\/\\\\/gist\\\\.github\\\\.com',
+ url: '^https?:\\/\\/gist\\.github\\.com',
include: ['.js-gist-file-update-container'],
exclude: ['.px-0'],
},
{
- url: '^https?:\\\\/\\\\/www\\\\.lennysnewsletter\\\\.com\\\\/p',
+ url: '^https?:\\/\\/www\\.lennysnewsletter\\.com\\/p',
include: ['.single-post-container', '.header-with-anchor-widget', 'h1', 'h2', 'h3', 'h4'],
exclude: [
'.meta-subheader',
@@ -115,27 +115,27 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/www\\\\.larksuite\\\\.com\\\\/hc\\\\/',
+ url: '^https?:\\/\\/www\\.larksuite\\.com\\/hc\\/',
include: ['#js-hc-breadcrumb ~ div'],
exclude: ['.image-wrapper-sizer'],
},
{
- url: '^https?:\\\\/\\\\/www\\\\.feishu\\\\.cn\\\\/hc\\\\/',
+ url: '^https?:\\/\\/www\\.feishu\\.cn\\/hc\\/',
include: ['#js-hc-breadcrumb ~ div'],
exclude: ['.image-wrapper-sizer'],
},
{
- url: '^https?:\\\\/\\\\/baijiahao\\\\.baidu\\\\.com\\\\/s',
+ url: '^https?:\\/\\/baijiahao\\.baidu\\.com\\/s',
include: ['#app > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1)'],
exclude: ['div > div:nth-child(1) > div:nth-child(1) > div:nth-child(2)', '#commentModule'],
},
{
- url: '^https?:\\\\/\\\\/mbd\\\\.baidu\\\\.com\\\\/newspage\\\\/data\\\\/landingsuper?',
+ url: '^https?:\\/\\/mbd\\.baidu\\.com\\/newspage\\/data\\/landingsuper?',
include: ['#app > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1)'],
exclude: ['div > div:nth-child(1) > div:nth-child(1) > div:nth-child(2)', '#commentModule'],
},
{
- url: '^https?:\\\\/\\\\/www\\\\.cnbc\\\\.com\\\\/\\\\d+\\\\/',
+ url: '^https?:\\/\\/www\\.cnbc\\.com\\/\\d+\\/',
include: ['.PageBuilder-pageWrapper'],
exclude: [
'.ArticleHeader-headerContentContainer',
@@ -154,7 +154,7 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/nypost\\\\.com\\\\/\\\\d+\\\\/',
+ url: '^https?:\\/\\/nypost\\.com\\/\\d+\\/',
include: ['.single--article'],
exclude: [
'.sharedaddy',
@@ -170,7 +170,7 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/time\\\\.geekbang\\\\.org\\\\/column\\\\/article\\\\/',
+ url: '^https?:\\/\\/time\\.geekbang\\.org\\/column\\/article\\/',
include: ['.Index_contentWidth_3_1Sf'],
exclude: [
'.recommend-read',
@@ -186,7 +186,7 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/dariusforoux\\\\.com',
+ url: '^https?:\\/\\/dariusforoux\\.com',
include: ['#content'],
exclude: [
'form',
@@ -199,7 +199,7 @@ export const parsePageConfig = [
],
},
{
- url: '^https?:\\\\/\\\\/cloud\\\\.google\\\\.com\\\\/blog\\\\/',
+ url: '^https?:\\/\\/cloud\\.google\\.com\\/blog\\/',
include: ['#jump-content', 'c-wiz'],
exclude: [
'article-sticky-share-block',
@@ -215,25 +215,25 @@ export const parsePageConfig = [
'.glue-modal',
],
},
- { url: '^https?:\\\\/\\\\/medium\\\\.com\\\\/$', include: ['article'], exclude: [] },
+ { url: '^https?:\\/\\/medium\\.com\\/$', include: ['article'], exclude: [] },
{
- url: '^https?:\\\\/\\\\/medium\\\\.com\\\\/',
+ url: '^https?:\\/\\/medium\\.com\\/',
include: ['section', 'main'],
exclude: ['header', 'footer', 'button'],
},
- { url: '^https?:\\\\/\\\\/([a-zA-Z0-9]+\\\\.)medium\\\\.com\\\\/([^about])', include: ['section'], exclude: [] },
- { url: '^https?:\\\\/\\\\/([a-zA-Z0-9]+\\\\.)medium\\\\.com\\\\/about', include: ['main'], exclude: [] },
- { url: '^https?:\\\\/\\\\/([a-zA-Z0-9]+\\\\.)medium\\\\.com\\\\/$', include: ['main'], exclude: [] },
+ { url: '^https?:\\/\\/([a-zA-Z0-9]+\\.)medium\\.com\\/([^about])', include: ['section'], exclude: [] },
+ { url: '^https?:\\/\\/([a-zA-Z0-9]+\\.)medium\\.com\\/about', include: ['main'], exclude: [] },
+ { url: '^https?:\\/\\/([a-zA-Z0-9]+\\.)medium\\.com\\/$', include: ['main'], exclude: [] },
{
- url: '^https?:\\\\/\\\\/www\\\\.wogoo\\\\.com\\\\/',
+ url: '^https?:\\/\\/www\\.wogoo\\.com\\/',
include: ['.leftSide'],
exclude: ['.articleComment', '.zan'],
},
- { url: '^https?:\\\\/\\\\/www\\\\.iocoder\\\\.cn\\\\/', include: ['#main'], exclude: ['.article-nav', 'footer'] },
+ { url: '^https?:\\/\\/www\\.iocoder\\.cn\\/', include: ['#main'], exclude: ['.article-nav', 'footer'] },
{
- url: '^https?:\\\\/\\\\/help\\\\.solidworks\\\\.com\\\\/',
+ url: '^https?:\\/\\/help\\.solidworks\\.com\\/',
include: ['#DSMainContent'],
exclude: ['#DSLeftPane', '#auto_links'],
},
- { url: '^https?:\\\\/\\\\/effecthouse\\\\.tiktok\\\\.com\\\\/', include: ['section', 'article'], exclude: [] },
+ { url: '^https?:\\/\\/effecthouse\\.tiktok\\.com\\/', include: ['section', 'article'], exclude: [] },
];
diff --git a/src/isomorphic/link-helper.ts b/src/isomorphic/link-helper.ts
index 6305356c..431092b3 100644
--- a/src/isomorphic/link-helper.ts
+++ b/src/isomorphic/link-helper.ts
@@ -3,7 +3,7 @@ import Env from './env';
const LinkHelper = {
goDoc: (doc: { id: number }) => `${YUQUE_DOMAIN}/go/doc/${doc.id}`,
- goMyNote: () => `${YUQUE_DOMAIN}/dashboard/notes`,
+ goMyNote: (id: number | string) => `${YUQUE_DOMAIN}/dashboard/notes?selectNoteId=${id}`,
goMyPage: (account: { login: string }) => `${YUQUE_DOMAIN}/${account.login}`,
feedback: () => {
return `https://www.yuque.com/feedbacks/new?body=系统信息:浏览器插件/${Env.isBate ? 'Beta版' : '正式版'}/${
diff --git a/src/pages/inject/WordMark/index.tsx b/src/pages/inject/WordMark/index.tsx
index 3828a969..8886372e 100644
--- a/src/pages/inject/WordMark/index.tsx
+++ b/src/pages/inject/WordMark/index.tsx
@@ -4,7 +4,6 @@ import LinkHelper from '@/isomorphic/link-helper';
import { backgroundBridge } from '@/core/bridge/background';
import { WordMarkOptionTypeEnum } from '@/isomorphic/constant/wordMark';
import { useForceUpdate } from '@/hooks/useForceUpdate';
-import { ClipAssistantMessageActions } from '@/isomorphic/event/clipAssistant';
import {
buildParamsForDoc,
buildParamsForNote,
@@ -34,13 +33,7 @@ function WordMarkApp() {
const save = useCallback(
async (text: string) => {
if (wordMarkContext.evokePanelWhenClip) {
- // 展开侧边栏
- window._yuque_ext_app.showSidePanel();
- // 发送消息在编辑器内加入内容
- window._yuque_ext_app?.sendMessageToClipAssistant(
- ClipAssistantMessageActions.addContent,
- `${text}
`,
- );
+ window._yuque_ext_app.addContentToClipAssistant(text, true);
showWordMarkRef.current = false;
forceUpdate();
return;
@@ -65,8 +58,8 @@ function WordMarkApp() {
const noteParams = {
...(await buildParamsForNote(editor as any)),
};
- await backgroundBridge.request.note.create(noteParams);
- const url = LinkHelper.goMyNote();
+ const result: any = await backgroundBridge.request.note.create(noteParams);
+ const url = LinkHelper.goMyNote(result.data.id);
apiMessage?.success(
{__i18n('保存成功!')}