@portabletext/editor 1.18.2 → 1.18.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.18.2",
3
+ "version": "1.18.4",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -1,10 +1,5 @@
1
1
  import {Schema as SanitySchema} from '@sanity/schema'
2
- import {
3
- defineField,
4
- defineType,
5
- type BlockDecoratorDefinition,
6
- type ObjectSchemaType,
7
- } from '@sanity/types'
2
+ import {defineField, defineType, type ObjectSchemaType} from '@sanity/types'
8
3
  import startCase from 'lodash.startcase'
9
4
  import type {PortableTextMemberSchemaTypes} from '../types/editor'
10
5
  import {createEditorSchema} from './create-editor-schema'
@@ -15,7 +10,6 @@ import {createEditorSchema} from './create-editor-schema'
15
10
  export type BaseDefinition = {
16
11
  name: string
17
12
  title?: string
18
- icon?: BlockDecoratorDefinition['icon']
19
13
  }
20
14
 
21
15
  /**
@@ -57,7 +51,6 @@ export function compileSchemaDefinition<
57
51
  // fields to objects with the name `image`
58
52
  name: blockObject.name === 'image' ? 'tmp-image' : blockObject.name,
59
53
  title: blockObject.title,
60
- icon: blockObject.icon,
61
54
  fields: [],
62
55
  }),
63
56
  ) ?? []
@@ -67,7 +60,6 @@ export function compileSchemaDefinition<
67
60
  type: 'object',
68
61
  name: inlineObject.name,
69
62
  title: inlineObject.title,
70
- icon: inlineObject.icon,
71
63
  fields: [],
72
64
  }),
73
65
  ) ?? []
@@ -86,27 +78,23 @@ export function compileSchemaDefinition<
86
78
  definition?.decorators?.map((decorator) => ({
87
79
  title: decorator.title ?? startCase(decorator.name),
88
80
  value: decorator.name,
89
- icon: decorator.icon,
90
81
  })) ?? [],
91
82
  annotations:
92
83
  definition?.annotations?.map((annotation) => ({
93
84
  name: annotation.name,
94
85
  type: 'object',
95
86
  title: annotation.title,
96
- icon: annotation.icon,
97
87
  })) ?? [],
98
88
  },
99
89
  lists:
100
90
  definition?.lists?.map((list) => ({
101
91
  value: list.name,
102
92
  title: list.title ?? startCase(list.name),
103
- icon: list.icon,
104
93
  })) ?? [],
105
94
  styles:
106
95
  definition?.styles?.map((style) => ({
107
96
  value: style.name,
108
97
  title: style.title ?? startCase(style.name),
109
- icon: style.icon,
110
98
  })) ?? [],
111
99
  },
112
100
  ],
@@ -4,10 +4,16 @@ import {looksLikeUrl} from './looks-like-url'
4
4
  test(looksLikeUrl.name, () => {
5
5
  expect(looksLikeUrl('https://example.com')).toBe(true)
6
6
  expect(looksLikeUrl('http://example.com')).toBe(true)
7
- expect(looksLikeUrl('example.com')).toBe(true)
8
7
  expect(looksLikeUrl('mailto:foo@example.com')).toBe(true)
9
8
  expect(looksLikeUrl('tel:+123456789')).toBe(true)
10
- expect(looksLikeUrl('http://example')).toBe(false)
11
- expect(looksLikeUrl('http:example')).toBe(false)
9
+ expect(looksLikeUrl('https://example')).toBe(true)
10
+ expect(looksLikeUrl('http://example')).toBe(true)
11
+ expect(looksLikeUrl('http:example')).toBe(true)
12
+
13
+ expect(looksLikeUrl('http: example')).toBe(false)
14
+ expect(looksLikeUrl('https://example. com')).toBe(false)
15
+ expect(looksLikeUrl('example.com')).toBe(false)
16
+ expect(looksLikeUrl('example. com')).toBe(false)
12
17
  expect(looksLikeUrl('a:b')).toBe(false)
18
+ expect(looksLikeUrl('a: b')).toBe(false)
13
19
  })
@@ -1,29 +1,13 @@
1
1
  export function looksLikeUrl(text: string) {
2
2
  let looksLikeUrl = false
3
3
  try {
4
- try {
5
- const url = new URL(text)
4
+ const url = new URL(text)
6
5
 
7
- if (!sensibleProtocols.includes(url.protocol)) {
8
- return false
9
- }
10
-
11
- const probablyHasTld =
12
- url.hostname.length > 0 ? url.hostname.includes('.') : true
13
-
14
- looksLikeUrl = probablyHasTld
15
- } catch {
16
- const url = new URL(`https://${text}`)
17
-
18
- if (!sensibleProtocols.includes(url.protocol)) {
19
- return false
20
- }
21
-
22
- const probablyHasTld =
23
- url.hostname.length > 0 ? url.hostname.includes('.') : true
24
-
25
- looksLikeUrl = probablyHasTld
6
+ if (!sensibleProtocols.includes(url.protocol)) {
7
+ return false
26
8
  }
9
+
10
+ looksLikeUrl = true
27
11
  } catch {}
28
12
  return looksLikeUrl
29
13
  }