pro-editor-schema 1.1.4 → 1.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.
- package/dist/index.d.mts +642 -14
- package/dist/index.d.ts +642 -14
- package/dist/index.js +30 -1
- package/dist/index.mjs +28 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,6 +72,8 @@ __export(index_exports, {
|
|
|
72
72
|
isIgnoredElement: () => isIgnoredElement,
|
|
73
73
|
isIgnoredValidation: () => isIgnoredValidation,
|
|
74
74
|
isTrackChangesSchema: () => isTrackChangesSchema,
|
|
75
|
+
queryAllElementsBySchema: () => queryAllElementsBySchema,
|
|
76
|
+
queryElementBySchema: () => queryElementBySchema,
|
|
75
77
|
validateXml: () => validateXml
|
|
76
78
|
});
|
|
77
79
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -2463,6 +2465,31 @@ var createElement = ({
|
|
|
2463
2465
|
return element;
|
|
2464
2466
|
};
|
|
2465
2467
|
|
|
2468
|
+
// src/schema/utils/queryElementBySchema.ts
|
|
2469
|
+
var queryElementBySchema = (content, schemaCode) => {
|
|
2470
|
+
const schema = findSchemaByCode(schemaCode);
|
|
2471
|
+
const element = content.querySelector(schema.tag.toLowerCase());
|
|
2472
|
+
if (!element) return void 0;
|
|
2473
|
+
if (schema.matchesElement && !schema.matchesElement(element)) {
|
|
2474
|
+
return void 0;
|
|
2475
|
+
}
|
|
2476
|
+
return element;
|
|
2477
|
+
};
|
|
2478
|
+
var queryAllElementsBySchema = (content, schemaCode) => {
|
|
2479
|
+
const schema = findSchemaByCode(schemaCode);
|
|
2480
|
+
const elements = content.querySelectorAll(
|
|
2481
|
+
schema.tag.toLowerCase()
|
|
2482
|
+
);
|
|
2483
|
+
const matchingElements = [];
|
|
2484
|
+
for (const element of elements) {
|
|
2485
|
+
if (schema.matchesElement && !schema.matchesElement(element)) {
|
|
2486
|
+
continue;
|
|
2487
|
+
}
|
|
2488
|
+
matchingElements.push(element);
|
|
2489
|
+
}
|
|
2490
|
+
return matchingElements;
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2466
2493
|
// src/schema/shared/labelElements.ts
|
|
2467
2494
|
var ElementLabel = {
|
|
2468
2495
|
referenceBibliomixed: "Reference Bibliomixed",
|
|
@@ -3002,7 +3029,7 @@ var collectPossibleWebLinks = (content) => {
|
|
|
3002
3029
|
const possibleWebLinks = /* @__PURE__ */ new Set();
|
|
3003
3030
|
const instance = new import_mark.default(clone);
|
|
3004
3031
|
instance.markRegExp(WEB_URI_IN_TEXT_REGEX, {
|
|
3005
|
-
acrossElements:
|
|
3032
|
+
acrossElements: false,
|
|
3006
3033
|
exclude: POSSIBLE_WEBLINK_EXCLUDE_SELECTORS,
|
|
3007
3034
|
filter: (_textNode, term) => {
|
|
3008
3035
|
possibleWebLinks.add(term);
|
|
@@ -3127,5 +3154,7 @@ var validateXml = (xml, elementsToLink, linkElements, schemasToValidateAgainst)
|
|
|
3127
3154
|
isIgnoredElement,
|
|
3128
3155
|
isIgnoredValidation,
|
|
3129
3156
|
isTrackChangesSchema,
|
|
3157
|
+
queryAllElementsBySchema,
|
|
3158
|
+
queryElementBySchema,
|
|
3130
3159
|
validateXml
|
|
3131
3160
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2385,6 +2385,31 @@ var createElement = ({
|
|
|
2385
2385
|
return element;
|
|
2386
2386
|
};
|
|
2387
2387
|
|
|
2388
|
+
// src/schema/utils/queryElementBySchema.ts
|
|
2389
|
+
var queryElementBySchema = (content, schemaCode) => {
|
|
2390
|
+
const schema = findSchemaByCode(schemaCode);
|
|
2391
|
+
const element = content.querySelector(schema.tag.toLowerCase());
|
|
2392
|
+
if (!element) return void 0;
|
|
2393
|
+
if (schema.matchesElement && !schema.matchesElement(element)) {
|
|
2394
|
+
return void 0;
|
|
2395
|
+
}
|
|
2396
|
+
return element;
|
|
2397
|
+
};
|
|
2398
|
+
var queryAllElementsBySchema = (content, schemaCode) => {
|
|
2399
|
+
const schema = findSchemaByCode(schemaCode);
|
|
2400
|
+
const elements = content.querySelectorAll(
|
|
2401
|
+
schema.tag.toLowerCase()
|
|
2402
|
+
);
|
|
2403
|
+
const matchingElements = [];
|
|
2404
|
+
for (const element of elements) {
|
|
2405
|
+
if (schema.matchesElement && !schema.matchesElement(element)) {
|
|
2406
|
+
continue;
|
|
2407
|
+
}
|
|
2408
|
+
matchingElements.push(element);
|
|
2409
|
+
}
|
|
2410
|
+
return matchingElements;
|
|
2411
|
+
};
|
|
2412
|
+
|
|
2388
2413
|
// src/schema/shared/labelElements.ts
|
|
2389
2414
|
var ElementLabel = {
|
|
2390
2415
|
referenceBibliomixed: "Reference Bibliomixed",
|
|
@@ -2924,7 +2949,7 @@ var collectPossibleWebLinks = (content) => {
|
|
|
2924
2949
|
const possibleWebLinks = /* @__PURE__ */ new Set();
|
|
2925
2950
|
const instance = new Mark(clone);
|
|
2926
2951
|
instance.markRegExp(WEB_URI_IN_TEXT_REGEX, {
|
|
2927
|
-
acrossElements:
|
|
2952
|
+
acrossElements: false,
|
|
2928
2953
|
exclude: POSSIBLE_WEBLINK_EXCLUDE_SELECTORS,
|
|
2929
2954
|
filter: (_textNode, term) => {
|
|
2930
2955
|
possibleWebLinks.add(term);
|
|
@@ -3048,5 +3073,7 @@ export {
|
|
|
3048
3073
|
isIgnoredElement,
|
|
3049
3074
|
isIgnoredValidation,
|
|
3050
3075
|
isTrackChangesSchema,
|
|
3076
|
+
queryAllElementsBySchema,
|
|
3077
|
+
queryElementBySchema,
|
|
3051
3078
|
validateXml
|
|
3052
3079
|
};
|