@fibery/prosemirror-schema 1.1.2 → 1.4.0
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/lib/index.js +189 -367
- package/package.json +11 -7
package/lib/index.js
CHANGED
|
@@ -1,210 +1,7 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ "use strict";
|
|
3
|
-
/******/
|
|
4
|
-
|
|
5
|
-
/***/ 17:
|
|
6
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
|
-
|
|
8
|
-
var __webpack_unused_export__;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
__webpack_unused_export__ = ({ value: true });
|
|
12
|
-
|
|
13
|
-
var prosemirrorModel = __webpack_require__(63);
|
|
14
|
-
|
|
15
|
-
// :: Object
|
|
16
|
-
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
|
|
17
|
-
var nodes = {
|
|
18
|
-
// :: NodeSpec The top level document node.
|
|
19
|
-
doc: {
|
|
20
|
-
content: "block+"
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
|
|
24
|
-
// as a `<p>` element.
|
|
25
|
-
paragraph: {
|
|
26
|
-
content: "inline*",
|
|
27
|
-
group: "block",
|
|
28
|
-
parseDOM: [{tag: "p"}],
|
|
29
|
-
toDOM: function toDOM() { return ["p", 0] }
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
33
|
-
blockquote: {
|
|
34
|
-
content: "block+",
|
|
35
|
-
group: "block",
|
|
36
|
-
defining: true,
|
|
37
|
-
parseDOM: [{tag: "blockquote"}],
|
|
38
|
-
toDOM: function toDOM() { return ["blockquote", 0] }
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
42
|
-
horizontal_rule: {
|
|
43
|
-
group: "block",
|
|
44
|
-
parseDOM: [{tag: "hr"}],
|
|
45
|
-
toDOM: function toDOM() { return ["hr"] }
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
// :: NodeSpec A heading textblock, with a `level` attribute that
|
|
49
|
-
// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
50
|
-
// `<h6>` elements.
|
|
51
|
-
heading: {
|
|
52
|
-
attrs: {level: {default: 1}},
|
|
53
|
-
content: "inline*",
|
|
54
|
-
group: "block",
|
|
55
|
-
defining: true,
|
|
56
|
-
parseDOM: [{tag: "h1", attrs: {level: 1}},
|
|
57
|
-
{tag: "h2", attrs: {level: 2}},
|
|
58
|
-
{tag: "h3", attrs: {level: 3}},
|
|
59
|
-
{tag: "h4", attrs: {level: 4}},
|
|
60
|
-
{tag: "h5", attrs: {level: 5}},
|
|
61
|
-
{tag: "h6", attrs: {level: 6}}],
|
|
62
|
-
toDOM: function toDOM(node) { return ["h" + node.attrs.level, 0] }
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
66
|
-
// nodes by default. Represented as a `<pre>` element with a
|
|
67
|
-
// `<code>` element inside of it.
|
|
68
|
-
code_block: {
|
|
69
|
-
content: "text*",
|
|
70
|
-
marks: "",
|
|
71
|
-
group: "block",
|
|
72
|
-
code: true,
|
|
73
|
-
defining: true,
|
|
74
|
-
parseDOM: [{tag: "pre", preserveWhitespace: "full"}],
|
|
75
|
-
toDOM: function toDOM() { return ["pre", ["code", 0]] }
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
// :: NodeSpec The text node.
|
|
79
|
-
text: {
|
|
80
|
-
group: "inline"
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
|
|
84
|
-
// `alt`, and `href` attributes. The latter two default to the empty
|
|
85
|
-
// string.
|
|
86
|
-
image: {
|
|
87
|
-
inline: true,
|
|
88
|
-
attrs: {
|
|
89
|
-
src: {},
|
|
90
|
-
alt: {default: null},
|
|
91
|
-
title: {default: null}
|
|
92
|
-
},
|
|
93
|
-
group: "inline",
|
|
94
|
-
draggable: true,
|
|
95
|
-
parseDOM: [{tag: "img[src]", getAttrs: function getAttrs(dom) {
|
|
96
|
-
return {
|
|
97
|
-
src: dom.getAttribute("src"),
|
|
98
|
-
title: dom.getAttribute("title"),
|
|
99
|
-
alt: dom.getAttribute("alt")
|
|
100
|
-
}
|
|
101
|
-
}}],
|
|
102
|
-
toDOM: function toDOM(node) { return ["img", node.attrs] }
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
|
|
106
|
-
hard_break: {
|
|
107
|
-
inline: true,
|
|
108
|
-
group: "inline",
|
|
109
|
-
selectable: false,
|
|
110
|
-
parseDOM: [{tag: "br"}],
|
|
111
|
-
toDOM: function toDOM() { return ["br"] }
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
|
|
116
|
-
var marks = {
|
|
117
|
-
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
|
|
118
|
-
// defaults to the empty string. Rendered and parsed as an `<a>`
|
|
119
|
-
// element.
|
|
120
|
-
link: {
|
|
121
|
-
attrs: {
|
|
122
|
-
href: {},
|
|
123
|
-
title: {default: null}
|
|
124
|
-
},
|
|
125
|
-
inclusive: false,
|
|
126
|
-
parseDOM: [{tag: "a[href]", getAttrs: function getAttrs(dom) {
|
|
127
|
-
return {href: dom.getAttribute("href"), title: dom.getAttribute("title")}
|
|
128
|
-
}}],
|
|
129
|
-
toDOM: function toDOM(node) { return ["a", node.attrs] }
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
|
|
133
|
-
// Has parse rules that also match `<i>` and `font-style: italic`.
|
|
134
|
-
em: {
|
|
135
|
-
parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}],
|
|
136
|
-
toDOM: function toDOM() { return ["em"] }
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
|
|
140
|
-
// also match `<b>` and `font-weight: bold`.
|
|
141
|
-
strong: {
|
|
142
|
-
parseDOM: [{tag: "strong"},
|
|
143
|
-
// This works around a Google Docs misbehavior where
|
|
144
|
-
// pasted content will be inexplicably wrapped in `<b>`
|
|
145
|
-
// tags with a font-weight normal.
|
|
146
|
-
{tag: "b", getAttrs: function (node) { return node.style.fontWeight != "normal" && null; }},
|
|
147
|
-
{style: "font-weight", getAttrs: function (value) { return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null; }}],
|
|
148
|
-
toDOM: function toDOM() { return ["strong"] }
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
// :: MarkSpec Code font mark. Represented as a `<code>` element.
|
|
152
|
-
code: {
|
|
153
|
-
parseDOM: [{tag: "code"}],
|
|
154
|
-
toDOM: function toDOM() { return ["code"] }
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// :: Schema
|
|
159
|
-
// This schema rougly corresponds to the document schema used by
|
|
160
|
-
// [CommonMark](http://commonmark.org/), minus the list elements,
|
|
161
|
-
// which are defined in the [`prosemirror-schema-list`](#schema-list)
|
|
162
|
-
// module.
|
|
163
|
-
//
|
|
164
|
-
// To reuse elements from this schema, extend or read from its
|
|
165
|
-
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
|
|
166
|
-
var schema = new prosemirrorModel.Schema({nodes: nodes, marks: marks});
|
|
167
|
-
|
|
168
|
-
exports.td = nodes;
|
|
169
|
-
exports.EI = marks;
|
|
170
|
-
__webpack_unused_export__ = schema;
|
|
171
|
-
//# sourceMappingURL=schema-basic.js.map
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/***/ }),
|
|
175
|
-
|
|
176
|
-
/***/ 63:
|
|
177
|
-
/***/ ((module) => {
|
|
178
|
-
|
|
179
|
-
module.exports = require("prosemirror-model");;
|
|
180
|
-
|
|
181
|
-
/***/ })
|
|
182
|
-
|
|
183
|
-
/******/ });
|
|
184
|
-
/************************************************************************/
|
|
185
|
-
/******/ // The module cache
|
|
186
|
-
/******/ var __webpack_module_cache__ = {};
|
|
187
|
-
/******/
|
|
188
|
-
/******/ // The require function
|
|
189
|
-
/******/ function __webpack_require__(moduleId) {
|
|
190
|
-
/******/ // Check if module is in cache
|
|
191
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
192
|
-
/******/ if (cachedModule !== undefined) {
|
|
193
|
-
/******/ return cachedModule.exports;
|
|
194
|
-
/******/ }
|
|
195
|
-
/******/ // Create a new module (and put it into the cache)
|
|
196
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
197
|
-
/******/ // no module.id needed
|
|
198
|
-
/******/ // no module.loaded needed
|
|
199
|
-
/******/ exports: {}
|
|
200
|
-
/******/ };
|
|
201
|
-
/******/
|
|
202
|
-
/******/ // Execute the module function
|
|
203
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
204
|
-
/******/
|
|
205
|
-
/******/ // Return the exports of the module
|
|
206
|
-
/******/ return module.exports;
|
|
207
|
-
/******/ }
|
|
3
|
+
/******/ // The require scope
|
|
4
|
+
/******/ var __webpack_require__ = {};
|
|
208
5
|
/******/
|
|
209
6
|
/************************************************************************/
|
|
210
7
|
/******/ /* webpack/runtime/define property getters */
|
|
@@ -237,8 +34,6 @@ module.exports = require("prosemirror-model");;
|
|
|
237
34
|
/******/
|
|
238
35
|
/************************************************************************/
|
|
239
36
|
var __webpack_exports__ = {};
|
|
240
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
241
|
-
(() => {
|
|
242
37
|
// ESM COMPAT FLAG
|
|
243
38
|
__webpack_require__.r(__webpack_exports__);
|
|
244
39
|
|
|
@@ -247,15 +42,16 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
247
42
|
"createSchema": () => (/* reexport */ createSchema)
|
|
248
43
|
});
|
|
249
44
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
45
|
+
;// CONCATENATED MODULE: external "prosemirror-model"
|
|
46
|
+
const external_prosemirror_model_namespaceObject = require("prosemirror-model");
|
|
47
|
+
;// CONCATENATED MODULE: external "prosemirror-schema-basic"
|
|
48
|
+
const external_prosemirror_schema_basic_namespaceObject = require("prosemirror-schema-basic");
|
|
254
49
|
;// CONCATENATED MODULE: external "prosemirror-schema-list"
|
|
255
|
-
const external_prosemirror_schema_list_namespaceObject = require("prosemirror-schema-list")
|
|
50
|
+
const external_prosemirror_schema_list_namespaceObject = require("prosemirror-schema-list");
|
|
256
51
|
;// CONCATENATED MODULE: external "prosemirror-tables"
|
|
257
|
-
const external_prosemirror_tables_namespaceObject = require("prosemirror-tables")
|
|
258
|
-
;// CONCATENATED MODULE: ./src/nodes/
|
|
52
|
+
const external_prosemirror_tables_namespaceObject = require("prosemirror-tables");
|
|
53
|
+
;// CONCATENATED MODULE: ./src/nodes/table-nodes.ts
|
|
54
|
+
// @ts-ignore
|
|
259
55
|
|
|
260
56
|
const tableNodes = (0,external_prosemirror_tables_namespaceObject.tableNodes)({
|
|
261
57
|
tableGroup: "block",
|
|
@@ -270,14 +66,14 @@ const tableNodes = (0,external_prosemirror_tables_namespaceObject.tableNodes)({
|
|
|
270
66
|
|
|
271
67
|
setDOMAttr(value, attrs) {
|
|
272
68
|
if (value) {
|
|
273
|
-
attrs.style = (attrs.style || "") +
|
|
69
|
+
attrs.style = (attrs.style || "") + "background-color: ".concat(value, ";");
|
|
274
70
|
}
|
|
275
71
|
}
|
|
276
72
|
|
|
277
73
|
}
|
|
278
74
|
}
|
|
279
75
|
});
|
|
280
|
-
;// CONCATENATED MODULE: ./src/nodes/paragraph.
|
|
76
|
+
;// CONCATENATED MODULE: ./src/nodes/paragraph.ts
|
|
281
77
|
const paragraph = {
|
|
282
78
|
content: "inline*",
|
|
283
79
|
group: "block",
|
|
@@ -303,7 +99,7 @@ const paragraph = {
|
|
|
303
99
|
}
|
|
304
100
|
|
|
305
101
|
};
|
|
306
|
-
;// CONCATENATED MODULE: ./src/nodes/heading.
|
|
102
|
+
;// CONCATENATED MODULE: ./src/nodes/heading.ts
|
|
307
103
|
const DEFAULT_GUID = "";
|
|
308
104
|
const makeHeading = ({
|
|
309
105
|
headingToDOM
|
|
@@ -371,7 +167,7 @@ const makeHeading = ({
|
|
|
371
167
|
}
|
|
372
168
|
|
|
373
169
|
});
|
|
374
|
-
;// CONCATENATED MODULE: ./src/nodes/media.
|
|
170
|
+
;// CONCATENATED MODULE: ./src/nodes/media.ts
|
|
375
171
|
const makeMedia = ({
|
|
376
172
|
mediaToDom
|
|
377
173
|
}) => ({
|
|
@@ -408,7 +204,7 @@ const makeMedia = ({
|
|
|
408
204
|
}
|
|
409
205
|
|
|
410
206
|
});
|
|
411
|
-
;// CONCATENATED MODULE: ./src/nodes/note.
|
|
207
|
+
;// CONCATENATED MODULE: ./src/nodes/note.ts
|
|
412
208
|
const note = {
|
|
413
209
|
content: "inline*",
|
|
414
210
|
group: "block",
|
|
@@ -423,7 +219,7 @@ const note = {
|
|
|
423
219
|
tag: "div.fibery-note"
|
|
424
220
|
}]
|
|
425
221
|
};
|
|
426
|
-
;// CONCATENATED MODULE: ./src/nodes/important.
|
|
222
|
+
;// CONCATENATED MODULE: ./src/nodes/important.ts
|
|
427
223
|
const important = {
|
|
428
224
|
content: "inline*",
|
|
429
225
|
group: "block",
|
|
@@ -438,7 +234,7 @@ const important = {
|
|
|
438
234
|
}
|
|
439
235
|
|
|
440
236
|
};
|
|
441
|
-
;// CONCATENATED MODULE: ./src/nodes/entity.
|
|
237
|
+
;// CONCATENATED MODULE: ./src/nodes/entity.ts
|
|
442
238
|
const entity = {
|
|
443
239
|
inline: true,
|
|
444
240
|
group: "inline",
|
|
@@ -457,10 +253,11 @@ const entity = {
|
|
|
457
253
|
parseDOM: [{
|
|
458
254
|
tag: "span[data-entity-id]",
|
|
459
255
|
getAttrs: domNode => {
|
|
256
|
+
const dom = domNode;
|
|
460
257
|
return {
|
|
461
|
-
id:
|
|
462
|
-
text:
|
|
463
|
-
typeId:
|
|
258
|
+
id: dom.getAttribute("data-entity-id"),
|
|
259
|
+
text: dom.textContent,
|
|
260
|
+
typeId: dom.getAttribute("data-entity-type-id")
|
|
464
261
|
};
|
|
465
262
|
}
|
|
466
263
|
}],
|
|
@@ -480,7 +277,7 @@ const entity = {
|
|
|
480
277
|
}
|
|
481
278
|
|
|
482
279
|
};
|
|
483
|
-
;// CONCATENATED MODULE: ./src/nodes/mention.
|
|
280
|
+
;// CONCATENATED MODULE: ./src/nodes/mention.ts
|
|
484
281
|
const mention = {
|
|
485
282
|
inline: true,
|
|
486
283
|
group: "inline",
|
|
@@ -499,10 +296,11 @@ const mention = {
|
|
|
499
296
|
parseDOM: [{
|
|
500
297
|
tag: "span[data-mention-id]",
|
|
501
298
|
getAttrs: domNode => {
|
|
299
|
+
const dom = domNode;
|
|
502
300
|
return {
|
|
503
|
-
id:
|
|
504
|
-
name:
|
|
505
|
-
typeId:
|
|
301
|
+
id: dom.getAttribute("data-mention-id"),
|
|
302
|
+
name: dom.textContent,
|
|
303
|
+
typeId: dom.getAttribute("data-mention-type-id")
|
|
506
304
|
};
|
|
507
305
|
}
|
|
508
306
|
}],
|
|
@@ -522,93 +320,9 @@ const mention = {
|
|
|
522
320
|
}
|
|
523
321
|
|
|
524
322
|
};
|
|
525
|
-
;// CONCATENATED MODULE:
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
// generators (like Math.random()).
|
|
529
|
-
var getRandomValues;
|
|
530
|
-
var rnds8 = new Uint8Array(16);
|
|
531
|
-
function rng() {
|
|
532
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
533
|
-
if (!getRandomValues) {
|
|
534
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
|
|
535
|
-
// find the complete implementation of crypto (msCrypto) on IE11.
|
|
536
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
537
|
-
|
|
538
|
-
if (!getRandomValues) {
|
|
539
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return getRandomValues(rnds8);
|
|
544
|
-
}
|
|
545
|
-
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
|
|
546
|
-
/* harmony default export */ const regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
|
|
547
|
-
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
function validate(uuid) {
|
|
551
|
-
return typeof uuid === 'string' && regex.test(uuid);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/* harmony default export */ const esm_browser_validate = (validate);
|
|
555
|
-
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
559
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
560
|
-
*/
|
|
561
|
-
|
|
562
|
-
var byteToHex = [];
|
|
563
|
-
|
|
564
|
-
for (var i = 0; i < 256; ++i) {
|
|
565
|
-
byteToHex.push((i + 0x100).toString(16).substr(1));
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
function stringify(arr) {
|
|
569
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
570
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
571
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
572
|
-
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
573
|
-
// of the following:
|
|
574
|
-
// - One or more input array values don't map to a hex octet (leading to
|
|
575
|
-
// "undefined" in the uuid)
|
|
576
|
-
// - Invalid input values for the RFC `version` or `variant` fields
|
|
577
|
-
|
|
578
|
-
if (!esm_browser_validate(uuid)) {
|
|
579
|
-
throw TypeError('Stringified UUID is invalid');
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
return uuid;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/* harmony default export */ const esm_browser_stringify = (stringify);
|
|
586
|
-
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
function v4(options, buf, offset) {
|
|
591
|
-
options = options || {};
|
|
592
|
-
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
593
|
-
|
|
594
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
595
|
-
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
596
|
-
|
|
597
|
-
if (buf) {
|
|
598
|
-
offset = offset || 0;
|
|
599
|
-
|
|
600
|
-
for (var i = 0; i < 16; ++i) {
|
|
601
|
-
buf[offset + i] = rnds[i];
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
return buf;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
return esm_browser_stringify(rnds);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/* harmony default export */ const esm_browser_v4 = (v4);
|
|
611
|
-
;// CONCATENATED MODULE: ./src/nodes/checkList.js
|
|
323
|
+
;// CONCATENATED MODULE: external "uuid"
|
|
324
|
+
const external_uuid_namespaceObject = require("uuid");
|
|
325
|
+
;// CONCATENATED MODULE: ./src/nodes/check-list.ts
|
|
612
326
|
|
|
613
327
|
const check_list = {
|
|
614
328
|
group: "block",
|
|
@@ -625,7 +339,7 @@ const check_list = {
|
|
|
625
339
|
// also used by ordered-list we need to make sure that we run this parser first.
|
|
626
340
|
priority: 100,
|
|
627
341
|
getAttrs: () => ({
|
|
628
|
-
id:
|
|
342
|
+
id: (0,external_uuid_namespaceObject.v4)()
|
|
629
343
|
})
|
|
630
344
|
}],
|
|
631
345
|
|
|
@@ -641,7 +355,7 @@ const check_list = {
|
|
|
641
355
|
}
|
|
642
356
|
|
|
643
357
|
};
|
|
644
|
-
;// CONCATENATED MODULE: ./src/nodes/
|
|
358
|
+
;// CONCATENATED MODULE: ./src/nodes/check-item.ts
|
|
645
359
|
|
|
646
360
|
const check_item = {
|
|
647
361
|
content: "inline*",
|
|
@@ -661,7 +375,7 @@ const check_item = {
|
|
|
661
375
|
// also used by list-item we need to make sure that we run this parser first.
|
|
662
376
|
priority: 100,
|
|
663
377
|
getAttrs: dom => ({
|
|
664
|
-
id:
|
|
378
|
+
id: (0,external_uuid_namespaceObject.v4)(),
|
|
665
379
|
state: dom.getAttribute("data-check-item-state")
|
|
666
380
|
})
|
|
667
381
|
}],
|
|
@@ -679,7 +393,117 @@ const check_item = {
|
|
|
679
393
|
}
|
|
680
394
|
|
|
681
395
|
};
|
|
682
|
-
;// CONCATENATED MODULE: ./src/nodes/
|
|
396
|
+
;// CONCATENATED MODULE: ./src/nodes/code-block.ts
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
const getLanguageFromEditorStyle = dom => {
|
|
400
|
+
return dom.getAttribute("data-language") || undefined;
|
|
401
|
+
}; // example of BB style:
|
|
402
|
+
// <div class="codehilite language-javascript"><pre><span>hello world</span><span>\n</span></pre></div>
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
const getLanguageFromBitbucketStyle = dom => {
|
|
406
|
+
if (dom && dom.classList.contains("codehilite")) {
|
|
407
|
+
// code block html from Bitbucket always contains an extra new line
|
|
408
|
+
return extractLanguageFromClass(dom.className);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return undefined;
|
|
412
|
+
}; // If there is a child code element, check that for data-language
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
const getLanguageFromCode = dom => {
|
|
416
|
+
const firstChild = dom.firstElementChild;
|
|
417
|
+
|
|
418
|
+
if (firstChild && firstChild.nodeName === "CODE") {
|
|
419
|
+
return firstChild.getAttribute("data-language") || undefined;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return undefined;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const extractLanguageFromClass = className => {
|
|
426
|
+
const languageRegex = /(?:^|\s)language-([^\s]+)/;
|
|
427
|
+
const result = languageRegex.exec(className);
|
|
428
|
+
|
|
429
|
+
if (result && result[1]) {
|
|
430
|
+
return result[1];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return undefined;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const removeLastNewLine = dom => {
|
|
437
|
+
const parent = dom && dom.parentElement;
|
|
438
|
+
|
|
439
|
+
if (parent && parent.classList.contains("codehilite")) {
|
|
440
|
+
dom.textContent = dom.textContent.replace(/\n$/, "");
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return dom;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
const code_block = {
|
|
447
|
+
content: "text*",
|
|
448
|
+
marks: "",
|
|
449
|
+
group: "block",
|
|
450
|
+
code: true,
|
|
451
|
+
defining: true,
|
|
452
|
+
attrs: {
|
|
453
|
+
language: {
|
|
454
|
+
default: null
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
parseDOM: [{
|
|
458
|
+
tag: "pre",
|
|
459
|
+
preserveWhitespace: "full",
|
|
460
|
+
getAttrs: domNode => {
|
|
461
|
+
const dom = domNode;
|
|
462
|
+
const language = getLanguageFromBitbucketStyle(dom.parentElement) || getLanguageFromEditorStyle(dom.parentElement) || getLanguageFromCode(dom) || dom.getAttribute("data-language");
|
|
463
|
+
removeLastNewLine(dom);
|
|
464
|
+
return {
|
|
465
|
+
language
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
}, // Handle VSCode paste
|
|
469
|
+
{
|
|
470
|
+
tag: "div[style]",
|
|
471
|
+
preserveWhitespace: "full",
|
|
472
|
+
getAttrs: domNode => {
|
|
473
|
+
const dom = domNode;
|
|
474
|
+
|
|
475
|
+
if (dom.style.whiteSpace === "pre" || dom.style.fontFamily && dom.style.fontFamily.toLowerCase().indexOf("monospace") > -1) {
|
|
476
|
+
return {};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return false;
|
|
480
|
+
},
|
|
481
|
+
getContent: (domNode, schema) => {
|
|
482
|
+
const dom = domNode;
|
|
483
|
+
const code = Array.from(dom.children).map(child => child.textContent).filter(x => x !== undefined).join("\n");
|
|
484
|
+
return code ? external_prosemirror_model_namespaceObject.Fragment.from(schema.text(code)) : external_prosemirror_model_namespaceObject.Fragment.empty;
|
|
485
|
+
}
|
|
486
|
+
}, // Handle GitHub/Gist paste
|
|
487
|
+
{
|
|
488
|
+
tag: "table[style]",
|
|
489
|
+
preserveWhitespace: "full",
|
|
490
|
+
getAttrs: dom => {
|
|
491
|
+
if (dom.querySelector('td[class*="blob-code"]')) {
|
|
492
|
+
return {};
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
}],
|
|
498
|
+
|
|
499
|
+
toDOM(node) {
|
|
500
|
+
return ["pre", ["code", {
|
|
501
|
+
"data-language": node.attrs.language
|
|
502
|
+
}, 0]];
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
};
|
|
506
|
+
;// CONCATENATED MODULE: ./src/nodes/video.ts
|
|
683
507
|
const DEFAULT_VIDEO_WIDTH = 400;
|
|
684
508
|
const DEFAULT_VIDEO_HEIGHT = 200;
|
|
685
509
|
const video = {
|
|
@@ -694,7 +518,7 @@ const video = {
|
|
|
694
518
|
default: DEFAULT_VIDEO_HEIGHT
|
|
695
519
|
},
|
|
696
520
|
title: {
|
|
697
|
-
default:
|
|
521
|
+
default: ""
|
|
698
522
|
},
|
|
699
523
|
alignment: {
|
|
700
524
|
default: ":alignment/block-center"
|
|
@@ -705,7 +529,8 @@ const video = {
|
|
|
705
529
|
parseDOM: [{
|
|
706
530
|
tag: "video",
|
|
707
531
|
|
|
708
|
-
getAttrs(
|
|
532
|
+
getAttrs(domNode) {
|
|
533
|
+
const dom = domNode;
|
|
709
534
|
return {
|
|
710
535
|
src: dom.getAttribute("src"),
|
|
711
536
|
type: dom.getAttribute("type"),
|
|
@@ -738,7 +563,7 @@ const video = {
|
|
|
738
563
|
}
|
|
739
564
|
|
|
740
565
|
};
|
|
741
|
-
;// CONCATENATED MODULE: ./src/marks/strike.
|
|
566
|
+
;// CONCATENATED MODULE: ./src/marks/strike.ts
|
|
742
567
|
const strike = {
|
|
743
568
|
parseDOM: [{
|
|
744
569
|
tag: "strike"
|
|
@@ -747,7 +572,7 @@ const strike = {
|
|
|
747
572
|
}],
|
|
748
573
|
toDOM: () => ["strike"]
|
|
749
574
|
};
|
|
750
|
-
;// CONCATENATED MODULE: ./src/marks/underline.
|
|
575
|
+
;// CONCATENATED MODULE: ./src/marks/underline.ts
|
|
751
576
|
const underline = {
|
|
752
577
|
parseDOM: [{
|
|
753
578
|
tag: "u"
|
|
@@ -756,7 +581,7 @@ const underline = {
|
|
|
756
581
|
}],
|
|
757
582
|
toDOM: () => ["u"]
|
|
758
583
|
};
|
|
759
|
-
;// CONCATENATED MODULE: ./src/marks/
|
|
584
|
+
;// CONCATENATED MODULE: ./src/marks/hint-query.ts
|
|
760
585
|
const hintQuery = {
|
|
761
586
|
excludes: "searchQuery",
|
|
762
587
|
inclusive: true,
|
|
@@ -782,7 +607,7 @@ const hintQuery = {
|
|
|
782
607
|
}
|
|
783
608
|
|
|
784
609
|
};
|
|
785
|
-
;// CONCATENATED MODULE: ./src/marks/highlight.
|
|
610
|
+
;// CONCATENATED MODULE: ./src/marks/highlight.ts
|
|
786
611
|
const highlight = {
|
|
787
612
|
attrs: {
|
|
788
613
|
color: {
|
|
@@ -795,8 +620,9 @@ const highlight = {
|
|
|
795
620
|
parseDOM: [{
|
|
796
621
|
tag: "span[data-highlight]",
|
|
797
622
|
getAttrs: domNode => {
|
|
623
|
+
const dom = domNode;
|
|
798
624
|
return {
|
|
799
|
-
color:
|
|
625
|
+
color: dom.style.backgroundColor || "#FFE4B5"
|
|
800
626
|
};
|
|
801
627
|
}
|
|
802
628
|
}],
|
|
@@ -805,23 +631,17 @@ const highlight = {
|
|
|
805
631
|
return ["span", {
|
|
806
632
|
"data-highlight": "true",
|
|
807
633
|
"data-guid": node.attrs.guid,
|
|
808
|
-
style:
|
|
634
|
+
style: "background-color:".concat(node.attrs.color)
|
|
809
635
|
}];
|
|
810
636
|
}
|
|
811
637
|
|
|
812
638
|
};
|
|
813
|
-
;// CONCATENATED MODULE: ./src/marks/
|
|
814
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
815
|
-
|
|
816
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
817
|
-
|
|
818
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
819
|
-
|
|
639
|
+
;// CONCATENATED MODULE: ./src/marks/linked-highlight.js
|
|
820
640
|
const hyphenatePascal = str => str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z]{2})[a-z]/, "$1-").toLowerCase();
|
|
821
641
|
|
|
822
642
|
const createMark = (markType, sharedColorGenerator) => {
|
|
823
|
-
const markTag =
|
|
824
|
-
const markClassName =
|
|
643
|
+
const markTag = "span.".concat(markType);
|
|
644
|
+
const markClassName = "".concat(markType);
|
|
825
645
|
|
|
826
646
|
const preserveBool = attr => attr === "true" ? true : attr === "false" ? false : attr;
|
|
827
647
|
|
|
@@ -840,7 +660,7 @@ const createMark = (markType, sharedColorGenerator) => {
|
|
|
840
660
|
}) => {
|
|
841
661
|
return {
|
|
842
662
|
id: dataset.id || false,
|
|
843
|
-
meta: Object.keys(dataset).filter(key => key !== "id" && dataset[key] !== "false").reduce((out, key) =>
|
|
663
|
+
meta: Object.keys(dataset).filter(key => key !== "id" && dataset[key] !== "false").reduce((out, key) => ({ ...out,
|
|
844
664
|
[key]: preserveBool(JSON.parse(dataset[key]))
|
|
845
665
|
}), {
|
|
846
666
|
type: markType
|
|
@@ -862,15 +682,16 @@ const createMark = (markType, sharedColorGenerator) => {
|
|
|
862
682
|
typeId
|
|
863
683
|
} = meta.links && meta.links.length > 0 ? meta.links[0] : {};
|
|
864
684
|
const color = sharedColorGenerator ? sharedColorGenerator.generate(typeId) : "#eeeeee";
|
|
865
|
-
return [markTag,
|
|
866
|
-
class: [markClassName, hidden ?
|
|
685
|
+
return [markTag, {
|
|
686
|
+
class: [markClassName, hidden ? "".concat(markClassName, "--collapsed") : ""].join(" "),
|
|
867
687
|
contenteditable: !hidden,
|
|
868
|
-
style: color ?
|
|
869
|
-
"data-id": id
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
688
|
+
style: color ? "background-color:".concat(color) : "",
|
|
689
|
+
"data-id": id,
|
|
690
|
+
...Object.keys(meta).filter(key => meta[key] !== false) // remove specials
|
|
691
|
+
.reduce((out, key) => ({ ...out,
|
|
692
|
+
["data-".concat(hyphenatePascal(key))]: JSON.stringify(meta[key])
|
|
693
|
+
}), {})
|
|
694
|
+
}];
|
|
874
695
|
}
|
|
875
696
|
};
|
|
876
697
|
};
|
|
@@ -880,17 +701,12 @@ const makeLinkedHighlight = ({
|
|
|
880
701
|
}) => {
|
|
881
702
|
return createMark("linkedhighlight", sharedColorGenerator);
|
|
882
703
|
};
|
|
883
|
-
;// CONCATENATED MODULE: ./src/marks/link.
|
|
884
|
-
function link_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
885
|
-
|
|
886
|
-
function link_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { link_ownKeys(Object(source), true).forEach(function (key) { link_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { link_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
887
|
-
|
|
888
|
-
function link_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
889
|
-
|
|
704
|
+
;// CONCATENATED MODULE: ./src/marks/link.ts
|
|
890
705
|
const makeLink = baseLink => {
|
|
891
|
-
return
|
|
706
|
+
return { ...baseLink,
|
|
707
|
+
|
|
892
708
|
toDOM(node) {
|
|
893
|
-
|
|
709
|
+
const {
|
|
894
710
|
href,
|
|
895
711
|
title
|
|
896
712
|
} = node.attrs;
|
|
@@ -901,9 +717,12 @@ const makeLink = baseLink => {
|
|
|
901
717
|
}, 0];
|
|
902
718
|
}
|
|
903
719
|
|
|
904
|
-
}
|
|
720
|
+
};
|
|
905
721
|
};
|
|
906
|
-
;// CONCATENATED MODULE: ./src/
|
|
722
|
+
;// CONCATENATED MODULE: ./src/create-schema.ts
|
|
723
|
+
// @ts-ignore
|
|
724
|
+
|
|
725
|
+
// @ts-ignore
|
|
907
726
|
|
|
908
727
|
|
|
909
728
|
|
|
@@ -929,14 +748,15 @@ const createSchema = ({
|
|
|
929
748
|
headingToDOM = null,
|
|
930
749
|
mediaToDom = null
|
|
931
750
|
} = {}) => {
|
|
932
|
-
|
|
933
|
-
|
|
751
|
+
external_prosemirror_schema_basic_namespaceObject.nodes.code_block = code_block;
|
|
752
|
+
external_prosemirror_schema_basic_namespaceObject.nodes.paragraph = paragraph;
|
|
753
|
+
external_prosemirror_schema_basic_namespaceObject.nodes.heading = makeHeading({
|
|
934
754
|
headingToDOM
|
|
935
755
|
});
|
|
936
|
-
|
|
937
|
-
const base = new
|
|
938
|
-
nodes:
|
|
939
|
-
marks:
|
|
756
|
+
external_prosemirror_schema_basic_namespaceObject.marks.link = makeLink(external_prosemirror_schema_basic_namespaceObject.marks.link);
|
|
757
|
+
const base = new external_prosemirror_model_namespaceObject.Schema({
|
|
758
|
+
nodes: external_prosemirror_schema_basic_namespaceObject.nodes,
|
|
759
|
+
marks: external_prosemirror_schema_basic_namespaceObject.marks
|
|
940
760
|
});
|
|
941
761
|
const customNodes = {
|
|
942
762
|
note: note,
|
|
@@ -950,16 +770,18 @@ const createSchema = ({
|
|
|
950
770
|
check_list: check_list,
|
|
951
771
|
video: video
|
|
952
772
|
};
|
|
953
|
-
return new
|
|
773
|
+
return new external_prosemirror_model_namespaceObject.Schema({
|
|
954
774
|
nodes: (0,external_prosemirror_schema_list_namespaceObject.addListNodes)(base.spec.nodes, "paragraph block*", "block").append(tableNodes).append(customNodes),
|
|
955
|
-
|
|
775
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
776
|
+
// @ts-ignore
|
|
777
|
+
marks: base.spec.marks // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
778
|
+
// @ts-ignore
|
|
779
|
+
.addToEnd("strike", strike).addToEnd("underline", underline).addToEnd("hintQuery", hintQuery).addToEnd("highlight", highlight).addToEnd("linkedhighlight", makeLinkedHighlight({
|
|
956
780
|
sharedColorGenerator
|
|
957
781
|
}))
|
|
958
782
|
});
|
|
959
783
|
};
|
|
960
|
-
;// CONCATENATED MODULE: ./index.
|
|
961
|
-
|
|
962
|
-
})();
|
|
784
|
+
;// CONCATENATED MODULE: ./index.ts
|
|
963
785
|
|
|
964
786
|
module.exports = __webpack_exports__;
|
|
965
787
|
/******/ })()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Fibery prosemirror schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "BABEL_ENV=production webpack",
|
|
12
12
|
"test": "jest",
|
|
13
|
-
"lint": "eslint
|
|
13
|
+
"lint": "eslint ",
|
|
14
14
|
"prepublishOnly": "npm run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
@@ -18,16 +18,20 @@
|
|
|
18
18
|
"uuid": "8.3.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"prosemirror-model": "^1.
|
|
21
|
+
"prosemirror-model": "^1.16.0",
|
|
22
22
|
"prosemirror-schema-list": "^1.0.2",
|
|
23
23
|
"prosemirror-tables": "^0.7.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"
|
|
26
|
+
"@types/prosemirror-model": "1.16.1",
|
|
27
27
|
"babel-loader": "8.2.2",
|
|
28
|
+
"babel-preset-fibery": "7.2.0",
|
|
28
29
|
"eslint-config-fibery": "7.0.0",
|
|
29
|
-
"jest": "
|
|
30
|
-
"webpack": "5.
|
|
31
|
-
"webpack-cli": "4.
|
|
30
|
+
"jest": "27.5.1",
|
|
31
|
+
"webpack": "5.64.2",
|
|
32
|
+
"webpack-cli": "4.7.2"
|
|
33
|
+
},
|
|
34
|
+
"jest": {
|
|
35
|
+
"testEnvironment": "jsdom"
|
|
32
36
|
}
|
|
33
37
|
}
|