@prosekit/extensions 0.7.2 → 0.7.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/dist/_tsup-dts-rollup.d.ts +393 -83
- package/dist/chunk-GPSAJOJA.js +188 -0
- package/dist/{chunk-PYT3MOTF.js → chunk-LVMTQOWG.js} +31 -14
- package/dist/{chunk-2JYT2MT7.js → chunk-OJCMRVEY.js} +36 -21
- package/dist/list/style.css +9 -5
- package/dist/placeholder/style.css +1 -1
- package/dist/prosekit-extensions-autocomplete.js +62 -33
- package/dist/prosekit-extensions-blockquote.js +2 -2
- package/dist/prosekit-extensions-bold.js +7 -3
- package/dist/prosekit-extensions-code-block.js +77 -41
- package/dist/prosekit-extensions-code.js +1 -1
- package/dist/prosekit-extensions-commit.js +70 -30
- package/dist/prosekit-extensions-enter-rule.js +1 -1
- package/dist/prosekit-extensions-heading.js +18 -8
- package/dist/prosekit-extensions-image.js +14 -5
- package/dist/prosekit-extensions-input-rule.js +1 -1
- package/dist/prosekit-extensions-italic.js +1 -1
- package/dist/prosekit-extensions-link.js +30 -17
- package/dist/prosekit-extensions-list.d.ts +4 -4
- package/dist/prosekit-extensions-list.js +33 -22
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-mention.js +6 -4
- package/dist/prosekit-extensions-placeholder.js +16 -7
- package/dist/prosekit-extensions-readonly.js +1 -1
- package/dist/prosekit-extensions-search.js +8 -5
- package/dist/prosekit-extensions-strike.js +1 -1
- package/dist/prosekit-extensions-table.js +68 -31
- package/dist/prosekit-extensions-text-align.d.ts +1 -0
- package/dist/prosekit-extensions-text-align.js +4 -2
- package/dist/prosekit-extensions-virtual-selection.js +11 -6
- package/package.json +9 -8
- package/dist/chunk-ZPEMHYTU.js +0 -140
@@ -1,9 +1,9 @@
|
|
1
1
|
import {
|
2
2
|
defineTextBlockEnterRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-OJCMRVEY.js";
|
4
4
|
import {
|
5
5
|
defineTextBlockInputRule
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-LVMTQOWG.js";
|
7
7
|
|
8
8
|
// src/code-block/code-block.ts
|
9
9
|
import { union } from "@prosekit/core";
|
@@ -18,10 +18,18 @@ import {
|
|
18
18
|
} from "@prosekit/core";
|
19
19
|
function defineCodeBlockCommands() {
|
20
20
|
return defineCommands({
|
21
|
-
setCodeBlock: (attrs) =>
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
setCodeBlock: (attrs) => {
|
22
|
+
return setBlockType({ type: "codeBlock", attrs });
|
23
|
+
},
|
24
|
+
insertCodeBlock: (attrs) => {
|
25
|
+
return insertNode({ type: "codeBlock", attrs });
|
26
|
+
},
|
27
|
+
toggleCodeBlock: (attrs) => {
|
28
|
+
return toggleNode({ type: "codeBlock", attrs });
|
29
|
+
},
|
30
|
+
setCodeBlockAttrs: (attrs) => {
|
31
|
+
return setNodeAttrs({ type: "codeBlock", attrs });
|
32
|
+
}
|
25
33
|
});
|
26
34
|
}
|
27
35
|
|
@@ -53,24 +61,32 @@ function defineCodeBlockKeymap() {
|
|
53
61
|
});
|
54
62
|
}
|
55
63
|
var existCodeBlock = (state, dispatch) => {
|
56
|
-
if (!state.selection.empty)
|
57
|
-
return
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
if (!state.selection.empty) {
|
65
|
+
return false;
|
66
|
+
}
|
67
|
+
const { $head } = state.selection;
|
68
|
+
const parent = $head.parent;
|
69
|
+
if (parent.isTextblock && parent.type.spec.code && $head.parentOffset === parent.content.size && parent.textContent.endsWith("\n\n")) {
|
70
|
+
const grandParent = $head.node(-1);
|
71
|
+
const insertIndex = $head.indexAfter(-1);
|
72
|
+
const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex));
|
73
|
+
if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) {
|
74
|
+
return false;
|
75
|
+
}
|
65
76
|
if (dispatch) {
|
66
|
-
|
77
|
+
const { tr } = state;
|
67
78
|
tr.delete($head.pos - 2, $head.pos);
|
68
|
-
|
69
|
-
|
79
|
+
const pos = tr.selection.$head.after();
|
80
|
+
const node = type.createAndFill();
|
81
|
+
if (node) {
|
82
|
+
tr.replaceWith(pos, pos, node);
|
83
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1));
|
84
|
+
dispatch(tr.scrollIntoView());
|
85
|
+
}
|
70
86
|
}
|
71
|
-
return
|
87
|
+
return true;
|
72
88
|
}
|
73
|
-
return
|
89
|
+
return false;
|
74
90
|
};
|
75
91
|
|
76
92
|
// src/code-block/code-block-spec.ts
|
@@ -80,8 +96,8 @@ function defineCodeBlockSpec() {
|
|
80
96
|
name: "codeBlock",
|
81
97
|
content: "text*",
|
82
98
|
group: "block",
|
83
|
-
code:
|
84
|
-
defining:
|
99
|
+
code: true,
|
100
|
+
defining: true,
|
85
101
|
marks: "",
|
86
102
|
attrs: { language: { default: "" } },
|
87
103
|
parseDOM: [
|
@@ -94,7 +110,8 @@ function defineCodeBlockSpec() {
|
|
94
110
|
}
|
95
111
|
],
|
96
112
|
toDOM(node) {
|
97
|
-
|
113
|
+
const attrs = node.attrs;
|
114
|
+
return ["pre", { "data-language": attrs.language }, ["code", 0]];
|
98
115
|
}
|
99
116
|
});
|
100
117
|
}
|
@@ -125,44 +142,63 @@ function defineCodeBlockHighlight({
|
|
125
142
|
import { createParser } from "prosemirror-highlight/shiki";
|
126
143
|
|
127
144
|
// src/code-block/shiki-highlighter.ts
|
128
|
-
var highlighter
|
145
|
+
var highlighter;
|
146
|
+
var loadedLangs = /* @__PURE__ */ new Set();
|
147
|
+
var loadedThemes = /* @__PURE__ */ new Set();
|
129
148
|
async function createHighlighter(options) {
|
130
|
-
|
131
|
-
|
149
|
+
const { getSingletonHighlighter } = await import("./shiki-import-UFUFVKJ2.js");
|
150
|
+
if (!highlighter) {
|
151
|
+
highlighter = await getSingletonHighlighter(options);
|
152
|
+
}
|
132
153
|
}
|
133
154
|
async function loadLanguages(langs) {
|
134
|
-
for (
|
155
|
+
for (const lang of langs) {
|
135
156
|
if (!highlighter) break;
|
136
|
-
await highlighter.loadLanguage(lang)
|
157
|
+
await highlighter.loadLanguage(lang);
|
158
|
+
loadedLangs.add(lang);
|
137
159
|
}
|
138
160
|
}
|
139
161
|
async function loadThemes(themes) {
|
140
|
-
for (
|
162
|
+
for (const theme of themes) {
|
141
163
|
if (!highlighter) break;
|
142
|
-
await highlighter.loadTheme(theme)
|
164
|
+
await highlighter.loadTheme(theme);
|
165
|
+
loadedThemes.add(theme);
|
143
166
|
}
|
144
167
|
}
|
145
168
|
function prepareHighlighter(options) {
|
146
|
-
if (!highlighter)
|
169
|
+
if (!highlighter) {
|
147
170
|
return { promise: createHighlighter(options) };
|
148
|
-
|
149
|
-
|
171
|
+
}
|
172
|
+
const langs = options.langs.filter((lang) => !loadedLangs.has(lang));
|
173
|
+
if (langs.length > 0) {
|
150
174
|
return { promise: loadLanguages(langs) };
|
151
|
-
|
152
|
-
|
175
|
+
}
|
176
|
+
const themes = options.themes.filter((theme) => !loadedThemes.has(theme));
|
177
|
+
if (themes.length > 0) {
|
178
|
+
return { promise: loadThemes(themes) };
|
179
|
+
}
|
180
|
+
return { highlighter };
|
153
181
|
}
|
154
182
|
|
155
183
|
// src/code-block/shiki-parser.ts
|
156
184
|
function createLazyParser(highlighterOptions) {
|
157
185
|
let parser;
|
158
|
-
|
159
|
-
|
186
|
+
prepareHighlighter(highlighterOptions);
|
187
|
+
return function lazyParser(options) {
|
188
|
+
const language = options.language || "";
|
189
|
+
const { highlighter: highlighter2, promise } = prepareHighlighter({
|
160
190
|
langs: [language],
|
161
191
|
themes: highlighterOptions.themes
|
162
192
|
});
|
163
|
-
|
164
|
-
|
165
|
-
}
|
193
|
+
if (!highlighter2) {
|
194
|
+
return promise;
|
195
|
+
}
|
196
|
+
if (!parser) {
|
197
|
+
parser = createParser(highlighter2, {
|
198
|
+
theme: highlighterOptions.themes[0]
|
199
|
+
});
|
200
|
+
}
|
201
|
+
return parser(options);
|
166
202
|
};
|
167
203
|
}
|
168
204
|
|
@@ -172,7 +208,7 @@ function defineCodeBlockShiki({
|
|
172
208
|
langs = ["text"],
|
173
209
|
langAlias = {}
|
174
210
|
} = {}) {
|
175
|
-
|
211
|
+
const parser = createLazyParser({ themes, langs, langAlias });
|
176
212
|
return defineCodeBlockHighlight({ parser });
|
177
213
|
}
|
178
214
|
|
@@ -16,23 +16,31 @@ import { Step } from "@prosekit/pm/transform";
|
|
16
16
|
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
17
17
|
import { ChangeSet } from "prosemirror-changeset";
|
18
18
|
function getChanges(doc, parent, steps) {
|
19
|
-
|
19
|
+
const initSet = ChangeSet.create(parent);
|
20
|
+
const currSet = initSet.addSteps(
|
20
21
|
doc,
|
21
22
|
steps.map((step) => step.getMap()),
|
22
23
|
null
|
23
|
-
)
|
24
|
+
);
|
25
|
+
return currSet.changes;
|
24
26
|
}
|
25
27
|
function renderDivWeight(view) {
|
26
|
-
|
28
|
+
const document = view.dom.ownerDocument;
|
29
|
+
return document.createElement("div");
|
27
30
|
}
|
28
31
|
function decorateDeletionSlice(slice) {
|
29
32
|
let { openStart, openEnd, content } = slice;
|
30
|
-
|
31
|
-
openStart
|
32
|
-
|
33
|
+
while (openStart > 0 && openEnd > 0 && content.childCount === 1) {
|
34
|
+
openStart--;
|
35
|
+
openEnd--;
|
36
|
+
content = content.child(0).content;
|
37
|
+
}
|
38
|
+
if (content.childCount === 0) {
|
33
39
|
return [];
|
40
|
+
}
|
34
41
|
if (openStart > 0 && openEnd > 0 && content.childCount === 2) {
|
35
|
-
|
42
|
+
const head = Fragment.from([content.child(0)]);
|
43
|
+
const tail = Fragment.from([content.child(1)]);
|
36
44
|
return [
|
37
45
|
...decorateDeletionSlice(new Slice(head, openStart, openStart)),
|
38
46
|
renderDivWeight,
|
@@ -40,32 +48,44 @@ function decorateDeletionSlice(slice) {
|
|
40
48
|
];
|
41
49
|
}
|
42
50
|
if (openStart > 0 && content.childCount >= 2) {
|
43
|
-
|
51
|
+
const nodes = collectNodes(content);
|
52
|
+
const head = Fragment.from(nodes.slice(0, 1));
|
53
|
+
const body = Fragment.from(nodes.slice(1));
|
44
54
|
return [
|
45
55
|
...decorateDeletionSlice(new Slice(head, openStart, openStart)),
|
46
56
|
...decorateDeletionSlice(new Slice(body, 0, openEnd))
|
47
57
|
];
|
48
58
|
}
|
49
59
|
if (openEnd > 0 && content.childCount >= 2) {
|
50
|
-
|
60
|
+
const nodes = collectNodes(content);
|
61
|
+
const body = Fragment.from(nodes.slice(0, -1));
|
62
|
+
const tail = Fragment.from(nodes.slice(-1));
|
51
63
|
return [
|
52
64
|
...decorateDeletionSlice(new Slice(body, openStart, 0)),
|
53
65
|
...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))
|
54
66
|
];
|
55
67
|
}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
68
|
+
const schema = content.child(0).type.schema;
|
69
|
+
const isInline = content.child(0).isInline;
|
70
|
+
const render = (view) => {
|
71
|
+
const document = view.dom.ownerDocument;
|
72
|
+
const element = document.createElement(isInline ? "span" : "div");
|
73
|
+
const serializer = DOMSerializer.fromSchema(schema);
|
74
|
+
serializer.serializeFragment(content, { document }, element);
|
75
|
+
element.classList.add("prosekit-commit-deletion");
|
76
|
+
return element;
|
77
|
+
};
|
78
|
+
return [render];
|
61
79
|
}
|
62
80
|
function decorateDeletion(doc, from, to, pos) {
|
63
|
-
|
81
|
+
const slice = doc.slice(from, to);
|
82
|
+
const renders = decorateDeletionSlice(slice);
|
83
|
+
const count = renders.length;
|
64
84
|
return renders.map(
|
65
85
|
(render, index) => Decoration.widget(pos, render, {
|
66
86
|
side: -20 - count + index,
|
67
87
|
// Ensure the text in the decoration is able to be selected.
|
68
|
-
ignoreSelection:
|
88
|
+
ignoreSelection: true
|
69
89
|
})
|
70
90
|
);
|
71
91
|
}
|
@@ -73,27 +93,42 @@ function decorateAddition(from, to) {
|
|
73
93
|
return Decoration.inline(from, to, { class: "prosekit-commit-addition" });
|
74
94
|
}
|
75
95
|
function decorateChange(prev, change) {
|
76
|
-
|
77
|
-
|
96
|
+
const { fromA, toA, fromB, toB } = change;
|
97
|
+
const decorations = [];
|
98
|
+
if (fromA < toA) {
|
99
|
+
decorations.push(...decorateDeletion(prev, fromA, toA, fromB));
|
100
|
+
}
|
101
|
+
if (fromB < toB) {
|
102
|
+
decorations.push(decorateAddition(fromB, toB));
|
103
|
+
}
|
104
|
+
return decorations;
|
78
105
|
}
|
79
106
|
function decorateCommit(doc, parent, steps) {
|
80
|
-
|
107
|
+
const changes = getChanges(doc, parent, steps);
|
108
|
+
const decorations = changes.flatMap(
|
81
109
|
(change) => decorateChange(parent, change)
|
82
110
|
);
|
83
111
|
return DecorationSet.create(doc, decorations);
|
84
112
|
}
|
85
113
|
function defineCommitDecoration(commit) {
|
86
|
-
|
114
|
+
const key = new PluginKey("prosekit-commit-decoration");
|
87
115
|
return definePlugin(({ schema }) => {
|
88
|
-
|
116
|
+
const parent = schema.nodeFromJSON(commit.parent);
|
117
|
+
const steps = commit.steps.map((step) => Step.fromJSON(schema, step));
|
89
118
|
return new ProseMirrorPlugin({
|
90
119
|
key,
|
91
120
|
state: {
|
92
|
-
init: (_, instance) =>
|
93
|
-
|
121
|
+
init: (_, instance) => {
|
122
|
+
return decorateCommit(instance.doc, parent, steps);
|
123
|
+
},
|
124
|
+
apply: (tr, deco) => {
|
125
|
+
return deco.map(tr.mapping, tr.doc);
|
126
|
+
}
|
94
127
|
},
|
95
128
|
props: {
|
96
|
-
decorations: (state) =>
|
129
|
+
decorations: (state) => {
|
130
|
+
return key.getState(state);
|
131
|
+
}
|
97
132
|
}
|
98
133
|
});
|
99
134
|
});
|
@@ -115,30 +150,35 @@ var CommitRecorder = class {
|
|
115
150
|
* will be returned if there is no change.
|
116
151
|
*/
|
117
152
|
commit() {
|
118
|
-
if (!this.parent || !this.doc || this.steps.length === 0 || this.parent.eq(this.doc))
|
153
|
+
if (!this.parent || !this.doc || this.steps.length === 0 || this.parent.eq(this.doc)) {
|
119
154
|
return null;
|
120
|
-
|
155
|
+
}
|
156
|
+
const commit = {
|
121
157
|
doc: jsonFromNode(this.doc),
|
122
158
|
parent: jsonFromNode(this.parent),
|
123
159
|
steps: this.steps.map((step) => step.toJSON())
|
124
160
|
};
|
125
|
-
|
161
|
+
this.init(this.doc);
|
162
|
+
return commit;
|
126
163
|
}
|
127
164
|
/**
|
128
165
|
* @internal
|
129
166
|
*/
|
130
167
|
init(doc) {
|
131
|
-
this.doc = doc
|
168
|
+
this.doc = doc;
|
169
|
+
this.parent = doc;
|
170
|
+
this.steps = [];
|
132
171
|
}
|
133
172
|
/**
|
134
173
|
* @internal
|
135
174
|
*/
|
136
175
|
apply(tr) {
|
137
|
-
this.steps.push(...tr.steps)
|
176
|
+
this.steps.push(...tr.steps);
|
177
|
+
this.doc = tr.doc;
|
138
178
|
}
|
139
179
|
};
|
140
180
|
function defineCommitRecorder(commitRecorder) {
|
141
|
-
|
181
|
+
const key = new PluginKey("prosekit-commit-recorder");
|
142
182
|
return definePlugin(
|
143
183
|
new ProseMirrorPlugin({
|
144
184
|
key,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineTextBlockInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-LVMTQOWG.js";
|
4
4
|
|
5
5
|
// src/heading/index.ts
|
6
6
|
import { union } from "@prosekit/core";
|
@@ -14,9 +14,15 @@ import {
|
|
14
14
|
} from "@prosekit/core";
|
15
15
|
function defineHeadingCommands() {
|
16
16
|
return defineCommands({
|
17
|
-
setHeading: (attrs) =>
|
18
|
-
|
19
|
-
|
17
|
+
setHeading: (attrs) => {
|
18
|
+
return setBlockType({ type: "heading", attrs });
|
19
|
+
},
|
20
|
+
insertHeading: (attrs) => {
|
21
|
+
return insertNode({ type: "heading", attrs });
|
22
|
+
},
|
23
|
+
toggleHeading: (attrs) => {
|
24
|
+
return toggleNode({ type: "heading", attrs });
|
25
|
+
}
|
20
26
|
});
|
21
27
|
}
|
22
28
|
|
@@ -27,7 +33,8 @@ function defineHeadingInputRule() {
|
|
27
33
|
type: "heading",
|
28
34
|
attrs: (match) => {
|
29
35
|
var _a, _b;
|
30
|
-
|
36
|
+
const level = (_b = (_a = match[1]) == null ? void 0 : _a.length) != null ? _b : 1;
|
37
|
+
return { level };
|
31
38
|
}
|
32
39
|
});
|
33
40
|
}
|
@@ -44,8 +51,11 @@ function toggleHeadingKeybinding(level) {
|
|
44
51
|
return withSkipCodeBlock(toggleNode2({ type: "heading", attrs: { level } }));
|
45
52
|
}
|
46
53
|
var backspaceUnsetHeading = (state, dispatch, view) => {
|
47
|
-
|
48
|
-
|
54
|
+
const $pos = isAtBlockStart(state, view);
|
55
|
+
if (($pos == null ? void 0 : $pos.parent.type.name) === "heading") {
|
56
|
+
return unsetBlockType()(state, dispatch, view);
|
57
|
+
}
|
58
|
+
return false;
|
49
59
|
};
|
50
60
|
function defineHeadingKeymap() {
|
51
61
|
return defineKeymap({
|
@@ -67,7 +77,7 @@ function defineHeadingSpec() {
|
|
67
77
|
attrs: { level: { default: 1 } },
|
68
78
|
content: "inline*",
|
69
79
|
group: "block",
|
70
|
-
defining:
|
80
|
+
defining: true,
|
71
81
|
parseDOM: [
|
72
82
|
{ tag: "h1", attrs: { level: 1 } },
|
73
83
|
{ tag: "h2", attrs: { level: 2 } },
|
@@ -12,22 +12,31 @@ function defineImageSpec() {
|
|
12
12
|
src: { default: null }
|
13
13
|
},
|
14
14
|
group: "block",
|
15
|
-
defining:
|
16
|
-
draggable:
|
15
|
+
defining: true,
|
16
|
+
draggable: true,
|
17
17
|
parseDOM: [
|
18
18
|
{
|
19
19
|
tag: "img[src]",
|
20
|
-
getAttrs: (element) =>
|
20
|
+
getAttrs: (element) => {
|
21
|
+
if (typeof element === "string") {
|
22
|
+
return { src: null };
|
23
|
+
}
|
24
|
+
const src = element.getAttribute("src") || null;
|
25
|
+
return { src };
|
26
|
+
}
|
21
27
|
}
|
22
28
|
],
|
23
29
|
toDOM(node) {
|
24
|
-
|
30
|
+
const attrs = node.attrs;
|
31
|
+
return ["img", attrs];
|
25
32
|
}
|
26
33
|
});
|
27
34
|
}
|
28
35
|
function defineImageCommands() {
|
29
36
|
return defineCommands({
|
30
|
-
insertImage: (attrs) =>
|
37
|
+
insertImage: (attrs) => {
|
38
|
+
return insertNode({ type: "image", attrs });
|
39
|
+
}
|
31
40
|
});
|
32
41
|
}
|
33
42
|
function defineImage() {
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-GPSAJOJA.js";
|
4
4
|
import {
|
5
5
|
defineEnterRule
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-OJCMRVEY.js";
|
7
7
|
import {
|
8
8
|
defineInputRule
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-LVMTQOWG.js";
|
10
10
|
|
11
11
|
// src/link/index.ts
|
12
12
|
import {
|
@@ -21,29 +21,41 @@ import {
|
|
21
21
|
import { InputRule } from "@prosekit/pm/inputrules";
|
22
22
|
|
23
23
|
// src/link/link-regex.ts
|
24
|
-
var TLD_RE_PATTERN = "a(?:a(?:a|rp)|b(?:arth|b(?:ott|vie)?|c|le|ogado|udhabi)|c(?:ademy|c(?:enture|ountants?)|o|tor)?|d(?:s|ult)?|e(?:g|ro|tna)?|f(?:l|rica)?|g(?:akhan|ency)?|i(?:g|r(?:bus|force|tel))?|kdn|l(?:faromeo|i(?:baba|pay)|l(?:finanz|state|y)|s(?:ace|tom))?|m(?:azon|e(?:rican(?:express|family)|x)|fam|ica|sterdam)?|n(?:alytics|droid|quan|z)|ol?|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:a(?:b|mco)|chi|my|pa|te?)?|s(?:da|ia|sociates)?|t(?:hleta|torney)?|u(?:ction|di(?:ble|o)?|spost|t(?:hor|os?))?|vianca|ws?|xa?|z(?:ure)?)|b(?:a(?:by|idu|n(?:a(?:mex|narepublic)|d|k)|r(?:c(?:elona|lay(?:card|s))|efoot|gains)?|s(?:eball|ketball)|uhaus|yern)?|b(?:c|t|va)?|c[gn]|d|e(?:a(?:ts|uty)|er|ntley|rlin|st(?:buy)?|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ngo?|o|z)?|j|l(?:ack(?:friday)?|o(?:ckbuster|g|omberg)|ue)|m[sw]?|n(?:pparibas)?|o(?:ats|ehringer|fa|m|nd|o(?:k(?:ing)?)?|s(?:ch|t(?:ik|on))|t|utique|x)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:ild(?:ers)?|siness|y|zz)|v|w|y|zh?)|c(?:a(?:b|fe|l(?:l|vinklein)?|m(?:era|p)?|non|p(?:etown|ital(?:one)?)|r(?:avan|ds|e(?:ers?)?|s)?|s(?:a|e|h|ino)|t(?:ering|holic)?)?|b(?:a|n|re|s)|c|d|e(?:nter|o|rn)|f[ad]?|g|h(?:a(?:n(?:el|nel)|rity|se|t)|eap|intai|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:adel|ic?|y(?:eats)?))?|k|l(?:aims|eaning|i(?:ck|ni(?:c|que))|o(?:thing|ud)|ub(?:med)?)?|m|n|o(?:ach|des|ffee|l(?:lege|ogne)|m(?:cast|m(?:bank|unity)|p(?:a(?:ny|re)|uter)|sec)?|n(?:dos|s(?:truction|ulting)|t(?:act|ractors))|o(?:king(?:channel)?|l|p)|rsica|u(?:ntry|pons?|rses))?|pa|r(?:edit(?:card|union)?|icket|own|s|uises?)?|u(?:isinella)?|v|w|x|y(?:mru|ou)?|z)|d(?:a(?:bur|d|nce|t(?:a|e|ing|sun)|y)|clk|ds|e(?:al(?:er|s)?|gree|l(?:ivery|l|oitte|ta)|mocrat|nt(?:al|ist)|si(?:gn)?|v)?|hl|i(?:amonds|et|gital|rect(?:ory)?|s(?:co(?:unt|ver)|h)|y)|j|k|m|np|o(?:c(?:s|tor)|g|mains|t|wnload)?|rive|tv|u(?:bai|nlop|pont|rban)|v(?:ag|r)|z)|e(?:a(?:rth|t)|co?|d(?:eka|u(?:cation)?)|e|g|m(?:ail|erck)|n(?:ergy|gineer(?:ing)?|terprises)|pson|quipment|r(?:icsson|ni)?|s(?:q|tate)?|t(?:isalat)?|u(?:rovision|s)?|vents|x(?:change|p(?:ert|osed|ress)|traspace))|f(?:a(?:ge|i(?:l|rwinds|th)|mily|ns?|rm(?:ers)?|s(?:hion|t))|e(?:dex|edback|rr(?:ari|ero))|i(?:at|d(?:elity|o)|lm|na(?:l|nc(?:e|ial))|r(?:e(?:stone)?|mdale)|sh(?:ing)?|t(?:ness)?)?|j|k|l(?:i(?:ckr|ghts|r)|o(?:rist|wers)|y)|m|o(?:o(?:d(?:network)?|tball)?|r(?:d|ex|sale|um)|undation|x)?|r(?:e(?:e|senius)|l|o(?:gans|nt(?:door|ier)))?|tr|u(?:jitsu|nd?|rniture|tbol)|yi)|g(?:a(?:l(?:l(?:ery|o|up))?|mes?|p|rden|y)?|b(?:iz)?|dn?|e(?:a|nt(?:ing)?|orge)?|f|g(?:ee)?|h|i(?:fts?|v(?:es|ing))?|l(?:ass|e|ob(?:al|o))?|m(?:ail|bh|o|x)?|n|o(?:daddy|l(?:d(?:point)?|f)|o(?:dyear|g(?:le)?)?|p|t|v)|p|q|r(?:a(?:inger|phics|tis)|een|ipe|o(?:cery|up))?|s|t|u(?:ardian|cci|ge|i(?:de|tars)|ru)?|w|y)|h(?:a(?:ir|mburg|ngout|us)|bo|dfc(?:bank)?|e(?:alth(?:care)?|l(?:p|sinki)|r(?:e|mes))|gtv|i(?:phop|samitsu|tachi|v)|kt?|m|n|o(?:ckey|l(?:dings|iday)|me(?:depot|goods|s(?:ense)?)|nda|rse|s(?:pital|t(?:ing)?)|t(?:el(?:es|s)|mail)?|use|w)|r|sbc|t|u(?:ghes)?|y(?:att|undai))|i(?:bm|c(?:bc|e|u)|d|e(?:ee)?|fm|kano|l|m(?:amat|db|mo(?:bilien)?)?|n(?:c|dustries|f(?:initi|o)|g|k|s(?:titute|ur(?:ance|e))|t(?:ernational|uit)?|vestments)?|o|piranga|q|r(?:ish)?|s(?:maili|t(?:anbul)?)?|t(?:au|v)?)|j(?:a(?:guar|va)|cb|e(?:ep|tzt|welry)?|io|ll|mp?|nj|o(?:b(?:s|urg)|t|y)?|p(?:morgan|rs)?|u(?:egos|niper))|k(?:aufen|ddi|e(?:rry(?:hotels|logistics|properties))?|fh|g|h|i(?:a|ds|m|nd(?:er|le)|tchen|wi)?|m|n|o(?:eln|matsu|sher)|p(?:mg|n)?|r(?:d|ed)?|uokgroup|w|y(?:oto)?|z)|l(?:a(?:caixa|m(?:borghini|er)|n(?:c(?:aster|ia)|d(?:rover)?|xess)|salle|t(?:ino|robe)?|w(?:yer)?)?|b|c|ds|e(?:ase|clerc|frak|g(?:al|o)|xus)|gbt|i(?:dl|fe(?:insurance|style)?|ghting|ke|lly|m(?:ited|o)|n(?:coln|de|k)|psy|v(?:e|ing))?|k|l[cp]|o(?:ans?|c(?:ker|us)|l|ndon|tt[eo]|ve)|pl(?:financial)?|r|s|t(?:da?)?|u(?:ndbeck|x(?:e|ury))?|v|y)|m(?:a(?:cys|drid|i(?:f|son)|keup|n(?:agement|go)?|p|r(?:ket(?:ing|s)?|riott|shalls)|serati|ttel)?|ba|c(?:kinsey)?|d|e(?:d(?:ia)?|et|lbourne|m(?:e|orial)|nu?|rckmsd)?|g|h|i(?:ami|crosoft|l|n[it]|t(?:subishi)?)|k|l[bs]?|ma?|n|o(?:bi(?:le)?|da|e|i|m|n(?:ash|ey|ster)|r(?:mon|tgage)|scow|to(?:rcycles)?|v(?:ie)?)?|p|q|r|sd?|t[nr]?|u(?:s(?:eum|ic)|tual)?|v|w|x|y|z)|n(?:a(?:b|goya|me|tura|vy)?|ba|c|e(?:c|t(?:bank|flix|work)?|ustar|ws?|x(?:t(?:direct)?|us))?|fl?|go?|hk|i(?:co|k(?:e|on)|nja|ssa[ny])?|l|o(?:kia|rt(?:hwesternmutual|on)|w(?:ruz|tv)?)?|p|r[aw]?|tt|u|yc|z)|o(?:b(?:i|server)|ffice|kinawa|l(?:ayan(?:group)?|dnavy|lo)|m(?:ega)?|n(?:e|g|l(?:ine)?)|oo|pen|r(?:a(?:cle|nge)|g(?:anic)?|igins)|saka|t(?:suka|t)|vh)|p(?:a(?:ge|nasonic|r(?:is|s|t(?:ners|s|y))|ssagens|y)?|ccw|et?|f(?:izer)?|g|h(?:armacy|d|ilips|o(?:ne|to(?:graphy|s)?)|ysio)?|i(?:c(?:s|t(?:et|ures))|d|n[gk]?|oneer|zza)|k|l(?:a(?:ce|y(?:station)?)|u(?:mbing|s))?|m|nc?|o(?:hl|ker|litie|rn|st)|r(?:a(?:merica|xi)|ess|ime|o(?:d(?:uctions)?|f|gressive|mo|pert(?:ies|y)|tection)?|u(?:dential)?)?|s|t|ub|wc?|y)|q(?:a|pon|ue(?:bec|st))|r(?:a(?:cing|dio)|e(?:a(?:d|l(?:estate|t(?:or|y)))|cipes|d(?:stone|umbrella)?|hab|i(?:sen?|t)|liance|n(?:t(?:als)?)?|p(?:air|ort|ublican)|st(?:aurant)?|views?|xroth)?|i(?:c(?:h(?:ardli)?|oh)|l|o|p)|o(?:c(?:her|ks)|deo|gers|om)?|s(?:vp)?|u(?:gby|hr|n)?|we?|yukyu)|s(?:a(?:arland|fe(?:ty)?|kura|l(?:e|on)|ms(?:club|ung)|n(?:dvik(?:coromant)?|ofi)|p|rl|s|ve|xo)?|b[is]?|c(?:a|b|h(?:aeffler|midt|o(?:larships|ol)|ule|warz)|ience|ot)?|d|e(?:a(?:rch|t)|cur(?:e|ity)|ek|lect|ner|rvices|ven|w|xy?)?|fr|g|h(?:a(?:ngrila|rp|w)|ell|i(?:a|ksha)|o(?:es|p(?:ping)?|uji|w(?:time)?))?|i(?:lk|n(?:a|gles)|te)?|j|k(?:in?|y(?:pe)?)?|l(?:ing)?|m(?:art|ile)?|n(?:cf)?|o(?:c(?:cer|ial)|ft(?:bank|ware)|hu|l(?:ar|utions)|n[gy]|y)?|p(?:a(?:ce)?|o(?:rt|t))|rl?|s|t(?:a(?:da|ples|r|te(?:bank|farm))|c(?:group)?|o(?:ckholm|r(?:age|e))|ream|ud(?:io|y)|yle)?|u(?:cks|pp(?:l(?:ies|y)|ort)|r(?:f|gery)|zuki)?|v|w(?:atch|iss)|x|y(?:dney|stems)?|z)|t(?:a(?:b|ipei|lk|obao|rget|t(?:a(?:motors|r)|too)|xi?)|ci?|dk?|e(?:am|ch(?:nology)?|l|masek|nnis|va)|f|g|h(?:d|eat(?:er|re))?|i(?:aa|ckets|enda|ffany|ps|r(?:es|ol))|j(?:maxx|x)?|k(?:maxx)?|l|m(?:all)?|n|o(?:day|kyo|ols|p|ray|shiba|tal|urs|wn|y(?:ota|s))?|r(?:a(?:d(?:e|ing)|ining|vel(?:channel|ers(?:insurance)?)?)|ust|v)?|t|u(?:be|i|nes|shu)|vs?|w|z)|u(?:a|b(?:ank|s)|g|k|n(?:i(?:com|versity)|o)|ol|ps|s|y|z)|v(?:a(?:cations|n(?:a|guard))?|c|e(?:gas|ntures|r(?:isign|sicherung)|t)?|g|i(?:ajes|deo|g|king|llas|n|p|rgin|s(?:a|ion)|v[ao])?|laanderen|n|o(?:dka|l(?:kswagen|vo)|t(?:e|ing|o)|yage)|u(?:elos)?)|w(?:a(?:l(?:es|mart|ter)|ng(?:gou)?|tch(?:es)?)|e(?:ather(?:channel)?|b(?:cam|er|site)|d(?:ding)?|i(?:bo|r))|f|hoswho|i(?:en|ki|lliamhill|n(?:dows|e|ners)?)|me|o(?:lterskluwer|odside|r(?:ks?|ld)|w)|s|t[cf])|x(?:box|erox|finity|i(?:huan|n)|xx|yz)|y(?:a(?:chts|hoo|maxun|ndex)|e|o(?:dobashi|ga|kohama|u(?:tube)?)|t|un)|z(?:a(?:ppos|ra)?|ero|ip|m|one|uerich|w)"
|
24
|
+
var TLD_RE_PATTERN = "a(?:a(?:a|rp)|b(?:arth|b(?:ott|vie)?|c|le|ogado|udhabi)|c(?:ademy|c(?:enture|ountants?)|o|tor)?|d(?:s|ult)?|e(?:g|ro|tna)?|f(?:l|rica)?|g(?:akhan|ency)?|i(?:g|r(?:bus|force|tel))?|kdn|l(?:faromeo|i(?:baba|pay)|l(?:finanz|state|y)|s(?:ace|tom))?|m(?:azon|e(?:rican(?:express|family)|x)|fam|ica|sterdam)?|n(?:alytics|droid|quan|z)|ol?|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:a(?:b|mco)|chi|my|pa|te?)?|s(?:da|ia|sociates)?|t(?:hleta|torney)?|u(?:ction|di(?:ble|o)?|spost|t(?:hor|os?))?|vianca|ws?|xa?|z(?:ure)?)|b(?:a(?:by|idu|n(?:a(?:mex|narepublic)|d|k)|r(?:c(?:elona|lay(?:card|s))|efoot|gains)?|s(?:eball|ketball)|uhaus|yern)?|b(?:c|t|va)?|c[gn]|d|e(?:a(?:ts|uty)|er|ntley|rlin|st(?:buy)?|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ngo?|o|z)?|j|l(?:ack(?:friday)?|o(?:ckbuster|g|omberg)|ue)|m[sw]?|n(?:pparibas)?|o(?:ats|ehringer|fa|m|nd|o(?:k(?:ing)?)?|s(?:ch|t(?:ik|on))|t|utique|x)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:ild(?:ers)?|siness|y|zz)|v|w|y|zh?)|c(?:a(?:b|fe|l(?:l|vinklein)?|m(?:era|p)?|non|p(?:etown|ital(?:one)?)|r(?:avan|ds|e(?:ers?)?|s)?|s(?:a|e|h|ino)|t(?:ering|holic)?)?|b(?:a|n|re|s)|c|d|e(?:nter|o|rn)|f[ad]?|g|h(?:a(?:n(?:el|nel)|rity|se|t)|eap|intai|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:adel|ic?|y(?:eats)?))?|k|l(?:aims|eaning|i(?:ck|ni(?:c|que))|o(?:thing|ud)|ub(?:med)?)?|m|n|o(?:ach|des|ffee|l(?:lege|ogne)|m(?:cast|m(?:bank|unity)|p(?:a(?:ny|re)|uter)|sec)?|n(?:dos|s(?:truction|ulting)|t(?:act|ractors))|o(?:king(?:channel)?|l|p)|rsica|u(?:ntry|pons?|rses))?|pa|r(?:edit(?:card|union)?|icket|own|s|uises?)?|u(?:isinella)?|v|w|x|y(?:mru|ou)?|z)|d(?:a(?:bur|d|nce|t(?:a|e|ing|sun)|y)|clk|ds|e(?:al(?:er|s)?|gree|l(?:ivery|l|oitte|ta)|mocrat|nt(?:al|ist)|si(?:gn)?|v)?|hl|i(?:amonds|et|gital|rect(?:ory)?|s(?:co(?:unt|ver)|h)|y)|j|k|m|np|o(?:c(?:s|tor)|g|mains|t|wnload)?|rive|tv|u(?:bai|nlop|pont|rban)|v(?:ag|r)|z)|e(?:a(?:rth|t)|co?|d(?:eka|u(?:cation)?)|e|g|m(?:ail|erck)|n(?:ergy|gineer(?:ing)?|terprises)|pson|quipment|r(?:icsson|ni)?|s(?:q|tate)?|t(?:isalat)?|u(?:rovision|s)?|vents|x(?:change|p(?:ert|osed|ress)|traspace))|f(?:a(?:ge|i(?:l|rwinds|th)|mily|ns?|rm(?:ers)?|s(?:hion|t))|e(?:dex|edback|rr(?:ari|ero))|i(?:at|d(?:elity|o)|lm|na(?:l|nc(?:e|ial))|r(?:e(?:stone)?|mdale)|sh(?:ing)?|t(?:ness)?)?|j|k|l(?:i(?:ckr|ghts|r)|o(?:rist|wers)|y)|m|o(?:o(?:d(?:network)?|tball)?|r(?:d|ex|sale|um)|undation|x)?|r(?:e(?:e|senius)|l|o(?:gans|nt(?:door|ier)))?|tr|u(?:jitsu|nd?|rniture|tbol)|yi)|g(?:a(?:l(?:l(?:ery|o|up))?|mes?|p|rden|y)?|b(?:iz)?|dn?|e(?:a|nt(?:ing)?|orge)?|f|g(?:ee)?|h|i(?:fts?|v(?:es|ing))?|l(?:ass|e|ob(?:al|o))?|m(?:ail|bh|o|x)?|n|o(?:daddy|l(?:d(?:point)?|f)|o(?:dyear|g(?:le)?)?|p|t|v)|p|q|r(?:a(?:inger|phics|tis)|een|ipe|o(?:cery|up))?|s|t|u(?:ardian|cci|ge|i(?:de|tars)|ru)?|w|y)|h(?:a(?:ir|mburg|ngout|us)|bo|dfc(?:bank)?|e(?:alth(?:care)?|l(?:p|sinki)|r(?:e|mes))|gtv|i(?:phop|samitsu|tachi|v)|kt?|m|n|o(?:ckey|l(?:dings|iday)|me(?:depot|goods|s(?:ense)?)|nda|rse|s(?:pital|t(?:ing)?)|t(?:el(?:es|s)|mail)?|use|w)|r|sbc|t|u(?:ghes)?|y(?:att|undai))|i(?:bm|c(?:bc|e|u)|d|e(?:ee)?|fm|kano|l|m(?:amat|db|mo(?:bilien)?)?|n(?:c|dustries|f(?:initi|o)|g|k|s(?:titute|ur(?:ance|e))|t(?:ernational|uit)?|vestments)?|o|piranga|q|r(?:ish)?|s(?:maili|t(?:anbul)?)?|t(?:au|v)?)|j(?:a(?:guar|va)|cb|e(?:ep|tzt|welry)?|io|ll|mp?|nj|o(?:b(?:s|urg)|t|y)?|p(?:morgan|rs)?|u(?:egos|niper))|k(?:aufen|ddi|e(?:rry(?:hotels|logistics|properties))?|fh|g|h|i(?:a|ds|m|nd(?:er|le)|tchen|wi)?|m|n|o(?:eln|matsu|sher)|p(?:mg|n)?|r(?:d|ed)?|uokgroup|w|y(?:oto)?|z)|l(?:a(?:caixa|m(?:borghini|er)|n(?:c(?:aster|ia)|d(?:rover)?|xess)|salle|t(?:ino|robe)?|w(?:yer)?)?|b|c|ds|e(?:ase|clerc|frak|g(?:al|o)|xus)|gbt|i(?:dl|fe(?:insurance|style)?|ghting|ke|lly|m(?:ited|o)|n(?:coln|de|k)|psy|v(?:e|ing))?|k|l[cp]|o(?:ans?|c(?:ker|us)|l|ndon|tt[eo]|ve)|pl(?:financial)?|r|s|t(?:da?)?|u(?:ndbeck|x(?:e|ury))?|v|y)|m(?:a(?:cys|drid|i(?:f|son)|keup|n(?:agement|go)?|p|r(?:ket(?:ing|s)?|riott|shalls)|serati|ttel)?|ba|c(?:kinsey)?|d|e(?:d(?:ia)?|et|lbourne|m(?:e|orial)|nu?|rckmsd)?|g|h|i(?:ami|crosoft|l|n[it]|t(?:subishi)?)|k|l[bs]?|ma?|n|o(?:bi(?:le)?|da|e|i|m|n(?:ash|ey|ster)|r(?:mon|tgage)|scow|to(?:rcycles)?|v(?:ie)?)?|p|q|r|sd?|t[nr]?|u(?:s(?:eum|ic)|tual)?|v|w|x|y|z)|n(?:a(?:b|goya|me|tura|vy)?|ba|c|e(?:c|t(?:bank|flix|work)?|ustar|ws?|x(?:t(?:direct)?|us))?|fl?|go?|hk|i(?:co|k(?:e|on)|nja|ssa[ny])?|l|o(?:kia|rt(?:hwesternmutual|on)|w(?:ruz|tv)?)?|p|r[aw]?|tt|u|yc|z)|o(?:b(?:i|server)|ffice|kinawa|l(?:ayan(?:group)?|dnavy|lo)|m(?:ega)?|n(?:e|g|l(?:ine)?)|oo|pen|r(?:a(?:cle|nge)|g(?:anic)?|igins)|saka|t(?:suka|t)|vh)|p(?:a(?:ge|nasonic|r(?:is|s|t(?:ners|s|y))|ssagens|y)?|ccw|et?|f(?:izer)?|g|h(?:armacy|d|ilips|o(?:ne|to(?:graphy|s)?)|ysio)?|i(?:c(?:s|t(?:et|ures))|d|n[gk]?|oneer|zza)|k|l(?:a(?:ce|y(?:station)?)|u(?:mbing|s))?|m|nc?|o(?:hl|ker|litie|rn|st)|r(?:a(?:merica|xi)|ess|ime|o(?:d(?:uctions)?|f|gressive|mo|pert(?:ies|y)|tection)?|u(?:dential)?)?|s|t|ub|wc?|y)|q(?:a|pon|ue(?:bec|st))|r(?:a(?:cing|dio)|e(?:a(?:d|l(?:estate|t(?:or|y)))|cipes|d(?:stone|umbrella)?|hab|i(?:sen?|t)|liance|n(?:t(?:als)?)?|p(?:air|ort|ublican)|st(?:aurant)?|views?|xroth)?|i(?:c(?:h(?:ardli)?|oh)|l|o|p)|o(?:c(?:her|ks)|deo|gers|om)?|s(?:vp)?|u(?:gby|hr|n)?|we?|yukyu)|s(?:a(?:arland|fe(?:ty)?|kura|l(?:e|on)|ms(?:club|ung)|n(?:dvik(?:coromant)?|ofi)|p|rl|s|ve|xo)?|b[is]?|c(?:a|b|h(?:aeffler|midt|o(?:larships|ol)|ule|warz)|ience|ot)?|d|e(?:a(?:rch|t)|cur(?:e|ity)|ek|lect|ner|rvices|ven|w|xy?)?|fr|g|h(?:a(?:ngrila|rp|w)|ell|i(?:a|ksha)|o(?:es|p(?:ping)?|uji|w(?:time)?))?|i(?:lk|n(?:a|gles)|te)?|j|k(?:in?|y(?:pe)?)?|l(?:ing)?|m(?:art|ile)?|n(?:cf)?|o(?:c(?:cer|ial)|ft(?:bank|ware)|hu|l(?:ar|utions)|n[gy]|y)?|p(?:a(?:ce)?|o(?:rt|t))|rl?|s|t(?:a(?:da|ples|r|te(?:bank|farm))|c(?:group)?|o(?:ckholm|r(?:age|e))|ream|ud(?:io|y)|yle)?|u(?:cks|pp(?:l(?:ies|y)|ort)|r(?:f|gery)|zuki)?|v|w(?:atch|iss)|x|y(?:dney|stems)?|z)|t(?:a(?:b|ipei|lk|obao|rget|t(?:a(?:motors|r)|too)|xi?)|ci?|dk?|e(?:am|ch(?:nology)?|l|masek|nnis|va)|f|g|h(?:d|eat(?:er|re))?|i(?:aa|ckets|enda|ffany|ps|r(?:es|ol))|j(?:maxx|x)?|k(?:maxx)?|l|m(?:all)?|n|o(?:day|kyo|ols|p|ray|shiba|tal|urs|wn|y(?:ota|s))?|r(?:a(?:d(?:e|ing)|ining|vel(?:channel|ers(?:insurance)?)?)|ust|v)?|t|u(?:be|i|nes|shu)|vs?|w|z)|u(?:a|b(?:ank|s)|g|k|n(?:i(?:com|versity)|o)|ol|ps|s|y|z)|v(?:a(?:cations|n(?:a|guard))?|c|e(?:gas|ntures|r(?:isign|sicherung)|t)?|g|i(?:ajes|deo|g|king|llas|n|p|rgin|s(?:a|ion)|v[ao])?|laanderen|n|o(?:dka|l(?:kswagen|vo)|t(?:e|ing|o)|yage)|u(?:elos)?)|w(?:a(?:l(?:es|mart|ter)|ng(?:gou)?|tch(?:es)?)|e(?:ather(?:channel)?|b(?:cam|er|site)|d(?:ding)?|i(?:bo|r))|f|hoswho|i(?:en|ki|lliamhill|n(?:dows|e|ners)?)|me|o(?:lterskluwer|odside|r(?:ks?|ld)|w)|s|t[cf])|x(?:box|erox|finity|i(?:huan|n)|xx|yz)|y(?:a(?:chts|hoo|maxun|ndex)|e|o(?:dobashi|ga|kohama|u(?:tube)?)|t|un)|z(?:a(?:ppos|ra)?|ero|ip|m|one|uerich|w)";
|
25
|
+
var PUNCTUATION_CHAR_PATTERN = "\\.\\,\\;\\!\\?";
|
26
|
+
var STOP_CHAR_PATTERN = "[" + PUNCTUATION_CHAR_PATTERN + "]";
|
27
|
+
var END_CHAR_PATTERN = "[^\\s" + PUNCTUATION_CHAR_PATTERN + "]";
|
28
|
+
var LINK_RE_BASE_PATTERN = (
|
25
29
|
// start of the link group
|
26
30
|
"((?:(?:(?:https?:)?\\/\\/)?(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:" + TLD_RE_PATTERN + "))(?::\\d{2,5})?(?:/(?:\\S*" + END_CHAR_PATTERN + ")?)?(?:\\?(?:\\S*" + END_CHAR_PATTERN + "))?(?:\\#(?:\\S*" + END_CHAR_PATTERN + ")?)?)"
|
27
|
-
)
|
31
|
+
);
|
32
|
+
var LINK_ENTER_PATTERN = LINK_RE_BASE_PATTERN + STOP_CHAR_PATTERN + "?$";
|
33
|
+
var LINK_INPUT_PATTERN = LINK_RE_BASE_PATTERN + STOP_CHAR_PATTERN + "?\\s$";
|
34
|
+
var LINK_MARK_PATTERN = LINK_RE_BASE_PATTERN + "(?=" + STOP_CHAR_PATTERN + "|\\s|$)";
|
35
|
+
var LINK_ENTER_RE = new RegExp(LINK_ENTER_PATTERN, "gi");
|
36
|
+
var LINK_INPUT_RE = new RegExp(LINK_INPUT_PATTERN, "gi");
|
37
|
+
var LINK_MARK_RE = new RegExp(LINK_MARK_PATTERN, "gi");
|
28
38
|
|
29
39
|
// src/link/index.ts
|
30
40
|
function defineLinkSpec() {
|
31
41
|
return defineMarkSpec({
|
32
42
|
name: "link",
|
33
|
-
inclusive:
|
43
|
+
inclusive: false,
|
44
|
+
attrs: {
|
45
|
+
href: {}
|
46
|
+
},
|
34
47
|
parseDOM: [
|
35
48
|
{
|
36
49
|
tag: "a[href]",
|
37
|
-
getAttrs: (dom) =>
|
38
|
-
|
39
|
-
|
50
|
+
getAttrs: (dom) => {
|
51
|
+
return {
|
52
|
+
href: dom.getAttribute("href")
|
53
|
+
};
|
54
|
+
}
|
40
55
|
}
|
41
56
|
],
|
42
|
-
attrs: {
|
43
|
-
href: {}
|
44
|
-
},
|
45
57
|
toDOM(node) {
|
46
|
-
|
58
|
+
const { href } = node.attrs;
|
47
59
|
return ["a", { href }, 0];
|
48
60
|
}
|
49
61
|
});
|
@@ -59,9 +71,9 @@ function defineLinkCommands() {
|
|
59
71
|
function defineLinkInputRule() {
|
60
72
|
return defineInputRule(
|
61
73
|
new InputRule(LINK_INPUT_RE, (state, match, from) => {
|
62
|
-
|
74
|
+
const href = match[1];
|
63
75
|
if (!href) return null;
|
64
|
-
|
76
|
+
const mark = state.schema.marks.link.create({ href });
|
65
77
|
return state.tr.addMark(from, from + href.length, mark).insertText(" ");
|
66
78
|
})
|
67
79
|
);
|
@@ -70,9 +82,10 @@ function defineLinkEnterRule() {
|
|
70
82
|
return defineEnterRule({
|
71
83
|
regex: LINK_ENTER_RE,
|
72
84
|
handler: ({ state, from, match }) => {
|
73
|
-
|
85
|
+
const href = match[1];
|
74
86
|
if (!href) return null;
|
75
|
-
|
87
|
+
const mark = state.schema.marks.link.create({ href });
|
88
|
+
const tr = state.tr.addMark(from, from + href.length, mark);
|
76
89
|
return tr.docChanged ? tr : null;
|
77
90
|
}
|
78
91
|
});
|
@@ -1,13 +1,13 @@
|
|
1
|
-
export { defineListSpec } from './_tsup-dts-rollup';
|
2
|
-
export { defineListPlugins } from './_tsup-dts-rollup';
|
3
|
-
export { defineListInputRules } from './_tsup-dts-rollup';
|
4
1
|
export { defineList } from './_tsup-dts-rollup';
|
5
2
|
export { ListDOMSerializer } from './_tsup-dts-rollup';
|
6
3
|
export { DedentListOptions } from './_tsup-dts-rollup';
|
7
4
|
export { IndentListOptions } from './_tsup-dts-rollup';
|
8
|
-
export { ListAttributes } from './_tsup-dts-rollup';
|
9
5
|
export { ToggleCollapsedOptions } from './_tsup-dts-rollup';
|
10
6
|
export { UnwrapListOptions } from './_tsup-dts-rollup';
|
11
7
|
export { WrapInListGetAttrs } from './_tsup-dts-rollup';
|
12
8
|
export { defineListCommands_alias_1 as defineListCommands } from './_tsup-dts-rollup';
|
9
|
+
export { defineListInputRules } from './_tsup-dts-rollup';
|
13
10
|
export { defineListKeymap } from './_tsup-dts-rollup';
|
11
|
+
export { defineListPlugins } from './_tsup-dts-rollup';
|
12
|
+
export { defineListSpec } from './_tsup-dts-rollup';
|
13
|
+
export { ListAttrs } from './_tsup-dts-rollup';
|