Skip to content

Commit

Permalink
chore: update ProseMirror casing
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jan 26, 2021
1 parent 849411e commit 926894c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ After
<ngx-editor-menu [customMenuRef]="customMenu"> </ngx-editor-menu>
```

### Prosemirror Configuration
### ProseMirror Configuration

**Before**

Expand Down
10 changes: 5 additions & 5 deletions demo/src/app/nodeviews/CodeMirror.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable:typedef */
import { undo, redo } from 'prosemirror-history';
import { TextSelection, Selection } from 'prosemirror-state';
import { Node as ProsemirrorNode } from 'prosemirror-model';
import { Node as ProseMirrorNode } from 'prosemirror-model';
import { EditorView, NodeView } from 'prosemirror-view';
import { exitCode } from 'prosemirror-commands';

Expand Down Expand Up @@ -33,7 +33,7 @@ function computeChange(oldVal: string, newVal: string): ComputeChange {
type GetPos = () => number;

class CodeMirrorView implements NodeView {
node: ProsemirrorNode;
node: ProseMirrorNode;
getPos: GetPos;
incomingChanges: boolean;

Expand All @@ -43,7 +43,7 @@ class CodeMirrorView implements NodeView {
dom: HTMLElement;
updating: boolean;

constructor(node: ProsemirrorNode, view: EditorView, getPos: GetPos) {
constructor(node: ProseMirrorNode, view: EditorView, getPos: GetPos) {
// Store for later
this.node = node;
this.view = view;
Expand Down Expand Up @@ -97,7 +97,7 @@ class CodeMirrorView implements NodeView {
}
}

asProseMirrorSelection(doc: ProsemirrorNode) {
asProseMirrorSelection(doc: ProseMirrorNode) {
const offset = this.getPos() + 1;
const anchor = this.cm.indexFromPos(this.cm.getCursor('anchor')) + offset;
const head = this.cm.indexFromPos(this.cm.getCursor('head')) + offset;
Expand Down Expand Up @@ -154,7 +154,7 @@ class CodeMirrorView implements NodeView {
this.view.focus();
}

update(node: ProsemirrorNode) {
update(node: ProseMirrorNode) {
if (node.type !== this.node.type) { return false; }
this.node = node;
const change = computeChange(this.cm.getValue(), node.textContent);
Expand Down
4 changes: 2 additions & 2 deletions demo/src/app/nodeviews/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Node as ProsemirrorNode } from 'prosemirror-model';
import { Node as ProseMirrorNode } from 'prosemirror-model';
import { EditorView } from 'prosemirror-view';

import CodeBlockView from './CodeMirror';

const nodeViews = {
code_mirror: (node: ProsemirrorNode, view: EditorView, getPos: () => number) => {
code_mirror: (node: ProseMirrorNode, view: EditorView, getPos: () => number) => {
return new CodeBlockView(node, view, getPos);
}
};
Expand Down
12 changes: 6 additions & 6 deletions docs/codemirror.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ See https://sibiraj-s.github.io/ngx-editor/#/menu?id=custom-menu for implementin
import { exitCode } from 'prosemirror-commands';
import { undo, redo } from 'prosemirror-history';
import { TextSelection, Selection } from 'prosemirror-state';
import { Node as ProsemirrorNode } from 'prosemirror-model';
import { Node as ProseMirrorNode } from 'prosemirror-model';
import { EditorView, NodeView } from 'prosemirror-view';

import CodeMirror from 'codemirror';
Expand Down Expand Up @@ -47,7 +47,7 @@ function computeChange(oldVal: string, newVal: string) {
type GetPos = () => number;

class CodeMirrorView implements NodeView {
node: ProsemirrorNode;
node: ProseMirrorNode;
getPos: GetPos;
incomingChanges: boolean;

Expand All @@ -57,7 +57,7 @@ class CodeMirrorView implements NodeView {
dom: HTMLElement;
updating: boolean;

constructor(node: ProsemirrorNode, view: EditorView, getPos: GetPos) {
constructor(node: ProseMirrorNode, view: EditorView, getPos: GetPos) {
// Store for later
this.node = node;
this.view = view;
Expand Down Expand Up @@ -113,7 +113,7 @@ class CodeMirrorView implements NodeView {
}
}

asProseMirrorSelection(doc: ProsemirrorNode) {
asProseMirrorSelection(doc: ProseMirrorNode) {
const offset = this.getPos() + 1;
const anchor = this.cm.indexFromPos(this.cm.getCursor('anchor')) + offset;
const head = this.cm.indexFromPos(this.cm.getCursor('head')) + offset;
Expand Down Expand Up @@ -184,7 +184,7 @@ class CodeMirrorView implements NodeView {
this.view.focus();
}

update(node: ProsemirrorNode) {
update(node: ProseMirrorNode) {
if (node.type !== this.node.type) {
return false;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ new Editor({
nodeViews: {
code_mirror: (
// first define schema `code_mirror`. see schema section
node: ProsemirrorNode,
node: ProseMirrorNode,
view: EditorView,
getPos: () => number
) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/migration-5-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ After
<ngx-editor-menu [customMenuRef]="customMenu"> </ngx-editor-menu>
```

## Prosemirror Configuration
## ProseMirror Configuration

**Before**

Expand Down
4 changes: 2 additions & 2 deletions src/lib/commands/Heading.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeType, Node as ProsemirrorNode } from 'prosemirror-model';
import { NodeType, Node as ProseMirrorNode } from 'prosemirror-model';
import { EditorState, Transaction } from 'prosemirror-state';
import { Command, setBlockType } from 'prosemirror-commands';

Expand Down Expand Up @@ -71,7 +71,7 @@ class Heading {
return supportedNodes.includes(node.type);
});

const acitveNode = nodes.find((node: ProsemirrorNode) => {
const acitveNode = nodes.find((node: ProseMirrorNode) => {
return node.attrs.level === this.level;
});

Expand Down
4 changes: 2 additions & 2 deletions src/lib/parsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DOMSerializer, Schema, DOMParser, Node as ProsemirrorNode } from 'prosemirror-model';
import { DOMSerializer, Schema, DOMParser, Node as ProseMirrorNode } from 'prosemirror-model';

import defaultSchema from './schema';

Expand Down Expand Up @@ -32,7 +32,7 @@ export const toDoc = (html: string, inputSchema?: Schema): Record<string, any> =
return DOMParser.fromSchema(schema).parse(el).toJSON();
};

export const parseContent = (value: string | Record<string, any> | null, schema: Schema): ProsemirrorNode => {
export const parseContent = (value: string | Record<string, any> | null, schema: Schema): ProseMirrorNode => {
if (!value) {
return schema.nodeFromJSON(emptyDoc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/validators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbstractControl, ValidatorFn } from '@angular/forms';
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model';
import { Schema, Node as ProseMirrorNode } from 'prosemirror-model';

import { parseContent } from './parsers';
import defaultSchema from './schema';
Expand All @@ -16,7 +16,7 @@ const hasValidLength = (value: any): boolean => {
return value != null && typeof value.length === 'number';
};

const isDocEmpty = (doc: ProsemirrorNode | null): boolean => {
const isDocEmpty = (doc: ProseMirrorNode | null): boolean => {
if (!doc) {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/image.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node as ProsemirrorNode } from 'prosemirror-model';
import { Node as ProseMirrorNode } from 'prosemirror-model';
import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
import { EditorView } from 'prosemirror-view';

Expand All @@ -17,7 +17,7 @@ class ImageRezieView {
dom: HTMLElement;
handle: HTMLElement;

constructor(node: ProsemirrorNode, view: EditorView, getPos: () => number) {
constructor(node: ProseMirrorNode, view: EditorView, getPos: () => number) {
const outer = document.createElement('span');
outer.className = WRAPPER_CLASSNAME;
outer.style.width = node.attrs.width;
Expand Down Expand Up @@ -125,7 +125,7 @@ const imagePlugin = (opts = defaultOptions): Plugin => {
key: new PluginKey('link'),
props: {
nodeViews: {
image: (node: ProsemirrorNode, view: EditorView, getPos: () => number) => {
image: (node: ProseMirrorNode, view: EditorView, getPos: () => number) => {
if (!options.resize) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/schema/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DOMOutputSpec, Node as ProsemirrorNode, NodeSpec } from 'prosemirror-model';
import { DOMOutputSpec, Node as ProseMirrorNode, NodeSpec } from 'prosemirror-model';
import * as sl from 'prosemirror-schema-list';

import { toStyleString } from 'ngx-editor/utils';
Expand Down Expand Up @@ -225,7 +225,7 @@ export const image: NodeSpec = {
}
}
],
toDOM(node: ProsemirrorNode): DOMOutputSpec {
toDOM(node: ProseMirrorNode): DOMOutputSpec {
const { src, alt, title, width } = node.attrs;
return ['img', { src, alt, title, width }];
}
Expand Down

0 comments on commit 926894c

Please sign in to comment.