1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 14:21:23 +00:00

optimize seafile editor link click

This commit is contained in:
杨顺强
2024-01-30 09:45:46 +08:00
parent 7417853897
commit 790917c433
4 changed files with 11 additions and 50 deletions

View File

@@ -14,7 +14,7 @@
"@seafile/resumablejs": "1.1.16",
"@seafile/sdoc-editor": "0.5.1",
"@seafile/seafile-calendar": "0.0.12",
"@seafile/seafile-editor": "1.0.20",
"@seafile/seafile-editor": "1.0.21",
"@uiw/codemirror-extensions-langs": "^4.19.4",
"@uiw/react-codemirror": "^4.19.4",
"chart.js": "2.9.4",
@@ -4838,9 +4838,9 @@
}
},
"node_modules/@seafile/seafile-editor": {
"version": "1.0.20",
"resolved": "https://registry.npmjs.org/@seafile/seafile-editor/-/seafile-editor-1.0.20.tgz",
"integrity": "sha512-Sv/SSZZvNmvdSgnzchLn3O9TmfuUMxjDHEseDG/NYU26N5Sd7MUAOnqgKQ5l6/zRgnikSGtwE0KZextwudnVLQ==",
"version": "1.0.21",
"resolved": "https://registry.npmjs.org/@seafile/seafile-editor/-/seafile-editor-1.0.21.tgz",
"integrity": "sha512-GsdYo2ECYEbVcJs9z6DxrRqRvzlmjXrtF4Ln/XzH9w4Np+9rQQ7hZQ6wI/fCvpkF76cjb2om1la5wQK8JmWddg==",
"dependencies": {
"@codemirror/lang-markdown": "6.2.3",
"@codemirror/language-data": "6.3.1",
@@ -31908,9 +31908,9 @@
}
},
"@seafile/seafile-editor": {
"version": "1.0.20",
"resolved": "https://registry.npmjs.org/@seafile/seafile-editor/-/seafile-editor-1.0.20.tgz",
"integrity": "sha512-Sv/SSZZvNmvdSgnzchLn3O9TmfuUMxjDHEseDG/NYU26N5Sd7MUAOnqgKQ5l6/zRgnikSGtwE0KZextwudnVLQ==",
"version": "1.0.21",
"resolved": "https://registry.npmjs.org/@seafile/seafile-editor/-/seafile-editor-1.0.21.tgz",
"integrity": "sha512-GsdYo2ECYEbVcJs9z6DxrRqRvzlmjXrtF4Ln/XzH9w4Np+9rQQ7hZQ6wI/fCvpkF76cjb2om1la5wQK8JmWddg==",
"requires": {
"@codemirror/lang-markdown": "6.2.3",
"@codemirror/language-data": "6.3.1",

View File

@@ -9,7 +9,7 @@
"@seafile/resumablejs": "1.1.16",
"@seafile/sdoc-editor": "0.5.1",
"@seafile/seafile-calendar": "0.0.12",
"@seafile/seafile-editor": "1.0.20",
"@seafile/seafile-editor": "1.0.21",
"@uiw/codemirror-extensions-langs": "^4.19.4",
"@uiw/react-codemirror": "^4.19.4",
"chart.js": "2.9.4",

View File

@@ -28,28 +28,6 @@ class SdocWikiPageViewer extends React.Component {
this.scrollRef = React.createRef();
}
componentDidMount() {
// const eventBus = EventBus.getInstance();
// this.unsubscribeLinkClick = eventBus.subscribe(EXTERNAL_EVENTS.ON_LINK_CLICK, this.onLinkClick);
}
componentWillUnmount() {
// this.unsubscribeLinkClick();
}
onLinkClick = (event) => {
event.preventDefault();
event.stopPropagation();
let link = '';
let target = event.target;
while (!target.dataset || !target.dataset.url) {
target = target.parentNode;
}
if (!target) return;
link = target.dataset.url;
this.props.onLinkClick(link);
};
changeInlineNode = (item) => {
const { repoID } = this.props;
let url, imagePath;

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { EXTERNAL_EVENTS, EventBus, MarkdownViewer } from '@seafile/seafile-editor';
import { MarkdownViewer } from '@seafile/seafile-editor';
import { gettext, mediaUrl, serviceURL, sharedToken, slug } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import Loading from '../loading';
@@ -28,25 +28,7 @@ class SeafileMarkdownViewer extends React.Component {
this.scrollRef = React.createRef();
}
componentDidMount() {
const eventBus = EventBus.getInstance();
this.unsubscribeLinkClick = eventBus.subscribe(EXTERNAL_EVENTS.ON_LINK_CLICK, this.onLinkClick);
}
componentWillUnmount() {
this.unsubscribeLinkClick();
}
onLinkClick = (event) => {
event.preventDefault();
event.stopPropagation();
let link = '';
let target = event.target;
while (!target.dataset || !target.dataset.url) {
target = target.parentNode;
}
if (!target) return;
link = target.dataset.url;
onLinkClick = (link) => {
this.props.onLinkClick(link);
};
@@ -105,6 +87,7 @@ class SeafileMarkdownViewer extends React.Component {
mathJaxSource: `${mediaUrl}js/mathjax/tex-svg.js`,
value: markdownContent,
scrollRef: this.scrollRef,
onLinkClick: this.onLinkClick,
...(isWiki && {beforeRenderCallback: this.modifyValueBeforeRender})
};