Skip to content

Commit

Permalink
wip: kinda introducing a lot of breaking changes
Browse files Browse the repository at this point in the history
Maybe getting out of hand.
  • Loading branch information
ifiokjr committed Mar 30, 2020
1 parent 9e450f1 commit 0a05c91
Show file tree
Hide file tree
Showing 67 changed files with 1,000 additions and 900 deletions.
6 changes: 3 additions & 3 deletions @remirror/core-extensions/src/core-extension-types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ObjectInterpolation } from '@emotion/core';

import { BaseExtensionConfig, NodeMatch } from '@remirror/core-types';
import { BaseExtensionSettings, NodeMatch } from '@remirror/core-types';

export interface CompositionExtensionOptions extends BaseExtensionConfig {
export interface CompositionExtensionOptions extends BaseExtensionSettings {
/**
* The nodes that need to be deleted when backspace is pressed
*/
ensureNodeDeletion?: NodeMatch[];
}

export interface PlaceholderExtensionOptions extends BaseExtensionConfig {
export interface PlaceholderExtensionOptions extends BaseExtensionSettings {
/**
* The placeholder text to use.
*/
Expand Down
4 changes: 2 additions & 2 deletions @remirror/core-extensions/src/core-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocExtension, InferFlexibleExtensionList, TextExtension } from '@remirror/core';
import { DocumentExtension, InferFlexibleExtensionList, TextExtension } from '@remirror/core';

import {
BaseKeymapExtension,
Expand All @@ -16,7 +16,7 @@ import { ParagraphExtension } from './nodes';
* or you can turn off all of the base extensions.
*/
export const baseExtensions = [
{ extension: new DocExtension(), priority: 1 },
{ extension: new DocumentExtension(), priority: 1 },
{ extension: new TextExtension(), priority: 1 },
{ extension: new ParagraphExtension(), priority: 2 },
{ extension: new HistoryExtension(), priority: 3 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {
import { undoInputRule } from 'prosemirror-inputrules';

import {
BaseExtensionConfig,
BaseExtensionSettings,
chainKeyBindingCommands,
convertCommand,
Extension,
ExtensionManagerParams,
ExtensionManagerParameter,
hasOwnProperty,
isFunction,
KeyBindings,
} from '@remirror/core';

export interface BaseKeymapExtensionOptions extends BaseExtensionConfig {
export interface BaseKeymapExtensionOptions extends BaseExtensionSettings {
/**
* Determines whether a backspace after an input rule has been applied undoes the input rule.
*
Expand Down Expand Up @@ -51,7 +51,7 @@ export interface BaseKeymapExtensionOptions extends BaseExtensionConfig {
* }});
* ```
*/
keymap?: KeyBindings | ((params: ExtensionManagerParams) => KeyBindings);
keymap?: KeyBindings | ((params: ExtensionManagerParameter) => KeyBindings);
}

export const defaultBaseKeymapExtensionOptions: BaseKeymapExtensionOptions = {
Expand Down Expand Up @@ -89,7 +89,7 @@ export class BaseKeymapExtension extends Extension<BaseKeymapExtensionOptions> {
/**
* Injects the baseKeymap into the editor.
*/
public keys(params: ExtensionManagerParams) {
public keys(parameters: ExtensionManagerParameter) {
const { selectParentNodeOnEscape, undoInputRuleOnBackspace, keymap } = this.options;
const backspaceRule: KeyBindings = undoInputRuleOnBackspace
? { Backspace: convertCommand(pmChainCommands(undoInputRule, baseKeymap.Backspace)) }
Expand All @@ -104,7 +104,7 @@ export class BaseKeymapExtension extends Extension<BaseKeymapExtensionOptions> {
...escapeRule,
};

const keyBindings = isFunction(keymap) ? keymap(params) : keymap;
const keyBindings = isFunction(keymap) ? keymap(parameters) : keymap;

for (const key in keyBindings) {
if (!hasOwnProperty(keymap, key)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { dropCursor } from 'prosemirror-dropcursor';

import { Extension } from '@remirror/core';
import { BaseExtensionConfig } from '@remirror/core-types';
import { BaseExtensionSettings } from '@remirror/core-types';

export interface DropCursorExtensionOptions extends BaseExtensionConfig {
export interface DropCursorExtensionOptions extends BaseExtensionSettings {
/**
* Set the color of the cursor.
*
Expand Down
4 changes: 2 additions & 2 deletions @remirror/core-extensions/src/extensions/history-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { history, redo, undo } from 'prosemirror-history';

import { Extension, isFunction, KeyBindings } from '@remirror/core';
import {
BaseExtensionConfig,
BaseExtensionSettings,
DispatchFunction,
EditorState,
ProsemirrorCommandFunction,
} from '@remirror/core-types';
import { convertCommand, environment } from '@remirror/core-utils';

export interface HistoryExtensionOptions extends BaseExtensionConfig {
export interface HistoryExtensionOptions extends BaseExtensionSettings {
/**
* The amount of history events that are collected before the
* oldest events are discarded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { EditorState, Plugin, Transaction } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view';

import {
BaseExtensionConfig,
BaseExtensionSettings,
Extension,
ExtensionManagerParams,
ExtensionManagerParameter,
isEmptyArray,
NodeMatch,
ResolvedPos,
Expand Down Expand Up @@ -106,7 +106,7 @@ const createNodeCursorExtensionPlugin = (context: NodeCursorExtension, nodeNames
});
};

export interface NodeCursorExtensionOptions extends BaseExtensionConfig {
export interface NodeCursorExtensionOptions extends BaseExtensionSettings {
targets?: NodeMatch[];
}

Expand All @@ -128,7 +128,7 @@ export class NodeCursorExtension extends Extension<NodeCursorExtensionOptions> {
};
}

public plugin({ tags }: ExtensionManagerParams) {
public plugin({ tags }: ExtensionManagerParameter) {
return createNodeCursorExtensionPlugin(this, tags.general.nodeCursor);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Children } from 'react';

import { Extension, isString } from '@remirror/core';
import { ExtensionManagerParams, Plugin } from '@remirror/core-types';
import { ExtensionManagerParameter, Plugin } from '@remirror/core-types';
import { isDocNodeEmpty } from '@remirror/core-utils';
import { cloneElement, getElementProps } from '@remirror/react-utils';

Expand Down Expand Up @@ -53,22 +53,22 @@ export class PlaceholderExtension extends Extension<PlaceholderExtensionOptions>
/**
* Add a class and props to the root element if the document is empty.
*/
public ssrTransformer(element: JSX.Element, { getState }: ExtensionManagerParams) {
public ssrTransformer(element: JSX.Element, { getState }: ExtensionManagerParameter) {
const state = getState();
const { emptyNodeClass, placeholder } = this.options;
const { children } = getElementProps(element);
if (Children.count(children) > 1 || !isDocNodeEmpty(state.doc)) {
return element;
}

const props = getElementProps(children);
const properties = getElementProps(children);
return cloneElement(
element,
{},
cloneElement(children, {
...props,
className: isString(props.className)
? `${props.className} ${emptyNodeClass}`
...properties,
className: isString(properties.className)
? `${properties.className} ${emptyNodeClass}`
: emptyNodeClass,
'data-placeholder': placeholder,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Decoration, DecorationSet } from 'prosemirror-view';
import { Extension } from '@remirror/core';
import { isNullOrUndefined, isNumber, isString, object } from '@remirror/core-helpers';
import {
BaseExtensionConfig,
CommandParams,
ExtensionManagerParams,
PosParams,
BaseExtensionSettings,
CommandParameter,
ExtensionManagerParameter,
PosParameter,
ProsemirrorCommandFunction,
Transaction,
} from '@remirror/core-types';
Expand All @@ -20,7 +20,7 @@ const defaultPositionTrackerExtensionOptions: Partial<PositionTrackerExtensionOp
defaultElement: 'tracker',
};

export interface PositionTrackerExtensionOptions extends BaseExtensionConfig {
export interface PositionTrackerExtensionOptions extends BaseExtensionSettings {
/**
* The className that is added to all tracker positions
*
Expand Down Expand Up @@ -52,7 +52,7 @@ export class PositionTrackerExtension extends Extension<PositionTrackerExtension
return defaultPositionTrackerExtensionOptions;
}

public helpers({ getState }: ExtensionManagerParams) {
public helpers({ getState }: ExtensionManagerParameter) {
const helpers = {
/**
* Add a tracker position with the specified params to the transaction and return the transaction.
Expand Down Expand Up @@ -134,12 +134,12 @@ export class PositionTrackerExtension extends Extension<PositionTrackerExtension
return helpers;
}

public commands({ getHelpers }: CommandParams) {
public commands({ getHelpers }: CommandParameter) {
const commandFactory = <GArg>(helperName: string) => (
params: GArg,
parameters: GArg,
): ProsemirrorCommandFunction => (_, dispatch) => {
const helper = getHelpers(helperName);
const tr = helper(params);
const tr = helper(parameters);

// Nothing changed therefore do nothing
if (!tr) {
Expand Down Expand Up @@ -245,7 +245,7 @@ interface RemovePositionTrackerParams {
id: unknown;
}

interface AddPositionTrackerParams extends Partial<PosParams>, RemovePositionTrackerParams {
interface AddPositionTrackerParams extends Partial<PosParameter>, RemovePositionTrackerParams {
/**
* A custom class name to use for the tracker position. All the trackers
* will automatically be given the class name `remirror-tracker-position`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Extension } from '@remirror/core';
import { BaseExtensionConfig, ExtensionManagerParams } from '@remirror/core-types';
import { BaseExtensionSettings, ExtensionManagerParameter } from '@remirror/core-types';

import { DEFAULT_TRANSFORMATIONS, SSRTransformer } from './ssr-helpers-utils';

export interface SSRHelperExtensionOptions extends BaseExtensionConfig {
export interface SSRHelperExtensionOptions extends BaseExtensionSettings {
transformers?: SSRTransformer[];
}

Expand Down Expand Up @@ -34,9 +34,9 @@ export class SSRHelperExtension extends Extension<SSRHelperExtensionOptions> {
/**
* Runs through all the provided transformations for changing the rendered SSR component.
*/
public ssrTransformer(element: JSX.Element, params: ExtensionManagerParams) {
public ssrTransformer(element: JSX.Element, parameters: ExtensionManagerParameter) {
return this.options.transformers.reduce((transformedElement, transformer) => {
return transformer(transformedElement, params);
return transformer(transformedElement, parameters);
}, element);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { jsx } from '@emotion/core';
import { Children, JSXElementConstructor } from 'react';

import { isArray } from '@remirror/core-helpers';
import { ExtensionManagerParams, PlainObject } from '@remirror/core-types';
import { ExtensionManagerParameter, PlainObject } from '@remirror/core-types';
import {
cloneElement,
getElementProps,
Expand All @@ -13,7 +13,10 @@ import {
/**
* A function that transforms the element received during Server Side Rendering
*/
export type SSRTransformer = (element: JSX.Element, params: ExtensionManagerParams) => JSX.Element;
export type SSRTransformer = (
element: JSX.Element,
params: ExtensionManagerParameter,
) => JSX.Element;

/**
* Clone SSR elements ignoring the top level Fragment
Expand All @@ -36,9 +39,9 @@ export const cloneSSRElement = (
}

const { children } = getElementProps(element);
const childrenProps = getElementProps(children);
const childrenProperties = getElementProps(children);

return cloneElement(element, {}, transformChildElements(children, childrenProps));
return cloneElement(element, {}, transformChildElements(children, childrenProperties));
};

/**
Expand Down Expand Up @@ -79,8 +82,8 @@ export const injectBrIntoEmptyParagraphs: SSRTransformer = (element) => {
return child;
}

const props = getElementProps(child);
return cloneElement(child, props, jsx('br'));
const properties = getElementProps(child);
return cloneElement(child, properties, jsx('br'));
});
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { Plugin } from 'prosemirror-state';
import { Extension, ExtensionParameters } from '@remirror/core';
import { entries, uniqueArray } from '@remirror/core-helpers';
import {
BaseExtensionConfig,
ExtensionManagerParams,
ExtensionTagParams,
SchemaParams,
BaseExtensionSettings,
ExtensionManagerParameter,
ExtensionTagParameter,
SchemaParameter,
} from '@remirror/core-types';
import { getPluginState, nodeEqualsType } from '@remirror/core-utils';

interface CreateTrailingNodePluginParams
extends ExtensionTagParams,
extends ExtensionTagParameter,
ExtensionParameters<TrailingNodeExtension>,
SchemaParams {}
SchemaParameter {}

/**
* Create the paragraph plugin which can check the end of the document and
Expand Down Expand Up @@ -76,7 +76,7 @@ export const createTrailingNodePlugin = ({
});
};

export interface TrailingNodeExtensionOptions extends BaseExtensionConfig {
export interface TrailingNodeExtensionOptions extends BaseExtensionSettings {
/**
* The node to create at the end of the document.
*
Expand Down Expand Up @@ -135,7 +135,7 @@ export class TrailingNodeExtension extends Extension<TrailingNodeExtensionOption
* Register the plugin which is responsible for inserting the configured node
* into the end of the node.
*/
public plugin({ tags, schema }: ExtensionManagerParams) {
public plugin({ tags, schema }: ExtensionManagerParameter) {
return createTrailingNodePlugin({ extension: this, tags, schema });
}
}
2 changes: 1 addition & 1 deletion @remirror/core-extensions/src/marks/link-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class LinkExtension extends MarkExtension<LinkExtensionOptions> {
markPasteRule({
regexp: /https?:\/\/(www\.)?[\w#%+.:=@~-]{2,256}\.[a-z]{2,6}\b([\w#%&+./:=?@~-]*)/g,
type,
getAttrs: (url) => ({ href: getMatchString(url) }),
getAttributes: (url) => ({ href: getMatchString(url) }),
}),
];
}
Expand Down

0 comments on commit 0a05c91

Please sign in to comment.