Skip to content

Commit

Permalink
docs: explain how to use basic extensions (remirror#1101)
Browse files Browse the repository at this point in the history
Docs for bold, italic, strike, and underline extension
  • Loading branch information
ronnyroeller authored Aug 19, 2021
1 parent 8076ae5 commit 453a2d1
Show file tree
Hide file tree
Showing 17 changed files with 543 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/extensions/bold-extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
hide_title: true
title: 'BoldExtension'
---

# `BoldExtension`

## Summary

When added to your editor it will provide the `toggleBold` command which makes the text under the cursor / or at the provided position range bold.

## Usage

### Installation

This extension is installed for you when you install the main `remirror` package.

You can use the imports in the following way.

```ts
import { boldExtension } from 'remirror/extensions';
```

To install it directly you can use

The extension is provided by the `@remirror/extension-bold` package. There are two ways of pulling it into your project.

### Examples

See [storybook](https://remirror.vercel.app/?path=/story/extensions-bold--basic) for examples.

## API

### Options

### Commands

### Helpers
38 changes: 38 additions & 0 deletions docs/extensions/italic-extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
hide_title: true
title: 'ItalicExtension'
---

# `ItalicExtension`

## Summary

The extension for adding italic marks to the editor.

## Usage

### Installation

This extension is installed for you when you install the main `remirror` package.

You can use the imports in the following way.

```ts
import { italicExtension } from 'remirror/extensions';
```

To install it directly you can use

The extension is provided by the `@remirror/extension-italic` package. There are two ways of pulling it into your project.

### Examples

See [storybook](https://remirror.vercel.app/?path=/story/extensions-italic--basic) for examples.

## API

### Options

### Commands

### Helpers
38 changes: 38 additions & 0 deletions docs/extensions/strike-extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
hide_title: true
title: 'StrikeExtension'
---

# `StrikeExtension`

## Summary

The extension for adding strike-through marks to the editor.

## Usage

### Installation

This extension is installed for you when you install the main `remirror` package.

You can use the imports in the following way.

```ts
import { strikeExtension } from 'remirror/extensions';
```

To install it directly you can use

The extension is provided by the `@remirror/extension-strike` package. There are two ways of pulling it into your project.

### Examples

See [storybook](https://remirror.vercel.app/?path=/story/extensions-strike--basic) for examples.

## API

### Options

### Commands

### Helpers
38 changes: 38 additions & 0 deletions docs/extensions/underline-extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
hide_title: true
title: 'UnderlineExtension'
---

# `UnderlineExtension`

## Summary

The extension for adding underline marks to the editor.

## Usage

### Installation

This extension is installed for you when you install the main `remirror` package.

You can use the imports in the following way.

```ts
import { underlineExtension } from 'remirror/extensions';
```

To install it directly you can use

The extension is provided by the `@remirror/extension-underline` package. There are two ways of pulling it into your project.

### Examples

See [storybook](https://remirror.vercel.app/?path=/story/extensions-underline--basic) for examples.

## API

### Options

### Commands

### Helpers
38 changes: 38 additions & 0 deletions packages/remirror__extension-bold/__stories__/bold.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'remirror/styles/all.css';
import './styles.css';

import { BoldExtension } from 'remirror/extensions';
import { cx, htmlToProsemirrorNode } from '@remirror/core';
import { ProsemirrorDevTools } from '@remirror/dev';
import { Remirror, ThemeProvider, useActive, useCommands, useRemirror } from '@remirror/react';

export default { title: 'Extensions / Bold' };

const extensions = () => [new BoldExtension()];

const BoldButton = () => {
const commands = useCommands();
const active = useActive(true);
return (
<button onClick={() => commands.toggleBold()} className={cx(active.bold() && 'active')}>
Bold
</button>
);
};

export const Basic = (): JSX.Element => {
const { manager, state, onChange } = useRemirror({
extensions: extensions,
content: '<p>Text in <b>bold</b></p>',
stringHandler: htmlToProsemirrorNode,
});

return (
<ThemeProvider>
<Remirror manager={manager} autoFocus onChange={onChange} state={state} autoRender='end'>
<BoldButton />
<ProsemirrorDevTools />
</Remirror>
</ThemeProvider>
);
};
3 changes: 3 additions & 0 deletions packages/remirror__extension-bold/__stories__/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.active {
font-weight: bold;
}
53 changes: 53 additions & 0 deletions packages/remirror__extension-bold/__stories__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"__AUTO_GENERATED__": [
"To update the configuration edit the following field.",
"`package.json > @remirror > tsconfigs > '__stories__'`",
"",
"Then run: `pnpm -w generate:ts`"
],
"extends": "../../../support/tsconfig.base.json",
"compilerOptions": {
"types": [],
"declaration": false,
"noEmit": true,
"skipLibCheck": true,
"importsNotUsedAsValues": "remove",
"paths": {
"react": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react/index.d.ts"
],
"react/jsx-dev-runtime": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react/jsx-dev-runtime.d.ts"
],
"react/jsx-runtime": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react/jsx-runtime.d.ts"
],
"react-dom": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react-dom/index.d.ts"
],
"reakit": [
"../../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/reakit/ts/index.d.ts"
],
"@remirror/react": ["../../remirror__react/src/index.ts"],
"@storybook/react": [
"../../../node_modules/.pnpm/@[email protected]_dfad392d5450b8683a621f3ec486af19/node_modules/@storybook/react/types-6-0.d.ts"
],
"@remirror/dev": ["../../remirror__dev/src/index.ts"]
}
},
"include": ["./"],
"references": [
{
"path": "../../testing/src"
},
{
"path": "../../remirror/src"
},
{
"path": "../../remirror__core/src"
},
{
"path": "../../remirror__messages/src"
}
]
}
38 changes: 38 additions & 0 deletions packages/remirror__extension-italic/__stories__/italic.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'remirror/styles/all.css';
import './styles.css';

import { ItalicExtension } from 'remirror/extensions';
import { cx, htmlToProsemirrorNode } from '@remirror/core';
import { ProsemirrorDevTools } from '@remirror/dev';
import { Remirror, ThemeProvider, useActive, useCommands, useRemirror } from '@remirror/react';

export default { title: 'Extensions / Italic' };

const extensions = () => [new ItalicExtension()];

const ItalicButton = () => {
const commands = useCommands();
const active = useActive(true);
return (
<button onClick={() => commands.toggleItalic()} className={cx(active.italic() && 'active')}>
Italic
</button>
);
};

export const Basic = (): JSX.Element => {
const { manager, state, onChange } = useRemirror({
extensions: extensions,
content: '<p>Text in <i>italic</i></p>',
stringHandler: htmlToProsemirrorNode,
});

return (
<ThemeProvider>
<Remirror manager={manager} autoFocus onChange={onChange} state={state} autoRender='end'>
<ItalicButton />
<ProsemirrorDevTools />
</Remirror>
</ThemeProvider>
);
};
3 changes: 3 additions & 0 deletions packages/remirror__extension-italic/__stories__/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.active {
font-weight: bold;
}
53 changes: 53 additions & 0 deletions packages/remirror__extension-italic/__stories__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"__AUTO_GENERATED__": [
"To update the configuration edit the following field.",
"`package.json > @remirror > tsconfigs > '__stories__'`",
"",
"Then run: `pnpm -w generate:ts`"
],
"extends": "../../../support/tsconfig.base.json",
"compilerOptions": {
"types": [],
"declaration": false,
"noEmit": true,
"skipLibCheck": true,
"importsNotUsedAsValues": "remove",
"paths": {
"react": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react/index.d.ts"
],
"react/jsx-dev-runtime": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react/jsx-dev-runtime.d.ts"
],
"react/jsx-runtime": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react/jsx-runtime.d.ts"
],
"react-dom": [
"../../../node_modules/.pnpm/@[email protected]/node_modules/@types/react-dom/index.d.ts"
],
"reakit": [
"../../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/reakit/ts/index.d.ts"
],
"@remirror/react": ["../../remirror__react/src/index.ts"],
"@storybook/react": [
"../../../node_modules/.pnpm/@[email protected]_dfad392d5450b8683a621f3ec486af19/node_modules/@storybook/react/types-6-0.d.ts"
],
"@remirror/dev": ["../../remirror__dev/src/index.ts"]
}
},
"include": ["./"],
"references": [
{
"path": "../../testing/src"
},
{
"path": "../../remirror/src"
},
{
"path": "../../remirror__core/src"
},
{
"path": "../../remirror__messages/src"
}
]
}
38 changes: 38 additions & 0 deletions packages/remirror__extension-strike/__stories__/strike.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'remirror/styles/all.css';
import './styles.css';

import { StrikeExtension } from 'remirror/extensions';
import { cx, htmlToProsemirrorNode } from '@remirror/core';
import { ProsemirrorDevTools } from '@remirror/dev';
import { Remirror, ThemeProvider, useActive, useCommands, useRemirror } from '@remirror/react';

export default { title: 'Extensions / Strike' };

const extensions = () => [new StrikeExtension()];

const StrikeButton = () => {
const commands = useCommands();
const active = useActive(true);
return (
<button onClick={() => commands.toggleStrike()} className={cx(active.strike() && 'active')}>
Strike
</button>
);
};

export const Basic = (): JSX.Element => {
const { manager, state, onChange } = useRemirror({
extensions: extensions,
content: '<p>Text in <strike>strike</strike></p>',
stringHandler: htmlToProsemirrorNode,
});

return (
<ThemeProvider>
<Remirror manager={manager} autoFocus onChange={onChange} state={state} autoRender='end'>
<StrikeButton />
<ProsemirrorDevTools />
</Remirror>
</ThemeProvider>
);
};
3 changes: 3 additions & 0 deletions packages/remirror__extension-strike/__stories__/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.active {
font-weight: bold;
}
Loading

0 comments on commit 453a2d1

Please sign in to comment.