Skip to content

Commit

Permalink
refactor: merge copy.ts paste.ts cut.ts into one file (#164)
Browse files Browse the repository at this point in the history
* refactor: merge copy.ts paste.ts cut.ts into one file

* ci: test check-circular

* fix: all circular dependences
  • Loading branch information
Jocs authored Apr 22, 2024
1 parent e6c54c7 commit b78393c
Show file tree
Hide file tree
Showing 52 changed files with 6,663 additions and 7,653 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
7 changes: 7 additions & 0 deletions .madgerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"lint:fix": "eslint packages --fix",
"lint:css": "stylelint \"**/*.css\"",
"postinstall": "husky install",
"release": "release-it"
"release": "release-it",
"check-circular": "madge --circular packages/core/src/index.ts"
},
"devDependencies": {
"@antfu/eslint-config": "^2.15.0",
Expand All @@ -54,6 +55,7 @@
"stylelint-config-standard": "^36.0.0",
"stylelint-order": "^6.0.4",
"turbo": "^1.13.2",
"madge": "^7.0.0",
"typescript": "^5.4.4",
"vite": "^5.2.10",
"vite-plugin-dts": "^3.8.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/base/content.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import diff from 'fast-diff';
import ScrollPage from '../../block/scrollPage';
import { ScrollPage } from '../../block/scrollPage';
import TreeNode from '../../block/base/treeNode';
import { BACK_HASH, BRACKET_HASH, EVENT_KEYS, isFirefox } from '../../config';
import type { Muya } from '../../muya';
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/block/base/format.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-fallthrough */
import ScrollPage from '../../block';
import { ScrollPage } from '../../block/scrollPage';
import Content from '../../block/base/content';
import {
CLASS_NAMES,
Expand All @@ -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
6 changes: 3 additions & 3 deletions packages/core/src/block/base/treeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IAttributes, IDatasets } from '../../utils/types';
import type { IConstructor } from '../types';
import type Content from './content';
import type { ILinkedNode } from './linkedList/linkedNode';
import Parent from './parent';
import type Parent from './parent';

class TreeNode implements ILinkedNode {
prev: Nullable<TreeNode> = null;
Expand Down Expand Up @@ -80,8 +80,8 @@ class TreeNode implements ILinkedNode {
* @param this
* @returns boolean
*/
isParent(this: unknown): this is Parent {
return this instanceof Parent;
isParent(this: TreeNode): this is Parent {
return 'children' in this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/atxHeading/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type Content from '../../base/content';
import Parent from '../../base/parent';
import LeafQueryBlock from '../../mixins/leafQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { TBlockPath } from '../../types';
import { mixins } from '../../../utils';
import type { IAtxHeadingState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/blockQuote/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { IBlockQuoteState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/bulletList/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import type { IBulletListState, IListItemState } from '../../../state/types';
import { mixins } from '../../../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/codeBlock/code.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import copyIcon from '../../../assets/icons/copy/2.png';
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type I18n from '../../../i18n';
import type { Muya } from '../../../muya';
import type { Nullable } from '../../../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/codeBlock/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import diff from 'fast-diff';
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { diffToTextOp } from '../../../utils';
import { operateClassName } from '../../../utils/dom';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/html/htmlContainer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import logger from '../../../utils/logger';
import type { IHtmlBlockState, TState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/html/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { TBlockPath } from '../../types';
import { CLASS_NAMES } from '../../../config';
import type { Muya } from '../../../muya';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/listItem/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { IListItemState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/orderList/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { IOrderListState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/paragraph/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Parent from '../../base/parent';
import type ParagraphContent from '../../content/paragraphContent';
import LeafQueryBlock from '../../mixins/leafQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { IParagraphState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/setextHeading/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Parent from '../../base/parent';
import type SetextHeadingContent from '../../content/setextHeadingContent';
import LeafQueryBlock from '../../mixins/leafQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { ISetextHeadingState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/commonMark/thematicBreak/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Parent from '../../base/parent';
import type ThematicBreakContent from '../../content/thematicBreakContent';
import LeafQueryBlock from '../../mixins/leafQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { IThematicBreakState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/content/atxHeadingContent/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ScrollPage from '../..';
import { ScrollPage } from '../../scrollPage';
import Format from '../../base/format';
import type AtxHeading from '../../commonMark/atxHeading';
import type { Muya } from '../../../muya';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/content/codeBlockContent/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Content from '../../base/content';
import type Code from '../../commonMark/codeBlock/code';
import type HTMLPreview from '../../commonMark/html/htmlPreview';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import { HTML_TAGS, VOID_HTML_TAGS } from '../../../config';
import type { Muya } from '../../../muya';
import type { ICursor } from '../../../selection/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/content/paragraphContent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type BulletList from '../../commonMark/bulletList';
import type OrderList from '../../commonMark/orderList';
import type Paragraph from '../../commonMark/paragraph';
import type TaskList from '../../gfm/taskList';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import { HTML_TAGS, VOID_HTML_TAGS } from '../../../config';
import type { Muya } from '../../../index';
import { tokenizer } from '../../../inlineRenderer/lexer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ScrollPage from '../..';
import { ScrollPage } from '../../scrollPage';
import Format from '../../base/format';
import type { Muya } from '../../../muya';
import type { ICursor } from '../../../selection/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/content/tableCell/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ScrollPage from '../..';
import { ScrollPage } from '../../scrollPage';
import Format from '../../base/format';
import type Table from '../../gfm/table';
import type Cell from '../../gfm/table/cell';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Format from '../../base/format';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import type { ICursor } from '../../../selection/types';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/extra/diagram/diagramContainer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import logger from '../../../utils/logger';
import type { IDiagramMeta, IDiagramState, TState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/extra/diagram/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { TBlockPath } from '../../types';
import type { Muya } from '../../../muya';
import logger from '../../../utils/logger';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/extra/frontmatter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import diff from 'fast-diff'
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
// import { diffToTextOp } from '../../../utils'
import { loadLanguage } from '../../../utils/prism';
// import { operateClassName } from '../../../utils/dom'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/extra/math/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { TBlockPath } from '../../types';
import type { Muya } from '../../../muya';
import type { IMathBlockState, IMathMeta } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/extra/math/mathContainer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parent from '../../base/parent';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import logger from '../../../utils/logger';
import type { IMathBlockState, TState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/gfm/table/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import type TableCellContent from '../../content/tableCell';
import LeafQueryBlock from '../../mixins/leafQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { ITableCellMeta, ITableCellState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/gfm/table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import diff from 'fast-diff';
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import type TableCellContent from '../../content/tableCell';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { TBlockPath } from '../../types';
import type { Muya } from '../../../muya';
import type { Nullable } from '../../../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/gfm/table/row.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { ITableRowState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/gfm/table/table.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { ITableState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/gfm/taskList/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
import type { ITaskListMeta, ITaskListState } from '../../../state/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/block/gfm/taskListItem/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkedList from '../../base/linkedList/linkedList';
import Parent from '../../base/parent';
import IContainerQueryBlock from '../../mixins/containerQueryBlock';
import ScrollPage from '../../scrollPage';
import { ScrollPage } from '../../scrollPage';
import type { TBlockPath } from '../../types';
import type { Muya } from '../../../muya';
import { mixins } from '../../../utils';
Expand Down
Loading

0 comments on commit b78393c

Please sign in to comment.