@takeshape/util 11.63.3 → 11.63.7

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,9 +1,5 @@
1
1
  import type { Entity, RawDraftContentState } from 'draft-js';
2
- export type Content = {
3
- [name: string]: any;
4
- _id: string;
5
- };
6
- export type MaybeContent = Content | undefined;
2
+ import type { MaybeContent } from './types.ts';
7
3
  type DraftEntityWithData = {
8
4
  type?: string;
9
5
  mutability?: string;
@@ -1,11 +1,15 @@
1
+ /*
2
+ * The intention is to move all this to the client package in the end, but right now it's here
3
+ * to be shared between the draftjs / mdx implementations, which span the client / server differently.
4
+ */
1
5
  import { getImageUrl } from '@takeshape/routing';
2
6
  import render from 'dom-serializer';
3
7
  import he from 'he';
4
8
  import { ElementType, parseDOM } from 'htmlparser2';
5
- import escape from 'lodash/escape.js';
9
+ import _escape from 'lodash/escape.js';
6
10
  import forEach from 'lodash/forEach.js';
7
11
  import pickBy from 'lodash/pickBy.js';
8
- import unescape from 'lodash/unescape.js';
12
+ import _unescape from 'lodash/unescape.js';
9
13
  import { draftToMarkdown, markdownToDraft } from 'markdown-draft-js';
10
14
  import shortid from 'shortid';
11
15
  import Url from 'url-parse';
@@ -166,7 +170,7 @@ export function fromDraftjs(draftjs, styleItems, entityItems) {
166
170
  LINK: {
167
171
  open(entity) {
168
172
  if (entity?.data?.target === '_blank') {
169
- const url = escape(entity?.data?.url || entity?.data?.href || '');
173
+ const url = _escape(entity?.data?.url || entity?.data?.href || '');
170
174
  return `<TSExternalLink text="${EXTERNAL_LINK_MARKER}" href="${url}">`;
171
175
  }
172
176
  return '[';
@@ -390,17 +394,17 @@ function mdxToDraftjsOembed(item, entityKeyGenerator) {
390
394
  return;
391
395
  }
392
396
  return getDraftjsOembed({
393
- html: unescape(dom.attribs.html),
397
+ html: _unescape(dom.attribs.html),
394
398
  width: dom.attribs.width ? Number(dom.attribs.width) : undefined,
395
399
  height: dom.attribs.height ? Number(dom.attribs.height) : undefined,
396
- url: unescape(dom.attribs.url),
397
- author_name: unescape(dom.attribs.author_name),
398
- author_url: unescape(dom.attribs.author_url),
399
- type: unescape(dom.attribs.type),
400
+ url: _unescape(dom.attribs.url),
401
+ author_name: _unescape(dom.attribs.author_name),
402
+ author_url: _unescape(dom.attribs.author_url),
403
+ type: _unescape(dom.attribs.type),
400
404
  cache_age: Number(dom.attribs.cache_age),
401
- provider_name: unescape(dom.attribs.provider_name),
402
- provider_url: unescape(dom.attribs.provider_url),
403
- version: unescape(dom.attribs.version),
405
+ provider_name: _unescape(dom.attribs.provider_name),
406
+ provider_url: _unescape(dom.attribs.provider_url),
407
+ version: _unescape(dom.attribs.version),
404
408
  key: entityKeyGenerator(),
405
409
  depth: item.level
406
410
  });
@@ -542,8 +546,8 @@ function mdxToDraftjsImage(item, entityKeyGenerator) {
542
546
  return;
543
547
  }
544
548
  return getDraftjsImage({
545
- captionText: unescape(dom.attribs.caption).replace(/<\/?p>/g, ''),
546
- creditText: unescape(dom.attribs.credit).replace(/<\/?p>/g, ''),
549
+ captionText: _unescape(dom.attribs.caption).replace(/<\/?p>/g, ''),
550
+ creditText: _unescape(dom.attribs.credit).replace(/<\/?p>/g, ''),
547
551
  alignment: dom.attribs.alignment,
548
552
  size: dom.attribs.size,
549
553
  assetId: dom.attribs.id,
@@ -562,7 +566,7 @@ function mdxToDraftjsPullquote(item) {
562
566
  return;
563
567
  }
564
568
  return getDraftjsPullquote({
565
- text: unescape(dom.attribs.text),
569
+ text: _unescape(dom.attribs.text),
566
570
  depth: item.level
567
571
  });
568
572
  }
@@ -16,11 +16,11 @@ import 'prismjs/components/prism-sass.js';
16
16
  import 'prismjs/components/prism-scss.js';
17
17
  import 'prismjs/components/prism-markdown.js';
18
18
  import 'prismjs/components/prism-json.js';
19
- import escape from 'lodash/escape.js';
19
+ import _escape from 'lodash/escape.js';
20
20
  export const highlightCode = (code, lang) => {
21
21
  if (lang) {
22
22
  const syntax = Prism.languages[lang];
23
23
  return Prism.highlight(code, syntax, lang);
24
24
  }
25
- return escape(code);
25
+ return _escape(code);
26
26
  };
@@ -1,5 +1,5 @@
1
1
  import { type ImgixParams } from '@takeshape/routing';
2
- import type { MaybeContent } from './draftjs.ts';
2
+ import type { MaybeContent } from './types.ts';
3
3
  export declare function getApplyPrefix(prefix: string): (str: string) => string;
4
4
  type AttrsObj = {
5
5
  alt: string;
@@ -4,7 +4,7 @@ import { getImageUrl } from '@takeshape/routing';
4
4
  * to be shared between the draftjs / mdx implementations, which span the client / server differently.
5
5
  */
6
6
  import classnames from 'classnames';
7
- import escape from 'lodash/escape.js';
7
+ import _escape from 'lodash/escape.js';
8
8
  import { highlightCode } from "./highlight-code.js";
9
9
  import { isRecord } from "./types.js";
10
10
  export function getApplyPrefix(prefix) {
@@ -17,7 +17,7 @@ export function attrs(obj) {
17
17
  for (const attrName of attrNames) {
18
18
  const value = obj[attrName];
19
19
  if (value) {
20
- attrStrings.push(`${attrName}="${escape(value)}"`);
20
+ attrStrings.push(`${attrName}="${_escape(value)}"`);
21
21
  }
22
22
  }
23
23
  return attrStrings.length ? ` ${attrStrings.join(' ')}` : '';
@@ -48,7 +48,7 @@ export function imageTemplate(applyPrefix, data) {
48
48
  return `<figure${classAttr}>${image}${figCaption}</figure>`;
49
49
  }
50
50
  function renderMdx(tag, attributes, data, children) {
51
- const tagWithAttributes = `${tag} ${attributes.map((attr) => `${attr}="${escape(data[attr])}"`).join(' ')}`;
51
+ const tagWithAttributes = `${tag} ${attributes.map((attr) => `${attr}="${_escape(data[attr])}"`).join(' ')}`;
52
52
  if (children) {
53
53
  return `<${tagWithAttributes}>
54
54
  ${children.replace(/[\n\r]+$/, '')}
@@ -67,3 +67,8 @@ export declare function getSingle<T>(t?: T | T[]): Maybe<T>;
67
67
  * Test whether a provided string is numeric, e.g., '9' is numeric while 'nine' is not.
68
68
  */
69
69
  export declare function isNumericString(key: string): boolean;
70
+ export type Content = {
71
+ [name: string]: any;
72
+ _id: string;
73
+ };
74
+ export type MaybeContent = Content | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/util",
3
- "version": "11.63.3",
3
+ "version": "11.63.7",
4
4
  "description": "Shared utilities",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -46,7 +46,7 @@
46
46
  "tiny-invariant": "^1.2.0",
47
47
  "uint8array-extras": "^1.4.0",
48
48
  "url-parse": "^1.5.3",
49
- "@takeshape/routing": "11.63.3"
49
+ "@takeshape/routing": "11.63.7"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/classnames": "^2.2.9",
@@ -57,6 +57,7 @@
57
57
  "@types/mime-types": "^2.1.0",
58
58
  "@types/prismjs": "^1.16.2",
59
59
  "@types/shortid": "^0.0.29",
60
+ "domhandler": "^5.0.3",
60
61
  "stripe": "13.8.0"
61
62
  },
62
63
  "engines": {