@readme/markdown 9.1.5 → 9.1.6

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.
@@ -1,6 +1,7 @@
1
1
  import copy from 'copy-to-clipboard';
2
2
  import React, { createRef, useContext } from 'react';
3
3
 
4
+ import CodeOptsContext from '../../contexts/CodeOpts';
4
5
  import ThemeContext from '../../contexts/Theme';
5
6
 
6
7
  // Only load CodeMirror in the browser, for SSR
@@ -53,8 +54,9 @@ interface CodeProps {
53
54
  }
54
55
 
55
56
  const Code = (props: CodeProps) => {
56
- const { children, copyButtons, lang, value } = props;
57
+ const { children, lang, value } = props;
57
58
  const theme = useContext(ThemeContext);
59
+ const copyButtons = useContext(CodeOptsContext) || props.copyButtons;
58
60
 
59
61
  const language = canonicalLanguage(lang);
60
62
 
@@ -0,0 +1,2 @@
1
+ declare const CodeOptsContext: import("react").Context<boolean>;
2
+ export default CodeOptsContext;
@@ -1,5 +1,5 @@
1
1
  import type { RunOpts } from '../lib/run';
2
2
  import React from 'react';
3
- type Props = Pick<RunOpts, 'baseUrl' | 'terms' | 'theme' | 'variables'> & React.PropsWithChildren;
4
- declare const Contexts: ({ children, terms, variables, baseUrl, theme }: Props) => React.ReactNode;
3
+ type Props = Pick<RunOpts, 'baseUrl' | 'copyButtons' | 'terms' | 'theme' | 'variables'> & React.PropsWithChildren;
4
+ declare const Contexts: ({ children, terms, variables, baseUrl, theme, copyButtons }: Props) => React.ReactNode;
5
5
  export default Contexts;
package/dist/lib/run.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { RunOptions } from '@mdx-js/mdx';
5
5
  export type RunOpts = Omit<RunOptions, 'Fragment'> & {
6
6
  baseUrl?: string;
7
7
  components?: CustomComponents;
8
+ copyButtons?: boolean;
8
9
  imports?: Record<string, unknown>;
9
10
  terms?: GlossaryTerm[];
10
11
  theme?: 'dark' | 'light';
package/dist/main.js CHANGED
@@ -18257,6 +18257,12 @@ const CardsGrid = ({ columns = 2, children }) => {
18257
18257
  // EXTERNAL MODULE: ./node_modules/copy-to-clipboard/index.js
18258
18258
  var copy_to_clipboard = __webpack_require__(7965);
18259
18259
  var copy_to_clipboard_default = /*#__PURE__*/__webpack_require__.n(copy_to_clipboard);
18260
+ ;// ./contexts/CodeOpts.ts
18261
+
18262
+ // used for the copyButtons prop
18263
+ const CodeOptsContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createContext)(false);
18264
+ /* harmony default export */ const CodeOpts = (CodeOptsContext);
18265
+
18260
18266
  ;// ./contexts/Theme.ts
18261
18267
 
18262
18268
  const ThemeContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createContext)('light');
@@ -18266,6 +18272,7 @@ const ThemeContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_R
18266
18272
 
18267
18273
 
18268
18274
 
18275
+
18269
18276
  // Only load CodeMirror in the browser, for SSR
18270
18277
  // apps. Necessary because of people like this:
18271
18278
  // https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
@@ -18292,8 +18299,9 @@ function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '', }) {
18292
18299
  return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("button", { ref: buttonRef, "aria-label": "Copy Code", className: `${rootClass} ${className}`, onClick: copier });
18293
18300
  }
18294
18301
  const Code = (props) => {
18295
- const { children, copyButtons, lang, value } = props;
18302
+ const { children, lang, value } = props;
18296
18303
  const theme = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(Theme);
18304
+ const copyButtons = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(CodeOpts) || props.copyButtons;
18297
18305
  const language = canonicalLanguage(lang);
18298
18306
  const codeRef = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createRef)();
18299
18307
  const codeOpts = {
@@ -99219,13 +99227,14 @@ var variable_default = /*#__PURE__*/__webpack_require__.n(variable_);
99219
99227
 
99220
99228
 
99221
99229
 
99230
+
99222
99231
  const compose = (children, ...contexts) => {
99223
99232
  return contexts.reduce((content, [Context, value]) => {
99224
99233
  return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Context.Provider, { value: value }, content);
99225
99234
  }, children);
99226
99235
  };
99227
- const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }, baseUrl = '/', theme }) => {
99228
- return compose(children, [GlossaryTerms, terms], [variable_.VariablesContext, variables], [BaseUrl, baseUrl], [Theme, theme]);
99236
+ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }, baseUrl = '/', theme, copyButtons }) => {
99237
+ return compose(children, [GlossaryTerms, terms], [variable_.VariablesContext, variables], [BaseUrl, baseUrl], [Theme, theme], [CodeOpts, copyButtons]);
99229
99238
  };
99230
99239
  /* harmony default export */ const contexts = (Contexts);
99231
99240
 
@@ -99286,7 +99295,7 @@ const makeUseMDXComponents = (more = {}) => {
99286
99295
 
99287
99296
  const run_run = async (string, _opts = {}) => {
99288
99297
  const { Fragment } = jsx_runtime_namespaceObject;
99289
- const { components = {}, terms, variables, baseUrl, imports = {}, theme, ...opts } = _opts;
99298
+ const { components = {}, terms, variables, baseUrl, imports = {}, theme, copyButtons, ...opts } = _opts;
99290
99299
  const tocsByTag = {};
99291
99300
  const exportedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
99292
99301
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -99320,7 +99329,7 @@ const run_run = async (string, _opts = {}) => {
99320
99329
  Toc = tocModule.default;
99321
99330
  }
99322
99331
  return {
99323
- default: (props) => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { baseUrl: baseUrl, terms: terms, theme: theme, variables: variables },
99332
+ default: (props) => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { baseUrl: baseUrl, copyButtons: copyButtons, terms: terms, theme: theme, variables: variables },
99324
99333
  external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, { ...props }))),
99325
99334
  toc,
99326
99335
  Toc: props => Toc ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,
package/dist/main.node.js CHANGED
@@ -8464,7 +8464,7 @@ fromJSON.default = fromJSON
8464
8464
 
8465
8465
 
8466
8466
  let { nanoid } = __webpack_require__(5042)
8467
- let { isAbsolute, resolve } = __webpack_require__(6928)
8467
+ let { isAbsolute, resolve } = __webpack_require__(4547)
8468
8468
  let { SourceMapConsumer, SourceMapGenerator } = __webpack_require__(7683)
8469
8469
  let { fileURLToPath, pathToFileURL } = __webpack_require__(7016)
8470
8470
 
@@ -9318,7 +9318,7 @@ list.default = list
9318
9318
  "use strict";
9319
9319
 
9320
9320
 
9321
- let { dirname, relative, resolve, sep } = __webpack_require__(6928)
9321
+ let { dirname, relative, resolve, sep } = __webpack_require__(4547)
9322
9322
  let { SourceMapConsumer, SourceMapGenerator } = __webpack_require__(7683)
9323
9323
  let { pathToFileURL } = __webpack_require__(7016)
9324
9324
 
@@ -11032,7 +11032,7 @@ postcss.default = postcss
11032
11032
 
11033
11033
 
11034
11034
  let { existsSync, readFileSync } = __webpack_require__(9896)
11035
- let { dirname, join } = __webpack_require__(6928)
11035
+ let { dirname, join } = __webpack_require__(4547)
11036
11036
  let { SourceMapConsumer, SourceMapGenerator } = __webpack_require__(7683)
11037
11037
 
11038
11038
  function fromBase64(str) {
@@ -15850,7 +15850,7 @@ module.exports = require("fs");
15850
15850
 
15851
15851
  /***/ }),
15852
15852
 
15853
- /***/ 6928:
15853
+ /***/ 4547:
15854
15854
  /***/ ((module) => {
15855
15855
 
15856
15856
  "use strict";
@@ -16342,6 +16342,12 @@ const CardsGrid = ({ columns = 2, children }) => {
16342
16342
  // EXTERNAL MODULE: ./node_modules/copy-to-clipboard/index.js
16343
16343
  var copy_to_clipboard = __webpack_require__(7965);
16344
16344
  var copy_to_clipboard_default = /*#__PURE__*/__webpack_require__.n(copy_to_clipboard);
16345
+ ;// ./contexts/CodeOpts.ts
16346
+
16347
+ // used for the copyButtons prop
16348
+ const CodeOptsContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createContext)(false);
16349
+ /* harmony default export */ const CodeOpts = (CodeOptsContext);
16350
+
16345
16351
  ;// ./contexts/Theme.ts
16346
16352
 
16347
16353
  const ThemeContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createContext)('light');
@@ -16351,6 +16357,7 @@ const ThemeContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_R
16351
16357
 
16352
16358
 
16353
16359
 
16360
+
16354
16361
  // Only load CodeMirror in the browser, for SSR
16355
16362
  // apps. Necessary because of people like this:
16356
16363
  // https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
@@ -16377,8 +16384,9 @@ function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '', }) {
16377
16384
  return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("button", { ref: buttonRef, "aria-label": "Copy Code", className: `${rootClass} ${className}`, onClick: copier });
16378
16385
  }
16379
16386
  const Code = (props) => {
16380
- const { children, copyButtons, lang, value } = props;
16387
+ const { children, lang, value } = props;
16381
16388
  const theme = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(Theme);
16389
+ const copyButtons = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(CodeOpts) || props.copyButtons;
16382
16390
  const language = canonicalLanguage(lang);
16383
16391
  const codeRef = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createRef)();
16384
16392
  const codeOpts = {
@@ -103811,13 +103819,14 @@ var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
103811
103819
 
103812
103820
 
103813
103821
 
103822
+
103814
103823
  const compose = (children, ...contexts) => {
103815
103824
  return contexts.reduce((content, [Context, value]) => {
103816
103825
  return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Context.Provider, { value: value }, content);
103817
103826
  }, children);
103818
103827
  };
103819
- const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }, baseUrl = '/', theme }) => {
103820
- return compose(children, [GlossaryTerms, terms], [dist.VariablesContext, variables], [BaseUrl, baseUrl], [Theme, theme]);
103828
+ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }, baseUrl = '/', theme, copyButtons }) => {
103829
+ return compose(children, [GlossaryTerms, terms], [dist.VariablesContext, variables], [BaseUrl, baseUrl], [Theme, theme], [CodeOpts, copyButtons]);
103821
103830
  };
103822
103831
  /* harmony default export */ const contexts = (Contexts);
103823
103832
 
@@ -103878,7 +103887,7 @@ const makeUseMDXComponents = (more = {}) => {
103878
103887
 
103879
103888
  const run_run = async (string, _opts = {}) => {
103880
103889
  const { Fragment } = jsx_runtime_namespaceObject;
103881
- const { components = {}, terms, variables, baseUrl, imports = {}, theme, ...opts } = _opts;
103890
+ const { components = {}, terms, variables, baseUrl, imports = {}, theme, copyButtons, ...opts } = _opts;
103882
103891
  const tocsByTag = {};
103883
103892
  const exportedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
103884
103893
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -103912,7 +103921,7 @@ const run_run = async (string, _opts = {}) => {
103912
103921
  Toc = tocModule.default;
103913
103922
  }
103914
103923
  return {
103915
- default: (props) => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { baseUrl: baseUrl, terms: terms, theme: theme, variables: variables },
103924
+ default: (props) => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { baseUrl: baseUrl, copyButtons: copyButtons, terms: terms, theme: theme, variables: variables },
103916
103925
  external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, { ...props }))),
103917
103926
  toc,
103918
103927
  Toc: props => Toc ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,