forked from remirror/remirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: formatting wasn't reflected in style attribute (remirror#1071)
The SchemaAttributesObject didn't have access to the current style. This meant that only one of the formatting attributes was reflected in the style. Solution provided by @whawker Fixes remirror#1063
- Loading branch information
1 parent
764841f
commit 7208b9f
Showing
4 changed files
with
132 additions
and
47 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/remirror__extension-node-formatting/__stories__/node-formatting.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'remirror/styles/all.css'; | ||
|
||
import React from 'react'; | ||
import { NodeFormattingExtension } from 'remirror/extensions'; | ||
import { htmlToProsemirrorNode } from '@remirror/core'; | ||
import { Remirror, ThemeProvider, useCommands, useRemirror } from '@remirror/react'; | ||
|
||
export default { title: 'Extensions / Node Formatting' }; | ||
|
||
export const Basic: React.FC = () => { | ||
const { manager, state, onChange } = useRemirror({ | ||
extensions: () => [new NodeFormattingExtension()], | ||
content: '<p>Click buttons to change alignment, indent,<br> and line height</p>', | ||
stringHandler: htmlToProsemirrorNode, | ||
}); | ||
|
||
return ( | ||
<ThemeProvider> | ||
<Remirror manager={manager} autoFocus onChange={onChange} state={state} autoRender='end'> | ||
<AlignButtons /> | ||
| ||
<IndentButtons /> | ||
| ||
<LineHeightButtons /> | ||
</Remirror> | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
const AlignButtons = () => { | ||
const commands = useCommands(); | ||
return ( | ||
<> | ||
<button onClick={() => commands.leftAlign()}>Left</button> | ||
<button onClick={() => commands.centerAlign()}>Center</button> | ||
<button onClick={() => commands.rightAlign()}>Right</button> | ||
</> | ||
); | ||
}; | ||
|
||
const IndentButtons = () => { | ||
const commands = useCommands(); | ||
return ( | ||
<> | ||
<button onClick={() => commands.decreaseIndent()}><<</button> | ||
<button onClick={() => commands.increaseIndent()}>>></button> | ||
</> | ||
); | ||
}; | ||
|
||
const LineHeightButtons = () => { | ||
const commands = useCommands(); | ||
return ( | ||
<> | ||
<button onClick={() => commands.setLineHeight(1)}>Narrow</button> | ||
<button onClick={() => commands.setLineHeight(2)}>Wide</button> | ||
</> | ||
); | ||
}; |
53 changes: 53 additions & 0 deletions
53
packages/remirror__extension-node-formatting/__stories__/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]_5adcf14f16f83a2edb2923710ccaaea0/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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters