Skip to content

Commit

Permalink
wip: still dropdown work
Browse files Browse the repository at this point in the history
  • Loading branch information
ifiokjr committed Sep 3, 2019
1 parent 5f2c732 commit 5523af8
Show file tree
Hide file tree
Showing 70 changed files with 1,140 additions and 2,631 deletions.
12 changes: 12 additions & 0 deletions .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@
"limit": "90 KB",
"ignore": ["@emotion/core"]
},
{
"name": "@remirror/react-hooks",
"path": "@remirror/react-hooks/lib/index.js",
"limit": "65 KB",
"ignore": ["@emotion/core", "@types/react", "react"]
},
{
"name": "@remirror/react-portals",
"path": "@remirror/react-portals/lib/index.js",
Expand Down Expand Up @@ -131,6 +137,12 @@
"limit": "70 KB",
"ignore": ["@emotion/core", "@types/react", "@types/react-dom", "react", "react-dom"]
},
{
"name": "@remirror/ui-dropdown",
"path": "@remirror/ui-dropdown/lib/index.js",
"limit": "70 KB",
"ignore": ["@emotion/core", "@types/react", "react"]
},
{
"name": "@remirror/ui-icons",
"path": "@remirror/ui-icons/lib/index.js",
Expand Down
6 changes: 3 additions & 3 deletions @remirror/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remirror/cli",
"description": "Core extensions for the remirror wysiwyg editor",
"description": "The remirror cli",
"license": "MIT",
"author": "Ifiok Jr. <ifiokotung@gmail.com>",
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/cli",
Expand Down Expand Up @@ -31,18 +31,18 @@
"dependencies": {
"@babel/runtime": "^7.5.2",
"@remirror/core-helpers": "0.4.2-canary.2",
"@types/ink-spinner": "^2.0.1",
"@types/jsesc": "0.4.29",
"@types/node": "^12.6.1",
"@types/parcel-bundler": "^1.12.0",
"@types/react": "^16.9.2",
"@types/rimraf": "^2.0.2",
"@types/yargs": "^13.0.0",
"figures": "^3.0.0",
"ink": "^2.3.0",
"ink-spinner": "^3.0.1",
"jsesc": "^2.5.2",
"parcel-bundler": "^1.12.3",
"react": "^16.9.0",
"react": "^16.8.0",
"react-use": "11.3.2",
"rimraf": "^3.0.0",
"yargs": "^14.0.0"
Expand Down
38 changes: 38 additions & 0 deletions @remirror/cli/src/patches.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
declare module 'ink-spinner' {
import { Chalk } from 'chalk';
import * as cliSpinners from 'cli-spinners';
import { Component } from 'react';

type StringifyPartial<T> = {
[P in keyof T]?: string;
};

type BooleansPartial<T> = {
[P in keyof T]?: boolean;
};

type TupleOfNumbersPartial<T> = {
[P in keyof T]?: [number, number, number];
};
// Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;

type ChalkColorModels = Pick<Chalk, 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'bgRgb' | 'bgHsl' | 'bgHsv' | 'bgHwb'>;
type ChalkKeywordsAndHexes = Pick<Chalk, 'keyword' | 'hex' | 'bgKeyword' | 'bgHex'>;
type ChalkCommons = Omit<
Chalk,
keyof ChalkColorModels | keyof ChalkKeywordsAndHexes | 'constructor' | 'level' | 'enabled'
>;

interface SpinnerProps {
type?: cliSpinners.SpinnerName;
}

type ChalkProps = BooleansPartial<ChalkCommons> &
StringifyPartial<ChalkKeywordsAndHexes> &
TupleOfNumbersPartial<ChalkColorModels>;

declare class Spinner extends Component<SpinnerProps & ChalkProps> {}

export = Spinner;
}
3 changes: 2 additions & 1 deletion @remirror/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../support/tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"types": ["node", "jest", "jest-extended"]
"types": ["node", "jest", "jest-extended"],
"skipLibCheck": true
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion @remirror/core-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"prosemirror-model": "^1.7.1",
"prosemirror-schema-list": "^1.0.3",
"prosemirror-state": "^1.2.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10",
Expand Down
2 changes: 1 addition & 1 deletion @remirror/core-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remirror/core-helpers",
"description": "Provide helper functions for the remirror codebase, kinda like lodash but smaller",
"description": "Provide helper functions for the remirror codebase, kinda like a tiny lodash",
"license": "MIT",
"author": "Ifiok Jr. <ifiokotung@gmail.com>",
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/core-helpers",
Expand Down
4 changes: 2 additions & 2 deletions @remirror/core-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remirror/core-types",
"description": "Provides the core TypeScript types for you used throughout the remirror codebase",
"description": "Provides the core TS types for use throughout the remirror codebase",
"license": "MIT",
"author": "Ifiok Jr. <ifiokotung@gmail.com>",
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/core-types",
Expand Down Expand Up @@ -44,7 +44,7 @@
"prosemirror-schema-list": "^1.0.3",
"prosemirror-state": "^1.2.4",
"prosemirror-transform": "^1.1.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10",
Expand Down
4 changes: 2 additions & 2 deletions @remirror/core-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remirror/core-utils",
"description": "Core extensions for the remirror wysiwyg editor",
"description": "Core utilities for dealing with the dom and prosemirror within remirror",
"license": "MIT",
"author": "Ifiok Jr. <ifiokotung@gmail.com>",
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/core-utils",
Expand Down Expand Up @@ -29,7 +29,7 @@
"@remirror/core-helpers": "0.4.2-canary.2",
"@remirror/core-types": "0.4.2-canary.2",
"@types/min-document": "^2.19.0",
"@types/node": "^10",
"@types/node": "^12.7.2",
"@types/prosemirror-commands": "^1.0.1",
"@types/prosemirror-inputrules": "^1.0.2",
"@types/prosemirror-model": "^1.7.2",
Expand Down
38 changes: 24 additions & 14 deletions @remirror/core-utils/src/keyboard-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,47 @@ import { environment } from './environment';
/**
* Keycode for ALT key.
*/
export const ALT = 'Alt';
export const ALT = ['Alt', '⌥'] as const;

/**
* Keycode for CTRL key.
*/
export const CTRL = 'Control';
export const CTRL = ['Control', '⌃'] as const;

/**
* Keycode for COMMAND/META key.
*/
export const COMMAND = 'Meta';
export const COMMAND = ['Meta', '⌘'] as const;

/**
* Keycode for SHIFT key.
*/
export const SHIFT = 'Shift';
export const SHIFT = ['Shift', '⇧'] as const;

/**
* Keycode for the windows key
*/
export const WINDOWS = ['Windows', '', '❖'];

/**
* Keycode and symbols for caps lock
*/
export const CAPS_LOCK = ['CapsLock', '⇪', '⇪'];

/**
* Shorthand names for common modifier key combinations which should `just` work on Apple and PC.
*/
export const Modifier = {
Primary: (isMac?: boolean) => (isMac ? [COMMAND] : [CTRL]),
PrimaryShift: (isMac?: boolean) => (isMac ? [SHIFT, COMMAND] : [CTRL, SHIFT]),
PrimaryAlt: (isMac?: boolean) => (isMac ? [ALT, COMMAND] : [CTRL, ALT]),
Secondary: (isMac?: boolean) => (isMac ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT]),
Access: (isMac?: boolean) => (isMac ? [CTRL, ALT] : [SHIFT, ALT]),
Ctrl: () => [CTRL],
Alt: () => [ALT],
CtrlShift: () => [CTRL, SHIFT],
Shift: () => [SHIFT],
ShiftAlt: () => [SHIFT, ALT],
Primary: (isMac?: boolean) => (isMac ? [COMMAND[0]] : [CTRL[0]]),
PrimaryShift: (isMac?: boolean) => (isMac ? [SHIFT[0], COMMAND[0]] : [CTRL[0], SHIFT[0]]),
PrimaryAlt: (isMac?: boolean) => (isMac ? [ALT[0], COMMAND[0]] : [CTRL[0], ALT[0]]),
Secondary: (isMac?: boolean) => (isMac ? [SHIFT[0], ALT[0], COMMAND[0]] : [CTRL[0], SHIFT[0], ALT[0]]),
Access: (isMac?: boolean) => (isMac ? [CTRL[0], ALT[0]] : [SHIFT[0], ALT[0]]),
Ctrl: () => [CTRL[0]],
Alt: () => [ALT[0]],
CtrlShift: () => [CTRL[0], SHIFT[0]],
Shift: () => [SHIFT[0]],
ShiftAlt: () => [SHIFT[0], ALT[0]],
};

/**
Expand Down
2 changes: 1 addition & 1 deletion @remirror/editor-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remirror/editor-markdown",
"description": "ui for a what you see is what you get (wysiwyg) editing experience",
"description": "A markdown editor",
"license": "MIT",
"author": "Ifiok Jr. <ifiokotung@gmail.com>",
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/editor-markdown",
Expand Down
3 changes: 1 addition & 2 deletions @remirror/editor-wysiwyg/src/components/wysiwyg-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ActionNames, AnyFunction, Attrs, KeyOfThemeVariant, memoize } from '@remirror/core';
import { useRemirror } from '@remirror/react';
import { bubblePositioner } from '@remirror/react-utils';
import { bubblePositioner, useRemirror } from '@remirror/react';
import { useRemirrorTheme } from '@remirror/ui';
import {
BoldIcon,
Expand Down
2 changes: 1 addition & 1 deletion @remirror/extension-code-block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"prosemirror-keymap": "^1.0.1",
"prosemirror-state": "^1.2.4",
"prosemirror-transform": "^1.1.4",
"prosemirror-view": "^1.10.0",
"prosemirror-view": "^1.10.1",
"react-syntax-highlighter": "^11.0.2",
"refractor": "^2.10.0"
},
Expand Down
2 changes: 1 addition & 1 deletion @remirror/extension-drop-cursor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/prosemirror-view": "^1.9.0",
"prosemirror-state": "^1.2.4",
"prosemirror-transform": "^1.1.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10",
Expand Down
2 changes: 1 addition & 1 deletion @remirror/extension-emoji/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"emoji-regex": "^8.0.0",
"prosemirror-model": "^1.7.1",
"prosemirror-state": "^1.2.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10",
Expand Down
2 changes: 1 addition & 1 deletion @remirror/extension-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"prosemirror-keymap": "^1.0.1",
"prosemirror-model": "^1.7.1",
"prosemirror-state": "^1.2.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10",
Expand Down
2 changes: 1 addition & 1 deletion @remirror/extension-mention/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/prosemirror-view": "^1.9.0",
"prosemirror-keymap": "^1.0.1",
"prosemirror-state": "^1.2.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10"
Expand Down
2 changes: 1 addition & 1 deletion @remirror/extension-multicursor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/prosemirror-state": "^1.2.3",
"@types/prosemirror-view": "^1.9.0",
"prosemirror-state": "^1.2.4",
"prosemirror-view": "^1.10.0"
"prosemirror-view": "^1.10.1"
},
"peerDependencies": {
"@emotion/core": "^10"
Expand Down
23 changes: 23 additions & 0 deletions @remirror/react-hooks/__mocks__/resize-observer-polyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const observers = new Map<HTMLElement, true>();

export const fakeResizeObserverPolyfill = Object.freeze({
observe: jest.fn((el: HTMLElement) => observers.set(el, true)),
unobserve: jest.fn((el: HTMLElement) => observers.delete(el)),
disconnect: jest.fn(() => observers.clear()),
});

let callback: any;
const defaultBounds = { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 };

export const triggerChange = (bounds: Partial<typeof defaultBounds> = {}, el: HTMLElement) => {
const target = observers.get(el);

if (callback && target) {
callback([Object.freeze({ target, contentRect: { defaultBounds, ...bounds } })]);
}
};

export default jest.fn(cb => {
callback = cb;
return fakeResizeObserverPolyfill;
});
7 changes: 7 additions & 0 deletions @remirror/react-hooks/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = require('../../support/jest/jest.config');

module.exports = {
...config,
name: '@remirror/react-hooks',
displayName: 'react-hooks',
};
45 changes: 45 additions & 0 deletions @remirror/react-hooks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@remirror/react-hooks",
"description": "React hooks for remirror",
"license": "MIT",
"author": "Ifiok Jr. <ifiokotung@gmail.com>",
"homepage": "https://github.com/ifiokjr/remirror/tree/master/@remirror/react-hooks",
"repository": "https://github.com/ifiokjr/remirror/tree/master/@remirror/react-hooks",
"version": "0.4.2-canary.2",
"main": "lib/index.js",
"module": "lib/dist/react-hooks.esm.js",
"files": [
"lib",
"src"
],
"scripts": {
"build": "run-p build:*",
"build:babel": "babel src --out-dir lib --root-mode=upward --extensions \".ts,.tsx\" -s",
"build:declaration": "tsc -p ./tsconfig.prod.json --emitDeclarationOnly --declarationMap",
"dev": "run-p dev:*",
"dev:babel": "babel src --out-dir lib --root-mode=upward --extensions \".ts,.tsx\" -s --watch",
"dev:declaration": "tsc -p ./tsconfig.prod.json --emitDeclarationOnly --declarationMap --watch",
"lint": "tslint --project tsconfig.lint.json --config ../../tslint.json",
"typecheck": "tsc -p ./tsconfig.json --noEmit"
},
"types": "lib/index.d.ts",
"dependencies": {
"@babel/runtime": "^7.5.5",
"@remirror/core-helpers": "0.4.2-canary.2",
"@remirror/core-types": "0.4.2-canary.2",
"resize-observer-polyfill": "^1.5.1"
},
"peerDependencies": {
"@emotion/core": "^10",
"@types/react": "^16.8.0",
"react": "^16.8.0"
},
"publishConfig": {
"access": "public"
},
"cjs": "lib/dist/react-hooks.cjs.js",
"meta": {
"sizeLimit": "65 KB"
},
"sideEffects": false
}
24 changes: 24 additions & 0 deletions @remirror/react-hooks/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div align="center">
<br />
<div align="center">
<img width="300" src="https://cdn.jsdelivr.net/gh/ifiokjr/remirror/support/assets/logo-icon.svg" alt="remirror" />
</div>
<br />
<br />
<br />
<br />
</div>

[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@remirror/react-hooks.svg?style=for-the-badge)](https://bundlephobia.com/result?p=@remirror/react-hooks) [![npm](https://img.shields.io/npm/dm/@remirror/react-hooks.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@remirror/react-hooks) [![Dependencies (path)](https://img.shields.io/david/ifiokjr/remirror.svg?logo=npm&path=@remirror%2Freact-hooks&style=for-the-badge)](https://github.com/ifiokjr/remirror/blob/master/@remirror/react-hooks/package.json) [![NPM](https://img.shields.io/npm/l/@remirror/react-hooks.svg?style=for-the-badge)](https://github.com/ifiokjr/remirror/blob/master/LICENSE) [![GitHub issues by-label](https://img.shields.io/github/issues/ifiokjr/remirror/@remirror/react-hooks.svg?label=Open%20Issues&logo=github&style=for-the-badge)](https://github.com/ifiokjr/remirror/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%40remirror%2Freact-hooks) [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/ifiokjr/remirror/@remirror/react-hooks.svg?label=Open%20Pull%20Requests&logo=github&style=for-the-badge)](https://github.com/ifiokjr/remirror/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+sort%3Aupdated-desc+label%3A%40remirror%2Freact-hooks)

Some helper react hooks for the remirror library.

## Installation

```bash
yarn add @remirror/react-hooks
```

## Usage

For in depth usage with proper code example see the [docs](https://docs.remirror.org)

0 comments on commit 5523af8

Please sign in to comment.