From 86a8a82b52f3547fa5c8155f278ce2cc3238c737 Mon Sep 17 00:00:00 2001 From: sibiraj-s Date: Mon, 18 Jan 2021 21:16:24 +0530 Subject: [PATCH] refactor: remove exported prosmirror methods --- .../components/custom-menu/custom-menu.component.ts | 2 +- demo/src/app/nodeviews/CodeMirror.ts | 3 +-- docs/collab.md | 4 ++-- docs/commands.md | 6 ------ src/commands/package.json | 3 +-- src/commands/public_api.ts | 1 - src/history/package.json | 10 ---------- src/history/public_api.ts | 1 - src/inputrules/package.json | 10 ---------- src/inputrules/public_api.ts | 1 - src/keymap/package.json | 10 ---------- src/keymap/public_api.ts | 1 - src/lib/EditorCommands.ts | 2 +- src/lib/commands/Blockquote.ts | 2 +- src/lib/commands/Heading.ts | 2 +- src/lib/commands/Image.ts | 2 +- src/lib/commands/Link.ts | 3 ++- src/lib/commands/ListItem.ts | 4 ++-- src/lib/commands/Mark.ts | 3 ++- src/lib/commands/TextAlign.ts | 2 +- src/lib/commands/TextColor.ts | 3 ++- src/lib/commands/types.ts | 2 +- src/lib/defaultPlugins.ts | 11 +++++------ src/lib/schema/nodes.ts | 2 +- src/ng-package.json | 7 ++++++- src/schema-list/package.json | 10 ---------- src/schema-list/public_api.ts | 1 - 27 files changed, 31 insertions(+), 77 deletions(-) delete mode 100644 src/history/package.json delete mode 100644 src/history/public_api.ts delete mode 100644 src/inputrules/package.json delete mode 100644 src/inputrules/public_api.ts delete mode 100644 src/keymap/package.json delete mode 100644 src/keymap/public_api.ts delete mode 100644 src/schema-list/package.json delete mode 100644 src/schema-list/public_api.ts diff --git a/demo/src/app/components/custom-menu/custom-menu.component.ts b/demo/src/app/components/custom-menu/custom-menu.component.ts index 2bd96074..fcbd36e6 100644 --- a/demo/src/app/components/custom-menu/custom-menu.component.ts +++ b/demo/src/app/components/custom-menu/custom-menu.component.ts @@ -1,10 +1,10 @@ import { Component, Input, OnInit } from '@angular/core'; import { EditorState, Plugin, PluginKey, Transaction } from 'prosemirror-state'; import { EditorView } from 'prosemirror-view'; +import { setBlockType } from 'prosemirror-commands'; import { Editor } from 'ngx-editor'; import { isNodeActive } from 'ngx-editor/helpers'; -import { setBlockType } from 'ngx-editor/commands'; @Component({ selector: 'app-custom-menu', diff --git a/demo/src/app/nodeviews/CodeMirror.ts b/demo/src/app/nodeviews/CodeMirror.ts index 4a92b8ff..c5a7a672 100644 --- a/demo/src/app/nodeviews/CodeMirror.ts +++ b/demo/src/app/nodeviews/CodeMirror.ts @@ -3,8 +3,7 @@ import { undo, redo } from 'prosemirror-history'; import { TextSelection, Selection } from 'prosemirror-state'; import { Node as ProsemirrorNode } from 'prosemirror-model'; import { EditorView } from 'prosemirror-view'; - -import { exitCode } from 'ngx-editor/commands'; +import { exitCode } from 'prosemirror-commands'; import CodeMirror from 'codemirror'; import 'codemirror/mode/javascript/javascript'; diff --git a/docs/collab.md b/docs/collab.md index 7bf937a2..7cbdab4a 100644 --- a/docs/collab.md +++ b/docs/collab.md @@ -17,8 +17,8 @@ import { redo, } from 'y-prosemirror'; import { Editor } from 'ngx-editor'; -import { history } from 'ngx-editor/history'; -import { keymap } from 'ngx-editor/keymap'; +import { keymap } from 'prosemirror-keymap'; +import { history } from 'prosemirror-history'; const ydoc = new Y.Doc(); const provider = new WebsocketProvider( diff --git a/docs/commands.md b/docs/commands.md index b063d142..dacdd2da 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -14,9 +14,3 @@ this.editor.commands You must invoke `exec` method at the end to apply the changes to the editor. **Note:** `exec` method is not chainable. - -Some commands are exported. Can be accessed via - -```ts -import { toggleMark } from 'ngx-editor/commands'; -``` diff --git a/src/commands/package.json b/src/commands/package.json index 664da785..820215c1 100644 --- a/src/commands/package.json +++ b/src/commands/package.json @@ -3,8 +3,7 @@ "lib": { "entryFile": "./public_api.ts", "umdModuleIds": { - "prosemirror-state": "prosemirrorState", - "prosemirror-commands": "prosemirrorCommands" + "prosemirror-state": "prosemirrorState" } } } diff --git a/src/commands/public_api.ts b/src/commands/public_api.ts index 55f86e70..50eb421e 100644 --- a/src/commands/public_api.ts +++ b/src/commands/public_api.ts @@ -1,4 +1,3 @@ -export * from 'prosemirror-commands'; export * from './removeLink'; export * from './applyMark'; export * from './removeMark'; diff --git a/src/history/package.json b/src/history/package.json deleted file mode 100644 index 9fccf3c1..00000000 --- a/src/history/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ngPackage": { - "lib": { - "entryFile": "./public_api.ts", - "umdModuleIds": { - "prosemirror-history": "prosemirrorHistory" - } - } - } -} diff --git a/src/history/public_api.ts b/src/history/public_api.ts deleted file mode 100644 index 055ec974..00000000 --- a/src/history/public_api.ts +++ /dev/null @@ -1 +0,0 @@ -export * from 'prosemirror-history'; diff --git a/src/inputrules/package.json b/src/inputrules/package.json deleted file mode 100644 index a12636eb..00000000 --- a/src/inputrules/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ngPackage": { - "lib": { - "entryFile": "./public_api.ts", - "umdModuleIds": { - "prosemirror-inputrules": "prosemirrorInputRules" - } - } - } -} diff --git a/src/inputrules/public_api.ts b/src/inputrules/public_api.ts deleted file mode 100644 index c6f22287..00000000 --- a/src/inputrules/public_api.ts +++ /dev/null @@ -1 +0,0 @@ -export * from 'prosemirror-inputrules'; diff --git a/src/keymap/package.json b/src/keymap/package.json deleted file mode 100644 index 3f972f86..00000000 --- a/src/keymap/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ngPackage": { - "lib": { - "entryFile": "./public_api.ts", - "umdModuleIds": { - "prosemirror-keymap": "prosemirrorKeymap" - } - } - } -} diff --git a/src/keymap/public_api.ts b/src/keymap/public_api.ts deleted file mode 100644 index 44b86bff..00000000 --- a/src/keymap/public_api.ts +++ /dev/null @@ -1 +0,0 @@ -export * from 'prosemirror-keymap'; diff --git a/src/lib/EditorCommands.ts b/src/lib/EditorCommands.ts index 6be9176a..b898792c 100644 --- a/src/lib/EditorCommands.ts +++ b/src/lib/EditorCommands.ts @@ -3,7 +3,7 @@ import { EditorView } from 'prosemirror-view'; import { chainCommands, createParagraphNear, liftEmptyBlock, newlineInCode, splitBlock -} from 'ngx-editor/commands'; +} from 'prosemirror-commands'; import MarkCommand from './commands/Mark'; import ListCommand from './commands/ListItem'; diff --git a/src/lib/commands/Blockquote.ts b/src/lib/commands/Blockquote.ts index eb0e3c24..d6684c0a 100644 --- a/src/lib/commands/Blockquote.ts +++ b/src/lib/commands/Blockquote.ts @@ -1,7 +1,7 @@ import { NodeType } from 'prosemirror-model'; import { EditorState, Transaction } from 'prosemirror-state'; +import { Command, lift, wrapIn } from 'prosemirror-commands'; -import { Command, lift, wrapIn } from 'ngx-editor/commands'; import { isNodeActive } from 'ngx-editor/helpers'; import { SimpleCommand } from './types'; diff --git a/src/lib/commands/Heading.ts b/src/lib/commands/Heading.ts index c8bfd33b..91dce7a9 100644 --- a/src/lib/commands/Heading.ts +++ b/src/lib/commands/Heading.ts @@ -1,7 +1,7 @@ import { NodeType, Node as ProsemirrorNode } from 'prosemirror-model'; import { EditorState, Transaction } from 'prosemirror-state'; +import { Command, setBlockType } from 'prosemirror-commands'; -import { Command, setBlockType } from 'ngx-editor/commands'; import { getSelectionNodes } from 'ngx-editor/helpers'; export type HeadingLevels = 1 | 2 | 3 | 4 | 5 | 6; diff --git a/src/lib/commands/Image.ts b/src/lib/commands/Image.ts index 6ff4acf4..80683068 100644 --- a/src/lib/commands/Image.ts +++ b/src/lib/commands/Image.ts @@ -1,6 +1,6 @@ import { EditorState, NodeSelection } from 'prosemirror-state'; +import { Command } from 'prosemirror-commands'; -import { Command } from 'ngx-editor/commands'; import { Dispatch } from './types'; export interface ImageAttrs { diff --git a/src/lib/commands/Link.ts b/src/lib/commands/Link.ts index 4f76d058..a599f157 100644 --- a/src/lib/commands/Link.ts +++ b/src/lib/commands/Link.ts @@ -1,8 +1,9 @@ import { MarkType } from 'prosemirror-model'; import { EditorState } from 'prosemirror-state'; +import { Command, toggleMark } from 'prosemirror-commands'; import { isMarkActive } from 'ngx-editor/helpers'; -import { removeLink, Command, toggleMark } from 'ngx-editor/commands'; +import { removeLink } from 'ngx-editor/commands'; import { Dispatch } from './types'; const defaultOptions = { diff --git a/src/lib/commands/ListItem.ts b/src/lib/commands/ListItem.ts index 49628d9b..955a3f95 100644 --- a/src/lib/commands/ListItem.ts +++ b/src/lib/commands/ListItem.ts @@ -1,9 +1,9 @@ import { NodeType, Schema } from 'prosemirror-model'; import { EditorState, Transaction } from 'prosemirror-state'; +import { liftListItem, wrapInList } from 'prosemirror-schema-list'; +import { Command } from 'prosemirror-commands'; import { isNodeActive } from 'ngx-editor/helpers'; -import { liftListItem, wrapInList } from 'ngx-editor/schema-list'; -import { Command } from 'ngx-editor/commands'; import { SimpleCommand } from './types'; diff --git a/src/lib/commands/Mark.ts b/src/lib/commands/Mark.ts index 9220040c..6d9f4e43 100644 --- a/src/lib/commands/Mark.ts +++ b/src/lib/commands/Mark.ts @@ -1,10 +1,11 @@ import { MarkType } from 'prosemirror-model'; import { EditorState, Transaction } from 'prosemirror-state'; +import { Command, toggleMark } from 'prosemirror-commands'; +import { applyMark } from 'ngx-editor/commands'; import { isMarkActive } from 'ngx-editor/helpers'; import { SimpleCommand } from './types'; -import { applyMark, Command, toggleMark } from 'ngx-editor/commands'; class Mark implements SimpleCommand { name: string; diff --git a/src/lib/commands/TextAlign.ts b/src/lib/commands/TextAlign.ts index ac3d11a6..f9e9f33a 100644 --- a/src/lib/commands/TextAlign.ts +++ b/src/lib/commands/TextAlign.ts @@ -1,8 +1,8 @@ import { EditorState, Transaction } from 'prosemirror-state'; import { Node } from 'prosemirror-model'; +import { Command } from 'prosemirror-commands'; import { getSelectionNodes } from 'ngx-editor/helpers'; -import { Command } from 'ngx-editor/commands'; export type Align = 'left' | 'center' | 'right' | 'justify'; diff --git a/src/lib/commands/TextColor.ts b/src/lib/commands/TextColor.ts index eb38053b..cd6d7642 100644 --- a/src/lib/commands/TextColor.ts +++ b/src/lib/commands/TextColor.ts @@ -1,8 +1,9 @@ import { MarkType } from 'prosemirror-model'; import { EditorState } from 'prosemirror-state'; +import { Command } from 'prosemirror-commands'; import { getSelectionMarks, isMarkActive } from 'ngx-editor/helpers'; -import { applyMark, removeMark, Command } from 'ngx-editor/commands'; +import { applyMark, removeMark } from 'ngx-editor/commands'; import { Dispatch } from './types'; diff --git a/src/lib/commands/types.ts b/src/lib/commands/types.ts index 7e0335d5..ec12496a 100644 --- a/src/lib/commands/types.ts +++ b/src/lib/commands/types.ts @@ -1,5 +1,5 @@ import { EditorState, Transaction } from 'prosemirror-state'; -import { Command } from 'ngx-editor/commands'; +import { Command } from 'prosemirror-commands'; export type Dispatch = (tr: Transaction) => void | null; diff --git a/src/lib/defaultPlugins.ts b/src/lib/defaultPlugins.ts index f4a42daf..28ddb48a 100644 --- a/src/lib/defaultPlugins.ts +++ b/src/lib/defaultPlugins.ts @@ -1,14 +1,13 @@ import { NodeType, Schema } from 'prosemirror-model'; import { Plugin } from 'prosemirror-state'; - -import { keymap } from 'ngx-editor/keymap'; -import { toggleMark, baseKeymap } from 'ngx-editor/commands'; -import { splitListItem, liftListItem, sinkListItem } from 'ngx-editor/schema-list'; -import { history, undo, redo } from 'ngx-editor/history'; +import { keymap } from 'prosemirror-keymap'; +import { toggleMark, baseKeymap } from 'prosemirror-commands'; +import { splitListItem, liftListItem, sinkListItem } from 'prosemirror-schema-list'; +import { history, undo, redo } from 'prosemirror-history'; import { inputRules, wrappingInputRule, textblockTypeInputRule, smartQuotes, emDash, ellipsis, InputRule -} from 'ngx-editor/inputrules'; +} from 'prosemirror-inputrules'; interface Options { history: boolean; diff --git a/src/lib/schema/nodes.ts b/src/lib/schema/nodes.ts index f4747800..2b5efc05 100644 --- a/src/lib/schema/nodes.ts +++ b/src/lib/schema/nodes.ts @@ -1,5 +1,5 @@ import { DOMOutputSpec, Node as ProsemirrorNode, NodeSpec } from 'prosemirror-model'; -import * as sl from 'ngx-editor/schema-list'; +import * as sl from 'prosemirror-schema-list'; import toStyleString from '../utils/toStyleString'; diff --git a/src/ng-package.json b/src/ng-package.json index a58422d6..01ab9d1e 100644 --- a/src/ng-package.json +++ b/src/ng-package.json @@ -6,7 +6,12 @@ "umdModuleIds": { "prosemirror-state": "prosemirrorState", "prosemirror-view": "prosemirrorView", - "prosemirror-model": "prosemirrorModel" + "prosemirror-model": "prosemirrorModel", + "prosemirror-keymap": "prosemirrorKeymap", + "prosemirror-schema-list": "prosemirroSchemaList", + "prosemirror-commands": "prosemirrorCommands", + "prosemirror-history": "prosemirrorHistory", + "prosemirror-inputrules": "prosemirrorInputRules" } }, "whitelistedNonPeerDependencies": [ diff --git a/src/schema-list/package.json b/src/schema-list/package.json deleted file mode 100644 index 98dc0660..00000000 --- a/src/schema-list/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ngPackage": { - "lib": { - "entryFile": "./public_api.ts", - "umdModuleIds": { - "prosemirror-schema-list": "prosemirrorSchemaList" - } - } - } -} diff --git a/src/schema-list/public_api.ts b/src/schema-list/public_api.ts deleted file mode 100644 index 3b973931..00000000 --- a/src/schema-list/public_api.ts +++ /dev/null @@ -1 +0,0 @@ -export * from 'prosemirror-schema-list';