Skip to content

Commit

Permalink
refactor: deprecate blocky-data (#78)
Browse files Browse the repository at this point in the history
* refactor: deprecate blocky-data

* fix: ts config

* fix: import error
  • Loading branch information
vincentdchan authored Nov 13, 2023
1 parent cc866f8 commit e678be5
Show file tree
Hide file tree
Showing 66 changed files with 100 additions and 260 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The developers only need to develop their blocks with their favourite UI framewo

![](./packages/blocky-example/src/arch.png)

- Data(![npm](https://img.shields.io/npm/v/blocky-data)): The data structure of the editor. Can be used without browser environment.
- Core(![npm](https://img.shields.io/npm/v/blocky-core)): The core of the editor. Written in vanilla JS. It can be used standalone without any
UI frameworks.
- Gzipped size: ~40kb
Expand Down
5 changes: 1 addition & 4 deletions packages/blocky-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@types/is-hotkey": "^0.1.7",
"@types/lodash-es": "^4.17.6",
"@types/node": "^17.0.41",
"blocky-data": "workspace:*",
"c8": "^8.0.1",
"jsdom": "^20.0.0",
"tsc-alias": "^1.6.9",
Expand All @@ -37,9 +36,7 @@
"blocky-common": "workspace:3.0.0",
"is-hotkey": "^0.2.0",
"lodash-es": "^4.17.21",
"quill-delta-es": "5.2.4",
"rxjs": "^7.8.1"
},
"peerDependencies": {
"blocky-data": "workspace:^3.2.0"
}
}
4 changes: 2 additions & 2 deletions packages/blocky-core/src/block/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
DataBaseElement,
CursorState,
Changeset,
Delta,
} from "blocky-data";
} from "@pkg/data";
import Delta from "quill-delta-es";
import { Subject } from "rxjs";
import { type Editor } from "@pkg/view/editor";
import { type EditorController } from "@pkg/view/controller";
Expand Down
5 changes: 2 additions & 3 deletions packages/blocky-core/src/block/textBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import {
BlockDataElement,
Changeset,
TextType,
Delta,
Op,
textTypePrecedence,
} from "blocky-data";
} from "@pkg/data";
import Delta, { Op } from "quill-delta-es";
import { TextInputEvent, type Editor } from "@pkg/view/editor";
import { HTMLConverter } from "@pkg/helper/htmlConverter";
import { EditorController } from "@pkg/view/controller";
Expand Down
3 changes: 2 additions & 1 deletion packages/blocky-core/src/block/titleBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
Block,
} from "./basic";
import { TextInputEvent } from "@pkg/view/editor";
import { BlockyTextModel, Delta } from "blocky-data";
import { BlockyTextModel } from "@pkg/data";
import Delta from "quill-delta-es";

export class TitleBlock extends Block {
static Name = "Title";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import Delta, { Op } from "quill-delta-es";

export { Delta, Op };
export * from "./tree";
export * from "./events";
export * from "./operations";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/blocky-core/src/helper/htmlConverter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isObject } from "lodash-es";
import { BlockDataElement, BlockyTextModel } from "blocky-data";
import { BlockDataElement, BlockyTextModel } from "@pkg/data";
import { TextBlock } from "@pkg/block/textBlock";
import { removeLineBreaks } from "blocky-common/es";
import { textToDeltaWithURL } from "@pkg/helper/urlHelper";
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/helper/test/urlHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Delta } from "blocky-data";
import Delta from "quill-delta-es";
import { test, expect, describe } from "vitest";
import { textToDeltaWithURL } from "../urlHelper";

Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/helper/urlHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Delta } from "blocky-data";
import Delta from "quill-delta-es";

/**
* Reference: https://stackoverflow.com/a/17773849
Expand Down
4 changes: 4 additions & 0 deletions packages/blocky-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Delta, { Op } from "quill-delta-es";

export { Delta, Op };
export * from "./view/editor";
export * from "./view/controller";
export * from "./block/basic";
Expand Down Expand Up @@ -37,3 +40,4 @@ export {
darkTheme,
} from "./model";
export { TextBlock } from "./block/textBlock";
export * from "./data";
4 changes: 2 additions & 2 deletions packages/blocky-core/src/model/editorState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
traverseNode,
CursorState,
State,
Delta,
} from "blocky-data";
} from "@pkg/data";
import Delta from "quill-delta-es";
import { Block } from "@pkg/block/basic";
import { BlockRegistry } from "@pkg/registry/blockRegistry";
import { TextBlock } from "@pkg/block/textBlock";
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/model/searchContext.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IDisposable } from "blocky-common/es";
import { Subject } from "rxjs";
import { elem, removeNode, ContainerWithCoord } from "blocky-common/es/dom";
import { BlockDataElement, DataBaseNode } from "blocky-data";
import { BlockDataElement, DataBaseNode } from "@pkg/data";
import { isString, isObject } from "lodash-es";
import { Editor } from "@pkg/view/editor";

Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/model/test/block.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "vitest";
import "@pkg/index";
import { BlockyDocument, BlockDataElement } from "blocky-data";
import { BlockyDocument, BlockDataElement } from "@pkg/data";
import { TextBlock } from "@pkg/block/textBlock";

test("block level 0", () => {
Expand Down
8 changes: 2 additions & 6 deletions packages/blocky-core/src/model/test/searchContext.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
BlockDataElement,
BlockyDocument,
BlockyTextModel,
Delta,
} from "blocky-data";
import { BlockDataElement, BlockyDocument, BlockyTextModel } from "@pkg/data";
import Delta from "quill-delta-es";
import { Editor } from "../../view/editor";
import { EditorController } from "../../view/controller";
import { expect, test } from "vitest";
Expand Down
4 changes: 2 additions & 2 deletions packages/blocky-core/src/model/test/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
BlockyDocument,
BlockyTextModel,
JSONNode,
Delta,
} from "blocky-data";
} from "@pkg/data";
import Delta from "quill-delta-es";
import { EditorState } from "../editorState";

function removeId(node: JSONNode) {
Expand Down
9 changes: 2 additions & 7 deletions packages/blocky-core/src/plugins/bulletListPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { isWhiteSpace } from "blocky-common/es";
import { isNumber, isString } from "lodash-es";
import {
BlockDataElement,
CursorState,
Changeset,
TextType,
Delta,
} from "blocky-data";
import { BlockDataElement, CursorState, Changeset, TextType } from "@pkg/data";
import Delta from "quill-delta-es";
import { filter, takeUntil } from "rxjs";
import {
getTextTypeForTextBlock,
Expand Down
3 changes: 2 additions & 1 deletion packages/blocky-core/src/plugins/codeTextPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type PluginContext, type IPlugin, TextBlock } from "@pkg/index";
import { CursorState, Changeset, Delta } from "blocky-data";
import { CursorState, Changeset } from "@pkg/data";
import Delta from "quill-delta-es";
import { isHotkey } from "is-hotkey";
import { isUndefined } from "lodash-es";
import { takeUntil } from "rxjs";
Expand Down
3 changes: 2 additions & 1 deletion packages/blocky-core/src/plugins/headingsPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isWhiteSpace } from "blocky-common/es";
import { type IPlugin, TextBlock, type PluginContext } from "@pkg/index";
import { Changeset, TextType, Delta } from "blocky-data";
import { Changeset, TextType } from "@pkg/data";
import Delta from "quill-delta-es";
import { isNumber, isString } from "lodash-es";
import { filter, takeUntil } from "rxjs";

Expand Down
9 changes: 2 additions & 7 deletions packages/blocky-core/src/plugins/numberListPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import {
type Editor,
getTextTypeForTextBlock,
} from "@pkg/index";
import {
BlockDataElement,
CursorState,
Changeset,
TextType,
Delta,
} from "blocky-data";
import { BlockDataElement, CursorState, Changeset, TextType } from "@pkg/data";
import Delta from "quill-delta-es";
import { isNumber, isString } from "lodash-es";
import { isWhiteSpace } from "blocky-common/es";
import { filter, takeUntil } from "rxjs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
BlockyTextModel,
Changeset,
ChangesetRecordOption,
Delta,
FinalizedChangeset,
InsertNodeOperation,
} from "blocky-data";
} from "@pkg/data";
import Delta from "quill-delta-es";
import "@pkg/index";

describe("FixedSizeStack", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/plugins/undoPlugin/undoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ChangesetApplyOptions,
ChangesetRecordOption,
FinalizedChangeset,
} from "blocky-data";
} from "@pkg/data";
import type { EditorState } from "@pkg/model/editorState";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/plugins/undoPlugin/undoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { takeUntil, filter } from "rxjs";
import { isHotkey } from "is-hotkey";
import { debounce } from "lodash-es";
import { UndoManager } from "./undoManager";
import { ChangesetRecordOption, FinalizedChangeset } from "blocky-data";
import { ChangesetRecordOption, FinalizedChangeset } from "@pkg/data";

function makeUndoPlugin(): IPlugin {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/registry/blockRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
IBlockDefinition,
TryParsePastedDOMEvent,
} from "@pkg/block/basic";
import type { BlockDataElement } from "blocky-data";
import type { BlockDataElement } from "@pkg/data";
import { Registry } from "./registry";
import { TextBlock } from "@pkg/block/textBlock";
import { TitleBlock } from "@pkg/block/titleBlock";
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/registry/spanRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Registry } from "./registry";
import type { AttributesObject } from "blocky-data";
import type { AttributesObject } from "@pkg/data";
import { isString } from "lodash-es";

export type SpanRenderer = (
Expand Down
4 changes: 2 additions & 2 deletions packages/blocky-core/src/view/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
blockyNodeFromJsonNode,
CursorStateUpdateReason,
ChangesetApplyOptions,
Delta,
} from "blocky-data";
} from "@pkg/data";
import Delta from "quill-delta-es";
import { BlockRegistry } from "@pkg/registry/blockRegistry";
import { PluginRegistry, type IPlugin } from "@pkg/registry/pluginRegistry";
import { SpanRegistry } from "@pkg/registry/spanRegistry";
Expand Down
4 changes: 2 additions & 2 deletions packages/blocky-core/src/view/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
FinalizedChangeset,
CursorStateUpdateReason,
TextType,
Delta,
} from "blocky-data";
} from "@pkg/data";
import Delta from "quill-delta-es";
import {
IPlugin,
PluginRegistry,
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/view/followerWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CursorState,
CursorStateUpdateReason,
type CursorStateUpdateEvent,
} from "blocky-data";
} from "@pkg/data";

/**
* {@link FollowerWidget} is a widget can follow the cursor.
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/view/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type DataBaseNode,
BlockDataElement,
BlockyTextModel,
} from "blocky-data";
} from "@pkg/data";
import type { Editor } from "@pkg/view/editor";

function ensureChild<K extends keyof HTMLElementTagNameMap>(
Expand Down
2 changes: 1 addition & 1 deletion packages/blocky-core/src/view/spannerDelegate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type IDisposable } from "blocky-common/es";
import type { EditorController } from "@pkg/view/controller";
import type { BlockDataElement } from "blocky-data";
import type { BlockDataElement } from "@pkg/data";
import { UIDelegate } from "./uiDelegate";

export interface SpannerInstance extends IDisposable {
Expand Down
1 change: 0 additions & 1 deletion packages/blocky-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@
],
"references": [
{ "path": "../blocky-common" },
{ "path": "../blocky-data" },
]
}
7 changes: 0 additions & 7 deletions packages/blocky-data/.npmignore

This file was deleted.

21 changes: 0 additions & 21 deletions packages/blocky-data/LICENSE.txt

This file was deleted.

3 changes: 0 additions & 3 deletions packages/blocky-data/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions packages/blocky-data/package.json

This file was deleted.

Loading

1 comment on commit e678be5

@vercel
Copy link

@vercel vercel bot commented on e678be5 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.