@burger-editor/client 4.0.0-alpha.60 → 4.0.0-alpha.61
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/client.js +84 -12
- package/dist/client.js.map +1 -1
- package/package.json +6 -6
package/dist/client.js
CHANGED
|
@@ -3344,9 +3344,14 @@ function getCustomProperties(scope, containerType) {
|
|
|
3344
3344
|
: newDefaultValue);
|
|
3345
3345
|
}
|
|
3346
3346
|
});
|
|
3347
|
+
// Filter out disabled properties declared with empty value (e.g. `--prop: ;`)
|
|
3348
|
+
// CSSOM getPropertyValue() returns ' ' for `--prop: ;`, which becomes '' after trim().
|
|
3349
|
+
// Note: `--prop:;` (no space) is dropped by current browsers (parse error).
|
|
3350
|
+
// @see https://drafts.csswg.org/css-variables-2/#defining-variables
|
|
3351
|
+
// @see https://github.com/w3c/csswg-drafts/issues/774
|
|
3347
3352
|
for (const propList of categories.values()) {
|
|
3348
3353
|
for (const [key, customProperty] of propList.properties.entries()) {
|
|
3349
|
-
if (customProperty.value.trim()
|
|
3354
|
+
if (customProperty.value.trim() === '') {
|
|
3350
3355
|
propList.properties.delete(key);
|
|
3351
3356
|
}
|
|
3352
3357
|
}
|
|
@@ -3386,15 +3391,77 @@ function getCustomProperty(scope, property) {
|
|
|
3386
3391
|
});
|
|
3387
3392
|
return resultValue;
|
|
3388
3393
|
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Collect the global top-level layer order across all stylesheets in the document.
|
|
3396
|
+
*
|
|
3397
|
+
* CSS cascade layers are ordered globally across the entire document, not per-stylesheet.
|
|
3398
|
+
* This function mirrors the browser's layer ordering algorithm:
|
|
3399
|
+
* - Pass 1: Collect layers declared in `@layer` statement rules (first-occurrence wins)
|
|
3400
|
+
* - Pass 2: Append layers that appear only in `@layer` block rules
|
|
3401
|
+
*
|
|
3402
|
+
* Cross-origin stylesheets that throw `SecurityError` are silently skipped.
|
|
3403
|
+
* @see {@link https://www.w3.org/TR/css-cascade-5/#layer-ordering CSS Cascading and Inheritance Level 5 §6.4.3 Layer Ordering}
|
|
3404
|
+
* > "Cascade layers are sorted by the order in which they first are declared,
|
|
3405
|
+
* > with nested layers grouped within their parent layers before any unlayered rules."
|
|
3406
|
+
* @see {@link https://www.w3.org/TR/css-cascade-5/#layer-empty CSS Cascading and Inheritance Level 5 §6.4.4.2 Declaring Without Styles}
|
|
3407
|
+
* @param scope - Document to scan
|
|
3408
|
+
* @returns Ordered array of top-level layer names
|
|
3409
|
+
*/
|
|
3410
|
+
function collectGlobalTopLevelLayerOrder(scope) {
|
|
3411
|
+
const CSSLayerStatementRule = scope.defaultView?.CSSLayerStatementRule;
|
|
3412
|
+
const CSSLayerBlockRule = scope.defaultView?.CSSLayerBlockRule;
|
|
3413
|
+
if (CSSLayerStatementRule === undefined || CSSLayerBlockRule === undefined) {
|
|
3414
|
+
return [];
|
|
3415
|
+
}
|
|
3416
|
+
const allLayerNames = [];
|
|
3417
|
+
// Pass 1: Collect layers declared in @layer statements (explicit order takes precedence)
|
|
3418
|
+
for (const styleSheet of scope.styleSheets) {
|
|
3419
|
+
try {
|
|
3420
|
+
for (const rule of styleSheet.cssRules) {
|
|
3421
|
+
if (rule instanceof CSSLayerStatementRule) {
|
|
3422
|
+
for (const name of rule.nameList) {
|
|
3423
|
+
if (!allLayerNames.includes(name)) {
|
|
3424
|
+
allLayerNames.push(name);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
catch (error) {
|
|
3431
|
+
if (error instanceof Error && error.name === 'SecurityError') {
|
|
3432
|
+
continue;
|
|
3433
|
+
}
|
|
3434
|
+
throw error;
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3437
|
+
// Pass 2: Append layers that appear only in @layer block rules (first-occurrence after statements)
|
|
3438
|
+
for (const styleSheet of scope.styleSheets) {
|
|
3439
|
+
try {
|
|
3440
|
+
for (const rule of styleSheet.cssRules) {
|
|
3441
|
+
if (rule instanceof CSSLayerBlockRule && !allLayerNames.includes(rule.name)) {
|
|
3442
|
+
allLayerNames.push(rule.name);
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
catch (error) {
|
|
3447
|
+
if (error instanceof Error && error.name === 'SecurityError') {
|
|
3448
|
+
continue;
|
|
3449
|
+
}
|
|
3450
|
+
throw error;
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
return allLayerNames;
|
|
3454
|
+
}
|
|
3389
3455
|
/**
|
|
3390
3456
|
* Get all CSSStyleRule from CSSRule array recursively
|
|
3391
3457
|
* @param rules - CSSRule array
|
|
3392
3458
|
* @param layers
|
|
3393
3459
|
* @param scope - Document
|
|
3394
3460
|
* @param scopeRoot
|
|
3461
|
+
* @param topLevelLayerOrder - Global layer order from collectGlobalTopLevelLayerOrder (top-level calls only)
|
|
3395
3462
|
* @returns CSSStyleRule array
|
|
3396
3463
|
*/
|
|
3397
|
-
function getStyleRules(rules, layers, scope, scopeRoot = null) {
|
|
3464
|
+
function getStyleRules(rules, layers, scope, scopeRoot = null, topLevelLayerOrder) {
|
|
3398
3465
|
const CSSStyleRule = scope.defaultView?.CSSStyleRule;
|
|
3399
3466
|
if (CSSStyleRule === undefined) {
|
|
3400
3467
|
throw new Error('CSSStyleRule is not available');
|
|
@@ -3408,14 +3475,18 @@ function getStyleRules(rules, layers, scope, scopeRoot = null) {
|
|
|
3408
3475
|
throw new Error('CSSLayerStatementRule is not available');
|
|
3409
3476
|
}
|
|
3410
3477
|
const CSSScopeRule = scope.defaultView?.CSSScopeRule;
|
|
3411
|
-
// Build unified layer order
|
|
3412
|
-
//
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3478
|
+
// Build unified layer order:
|
|
3479
|
+
// - When topLevelLayerOrder is provided (top-level call), use it as the base and append any local-only names
|
|
3480
|
+
// - When not provided (recursive call for nested layers), compute locally from this rule list
|
|
3481
|
+
const allLayerNames = topLevelLayerOrder ? [...topLevelLayerOrder] : [];
|
|
3482
|
+
if (!topLevelLayerOrder) {
|
|
3483
|
+
// Pass 1: Collect layers declared in @layer statements (explicit order takes precedence)
|
|
3484
|
+
for (const rule of rules) {
|
|
3485
|
+
if (rule instanceof CSSLayerStatementRule) {
|
|
3486
|
+
for (const name of rule.nameList) {
|
|
3487
|
+
if (!allLayerNames.includes(name)) {
|
|
3488
|
+
allLayerNames.push(name);
|
|
3489
|
+
}
|
|
3419
3490
|
}
|
|
3420
3491
|
}
|
|
3421
3492
|
}
|
|
@@ -3462,9 +3533,10 @@ function getStyleRules(rules, layers, scope, scopeRoot = null) {
|
|
|
3462
3533
|
* @param found
|
|
3463
3534
|
*/
|
|
3464
3535
|
function searchCustomProperty(scope, found) {
|
|
3536
|
+
const globalLayerOrder = collectGlobalTopLevelLayerOrder(scope);
|
|
3465
3537
|
for (const styleSheet of scope.styleSheets) {
|
|
3466
3538
|
try {
|
|
3467
|
-
const styleRules = getStyleRules(styleSheet.cssRules, [], scope);
|
|
3539
|
+
const styleRules = getStyleRules(styleSheet.cssRules, [], scope, null, globalLayerOrder);
|
|
3468
3540
|
for (const cssRule of styleRules) {
|
|
3469
3541
|
const selector = cssRule.rule.selectorText.trim().replace(/^&/, '').trim();
|
|
3470
3542
|
if (selector === BLOCK_OPTION_SCOPE_SELECTOR ||
|
|
@@ -45044,7 +45116,7 @@ function parseConfig(config) {
|
|
|
45044
45116
|
}
|
|
45045
45117
|
}
|
|
45046
45118
|
|
|
45047
|
-
const version = "4.0.0-alpha.
|
|
45119
|
+
const version = "4.0.0-alpha.60";
|
|
45048
45120
|
function attachDraftSwitcher(engine) {
|
|
45049
45121
|
if (engine.hasDraft()) {
|
|
45050
45122
|
const container = document.createElement("div");
|