@looker/code-editor 0.1.30 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -148
- package/README.md +13 -13
- package/lib/CodeCopy/CodeCopy.d.ts +2 -2
- package/lib/CodeCopy/CodeCopy.js.map +1 -1
- package/lib/CodeCopy/index.js.map +1 -1
- package/lib/CodeDisplay/CodeDisplay.js +5 -5
- package/lib/CodeDisplay/CodeDisplay.js.map +1 -1
- package/lib/CodeDisplay/CodeWrapper.js.map +1 -1
- package/lib/CodeDisplay/LineItem.js.map +1 -1
- package/lib/CodeDisplay/index.js.map +1 -1
- package/lib/CodeDisplay/types.d.ts +1 -1
- package/lib/CodeDisplay/types.js.map +1 -1
- package/lib/CodeEditor/CodeEditor.js.map +1 -1
- package/lib/CodeEditor/index.js.map +1 -1
- package/lib/Markdown/Markdown.d.ts +2 -1
- package/lib/Markdown/Markdown.js +1 -1
- package/lib/Markdown/Markdown.js.map +1 -1
- package/lib/Markdown/TableCell.js.map +1 -1
- package/lib/Markdown/common.js +10 -14
- package/lib/Markdown/common.js.map +1 -1
- package/lib/Markdown/index.js.map +1 -1
- package/lib/Markdown/utils.js.map +1 -1
- package/lib/esm/CodeCopy/CodeCopy.js +7 -15
- package/lib/esm/CodeCopy/CodeCopy.js.map +1 -1
- package/lib/esm/CodeCopy/index.js +1 -16
- package/lib/esm/CodeCopy/index.js.map +1 -1
- package/lib/esm/CodeDisplay/CodeDisplay.js +22 -32
- package/lib/esm/CodeDisplay/CodeDisplay.js.map +1 -1
- package/lib/esm/CodeDisplay/CodeWrapper.js +6 -14
- package/lib/esm/CodeDisplay/CodeWrapper.js.map +1 -1
- package/lib/esm/CodeDisplay/LineItem.js +3 -11
- package/lib/esm/CodeDisplay/LineItem.js.map +1 -1
- package/lib/esm/CodeDisplay/index.js +1 -12
- package/lib/esm/CodeDisplay/index.js.map +1 -1
- package/lib/esm/CodeDisplay/types.js.map +1 -1
- package/lib/esm/CodeEditor/CodeEditor.js +6 -14
- package/lib/esm/CodeEditor/CodeEditor.js.map +1 -1
- package/lib/esm/CodeEditor/index.js +1 -12
- package/lib/esm/CodeEditor/index.js.map +1 -1
- package/lib/esm/Markdown/Markdown.js +32 -40
- package/lib/esm/Markdown/Markdown.js.map +1 -1
- package/lib/esm/Markdown/TableCell.js +4 -12
- package/lib/esm/Markdown/TableCell.js.map +1 -1
- package/lib/esm/Markdown/common.js +17 -29
- package/lib/esm/Markdown/common.js.map +1 -1
- package/lib/esm/Markdown/index.js +1 -16
- package/lib/esm/Markdown/index.js.map +1 -1
- package/lib/esm/Markdown/utils.js +10 -24
- package/lib/esm/Markdown/utils.js.map +1 -1
- package/lib/esm/index.js +4 -49
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/test-data/codeBlob.js +1 -8
- package/lib/esm/test-data/codeBlob.js.map +1 -1
- package/lib/esm/test-data/index.js +1 -12
- package/lib/esm/test-data/index.js.map +1 -1
- package/lib/esm/utils/index.js +1 -24
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/esm/utils/utils.js +19 -29
- package/lib/esm/utils/utils.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/test-data/codeBlob.js +1 -2
- package/lib/test-data/codeBlob.js.map +1 -1
- package/lib/test-data/index.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/utils.js.map +1 -1
- package/package.json +17 -17
|
@@ -1,39 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CodeDisplay = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _components = require("@looker/components");
|
|
10
|
-
var _prismReactRenderer = _interopRequireWildcard(require("prism-react-renderer"));
|
|
11
|
-
var _utils = require("../utils");
|
|
12
|
-
var _CodeWrapper = require("./CodeWrapper");
|
|
13
|
-
var _LineItem = require("./LineItem");
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Span } from '@looker/components';
|
|
5
|
+
import Highlight, { Prism, defaultProps } from 'prism-react-renderer';
|
|
6
|
+
import { getOverriddenTheme, getPrismLanguage } from '../utils';
|
|
7
|
+
import { CodeWrapper } from './CodeWrapper';
|
|
8
|
+
import { LineItem } from './LineItem';
|
|
9
|
+
(typeof global !== 'undefined' ? global : window).Prism = Prism;
|
|
19
10
|
require('prismjs/components/prism-kotlin');
|
|
20
11
|
require('prismjs/components/prism-csharp');
|
|
21
12
|
require('prismjs/components/prism-swift');
|
|
22
13
|
require('prismjs/components/prism-ruby');
|
|
23
14
|
require('prismjs/components/prism-markdown');
|
|
24
|
-
var Line = (
|
|
15
|
+
var Line = styled(Span).withConfig({
|
|
25
16
|
displayName: "CodeDisplay__Line",
|
|
26
|
-
componentId: "
|
|
17
|
+
componentId: "iaw0ts-0"
|
|
27
18
|
})(["display:table-row;"]);
|
|
28
|
-
var LineNo = (
|
|
19
|
+
var LineNo = styled(Span).withConfig({
|
|
29
20
|
displayName: "CodeDisplay__LineNo",
|
|
30
|
-
componentId: "
|
|
21
|
+
componentId: "iaw0ts-1"
|
|
31
22
|
})(["display:table-cell;text-align:right;padding-right:1em;user-select:none;opacity:0.5;"]);
|
|
32
|
-
var LineContent = (
|
|
23
|
+
var LineContent = styled(Span).withConfig({
|
|
33
24
|
displayName: "CodeDisplay__LineContent",
|
|
34
|
-
componentId: "
|
|
25
|
+
componentId: "iaw0ts-2"
|
|
35
26
|
})(["display:table-cell;font-family:monospace;"]);
|
|
36
|
-
var CodeDisplay = _ref => {
|
|
27
|
+
export var CodeDisplay = _ref => {
|
|
37
28
|
var {
|
|
38
29
|
language = 'json',
|
|
39
30
|
code,
|
|
@@ -42,10 +33,10 @@ var CodeDisplay = _ref => {
|
|
|
42
33
|
inline = false,
|
|
43
34
|
lineNumbers = true
|
|
44
35
|
} = _ref;
|
|
45
|
-
return
|
|
36
|
+
return React.createElement(Highlight, _extends({}, defaultProps, {
|
|
46
37
|
code: code.trim(),
|
|
47
|
-
language:
|
|
48
|
-
theme:
|
|
38
|
+
language: getPrismLanguage(language),
|
|
39
|
+
theme: getOverriddenTheme(transparent, inline)
|
|
49
40
|
}), _ref2 => {
|
|
50
41
|
var {
|
|
51
42
|
className,
|
|
@@ -54,21 +45,21 @@ var CodeDisplay = _ref => {
|
|
|
54
45
|
getLineProps,
|
|
55
46
|
getTokenProps
|
|
56
47
|
} = _ref2;
|
|
57
|
-
return
|
|
48
|
+
return React.createElement(CodeWrapper, {
|
|
58
49
|
className: className,
|
|
59
50
|
style: style,
|
|
60
51
|
inline: inline
|
|
61
|
-
}, tokens.map((line, i) =>
|
|
52
|
+
}, tokens.map((line, i) => React.createElement(Line, _extends({
|
|
62
53
|
key: i
|
|
63
54
|
}, getLineProps({
|
|
64
55
|
line,
|
|
65
56
|
key: i
|
|
66
|
-
})), lineNumbers &&
|
|
57
|
+
})), lineNumbers && React.createElement(LineNo, null, i + 1), React.createElement(LineContent, null, line.map((token, key) => {
|
|
67
58
|
var tokenProps = getTokenProps({
|
|
68
59
|
token,
|
|
69
60
|
key
|
|
70
61
|
});
|
|
71
|
-
return
|
|
62
|
+
return React.createElement(LineItem, {
|
|
72
63
|
key: key,
|
|
73
64
|
index: key,
|
|
74
65
|
tokenProps: tokenProps,
|
|
@@ -77,5 +68,4 @@ var CodeDisplay = _ref => {
|
|
|
77
68
|
})))));
|
|
78
69
|
});
|
|
79
70
|
};
|
|
80
|
-
exports.CodeDisplay = CodeDisplay;
|
|
81
71
|
//# sourceMappingURL=CodeDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeDisplay.js","names":["
|
|
1
|
+
{"version":3,"file":"CodeDisplay.js","names":["React","styled","Span","Highlight","Prism","defaultProps","getOverriddenTheme","getPrismLanguage","CodeWrapper","LineItem","global","window","require","Line","withConfig","displayName","componentId","LineNo","LineContent","CodeDisplay","_ref","language","code","pattern","transparent","inline","lineNumbers","createElement","_extends","trim","theme","_ref2","className","style","tokens","getLineProps","getTokenProps","map","line","i","key","token","tokenProps","index"],"sources":["../../../src/CodeDisplay/CodeDisplay.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React from 'react';\nimport styled from 'styled-components';\nimport { Span } from '@looker/components';\nimport Highlight, { Prism, defaultProps } from 'prism-react-renderer';\n\nimport { getOverriddenTheme, getPrismLanguage } from '../utils';\nimport { CodeWrapper } from './CodeWrapper';\nimport { LineItem } from './LineItem';\nimport type { CodeDisplayProps } from './types';\n(typeof global !== 'undefined' ? (global as any) : (window as any)).Prism =\n Prism;\nrequire('prismjs/components/prism-kotlin');\nrequire('prismjs/components/prism-csharp');\nrequire('prismjs/components/prism-swift');\nrequire('prismjs/components/prism-ruby');\nrequire('prismjs/components/prism-markdown');\n\nconst Line = styled(Span)`\n display: table-row;\n`;\n\nconst LineNo = styled(Span)`\n display: table-cell;\n text-align: right;\n padding-right: 1em;\n user-select: none;\n opacity: 0.5;\n`;\n\nconst LineContent = styled(Span)`\n display: table-cell;\n font-family: monospace;\n`;\n\n/**\n * Provides a view-only syntax highlighter for all supported SDK languages.\n * @param language - highlighting language\n * @param code - string content to display\n * @param pattern - Search pattern to be marked\n * @param transparent - Flag to provide background styling or not\n * @param inline - Flag to use block or inline code\n * @param lineNumbers - flag to toggle line numbers\n */\nexport const CodeDisplay: FC<CodeDisplayProps> = ({\n language = 'json',\n code,\n pattern = '',\n transparent = false,\n inline = false,\n lineNumbers = true,\n}) => {\n return (\n <Highlight\n {...defaultProps}\n code={code.trim()}\n language={getPrismLanguage(language)}\n theme={getOverriddenTheme(transparent, inline)}\n >\n {({ className, style, tokens, getLineProps, getTokenProps }) => (\n <CodeWrapper className={className} style={style} inline={inline}>\n {tokens.map((line, i) => (\n <Line key={i} {...getLineProps({ line, key: i })}>\n {lineNumbers && <LineNo>{i + 1}</LineNo>}\n <LineContent>\n {line.map((token, key) => {\n const tokenProps = getTokenProps({ token, key });\n return (\n <LineItem\n key={key}\n index={key}\n tokenProps={tokenProps}\n pattern={pattern}\n />\n );\n })}\n </LineContent>\n </Line>\n ))}\n </CodeWrapper>\n )}\n </Highlight>\n );\n};\n"],"mappings":";AA2BA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,mBAAmB;AACtC,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,SAAS,IAAIC,KAAK,EAAEC,YAAY,QAAQ,sBAAsB;AAErE,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAC/D,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,QAAQ,QAAQ,YAAY;AAErC,CAAC,OAAOC,MAAM,KAAK,WAAW,GAAIA,MAAM,GAAYC,MAAc,EAAEP,KAAK,GACvEA,KAAK;AACPQ,OAAO,CAAC,iCAAiC,CAAC;AAC1CA,OAAO,CAAC,iCAAiC,CAAC;AAC1CA,OAAO,CAAC,gCAAgC,CAAC;AACzCA,OAAO,CAAC,+BAA+B,CAAC;AACxCA,OAAO,CAAC,mCAAmC,CAAC;AAE5C,IAAMC,IAAI,GAAGZ,MAAM,CAACC,IAAI,CAAC,CAAAY,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,0BAExB;AAED,IAAMC,MAAM,GAAGhB,MAAM,CAACC,IAAI,CAAC,CAAA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,KAAK;MACxB,IAAME,UAAU,GAAGN,aAAa,CAAC;QAAEK,KAAK;QAAED;MAAI,CAAC,CAAC;MAChD,OACExC,KAAA,CAAA2B,aAAA,CAAClB,QAAQ;QACP+B,GAAG,EAAEA,GAAI;QACTG,KAAK,EAAEH,GAAI;QACXE,UAAU,EAAEA,UAAW;QACvBnB,OAAO,EAAEA;MAAQ,CAClB,CAAC;IAEN,CAAC,CACU,CACT,CACP,CACU,CAAC;EAAA,CAEP,CAAC;AAEhB,CAAC"}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CodeWrapper = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
var Pre = _styledComponents.default.pre.withConfig({
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
var Pre = styled.pre.withConfig({
|
|
11
4
|
displayName: "CodeWrapper__Pre",
|
|
12
5
|
componentId: "sc-156h0dr-0"
|
|
13
6
|
})(["white-space:pre-wrap;overflow:auto;margin:0px;.match{background:#000000;border:1px#fff2c2 solid;border-radius:10px;padding:0.15px 4px;}"]);
|
|
14
|
-
var Code =
|
|
7
|
+
var Code = styled.code.withConfig({
|
|
15
8
|
displayName: "CodeWrapper__Code",
|
|
16
9
|
componentId: "sc-156h0dr-1"
|
|
17
10
|
})([".match{background-color:yellow;}"]);
|
|
18
|
-
var CodeWrapper = _ref => {
|
|
11
|
+
export var CodeWrapper = _ref => {
|
|
19
12
|
var {
|
|
20
13
|
className,
|
|
21
14
|
style,
|
|
@@ -23,10 +16,9 @@ var CodeWrapper = _ref => {
|
|
|
23
16
|
children
|
|
24
17
|
} = _ref;
|
|
25
18
|
var Wrapper = inline ? Code : Pre;
|
|
26
|
-
return
|
|
19
|
+
return React.createElement(Wrapper, {
|
|
27
20
|
className: className,
|
|
28
21
|
style: style
|
|
29
22
|
}, children);
|
|
30
23
|
};
|
|
31
|
-
exports.CodeWrapper = CodeWrapper;
|
|
32
24
|
//# sourceMappingURL=CodeWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeWrapper.js","names":["
|
|
1
|
+
{"version":3,"file":"CodeWrapper.js","names":["React","styled","Pre","pre","withConfig","displayName","componentId","Code","code","CodeWrapper","_ref","className","style","inline","children","Wrapper","createElement"],"sources":["../../../src/CodeDisplay/CodeWrapper.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React from 'react';\nimport styled from 'styled-components';\n\ninterface CodeWrapperProps {\n className: string;\n style: any;\n inline: boolean;\n children: any;\n}\n\nconst Pre = styled.pre`\n white-space: pre-wrap;\n overflow: auto;\n // override default margin for Pre\n // so we can set from parent\n margin: 0px;\n\n // selector for search matches\n .match {\n background: #000000;\n border: 1px#fff2c2 solid;\n border-radius: 10px;\n padding: 0.15px 4px;\n }\n`;\nconst Code = styled.code`\n // selector for search matches\n .match {\n background-color: yellow;\n }\n`;\n\n/**\n * A wrapper for CodeDisplay which applies search highlighting styles on proper container component\n */\nexport const CodeWrapper: FC<CodeWrapperProps> = ({\n className,\n style,\n inline,\n children,\n}) => {\n const Wrapper = inline ? Code : Pre;\n return (\n <Wrapper className={className} style={style}>\n {children}\n </Wrapper>\n );\n};\n"],"mappings":"AA2BA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,mBAAmB;AAStC,IAAMC,GAAG,GAAGD,MAAM,CAACE,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,+IAcrB;AACD,IAAMC,IAAI,GAAGN,MAAM,CAACO,IAAI,CAAAJ,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,wCAKvB;AAKD,OAAO,IAAMG,WAAiC,GAAGC,IAAA,IAK3C;EAAA,IAL4C;IAChDC,SAAS;IACTC,KAAK;IACLC,MAAM;IACNC;EACF,CAAC,GAAAJ,IAAA;EACC,IAAMK,OAAO,GAAGF,MAAM,GAAGN,IAAI,GAAGL,GAAG;EACnC,OACEF,KAAA,CAAAgB,aAAA,CAACD,OAAO;IAACJ,SAAS,EAAEA,SAAU;IAACC,KAAK,EAAEA;EAAM,GACzCE,QACM,CAAC;AAEd,CAAC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LineItem = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
10
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export var LineItem = _ref => {
|
|
11
4
|
var {
|
|
12
5
|
index,
|
|
13
6
|
tokenProps,
|
|
@@ -17,9 +10,8 @@ var LineItem = _ref => {
|
|
|
17
10
|
if (pattern !== '' && text.includes(pattern.toLowerCase())) {
|
|
18
11
|
tokenProps.className += ' match';
|
|
19
12
|
}
|
|
20
|
-
return
|
|
13
|
+
return React.createElement("span", _extends({
|
|
21
14
|
key: index
|
|
22
15
|
}, tokenProps));
|
|
23
16
|
};
|
|
24
|
-
exports.LineItem = LineItem;
|
|
25
17
|
//# sourceMappingURL=LineItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineItem.js","names":["
|
|
1
|
+
{"version":3,"file":"LineItem.js","names":["React","LineItem","_ref","index","tokenProps","pattern","text","children","toLowerCase","includes","className","createElement","_extends","key"],"sources":["../../../src/CodeDisplay/LineItem.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React from 'react';\nimport type { LineItemProps } from './types';\n\n/**\n * Takes a 'line of code' as a list of Tokens and returns syntax highlighting styled spans\n * @param key - component identifier\n * @param tokenProps - the style props from prism renderer\n * @param pattern - search pattern to consider\n */\nexport const LineItem: FC<LineItemProps> = ({ index, tokenProps, pattern }) => {\n const text = tokenProps.children.toLowerCase();\n if (pattern !== '' && text.includes(pattern.toLowerCase())) {\n tokenProps.className += ' match';\n }\n return <span key={index} {...tokenProps} />;\n};\n"],"mappings":";AA2BA,OAAOA,KAAK,MAAM,OAAO;AASzB,OAAO,IAAMC,QAA2B,GAAGC,IAAA,IAAoC;EAAA,IAAnC;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAQ,CAAC,GAAAH,IAAA;EACxE,IAAMI,IAAI,GAAGF,UAAU,CAACG,QAAQ,CAACC,WAAW,CAAC,CAAC;EAC9C,IAAIH,OAAO,KAAK,EAAE,IAAIC,IAAI,CAACG,QAAQ,CAACJ,OAAO,CAACG,WAAW,CAAC,CAAC,CAAC,EAAE;IAC1DJ,UAAU,CAACM,SAAS,IAAI,QAAQ;EAClC;EACA,OAAOV,KAAA,CAAAW,aAAA,SAAAC,QAAA;IAAMC,GAAG,EAAEV;EAAM,GAAKC,UAAU,CAAG,CAAC;AAC7C,CAAC"}
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "CodeDisplay", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _CodeDisplay.CodeDisplay;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _CodeDisplay = require("./CodeDisplay");
|
|
1
|
+
export { CodeDisplay } from './CodeDisplay';
|
|
13
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["CodeDisplay"],"sources":["../../../src/CodeDisplay/index.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nexport { CodeDisplay } from './CodeDisplay';\nexport type { CodeDisplayProps } from './types';\n"],"mappings":"AAyBA,SAASA,WAAW,QAAQ,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/CodeDisplay/types.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport interface CodeDisplayProps {\n code: string
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/CodeDisplay/types.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport interface CodeDisplayProps {\n code: string;\n language?: string;\n pattern?: string;\n transparent?: boolean;\n inline?: boolean;\n lineNumbers?: boolean;\n}\n\nexport type TokenOutputProps = {\n key?: React.Key;\n style?: any;\n className: string;\n children: string;\n [otherProp: string]: any;\n};\n\nexport interface LineItemProps {\n index: number;\n tokenProps: TokenOutputProps;\n pattern: string;\n}\n"],"mappings":""}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.CodeEditor = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactSimpleCodeEditor = _interopRequireDefault(require("react-simple-code-editor"));
|
|
9
|
-
var _index = require("../index");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var CodeEditor = _ref => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Editor from 'react-simple-code-editor';
|
|
3
|
+
import { CodeDisplay } from '../index';
|
|
4
|
+
export var CodeEditor = _ref => {
|
|
12
5
|
var {
|
|
13
6
|
code,
|
|
14
7
|
onChange,
|
|
@@ -17,11 +10,11 @@ var CodeEditor = _ref => {
|
|
|
17
10
|
transparent = false,
|
|
18
11
|
lineNumbers = true
|
|
19
12
|
} = _ref;
|
|
20
|
-
return
|
|
13
|
+
return React.createElement(Editor, {
|
|
21
14
|
value: code.trim(),
|
|
22
15
|
role: 'code-editor',
|
|
23
16
|
onValueChange: onChange,
|
|
24
|
-
highlight: code =>
|
|
17
|
+
highlight: code => React.createElement(CodeDisplay, {
|
|
25
18
|
code: code,
|
|
26
19
|
language: language,
|
|
27
20
|
pattern: pattern,
|
|
@@ -38,5 +31,4 @@ var CodeEditor = _ref => {
|
|
|
38
31
|
}
|
|
39
32
|
});
|
|
40
33
|
};
|
|
41
|
-
exports.CodeEditor = CodeEditor;
|
|
42
34
|
//# sourceMappingURL=CodeEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.js","names":["
|
|
1
|
+
{"version":3,"file":"CodeEditor.js","names":["React","Editor","CodeDisplay","CodeEditor","_ref","code","onChange","language","pattern","transparent","lineNumbers","createElement","value","trim","role","onValueChange","highlight","padding","style","width","color","whiteSpace","overflow","fontFamily"],"sources":["../../../src/CodeEditor/CodeEditor.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React from 'react';\nimport Editor from 'react-simple-code-editor';\n\nimport type { CodeDisplayProps } from '../CodeDisplay/types';\nimport { CodeDisplay } from '../index';\n\ninterface CodeEditorProps extends CodeDisplayProps {\n /** onChange event handler, for Editor functionality */\n onChange: (text: string) => void;\n}\n\n/**\n * Extends CodeDisplay functionality to provide\n * Editor functionality for syntax highlighted code blocks\n */\nexport const CodeEditor: FC<CodeEditorProps> = ({\n code,\n onChange,\n language = 'json',\n pattern = '',\n transparent = false,\n lineNumbers = true,\n}) => {\n return (\n <Editor\n value={code.trim()}\n role={'code-editor'}\n onValueChange={onChange}\n highlight={(code: string) => (\n <CodeDisplay\n code={code}\n language={language}\n pattern={pattern}\n transparent={transparent}\n lineNumbers={lineNumbers}\n />\n )}\n padding=\"1rem\"\n style={{\n width: '100%',\n color: '#FFF',\n whiteSpace: 'pre-wrap',\n overflow: 'auto',\n fontFamily: 'monospace',\n }}\n />\n );\n};\n"],"mappings":"AA2BA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,0BAA0B;AAG7C,SAASC,WAAW,QAAQ,UAAU;AAWtC,OAAO,IAAMC,UAA+B,GAAGC,IAAA,IAOzC;EAAA,IAP0C;IAC9CC,IAAI;IACJC,QAAQ;IACRC,QAAQ,GAAG,MAAM;IACjBC,OAAO,GAAG,EAAE;IACZC,WAAW,GAAG,KAAK;IACnBC,WAAW,GAAG;EAChB,CAAC,GAAAN,IAAA;EACC,OACEJ,KAAA,CAAAW,aAAA,CAACV,MAAM;IACLW,KAAK,EAAEP,IAAI,CAACQ,IAAI,CAAC,CAAE;IACnBC,IAAI,EAAE,aAAc;IACpBC,aAAa,EAAET,QAAS;IACxBU,SAAS,EAAGX,IAAY,IACtBL,KAAA,CAAAW,aAAA,CAACT,WAAW;MACVG,IAAI,EAAEA,IAAK;MACXE,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,WAAW,EAAEA,WAAY;MACzBC,WAAW,EAAEA;IAAY,CAC1B,CACD;IACFO,OAAO,EAAC,MAAM;IACdC,KAAK,EAAE;MACLC,KAAK,EAAE,MAAM;MACbC,KAAK,EAAE,MAAM;MACbC,UAAU,EAAE,UAAU;MACtBC,QAAQ,EAAE,MAAM;MAChBC,UAAU,EAAE;IACd;EAAE,CACH,CAAC;AAEN,CAAC"}
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "CodeEditor", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _CodeEditor.CodeEditor;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _CodeEditor = require("./CodeEditor");
|
|
1
|
+
export { CodeEditor } from './CodeEditor';
|
|
13
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["CodeEditor"],"sources":["../../../src/CodeEditor/index.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nexport { CodeEditor } from './CodeEditor';\n"],"mappings":"AAyBA,SAASA,UAAU,QAAQ,cAAc"}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
var _components = require("@looker/components");
|
|
13
|
-
var _CodeDisplay = require("../CodeDisplay");
|
|
14
|
-
var _utils = require("./utils");
|
|
15
|
-
var _TableCell = require("./TableCell");
|
|
16
|
-
var _common = require("./common");
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
var Markdown = _ref => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import ReactMarkdown from 'react-markdown';
|
|
4
|
+
import rehypeRaw from 'rehype-raw';
|
|
5
|
+
import gfm from 'remark-gfm';
|
|
6
|
+
import { Link, TableBody, TableHead, TableRow } from '@looker/components';
|
|
7
|
+
import { CodeDisplay } from '../CodeDisplay';
|
|
8
|
+
import { prepareCodeText, qualifyMarkdownText } from './utils';
|
|
9
|
+
import { TableCell } from './TableCell';
|
|
10
|
+
import { MDHeading, MDList, MDListItem, MDParagraph, MDTable } from './common';
|
|
11
|
+
export var Markdown = _ref => {
|
|
19
12
|
var {
|
|
20
13
|
source,
|
|
21
14
|
pattern = '',
|
|
@@ -44,7 +37,7 @@ var Markdown = _ref => {
|
|
|
44
37
|
level,
|
|
45
38
|
children
|
|
46
39
|
} = _ref2;
|
|
47
|
-
return
|
|
40
|
+
return React.createElement(MDHeading, {
|
|
48
41
|
as: "h".concat(level)
|
|
49
42
|
}, children);
|
|
50
43
|
};
|
|
@@ -52,7 +45,7 @@ var Markdown = _ref => {
|
|
|
52
45
|
var {
|
|
53
46
|
children
|
|
54
47
|
} = _ref3;
|
|
55
|
-
return
|
|
48
|
+
return React.createElement(MDParagraph, null, children);
|
|
56
49
|
};
|
|
57
50
|
var code = _ref4 => {
|
|
58
51
|
var {
|
|
@@ -62,7 +55,7 @@ var Markdown = _ref => {
|
|
|
62
55
|
var {
|
|
63
56
|
text,
|
|
64
57
|
language
|
|
65
|
-
} =
|
|
58
|
+
} = prepareCodeText((children === null || children === void 0 ? void 0 : children.toString()) || '');
|
|
66
59
|
var codeProps = {
|
|
67
60
|
language: language,
|
|
68
61
|
code: text,
|
|
@@ -70,7 +63,7 @@ var Markdown = _ref => {
|
|
|
70
63
|
lineNumbers: false,
|
|
71
64
|
inline: inline
|
|
72
65
|
};
|
|
73
|
-
return
|
|
66
|
+
return React.createElement(CodeDisplay, codeProps);
|
|
74
67
|
};
|
|
75
68
|
var components = {
|
|
76
69
|
h1: heading,
|
|
@@ -81,29 +74,28 @@ var Markdown = _ref => {
|
|
|
81
74
|
h6: heading,
|
|
82
75
|
p: paragraphOverride || paragraph,
|
|
83
76
|
code: code,
|
|
84
|
-
a:
|
|
85
|
-
ul:
|
|
86
|
-
ol:
|
|
87
|
-
link:
|
|
88
|
-
li:
|
|
89
|
-
table:
|
|
90
|
-
thead:
|
|
91
|
-
tbody:
|
|
92
|
-
tr:
|
|
93
|
-
td:
|
|
94
|
-
th:
|
|
77
|
+
a: Link,
|
|
78
|
+
ul: MDList,
|
|
79
|
+
ol: MDList,
|
|
80
|
+
link: Link,
|
|
81
|
+
li: MDListItem,
|
|
82
|
+
table: MDTable,
|
|
83
|
+
thead: TableHead,
|
|
84
|
+
tbody: TableBody,
|
|
85
|
+
tr: TableRow,
|
|
86
|
+
td: TableCell,
|
|
87
|
+
th: TableCell
|
|
95
88
|
};
|
|
96
|
-
return
|
|
89
|
+
return React.createElement(MarkdownWrapper, {
|
|
97
90
|
onClick: handleClick
|
|
98
|
-
},
|
|
99
|
-
remarkPlugins: [
|
|
100
|
-
rehypePlugins: [
|
|
91
|
+
}, React.createElement(ReactMarkdown, {
|
|
92
|
+
remarkPlugins: [gfm],
|
|
93
|
+
rehypePlugins: [rehypeRaw],
|
|
101
94
|
transformLinkUri: transformLinkUri,
|
|
102
95
|
components: components
|
|
103
|
-
},
|
|
96
|
+
}, qualifyMarkdownText(source, pattern !== null && pattern !== void 0 ? pattern : '')));
|
|
104
97
|
};
|
|
105
|
-
|
|
106
|
-
var MarkdownWrapper = _styledComponents.default.div.withConfig({
|
|
98
|
+
var MarkdownWrapper = styled.div.withConfig({
|
|
107
99
|
displayName: "Markdown__MarkdownWrapper",
|
|
108
100
|
componentId: "sc-11uco0h-0"
|
|
109
101
|
})(["& > ul{padding-left:20px;list-style:disc outside;}& > ol{padding-left:20px;list-style:decimal outside;}& mark{background-color:#fff2c2;font-weight:500;}"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.js","names":["
|
|
1
|
+
{"version":3,"file":"Markdown.js","names":["React","styled","ReactMarkdown","rehypeRaw","gfm","Link","TableBody","TableHead","TableRow","CodeDisplay","prepareCodeText","qualifyMarkdownText","TableCell","MDHeading","MDList","MDListItem","MDParagraph","MDTable","Markdown","_ref","source","pattern","transformLinkUri","linkClickHandler","paragraphOverride","findAnchor","ele","tagName","parentElement","undefined","handleClick","e","preventDefault","a","target","getAttribute","heading","_ref2","level","children","createElement","as","concat","paragraph","_ref3","code","_ref4","inline","text","language","toString","codeProps","lineNumbers","components","h1","h2","h3","h4","h5","h6","p","ul","ol","link","li","table","thead","tbody","tr","td","th","MarkdownWrapper","onClick","remarkPlugins","rehypePlugins","div","withConfig","displayName","componentId"],"sources":["../../../src/Markdown/Markdown.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport React from 'react';\nimport styled from 'styled-components';\nimport ReactMarkdown from 'react-markdown';\nimport rehypeRaw from 'rehype-raw';\nimport gfm from 'remark-gfm';\nimport { Link, TableBody, TableHead, TableRow } from '@looker/components';\n\nimport { CodeDisplay } from '../CodeDisplay';\nimport { prepareCodeText, qualifyMarkdownText } from './utils';\nimport { TableCell } from './TableCell';\nimport { MDHeading, MDList, MDListItem, MDParagraph, MDTable } from './common';\n\ntype HeadingLevels = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\ninterface MarkdownProps {\n source: string;\n pattern?: string;\n transformLinkUri?: (url: string) => string;\n linkClickHandler?: (pathname: string, href: string) => void;\n paragraphOverride?: ({ children }: { children: ReactNode }) => ReactNode;\n}\n\nexport const Markdown = ({\n source,\n pattern = '',\n transformLinkUri,\n linkClickHandler,\n paragraphOverride,\n}: MarkdownProps) => {\n const findAnchor = (ele: HTMLElement): HTMLAnchorElement | undefined => {\n if (ele.tagName === 'A') return ele as HTMLAnchorElement;\n if (ele.parentElement) {\n return findAnchor(ele.parentElement);\n }\n return undefined;\n };\n\n const handleClick = (e: BaseSyntheticEvent) => {\n e.preventDefault();\n if (linkClickHandler) {\n // Could be a <mark> tag wrapped by an anchor\n const a = findAnchor(e.target);\n if (a) {\n linkClickHandler(\n a.getAttribute('pathname') || '',\n a.getAttribute('href') || ''\n );\n }\n }\n };\n\n const heading = ({\n level,\n children,\n }: {\n level: number;\n children: ReactNode;\n }) => <MDHeading as={`h${level}` as HeadingLevels}>{children}</MDHeading>;\n\n const paragraph = ({ children }: { children: ReactNode }) => (\n <MDParagraph>{children}</MDParagraph>\n );\n\n const code = ({\n inline,\n children,\n }: {\n inline?: boolean;\n children: ReactNode;\n }) => {\n const { text, language } = prepareCodeText(children?.toString() || '');\n const codeProps = {\n language: language,\n code: text,\n pattern: pattern,\n lineNumbers: false,\n inline: inline,\n };\n return <CodeDisplay {...codeProps} />;\n };\n\n const components = {\n h1: heading,\n h2: heading,\n h3: heading,\n h4: heading,\n h5: heading,\n h6: heading,\n p: paragraphOverride || paragraph,\n code: code,\n a: Link,\n ul: MDList,\n ol: MDList,\n link: Link,\n li: MDListItem,\n table: MDTable,\n thead: TableHead,\n tbody: TableBody,\n tr: TableRow,\n td: TableCell,\n th: TableCell,\n };\n\n return (\n <MarkdownWrapper onClick={handleClick}>\n <ReactMarkdown\n remarkPlugins={[gfm] as any}\n rehypePlugins={[rehypeRaw] as any}\n transformLinkUri={transformLinkUri}\n components={components}\n >\n {qualifyMarkdownText(source, pattern ?? '')}\n </ReactMarkdown>\n </MarkdownWrapper>\n );\n};\n\nconst MarkdownWrapper = styled.div`\n & > ul {\n padding-left: 20px;\n list-style: disc outside;\n }\n & > ol {\n padding-left: 20px;\n list-style: decimal outside;\n }\n & mark {\n background-color: #fff2c2;\n font-weight: 500;\n }\n`;\n"],"mappings":"AA2BA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,aAAa,MAAM,gBAAgB;AAC1C,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,GAAG,MAAM,YAAY;AAC5B,SAASC,IAAI,EAAEC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AAEzE,SAASC,WAAW,QAAQ,gBAA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AACrE,GAAG,CAAS;IAC5BsE,aAAa,EAAE,CAACvE,SAAS,CAAS;IAClCmB,gBAAgB,EAAEA,gBAAiB;IACnC+B,UAAU,EAAEA;EAAW,GAEtB1C,mBAAmB,CAACS,MAAM,EAAEC,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE,CAC7B,CACA,CAAC;AAEtB,CAAC;AAED,IAAMkD,eAAe,GAAGtE,MAAM,CAAC0E,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gKAajC"}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TableCell = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _components = require("@looker/components");
|
|
9
1
|
var _excluded = ["isHeader"];
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
-
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { TableDataCell, TableHeaderCell } from '@looker/components';
|
|
6
|
+
export var TableCell = _ref => {
|
|
14
7
|
var {
|
|
15
8
|
isHeader
|
|
16
9
|
} = _ref,
|
|
17
10
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
-
return isHeader ?
|
|
11
|
+
return isHeader ? React.createElement(TableHeaderCell, rest) : React.createElement(TableDataCell, rest);
|
|
19
12
|
};
|
|
20
|
-
exports.TableCell = TableCell;
|
|
21
13
|
//# sourceMappingURL=TableCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.js","names":["
|
|
1
|
+
{"version":3,"file":"TableCell.js","names":["React","TableDataCell","TableHeaderCell","TableCell","_ref","isHeader","rest","_objectWithoutProperties","_excluded","createElement"],"sources":["../../../src/Markdown/TableCell.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { FC, PropsWithChildren } from 'react';\nimport React from 'react';\nimport { TableDataCell, TableHeaderCell } from '@looker/components';\n\nexport const TableCell: FC<PropsWithChildren<any>> = ({ isHeader, ...rest }) =>\n isHeader ? <TableHeaderCell {...rest} /> : <TableDataCell {...rest} />;\n"],"mappings":";;;AA0BA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,EAAEC,eAAe,QAAQ,oBAAoB;AAEnE,OAAO,IAAMC,SAAqC,GAAGC,IAAA;EAAA,IAAC;MAAEC;IAAkB,CAAC,GAAAD,IAAA;IAANE,IAAI,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAAA,OACvEH,QAAQ,GAAGL,KAAA,CAAAS,aAAA,CAACP,eAAe,EAAKI,IAAO,CAAC,GAAGN,KAAA,CAAAS,aAAA,CAACR,aAAa,EAAKK,IAAO,CAAC;AAAA"}
|