Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Branch] EuiMarkdownEditor #3522

Merged
merged 58 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f620292
WIP: Add markdown_editor component
i-a-n Dec 5, 2019
edd7816
WIP: commit auto-added i18n tokens
i-a-n Dec 5, 2019
f1a2cab
Adding button toggle for previewing
miukimiu Feb 5, 2020
37e1f23
Adding toolbar component
miukimiu Feb 10, 2020
e489f11
Adding file picker initial structure
miukimiu Feb 10, 2020
cf99ece
Adding text area component
miukimiu Feb 10, 2020
7568dfb
Buttons order
miukimiu Feb 11, 2020
7b6c69e
Moving markdown editor to docs form section
miukimiu Feb 12, 2020
e5e5e1a
Improving file picker
miukimiu Feb 13, 2020
a1cc078
Merge remote-tracking branch 'upstream/master' into markdown-editor
miukimiu Feb 14, 2020
ab7833b
Adding dropZone component and preview styles
miukimiu Feb 17, 2020
3b30207
Fixing height issue while resizing textarea
miukimiu Feb 17, 2020
0b28523
Small UI fix
miukimiu Feb 18, 2020
fb284ce
Improving markdown example
miukimiu Feb 18, 2020
e94b213
Merge remote-tracking branch 'upstream/master' into markdown-editor
snide Mar 18, 2020
3831407
remove showdown, since it wasn't being used
snide Mar 19, 2020
2f95bbc
Adding code highlight
miukimiu Mar 19, 2020
76a6962
Merge branch 'markdown-editor' of https://github.com/miukimiu/eui int…
miukimiu Mar 19, 2020
7583186
Better coding highlight
miukimiu Mar 19, 2020
9acf563
Merge remote-tracking branch 'upstream/master' into markdown-editor
miukimiu Mar 19, 2020
8aa5b7f
Replacing UglifyJsPlugin with TerserPlugin
miukimiu Mar 19, 2020
b877378
Adding button enter key and buttons tooltips
miukimiu Mar 20, 2020
71c34dc
Merge remote-tracking branch 'upstream/master' into markdown-editor
miukimiu Mar 20, 2020
d1b9223
More code highlight fixes
miukimiu Mar 20, 2020
2fd8a6d
Merge remote-tracking branch 'upstream/master' into markdown-editor
miukimiu Apr 8, 2020
57ed734
Merge branch 'master' into markdown-editor
chandlerprall Apr 28, 2020
c652d1c
Markdown editor plugins (#3457)
chandlerprall May 12, 2020
40f9642
[markdown] chart & tooltip plugins (#3479)
chandlerprall May 16, 2020
2d468c3
[Markdown] Checkbox plugin (#3493)
chandlerprall May 21, 2020
212bc8c
Merge branch 'master' into markdown-editor
chandlerprall May 25, 2020
df423d0
Merge branch 'markdown-editor' of https://github.com/miukimiu/eui int…
miukimiu May 27, 2020
75441e0
Merge remote-tracking branch 'upstream/markdown-editor' into markdown…
miukimiu May 27, 2020
512914f
[EuiMarkdownEditor] Improve markdown editor font (#3525)
miukimiu May 29, 2020
d0bf6ac
Re-enable default markdown list parsing (#3531)
chandlerprall Jun 1, 2020
dc8fee5
Enable undo/redo for markdown editor, apart from firefox (#3582)
chandlerprall Jun 15, 2020
a35fc03
Added AST & info/fail message reporting to application; added info me…
chandlerprall Jun 16, 2020
652a607
Add an imperative ref to EuiMarkdownEditor (#3622)
chandlerprall Jun 18, 2020
eb1e1ff
Merge branch 'master' into feature/markdown-editor
chandlerprall Jun 18, 2020
136f5b0
eslint errors
chandlerprall Jun 18, 2020
59c623d
Add a markdown help modal, move tooltip & checkbox plugins into src (…
chandlerprall Jul 1, 2020
2873e60
[EuiMarkdownEditor] Improving markdown format styles (#3534)
miukimiu Jul 3, 2020
779df96
[EuiMarkdownEditor] Better styles and class names (#3697)
miukimiu Jul 7, 2020
4710782
Add types to markdown editor (#3703)
chandlerprall Jul 8, 2020
5f44686
Merge remote-tracking branch 'upstream/master' into feature/markdown-…
miukimiu Jul 13, 2020
9e4b8a2
Merge remote-tracking branch 'upstream/master' into feature/markdown-…
miukimiu Jul 14, 2020
309bf7a
Adding missing types and dependency
miukimiu Jul 14, 2020
942595c
Fixing firefox text area margin (#3802)
miukimiu Jul 28, 2020
a520c68
Markdown Format / Editor documentation + features (#3696)
snide Jul 28, 2020
b61c2e4
Merge branch 'master' into feature/markdown-editor
chandlerprall Jul 28, 2020
b84f0dd
[Markdown editor] drag and drop api, functionality (#3748)
chandlerprall Jul 29, 2020
7f73c82
Feature/markdown editor cleanup (#3830)
chandlerprall Jul 30, 2020
b111e01
Prevent markdown plugin extensions from interacting with each other (…
chandlerprall Jul 31, 2020
252467b
Simplify the markdown editor's plugin API (#3843)
chandlerprall Aug 4, 2020
fb65ab3
Add license info around markdown tag processing; Support block-level …
chandlerprall Aug 10, 2020
0cf3b90
Merge branch 'master' into feature/markdown-editor
chandlerprall Aug 11, 2020
004fb4a
changelog
chandlerprall Aug 11, 2020
dead485
Improved, and proper, types for the markdown editor's usage in downst…
chandlerprall Aug 12, 2020
d7c15bf
Fixes some ARIA issues in EuiMarkdownEditor (#3899)
chandlerprall Aug 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
"number-leading-zero": "never",
"color-hex-case": "upper"
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Update `createTheme` to apply latest changes to elastic charts `Theme`. ([#3792](https://github.com/elastic/eui/pull/3792))
- Added icons for `appSearchApp` and `workplaceSearchApp` to `EuiIcon` ([#3859](https://github.com/elastic/eui/pull/3859))
- Added `unlink` glyph to `EuiIcon` ([#3869](https://github.com/elastic/eui/pull/3869))
- Added `EuiMarkdownEditor` and `EuiMarkdownFormat` components ([#3522](https://github.com/elastic/eui/pull/3522))

**Bug fixes**

Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@types/react-input-autosize": "^2.0.2",
"@types/react-virtualized-auto-sizer": "^1.0.0",
"@types/react-window": "^1.8.1",
"@types/vfile-message": "^2.0.0",
"chroma-js": "^2.0.4",
"classnames": "^2.2.5",
"highlight.js": "^9.12.0",
Expand All @@ -66,15 +67,25 @@
"prop-types": "^15.6.0",
"react-ace": "^7.0.5",
"react-beautiful-dnd": "^13.0.0",
"react-dropzone": "^10.2.1",
"react-focus-on": "^3.4.1",
"react-input-autosize": "^2.2.2",
"react-is": "~16.3.0",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "^1.8.5",
"rehype-raw": "^4.0.1",
"rehype-react": "^6.0.0",
"rehype-stringify": "^6.0.1",
"remark-emoji": "^2.1.0",
"remark-highlight.js": "^5.2.0",
"remark-parse": "^7.0.2",
"remark-rehype": "^7.0.0",
"resize-observer-polyfill": "^1.5.0",
"tabbable": "^3.0.0",
"text-diff": "^1.0.1",
"uuid": "^3.1.0"
"unified": "^8.4.2",
"uuid": "^3.1.0",
"vfile": "^4.1.1"
},
"devDependencies": {
"@babel/cli": "^7.8.3",
Expand Down Expand Up @@ -174,6 +185,7 @@
"postcss-loader": "^2.0.8",
"pre-commit": "^1.2.2",
"prettier": "^1.19.1",
"prettier-stylelint": "^0.4.2",
"prompt": "^1.0.0",
"prop-types": "^15.6.0",
"puppeteer": "^2.0.0",
Expand All @@ -198,6 +210,7 @@
"shelljs": "^0.8.1",
"start-server-and-test": "^1.1.4",
"style-loader": "^0.19.0",
"terser-webpack-plugin": "^2.3.5",
"typescript": "3.7.2",
"uglifyjs-webpack-plugin": "^2.0.1",
"url-loader": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/babel/fetch-i18n-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const files = glob.sync(
'**/*.@(js|ts|tsx)',
{ cwd: srcDir, realpath: true },
).filter(filepath => {
if (filepath.endsWith('index.d.ts')) return false;
if (filepath.endsWith('.d.ts')) return false;
if (filepath.endsWith('test.ts')) return false;
if (filepath.endsWith('test.tsx')) return false;
if (filepath.endsWith('test.js')) return false;
Expand Down
8 changes: 8 additions & 0 deletions scripts/babel/proptypes-from-ts-props/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function resolveArrayTypeToPropTypes(node, state) {
* - Arrays
* - MouseEventHandler is interpretted as functions
* - ExclusiveUnion custom type
* - OneOf custom type
* - defined types/interfaces (found during initial program body parsing)
* Returns `null` for unresolvable types
* @param node
Expand Down Expand Up @@ -342,6 +343,13 @@ function resolveIdentifierToPropTypes(node, state) {
return propTypes;
}

if (identifier.name === 'OneOf') {
// the second type parameter is ignorable as it is a subset of the first,
// and the OneOf operation cannot be well-described by proptypes
const [sourceTypes] = node.typeParameters.params;
return getPropTypesForNode(sourceTypes, true, state);
}

// Lookup this identifier from types/interfaces defined in code
const identifierDefinition = typeDefinitions[identifier.name];

Expand Down
18 changes: 16 additions & 2 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ import { ListGroupExample } from './views/list_group/list_group_example';

import { LoadingExample } from './views/loading/loading_example';

import { MarkdownEditorExample } from './views/markdown_editor/mardown_editor_example';

import { MarkdownFormatExample } from './views/markdown_editor/mardown_format_example';

import { MarkdownPluginExample } from './views/markdown_editor/markdown_plugin_example';

import { ModalExample } from './views/modal/modal_example';

import { MutationObserverExample } from './views/mutation_observer/mutation_observer_example';
Expand Down Expand Up @@ -377,7 +383,6 @@ const navigation = [
BadgeExample,
CallOutExample,
CardExample,
CodeExample,
CommentListExample,
DescriptionListExample,
DragAndDropExample,
Expand Down Expand Up @@ -407,7 +412,6 @@ const navigation = [
SuperSelectExample,
ComboBoxExample,
ColorPickerExample,
CodeEditorExample,
DatePickerExample,
ExpressionExample,
FilterGroupExample,
Expand All @@ -418,6 +422,16 @@ const navigation = [
SuperDatePickerExample,
].map(example => createExample(example)),
},
{
name: 'Editors & syntax',
items: [
MarkdownFormatExample,
MarkdownEditorExample,
MarkdownPluginExample,
CodeEditorExample,
CodeExample,
].map(example => createExample(example)),
},
{
name: 'Elastic Charts',
items: [
Expand Down
99 changes: 99 additions & 0 deletions src-docs/src/views/markdown_editor/mardown_editor_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import {
EuiMarkdownEditor,
EuiText,
EuiSpacer,
EuiCode,
} from '../../../../src/components';

import { Link } from 'react-router-dom';

import MarkdownEditor from './markdown_editor';
const markdownEditorSource = require('!!raw-loader!./markdown_editor');
const markdownEditorHtml = renderToHtml(MarkdownEditor);

import MarkdownEditorErrors from './markdown_editor_errors';
const markdownEditorErrorsSource = require('!!raw-loader!./markdown_editor_errors');
const markdownEditorErrorsHtml = renderToHtml(MarkdownEditorErrors);

export const MarkdownEditorExample = {
title: 'Markdown editor',
beta: true,
isNew: true,
intro: (
<Fragment>
<EuiText>
<p>
<strong>EuiMarkdownEditor</strong> provides a markdown authoring
experience for the user. The component consists of a toolbar, text
area, and a drag-and-drop zone to accept files (if configured to do
so). There are two modes: a textarea that keeps track of cursor
position, and a rendered preview mode that is powered by{' '}
<strong>
<Link to="/editors-syntax/markdown-format/">EuiMarkdownFormat</Link>
</strong>
. State is maintained between the two and it is possible to pass
changes from the preview area to the textarea and vice versa.
</p>
</EuiText>
<EuiSpacer size="xxl" />
</Fragment>
),
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: markdownEditorSource,
},
{
type: GuideSectionTypes.HTML,
code: markdownEditorHtml,
},
],
title: 'Base editor',
text: (
<p>
The base editor can render basic markdown along with some built-in
plugins.
</p>
),
props: {
EuiMarkdownEditor,
},
demo: <MarkdownEditor />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: markdownEditorErrorsSource,
},
{
type: GuideSectionTypes.HTML,
code: markdownEditorErrorsHtml,
},
],
title: 'Error handling and feedback',
text: (
<p>
The <EuiCode>errors</EuiCode> prop allows you to pass an array of
errors if syntax is malformed. The below example starts with an
incomplete tooltip tag, showing this error message by default. These
errors are meant to be ephemeral and part of the editing experience.
They should not be a substitute for{' '}
<Link to="/forms/form-validation">form validation</Link>.
</p>
),
props: {
EuiMarkdownEditor,
},
demo: <MarkdownEditorErrors />,
},
],
};
96 changes: 96 additions & 0 deletions src-docs/src/views/markdown_editor/mardown_format_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import {
EuiMarkdownFormat,
EuiText,
EuiSpacer,
} from '../../../../src/components';

import { Link } from 'react-router-dom';

import MarkdownFormat from './markdown_format';
const markdownFormatSource = require('!!raw-loader!./markdown_format');
const markdownFormatHtml = renderToHtml(MarkdownFormat);

import MarkdownFormatSink from './markdown_format_sink';
const markdownFormatSinkSource = require('!!raw-loader!./markdown_format_sink');
const markdownFormatSinkHtml = renderToHtml(MarkdownFormatSink);

export const MarkdownFormatExample = {
title: 'Markdown format',
beta: true,
isNew: true,
intro: (
<Fragment>
<EuiText>
<p>
<strong>EuiMarkdownFormat</strong> is a read-only way to render
markdown-style content in a page. It is a peer component to{' '}
<strong>
<Link to="/editors-syntax/markdown-editor/">EuiMarkdownEditor</Link>
</strong>{' '}
and has the ability to be modified by additional{' '}
<Link to="/editors-syntax/markdown-plugins">markdown plugins</Link>.
</p>
</EuiText>
<EuiSpacer size="xxl" />
</Fragment>
),
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: markdownFormatSource,
},
{
type: GuideSectionTypes.HTML,
code: markdownFormatHtml,
},
],
title: 'Built in plugins',
text: (
<p>
<strong>EuiMarkdownFormat</strong> is a wrapper that will render
Markdown provided. EuiMarkdownFormat uses{' '}
<Link to="https://github.com/remarkjs/remark)">Remark</Link> by
default. The translation layer automatically substitutes raw HTML
output with their EUI equivilant. This means anchor and code blocks
will become <strong>EuiLink</strong> and <strong>EuiCodeBlock</strong>{' '}
components respectively.
</p>
),
props: {
EuiMarkdownFormat,
},
demo: <MarkdownFormat />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: markdownFormatSinkSource,
},
{
type: GuideSectionTypes.HTML,
code: markdownFormatSinkHtml,
},
],
title: 'Kitchen sink',
text: (
<p>
This example shows of all the styling and markup possibilities. It is
mostly used for testing.
</p>
),
props: {
EuiMarkdownFormat,
},
demo: <MarkdownFormatSink />,
},
],
};
Loading