Skip to content

Commit 4c75e2a

Browse files
committed
增加debug后门
1 parent 478b645 commit 4c75e2a

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

src/components/layout/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ function LayoutComponent(props: {session: Session, config: Config, pluginManager
7878
const [curDocInfo, setCurDocInfo] = useState({});
7979
const [editor, setEditor] = useState<IDomEditor | null>(null);
8080
const [html, setHtml] = useState('<p>');
81+
const [debugSelecting, setDebugSelecting] = useState(props.session.selecting);
8182
const [xml, setXml] = useState<string | undefined>();
8283
const [vd, setVd] = React.useState<Vditor>();
84+
useEffect(() => {
85+
console.log('found session change');
86+
setDebugSelecting(props.session.selecting);
87+
}, [props.session.selecting, props.session.hoverRow]);
8388
useEffect(() => {
8489
setCurPage(location.pathname.split('/')[1] || 'note');
8590
}, [location]);
@@ -398,6 +403,24 @@ function LayoutComponent(props: {session: Session, config: Config, pluginManager
398403
}
399404
}
400405
}}/>
406+
{
407+
props.session.debugMode &&
408+
<div style={{display: 'flex'}}>
409+
{/*<div>*/}
410+
{/* <span>hover: {props.session.hoverRow?.row}</span>*/}
411+
{/* <span>anchor: {props.session.getAnchor()?.row}</span>*/}
412+
{/* <span>cursor: {props.session.cursor.row}</span>*/}
413+
{/* <span>selectInlinePath: {props.session.selectInlinePath?.row}</span>*/}
414+
{/*</div>*/}
415+
<div>
416+
<span>selecting: {debugSelecting ? 'true' : 'false'}</span>
417+
<span>dragging: {props.session.dragging}</span>
418+
<span>selectPopoverOpen: {props.session.selectPopoverOpen}</span>
419+
<span>selectMousePressing: {props.session.selectMousePressing}</span>
420+
<span>stopMonitor: {props.session.stopMonitor}</span>
421+
</div>
422+
</div>
423+
}
401424
{
402425
curPage === 'note' &&
403426
<Button onClick={() => {

src/share/components/Block/block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class RowComponent extends React.Component<RowProps, {showDragHint: boolean}> {
168168
}}
169169
onMouseMove={(e) => {
170170
if (path && !session.dragging && e.buttons === 1 && session.getAnchor()) {
171-
console.log(`onLineMouseMove set selectInlinePath ${path}`);
171+
// console.log(`onLineMouseMove set selectInlinePath ${path}`);
172172
session.markSelecting(true, 'onLineMouseMove');
173173
session.selectMousePressing = true;
174174
session.selectInlinePath = path;

src/share/components/Line/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export default class LineComponent extends React.Component<LineProps, {input: st
174174
},
175175
onMouseMove: (e) => {
176176
if (path && !session.dragging && e.buttons === 1 && session.getAnchor()) {
177-
console.log(`onColMouseMove set selectInlinePath ${path.row}`);
177+
// console.log(`onColMouseMove set selectInlinePath ${path.row}`);
178178
session.markSelecting(true, 'onColMouseMove');
179179
session.selectMousePressing = true;
180180
session.selectInlinePath = path;

src/share/components/Session/Session.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class SessionComponent extends React.Component<Props, State> {
8080
if (session.mode === 'INSERT') {
8181
session.markSelecting(true, 'onCharDoubleClick');
8282
if (session.selectInlinePath === null || !session.selectInlinePath.is(session.cursor.path)) {
83-
console.log(`selectWord selectInlinePath ${session.selectInlinePath} currentPath ${session.cursor.path}`);
83+
// console.log(`selectWord selectInlinePath ${session.selectInlinePath} currentPath ${session.cursor.path}`);
8484
session.cursor.beginningWord().then(() => {
8585
session.setAnchor(session.cursor.path, session.cursor.col, 'onCharDoubleClickSelectWord').then(() => {
8686
session.cursor.endWord({cursor: {pastEndWord: true}}).then(() => {
@@ -90,7 +90,7 @@ export default class SessionComponent extends React.Component<Props, State> {
9090
});
9191
});
9292
} else {
93-
console.log(`selectLine selectInlinePath ${session.selectInlinePath}`);
93+
// console.log(`selectLine selectInlinePath ${session.selectInlinePath}`);
9494
session.cursor.home().then(() => {
9595
session.setAnchor(session.cursor.path, session.cursor.col, 'onCharDoubleClickSelectLine').then(() => {
9696
session.cursor.end({pastEnd: true}).then(() => {
@@ -190,7 +190,7 @@ export default class SessionComponent extends React.Component<Props, State> {
190190
await virtualCursor.setCol(-1);
191191
anchorCol = virtualCursor.col;
192192
}
193-
console.log(`anchor : ${anchorCol} cursor ${cursor.col}`);
193+
// console.log(`anchor : ${anchorCol} cursor ${cursor.col}`);
194194
let start = Math.min(cursor.col, anchorCol);
195195
const end = Math.max(cursor.col, anchorCol);
196196
let cols: Array<Col> = [];

src/share/ts/session.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ export default class Session extends EventEmitter {
183183
}
184184

185185
public startKeyMonitor() {
186-
console.log('startKeyMonitor');
186+
// console.log('startKeyMonitor');
187187
this.stopMonitor = this.clientStore.getClientSetting('curView') === 'discovery';
188188
}
189189

190190
public markSelecting(selecting: boolean, callsite: string) {
191-
console.log('markSelecting', selecting, callsite);
191+
// console.log('markSelecting', selecting, callsite);
192192
this.selecting = selecting;
193193
}
194194

195195
public stopKeyMonitor(caller: string) {
196-
console.log('stopKeyMonitor from:', caller);
196+
// console.log('stopKeyMonitor from:', caller);
197197
this.stopMonitor = true;
198198
}
199199

@@ -1738,7 +1738,7 @@ export default class Session extends EventEmitter {
17381738
}
17391739

17401740
public async setAnchor(path: Path, col: number, callsite: string) {
1741-
console.log(`setAnchor`, path, col, this.cursor, callsite);
1741+
// console.log(`setAnchor`, path, col, this.cursor, callsite);
17421742
this._anchor = new Cursor(this, path);
17431743
await this._anchor.setCol(col);
17441744
}
@@ -1756,7 +1756,7 @@ export default class Session extends EventEmitter {
17561756
await this.document.getCommonAncestor(cursor.path, anchor.path);
17571757
if (ancestors1.length === 0) {
17581758
if (common.parent == null) {
1759-
console.log(cursor, anchor);
1759+
// console.log(cursor, anchor);
17601760
throw new Error('Invalid state: cursor was at root?');
17611761
}
17621762
// anchor is underneath cursor

0 commit comments

Comments
 (0)