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

[Shared UX] Markdown Component #142228

Merged
merged 80 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ecfab80
initial commit
rshen91 Sep 29, 2022
43a8c70
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Sep 29, 2022
1a9aa04
package updates
rshen91 Sep 29, 2022
340603b
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Sep 29, 2022
7b9adee
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 29, 2022
623926b
readonly markdown
rshen91 Sep 30, 2022
738f16d
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Sep 30, 2022
fd5bf5c
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 30, 2022
cff592e
refactor to include impl and types packages
rshen91 Oct 3, 2022
01a3cf6
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 3, 2022
45ca78f
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 3, 2022
095e315
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Oct 3, 2022
1feae32
update
rshen91 Oct 3, 2022
2658ba1
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 3, 2022
5868c56
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 3, 2022
c52f9c3
add render test
rshen91 Oct 3, 2022
5815a04
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 3, 2022
24df4e2
update
rshen91 Oct 4, 2022
bae0552
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 4, 2022
173c53b
Merge branch 'main' into markdown
rshen91 Oct 4, 2022
e347b0c
Merge branch 'main' into markdown
rshen91 Oct 4, 2022
08f6c0a
wip updating props and story mocks
rshen91 Oct 4, 2022
865dcab
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 4, 2022
c3ab0f3
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 4, 2022
449903a
update
rshen91 Oct 4, 2022
44e752b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 4, 2022
7dc10d5
update mocks
rshen91 Oct 5, 2022
8a85478
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 5, 2022
8397783
markdown types package
rshen91 Oct 5, 2022
43b5bee
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 5, 2022
690c9d5
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Oct 5, 2022
b9a4ef4
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 5, 2022
97f2d6c
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 5, 2022
d94d3d8
mdx error
rshen91 Oct 5, 2022
d79daef
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 5, 2022
d4f9d12
update
rshen91 Oct 5, 2022
c633a92
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 5, 2022
02cef63
add test for simple
rshen91 Oct 6, 2022
89a6827
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 6, 2022
5c72368
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 6, 2022
135e3c1
update documentation
rshen91 Oct 6, 2022
6764d76
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 6, 2022
c9dd7d3
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 6, 2022
c80ae95
add test
rshen91 Oct 6, 2022
5fb3263
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 6, 2022
49ce4e4
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 6, 2022
fa07389
Merge branch 'main' into markdown
rshen91 Oct 10, 2022
e4f7379
remove open in new tabs
rshen91 Oct 10, 2022
734229c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 10, 2022
8c0a4df
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 11, 2022
4a11a5d
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 11, 2022
e3f1f6a
update docs
rshen91 Oct 11, 2022
b3a68c5
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 11, 2022
82685e2
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 13, 2022
a9aea28
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 13, 2022
afabced
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 14, 2022
5bc2451
code review
rshen91 Oct 14, 2022
e4f1adc
fix tests
rshen91 Oct 14, 2022
4bc7e51
remove file
rshen91 Oct 14, 2022
ea928d2
Merge branch 'main' into markdown
rshen91 Oct 14, 2022
d79855c
update story
rshen91 Oct 17, 2022
8f14403
Merge remote-tracking branch 'upstream/main' into markdown
rshen91 Oct 17, 2022
961ef04
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 17, 2022
342ed7f
update
rshen91 Oct 17, 2022
a44f15a
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 17, 2022
bac996b
update docs
rshen91 Oct 17, 2022
4ac5528
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 17, 2022
9ed1c9a
code review
rshen91 Oct 18, 2022
d759c2f
Merge branch 'main' into markdown
rshen91 Oct 18, 2022
32ae70b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 18, 2022
66ed116
add openLinksInNewTab functionality from eui
rshen91 Oct 18, 2022
ef287b5
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 18, 2022
af3fcb9
show openLinksInNewTab in stories
rshen91 Oct 18, 2022
048a735
Merge branch 'main' into markdown
rshen91 Oct 18, 2022
1615ec0
add params to second story
rshen91 Oct 18, 2022
af82cf7
Merge remote-tracking branch 'origin/markdown' into markdown
rshen91 Oct 18, 2022
b5dfab1
Merge branch 'main' into markdown
rshen91 Oct 18, 2022
bb9ccf8
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 18, 2022
a3fa6a4
Update index.d.ts
rshen91 Oct 18, 2022
fbdd574
Merge branch 'main' into markdown
rshen91 Oct 18, 2022
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
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@ packages/shared-ux/card/no_data/types @elastic/shared-ux
packages/shared-ux/link/redirect_app/impl @elastic/shared-ux
packages/shared-ux/link/redirect_app/mocks @elastic/shared-ux
packages/shared-ux/link/redirect_app/types @elastic/shared-ux
packages/shared-ux/markdown/impl @elastic/shared-ux
packages/shared-ux/markdown/mocks @elastic/shared-ux
packages/shared-ux/markdown/types @elastic/shared-ux
packages/shared-ux/page/analytics_no_data/impl @elastic/shared-ux
packages/shared-ux/page/analytics_no_data/mocks @elastic/shared-ux
packages/shared-ux/page/analytics_no_data/types @elastic/shared-ux
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@
"@kbn/shared-ux-link-redirect-app": "link:bazel-bin/packages/shared-ux/link/redirect_app/impl",
"@kbn/shared-ux-link-redirect-app-mocks": "link:bazel-bin/packages/shared-ux/link/redirect_app/mocks",
"@kbn/shared-ux-link-redirect-app-types": "link:bazel-bin/packages/shared-ux/link/redirect_app/types",
"@kbn/shared-ux-markdown": "link:bazel-bin/packages/shared-ux/markdown/impl",
"@kbn/shared-ux-markdown-mocks": "link:bazel-bin/packages/shared-ux/markdown/mocks",
"@kbn/shared-ux-markdown-types": "link:bazel-bin/packages/shared-ux/markdown/types",
"@kbn/shared-ux-page-analytics-no-data": "link:bazel-bin/packages/shared-ux/page/analytics_no_data/impl",
"@kbn/shared-ux-page-analytics-no-data-mocks": "link:bazel-bin/packages/shared-ux/page/analytics_no_data/mocks",
"@kbn/shared-ux-page-analytics-no-data-types": "link:bazel-bin/packages/shared-ux/page/analytics_no_data/types",
Expand Down Expand Up @@ -1131,6 +1134,9 @@
"@types/kbn__shared-ux-link-redirect-app": "link:bazel-bin/packages/shared-ux/link/redirect_app/impl/npm_module_types",
"@types/kbn__shared-ux-link-redirect-app-mocks": "link:bazel-bin/packages/shared-ux/link/redirect_app/mocks/npm_module_types",
"@types/kbn__shared-ux-link-redirect-app-types": "link:bazel-bin/packages/shared-ux/link/redirect_app/types/npm_module_types",
"@types/kbn__shared-ux-markdown": "link:bazel-bin/packages/shared-ux/markdown/impl/npm_module_types",
"@types/kbn__shared-ux-markdown-mocks": "link:bazel-bin/packages/shared-ux/markdown/mocks/npm_module_types",
"@types/kbn__shared-ux-markdown-types": "link:bazel-bin/packages/shared-ux/markdown/types/npm_module_types",
"@types/kbn__shared-ux-page-analytics-no-data": "link:bazel-bin/packages/shared-ux/page/analytics_no_data/impl/npm_module_types",
"@types/kbn__shared-ux-page-analytics-no-data-mocks": "link:bazel-bin/packages/shared-ux/page/analytics_no_data/mocks/npm_module_types",
"@types/kbn__shared-ux-page-analytics-no-data-types": "link:bazel-bin/packages/shared-ux/page/analytics_no_data/types/npm_module_types",
Expand Down
6 changes: 6 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ filegroup(
"//packages/shared-ux/link/redirect_app/impl:build",
"//packages/shared-ux/link/redirect_app/mocks:build",
"//packages/shared-ux/link/redirect_app/types:build",
"//packages/shared-ux/markdown/impl:build",
"//packages/shared-ux/markdown/mocks:build",
"//packages/shared-ux/markdown/types:build",
"//packages/shared-ux/page/analytics_no_data/impl:build",
"//packages/shared-ux/page/analytics_no_data/mocks:build",
"//packages/shared-ux/page/analytics_no_data/types:build",
Expand Down Expand Up @@ -639,6 +642,9 @@ filegroup(
"//packages/shared-ux/card/no_data/mocks:build_types",
"//packages/shared-ux/link/redirect_app/impl:build_types",
"//packages/shared-ux/link/redirect_app/mocks:build_types",
"//packages/shared-ux/markdown/impl:build_types",
"//packages/shared-ux/markdown/mocks:build_types",
"//packages/shared-ux/markdown/types:build_types",
"//packages/shared-ux/page/analytics_no_data/impl:build_types",
"//packages/shared-ux/page/analytics_no_data/mocks:build_types",
"//packages/shared-ux/page/kibana_no_data/impl:build_types",
Expand Down
145 changes: 145 additions & 0 deletions packages/shared-ux/markdown/impl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_DIRNAME = "impl"
PKG_REQUIRE_NAME = "@kbn/shared-ux-markdown"

SOURCE_FILES = glob(
[
"**/*.ts",
"**/*.tsx",
"**/*.mdx",
],
exclude = [
"**/*.config.js",
"**/*.mock.*",
"**/*.test.*",
"**/*.stories.*",
"**/__snapshots__/**",
"**/integration_tests/**",
"**/mocks/**",
"**/scripts/**",
"**/storybook/**",
"**/test_fixtures/**",
"**/test_helpers/**",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

# In this array place runtime dependencies, including other packages and NPM packages
# which must be available for this code to run.
#
# To reference other packages use:
# "//repo/relative/path/to/package"
# eg. "//packages/kbn-utils"
#
# To reference a NPM package use:
# "@npm//name-of-package"
# eg. "@npm//lodash"
RUNTIME_DEPS = [
"@npm//react",
"@npm//enzyme",
"@npm//@elastic/eui",
"//packages/kbn-ambient-ui-types",
]

# In this array place dependencies necessary to build the types, which will include the
# :npm_module_types target of other packages and packages from NPM, including @types/*
# packages.
#
# To reference the types for another package use:
# "//repo/relative/path/to/package:npm_module_types"
# eg. "//packages/kbn-utils:npm_module_types"
#
# References to NPM packages work the same as RUNTIME_DEPS
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//@elastic/eui",
"//packages/kbn-ambient-ui-types",
"//packages/kbn-shared-ux-utility:npm_module_types",
]

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
additional_args = [
"--copy-files",
"--quiet"
],
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)

ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)

filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)
33 changes: 33 additions & 0 deletions packages/shared-ux/markdown/impl/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: sharedUX/Components/Markdown
slug: /shared-ux/components/markdown
title: Markdown
description: A wrapper around EuiMarkdownEditor and EuiMarkdownFormat.
tags: ['shared-ux', 'component']
date: 2022-10-03
---

## Description

This markdown component uses the **EuiMarkdownEditor** and **EuiMarkdownFormat** managed by `@elastic/eui`. If `readOnly` is set to true, and `markdownContent` or `children` are set, then the component renders **EuiMarkdownFormat** text. Otherwise the component will render the **EuiMarkdownEditor**. The height of the component can be set, but in order the control the width of the component, you can place the `<Markdown />` component in another component.
Markdown extends all the EuiMarkdownEditorProps except for the `editorId`, `uiPlugins`, and `MarkdownFormatProps`.

## Component Properties

| Prop Name | Type | Description |
|---|---|---|
| `readOnly` | `boolean` | Needed to differentiate where markdown is used as a presentation of error messages. This was previous the MarkdownSimple component |
| ** TODO ** `openLinksInNewTab` | `boolean` | An optional property needed to replace the Markdown component from kibana-react |
|`markdownContent` | `string` | This prop can be set along with `readOnly` to display error.message etc text to the kibana user. This property is optional. |
| `ariaLabelContent` | `string` | An optional property to be set for the markdown component. It will be `markdown component` if not set explicitly. |
| `height` | `number` or `'full'` | The height of the markdown component can be set to a number. By default, height is set to `'full'`. To set the width, include a container for the markdown component to be within with set width. |
| `placeholder` | `string` or `undefined` | This prop can be set to a string to display the placeholder content of the markdown component. |
| `defaultValue` | `string` | The default value for the markdown editor. If not set it will default to an empty string. |

## API

| Export | Description |
|---|---|
| `Markdown` | This component provides a markdown editor or text to be supported with Markdown formatting (must have static content set for the `markdownContent`) prop and be `readOnly` |
| `MarkdownProps` | Exported by `@kbn/shared-ux-markdown-types` |

Loading