-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port demo site 1: Move Content Model pane files (#2462)
- Loading branch information
1 parent
a67d54c
commit 2d9d5f0
Showing
90 changed files
with
147 additions
and
149 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
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
2 changes: 1 addition & 1 deletion
2
demo/scripts/controls/sidePane/contentModel/ContentModelPane.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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions
16
...mat/formatPart/WordBreakFormatRenderer.ts → ...mat/formatPart/WordBreakFormatRenderer.ts
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,8 +1,8 @@ | ||
import { createTextFormatRenderer } from '../utils/createTextFormatRenderer'; | ||
import { WordBreakFormat } from 'roosterjs-content-model-types'; | ||
|
||
export const WordBreakFormatRenderer = createTextFormatRenderer<WordBreakFormat>( | ||
'Word break', | ||
format => format.wordBreak, | ||
(format, value) => (format.wordBreak = value) | ||
); | ||
import { createTextFormatRenderer } from '../utils/createTextFormatRenderer'; | ||
import { WordBreakFormat } from 'roosterjs-content-model-types'; | ||
|
||
export const WordBreakFormatRenderer = createTextFormatRenderer<WordBreakFormat>( | ||
'Word break', | ||
format => format.wordBreak, | ||
(format, value) => (format.wordBreak = value) | ||
); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
262 changes: 131 additions & 131 deletions
262
...nents/model/ContentModelTableCellView.tsx → ...nents/model/ContentModelTableCellView.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,131 +1,131 @@ | ||
import * as React from 'react'; | ||
import { BackgroundColorFormatRenderer } from '../format/formatPart/BackgroundColorFormatRenderer'; | ||
import { BlockGroupContentView } from './BlockGroupContentView'; | ||
import { BorderBoxFormatRenderer } from '../format/formatPart/BorderBoxFormatRenderer'; | ||
import { BorderFormatRenderers } from '../format/formatPart/BorderFormatRenderers'; | ||
import { ContentModelTableCell, ContentModelTableCellFormat } from 'roosterjs-content-model-types'; | ||
import { ContentModelView } from '../ContentModelView'; | ||
import { DirectionFormatRenderer } from '../format/formatPart/DirectionFormatRenderer'; | ||
import { FormatRenderer } from '../format/utils/FormatRenderer'; | ||
import { FormatView } from '../format/FormatView'; | ||
import { hasSelectionInBlockGroup, updateTableCellMetadata } from 'roosterjs-content-model-core'; | ||
import { HtmlAlignFormatRenderer } from '../format/formatPart/HtmlAlignFormatRenderer'; | ||
import { MetadataView } from '../format/MetadataView'; | ||
import { PaddingFormatRenderer } from '../format/formatPart/PaddingFormatRenderer'; | ||
import { SizeFormatRenderers } from '../format/formatPart/SizeFormatRenderers'; | ||
import { TableCellMetadataFormatRenders } from '../format/formatPart/TableCellMetadataFormatRenders'; | ||
import { TextAlignFormatRenderer } from '../format/formatPart/TextAlignFormatRenderer'; | ||
import { TextColorFormatRenderer } from '../format/formatPart/TextColorFormatRenderer'; | ||
import { useProperty } from '../../hooks/useProperty'; | ||
import { VerticalAlignFormatRenderer } from '../format/formatPart/VerticalAlignFormatRenderer'; | ||
import { WordBreakFormatRenderer } from '../format/formatPart/WordBreakFormatRenderer'; | ||
|
||
const styles = require('./ContentModelTableCellView.scss'); | ||
|
||
const TableCellFormatRenderers: FormatRenderer<ContentModelTableCellFormat>[] = [ | ||
...BorderFormatRenderers, | ||
DirectionFormatRenderer, | ||
TextAlignFormatRenderer, | ||
HtmlAlignFormatRenderer, | ||
BorderBoxFormatRenderer, | ||
BackgroundColorFormatRenderer, | ||
PaddingFormatRenderer, | ||
VerticalAlignFormatRenderer, | ||
WordBreakFormatRenderer, | ||
TextColorFormatRenderer, | ||
...SizeFormatRenderers, | ||
]; | ||
|
||
export function ContentModelTableCellView(props: { cell: ContentModelTableCell }) { | ||
const { cell } = props; | ||
const checkboxHeader = React.useRef<HTMLInputElement>(null); | ||
const checkboxSpanLeft = React.useRef<HTMLInputElement>(null); | ||
const checkboxSpanAbove = React.useRef<HTMLInputElement>(null); | ||
const [isHeader, setIsHeader] = useProperty(cell.isHeader); | ||
const [spanLeft, setSpanLeft] = useProperty(cell.spanLeft); | ||
const [spanAbove, setSpanAbove] = useProperty(cell.spanAbove); | ||
|
||
const onHeaderChanged = React.useCallback(() => { | ||
const value = checkboxHeader.current.checked; | ||
cell.isHeader = value; | ||
setIsHeader(value); | ||
}, [cell, setIsHeader]); | ||
|
||
const onSpanLeftChanged = React.useCallback(() => { | ||
const value = checkboxSpanLeft.current.checked; | ||
cell.spanLeft = value; | ||
setSpanLeft(value); | ||
}, [cell, setSpanLeft]); | ||
|
||
const onSpanAboveChanged = React.useCallback(() => { | ||
const value = checkboxSpanAbove.current.checked; | ||
cell.spanAbove = value; | ||
setSpanAbove(value); | ||
}, [cell, setSpanAbove]); | ||
|
||
const getContent = React.useCallback(() => { | ||
return ( | ||
<> | ||
<div> | ||
<input | ||
type="checkbox" | ||
checked={isHeader} | ||
ref={checkboxHeader} | ||
onChange={onHeaderChanged} | ||
/> | ||
Header | ||
</div> | ||
<div> | ||
<input | ||
type="checkbox" | ||
checked={spanLeft} | ||
ref={checkboxSpanLeft} | ||
onChange={onSpanLeftChanged} | ||
/> | ||
Span Left | ||
</div> | ||
<div> | ||
<input | ||
type="checkbox" | ||
checked={spanAbove} | ||
ref={checkboxSpanAbove} | ||
onChange={onSpanAboveChanged} | ||
/> | ||
Span Above | ||
</div> | ||
<BlockGroupContentView group={cell} /> | ||
</> | ||
); | ||
}, [cell, isHeader, spanAbove, spanLeft]); | ||
|
||
const getMetadata = React.useCallback(() => { | ||
return ( | ||
<MetadataView | ||
model={cell} | ||
renderers={TableCellMetadataFormatRenders} | ||
updater={updateTableCellMetadata} | ||
/> | ||
); | ||
}, [cell]); | ||
|
||
const getFormat = React.useCallback(() => { | ||
return <FormatView format={cell.format} renderers={TableCellFormatRenderers} />; | ||
}, [cell.format]); | ||
|
||
const subTitle = | ||
cell.spanAbove && cell.spanLeft ? '↖' : cell.spanLeft ? '←' : cell.spanAbove ? '↑' : ''; | ||
|
||
return ( | ||
<ContentModelView | ||
title={isHeader ? 'TableCellHeader' : 'TableCell'} | ||
subTitle={subTitle} | ||
className={styles.modelTableCell} | ||
hasSelection={hasSelectionInBlockGroup(cell)} | ||
isSelected={cell.isSelected} | ||
jsonSource={cell} | ||
getContent={getContent} | ||
getFormat={getFormat} | ||
getMetadata={getMetadata} | ||
/> | ||
); | ||
} | ||
import * as React from 'react'; | ||
import { BackgroundColorFormatRenderer } from '../format/formatPart/BackgroundColorFormatRenderer'; | ||
import { BlockGroupContentView } from './BlockGroupContentView'; | ||
import { BorderBoxFormatRenderer } from '../format/formatPart/BorderBoxFormatRenderer'; | ||
import { BorderFormatRenderers } from '../format/formatPart/BorderFormatRenderers'; | ||
import { ContentModelTableCell, ContentModelTableCellFormat } from 'roosterjs-content-model-types'; | ||
import { ContentModelView } from '../ContentModelView'; | ||
import { DirectionFormatRenderer } from '../format/formatPart/DirectionFormatRenderer'; | ||
import { FormatRenderer } from '../format/utils/FormatRenderer'; | ||
import { FormatView } from '../format/FormatView'; | ||
import { hasSelectionInBlockGroup, updateTableCellMetadata } from 'roosterjs-content-model-core'; | ||
import { HtmlAlignFormatRenderer } from '../format/formatPart/HtmlAlignFormatRenderer'; | ||
import { MetadataView } from '../format/MetadataView'; | ||
import { PaddingFormatRenderer } from '../format/formatPart/PaddingFormatRenderer'; | ||
import { SizeFormatRenderers } from '../format/formatPart/SizeFormatRenderers'; | ||
import { TableCellMetadataFormatRenders } from '../format/formatPart/TableCellMetadataFormatRenders'; | ||
import { TextAlignFormatRenderer } from '../format/formatPart/TextAlignFormatRenderer'; | ||
import { TextColorFormatRenderer } from '../format/formatPart/TextColorFormatRenderer'; | ||
import { useProperty } from '../../hooks/useProperty'; | ||
import { VerticalAlignFormatRenderer } from '../format/formatPart/VerticalAlignFormatRenderer'; | ||
import { WordBreakFormatRenderer } from '../format/formatPart/WordBreakFormatRenderer'; | ||
|
||
const styles = require('./ContentModelTableCellView.scss'); | ||
|
||
const TableCellFormatRenderers: FormatRenderer<ContentModelTableCellFormat>[] = [ | ||
...BorderFormatRenderers, | ||
DirectionFormatRenderer, | ||
TextAlignFormatRenderer, | ||
HtmlAlignFormatRenderer, | ||
BorderBoxFormatRenderer, | ||
BackgroundColorFormatRenderer, | ||
PaddingFormatRenderer, | ||
VerticalAlignFormatRenderer, | ||
WordBreakFormatRenderer, | ||
TextColorFormatRenderer, | ||
...SizeFormatRenderers, | ||
]; | ||
|
||
export function ContentModelTableCellView(props: { cell: ContentModelTableCell }) { | ||
const { cell } = props; | ||
const checkboxHeader = React.useRef<HTMLInputElement>(null); | ||
const checkboxSpanLeft = React.useRef<HTMLInputElement>(null); | ||
const checkboxSpanAbove = React.useRef<HTMLInputElement>(null); | ||
const [isHeader, setIsHeader] = useProperty(cell.isHeader); | ||
const [spanLeft, setSpanLeft] = useProperty(cell.spanLeft); | ||
const [spanAbove, setSpanAbove] = useProperty(cell.spanAbove); | ||
|
||
const onHeaderChanged = React.useCallback(() => { | ||
const value = checkboxHeader.current.checked; | ||
cell.isHeader = value; | ||
setIsHeader(value); | ||
}, [cell, setIsHeader]); | ||
|
||
const onSpanLeftChanged = React.useCallback(() => { | ||
const value = checkboxSpanLeft.current.checked; | ||
cell.spanLeft = value; | ||
setSpanLeft(value); | ||
}, [cell, setSpanLeft]); | ||
|
||
const onSpanAboveChanged = React.useCallback(() => { | ||
const value = checkboxSpanAbove.current.checked; | ||
cell.spanAbove = value; | ||
setSpanAbove(value); | ||
}, [cell, setSpanAbove]); | ||
|
||
const getContent = React.useCallback(() => { | ||
return ( | ||
<> | ||
<div> | ||
<input | ||
type="checkbox" | ||
checked={isHeader} | ||
ref={checkboxHeader} | ||
onChange={onHeaderChanged} | ||
/> | ||
Header | ||
</div> | ||
<div> | ||
<input | ||
type="checkbox" | ||
checked={spanLeft} | ||
ref={checkboxSpanLeft} | ||
onChange={onSpanLeftChanged} | ||
/> | ||
Span Left | ||
</div> | ||
<div> | ||
<input | ||
type="checkbox" | ||
checked={spanAbove} | ||
ref={checkboxSpanAbove} | ||
onChange={onSpanAboveChanged} | ||
/> | ||
Span Above | ||
</div> | ||
<BlockGroupContentView group={cell} /> | ||
</> | ||
); | ||
}, [cell, isHeader, spanAbove, spanLeft]); | ||
|
||
const getMetadata = React.useCallback(() => { | ||
return ( | ||
<MetadataView | ||
model={cell} | ||
renderers={TableCellMetadataFormatRenders} | ||
updater={updateTableCellMetadata} | ||
/> | ||
); | ||
}, [cell]); | ||
|
||
const getFormat = React.useCallback(() => { | ||
return <FormatView format={cell.format} renderers={TableCellFormatRenderers} />; | ||
}, [cell.format]); | ||
|
||
const subTitle = | ||
cell.spanAbove && cell.spanLeft ? '↖' : cell.spanLeft ? '←' : cell.spanAbove ? '↑' : ''; | ||
|
||
return ( | ||
<ContentModelView | ||
title={isHeader ? 'TableCellHeader' : 'TableCell'} | ||
subTitle={subTitle} | ||
className={styles.modelTableCell} | ||
hasSelection={hasSelectionInBlockGroup(cell)} | ||
isSelected={cell.isSelected} | ||
jsonSource={cell} | ||
getContent={getContent} | ||
getFormat={getFormat} | ||
getMetadata={getMetadata} | ||
/> | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.