Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: merge copy.ts paste.ts cut.ts into one file #164

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading