-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tables): apply table columns sizes when
editable=false
(#1948)
* fix(tables): apply table columns sizes when editable=false. Fixes #1937 * feat(doc): add helper to determine if doc node content is default
- Loading branch information
Showing
10 changed files
with
214 additions
and
4 deletions.
There are no files selected for viewing
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,6 @@ | ||
--- | ||
'@remirror/extension-doc': minor | ||
'@remirror/core-utils': patch | ||
--- | ||
|
||
Expose a helper for detecting doc changes from the default |
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,5 @@ | ||
--- | ||
'@remirror/extension-tables': patch | ||
--- | ||
|
||
Apply table columns sizes when view not is editable. Fixes #1937 |
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
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
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
39 changes: 39 additions & 0 deletions
39
packages/storybook-react/stories/extension-tables/not-editable.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,39 @@ | ||
import React from 'react'; | ||
import { TableExtension } from 'remirror/extensions'; | ||
import { EditorComponent, Remirror, ThemeProvider, useRemirror } from '@remirror/react'; | ||
|
||
const content = ` | ||
<table> | ||
<tr> | ||
<td data-colwidth="113"><p>This</p></td> | ||
<td data-colwidth="162"><p>editor</p></td> | ||
<td><p>is non editable</p></td> | ||
</tr> | ||
<tr> | ||
<td data-colwidth="113"><p>But</p></td> | ||
<td data-colwidth="162"><p>table</p></td> | ||
<td><p>columns widths are still applied</p></td> | ||
</tr> | ||
<tr> | ||
<td data-colwidth="113"><p></p></td> | ||
<td data-colwidth="162"><p></p></td> | ||
<td><p></p></td> | ||
</tr> | ||
</table> | ||
`; | ||
|
||
const NotEditable = (): JSX.Element => { | ||
const { manager, state } = useRemirror({ extensions, stringHandler: 'html', content }); | ||
|
||
return ( | ||
<ThemeProvider> | ||
<Remirror manager={manager} initialContent={state} editable={false}> | ||
<EditorComponent /> | ||
</Remirror> | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
const extensions = () => [new TableExtension()]; | ||
|
||
export default NotEditable; |
3 changes: 2 additions & 1 deletion
3
packages/storybook-react/stories/extension-tables/table.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Basic from './basic'; | ||
import NotEditable from './not-editable'; | ||
|
||
export { Basic }; | ||
export { Basic, NotEditable }; | ||
export default { title: 'Extensions / Tables (simple)' }; |
30 changes: 30 additions & 0 deletions
30
website/extension-examples/extension-tables/not-editable.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,30 @@ | ||
/** | ||
* THIS FILE IS AUTO GENERATED! | ||
* | ||
* Run `pnpm -w generate:website-examples` to regenerate this file. | ||
*/ | ||
|
||
// @ts-nocheck | ||
|
||
import React from 'react'; | ||
import CodeBlock from '@theme/CodeBlock'; | ||
import BrowserOnly from '@docusaurus/BrowserOnly'; | ||
import ComponentSource from '!!raw-loader!../../../packages/storybook-react/stories/extension-tables/not-editable.tsx'; | ||
|
||
import { StoryExample } from '../../src/components/story-example-component'; | ||
|
||
const ExampleComponent = (): JSX.Element => { | ||
const story = ( | ||
<BrowserOnly> | ||
{() => { | ||
const ComponentStory = require('../../../packages/storybook-react/stories/extension-tables/not-editable').default | ||
return <ComponentStory/> | ||
}} | ||
</BrowserOnly> | ||
); | ||
const source = <CodeBlock className='language-tsx'>{ComponentSource}</CodeBlock>; | ||
|
||
return <StoryExample story={story} source={source} />; | ||
}; | ||
|
||
export default ExampleComponent; |
8bd49f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://remirror.io as production
🚀 Deployed on https://6380e0431f56593010878a26--remirror.netlify.app