-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41477d6
commit 568d46d
Showing
70 changed files
with
1,389 additions
and
574 deletions.
There are no files selected for viewing
12 changes: 10 additions & 2 deletions
12
...tputFormats/Angular/app/app.component.css → ...downSupport/Angular/app/app.component.css
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
23 changes: 23 additions & 0 deletions
23
apps/demos/Demos/HtmlEditor/MarkdownSupport/Angular/app/app.component.html
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,23 @@ | ||
<dx-html-editor [height]="300" [converter]="converter" [(value)]="valueContent"> | ||
<dxo-toolbar> | ||
<dxi-item name="undo"></dxi-item> | ||
<dxi-item name="redo"></dxi-item> | ||
<dxi-item name="separator"></dxi-item> | ||
<dxi-item name="bold"></dxi-item> | ||
<dxi-item name="italic"></dxi-item> | ||
<dxi-item name="separator"></dxi-item> | ||
<dxi-item | ||
name="header" | ||
[acceptedValues]="[false, 1, 2, 3, 4, 5]" | ||
[options]="{ inputAttr: { 'aria-label': 'Header' } }" | ||
></dxi-item> | ||
<dxi-item name="separator"></dxi-item> | ||
<dxi-item name="orderedList"></dxi-item> | ||
<dxi-item name="bulletList"></dxi-item> | ||
</dxo-toolbar> | ||
</dx-html-editor> | ||
|
||
<div class="options"> | ||
<div class="value-title"> Markdown Preview </div> | ||
<div class="value-content" tabindex="0">{{ valueContent }}</div> | ||
</div> |
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
21 changes: 21 additions & 0 deletions
21
apps/demos/Demos/HtmlEditor/MarkdownSupport/Angular/app/app.service.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
const markup = `## ![HtmlEditor](../../../../images/widgets/HtmlEditor.svg) Formatted Text Editor (HTML Editor) | ||
Lists: | ||
1. Use numbers followed by a period for an ordered list. | ||
2. Use a single asterisk for a bullet list. | ||
Formats: | ||
* Enclose a word in single asterisks for *italic*. | ||
* Enclose a word in double asterisks for **bold**. | ||
`; | ||
|
||
@Injectable() | ||
export class Service { | ||
getMarkup(): string { | ||
return markup; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import HtmlEditor, { Toolbar, Item } from 'devextreme-react/html-editor'; | ||
import { markup } from './data.ts'; | ||
|
||
const headerValues = [false, 1, 2, 3, 4, 5]; | ||
const headerOptions = { | ||
inputAttr: { | ||
'aria-label': 'Header', | ||
}, | ||
}; | ||
const converter = { | ||
toHtml(value) { | ||
// @ts-expect-error | ||
const result = unified() | ||
// @ts-expect-error | ||
.use(remarkParse) | ||
// @ts-expect-error | ||
.use(remarkRehype) | ||
// @ts-expect-error | ||
.use(rehypeStringify) | ||
.processSync(value) | ||
.toString(); | ||
|
||
return result; | ||
}, | ||
fromHtml(value) { | ||
// @ts-expect-error | ||
const result = unified() | ||
// @ts-expect-error | ||
.use(rehypeParse) | ||
// @ts-expect-error | ||
.use(rehypeRemark) | ||
// @ts-expect-error | ||
.use(remarkStringify) | ||
.processSync(value) | ||
.toString(); | ||
|
||
return result; | ||
}, | ||
}; | ||
|
||
export default function App() { | ||
const [valueContent, setValueContent] = useState(markup); | ||
|
||
const valueChanged = useCallback((e: { value?: string; }) => { | ||
setValueContent(e.value); | ||
}, [setValueContent]); | ||
|
||
return ( | ||
<div className="widget-container"> | ||
<HtmlEditor | ||
converter={converter} | ||
height={300} | ||
defaultValue={valueContent} | ||
onValueChanged={valueChanged} | ||
> | ||
<Toolbar> | ||
<Item name="undo" /> | ||
<Item name="redo" /> | ||
<Item name="separator" /> | ||
<Item name="bold" /> | ||
<Item name="italic" /> | ||
<Item name="separator" /> | ||
<Item name="header" acceptedValues={headerValues} options={headerOptions} /> | ||
<Item name="separator" /> | ||
<Item name="orderedList" /> | ||
<Item name="bulletList" /> | ||
</Toolbar> | ||
</HtmlEditor> | ||
|
||
<div className="options"> | ||
<div className="value-title"> | ||
Markdown Preview | ||
</div> | ||
<div className="value-content" tabIndex={0}> | ||
{valueContent} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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,12 @@ | ||
export const markup = `## ![HtmlEditor](../../../../images/widgets/HtmlEditor.svg) Formatted Text Editor (HTML Editor) | ||
Lists: | ||
1. Use numbers followed by a period for an ordered list. | ||
2. Use a single asterisk for a bullet list. | ||
Formats: | ||
* Enclose a word in single asterisks for *italic*. | ||
* Enclose a word in double asterisks for **bold**. | ||
`; |
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.
12 changes: 10 additions & 2 deletions
12
...mlEditor/OutputFormats/ReactJs/styles.css → ...mlEditor/MarkdownSupport/React/styles.css
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
Oops, something went wrong.