Skip to content

Commit

Permalink
fix: all circular dependences
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Apr 22, 2024
1 parent 94000c7 commit 2b2ae90
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 31 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci-circular.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ⭕️ CI Circular Dependences Check

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
circular-dependences:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: ./.github/actions/setup-node

- name: 🧬 Circular dependences checking
run: npm run check-circular
13 changes: 0 additions & 13 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,3 @@ jobs:

- name: 🧼 Type checking
run: npm run lint:types

circular-dependences:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: ./.github/actions/setup-node

- name: 🧬 Circular dependences checking
run: npm run check-circular
4 changes: 2 additions & 2 deletions packages/core/src/block/base/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import type {
TextToken,
Token,
} from '../../inlineRenderer/types';
import Selection from '../../selection';
import Selection, { getCursorReference } from '../../selection';
import { getTextContent } from '../../selection/dom';
import type { ICursor } from '../../selection/types';
import type { IBulletListState, IOrderListState } from '../../state/types';
import { conflict, getCursorReference, isMouseEvent } from '../../utils';
import { conflict, isMouseEvent } from '../../utils';
import type { IImageInfo } from '../../utils/image';
import { correctImageSrc, getImageInfo } from '../../utils/image';
import logger from '../../utils/logger';
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/selection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,19 @@ class Selection {
}
}

export function getCursorReference() {
const rect = Selection.getCursorCoords();

if (!rect)
return null;

return {
getBoundingClientRect() {
return rect;
},
clientWidth: rect.width,
clientHeight: rect.height,
};
}

export default Selection;
16 changes: 0 additions & 16 deletions packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Diff } from 'fast-diff';
import type Content from '../block/base/content';
import { EVENT_KEYS } from '../config';
import Selection from '../selection';
import type { Config } from './dompurify';
import runSanitize from './dompurify';

Expand Down Expand Up @@ -242,21 +241,6 @@ export function diffToTextOp(diffs: Diff[]) {
return op;
}

export function getCursorReference() {
const rect = Selection.getCursorCoords();

if (!rect)
return null;

return {
getBoundingClientRect() {
return rect;
},
clientWidth: rect.width,
clientHeight: rect.height,
};
}

// If the next block is header, put cursor after the `#{1,6} *`
export function adjustOffset<T extends Content>(offset: number, block: T, event: KeyboardEvent) {
if (
Expand Down

0 comments on commit 2b2ae90

Please sign in to comment.