stickyflow 0.9.2 → 0.9.3
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.
|
@@ -6819,12 +6819,69 @@ function outermostRemovalRanges(ranges) {
|
|
|
6819
6819
|
);
|
|
6820
6820
|
}
|
|
6821
6821
|
|
|
6822
|
+
// src/runtime/interaction/sflPatch/canvasObjectPatch/repeatCell.ts
|
|
6823
|
+
var REPEAT_HEADER = /^(\s*)Repeat\s+[A-Za-z_]\w*\s*\{\s*$/;
|
|
6824
|
+
var TEMPLATE_HEADER = /^\s*[A-Z]\w*\s+([A-Za-z_]\w*)\b[^{]*\{/;
|
|
6825
|
+
var PROPERTY = /^\s*[A-Za-z_]\w*\s*:/;
|
|
6826
|
+
var WHERE = /^(\s*)where\s*:\s*(.+?)\s*$/;
|
|
6827
|
+
var escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6828
|
+
function excludeRepeatCell(lines, id) {
|
|
6829
|
+
const masked = maskLines(lines);
|
|
6830
|
+
if (masked === null) {
|
|
6831
|
+
return null;
|
|
6832
|
+
}
|
|
6833
|
+
for (let start = 0; start < masked.length; start++) {
|
|
6834
|
+
const header = masked[start].match(REPEAT_HEADER);
|
|
6835
|
+
if (!header) {
|
|
6836
|
+
continue;
|
|
6837
|
+
}
|
|
6838
|
+
const end = blockEndLine(lines, start);
|
|
6839
|
+
let depth = 0;
|
|
6840
|
+
let cell = null;
|
|
6841
|
+
let whereLine = -1;
|
|
6842
|
+
let lastProperty = start;
|
|
6843
|
+
let seenTemplate = false;
|
|
6844
|
+
for (let i = start; i <= end; i++) {
|
|
6845
|
+
if (depth === 1 && i > start) {
|
|
6846
|
+
const template = masked[i].match(TEMPLATE_HEADER);
|
|
6847
|
+
if (template) {
|
|
6848
|
+
seenTemplate = true;
|
|
6849
|
+
const made = id.match(new RegExp(`^${escaped(template[1])}_(\\d+)(?:_(\\d+))?$`));
|
|
6850
|
+
if (made) {
|
|
6851
|
+
cell = { col: Number(made[1]), row: made[2] === void 0 ? 0 : Number(made[2]) };
|
|
6852
|
+
}
|
|
6853
|
+
} else if (WHERE.test(masked[i])) {
|
|
6854
|
+
whereLine = i;
|
|
6855
|
+
} else if (!seenTemplate && PROPERTY.test(masked[i])) {
|
|
6856
|
+
lastProperty = i;
|
|
6857
|
+
}
|
|
6858
|
+
}
|
|
6859
|
+
depth += braceDelta(masked[i]);
|
|
6860
|
+
}
|
|
6861
|
+
if (!cell) {
|
|
6862
|
+
continue;
|
|
6863
|
+
}
|
|
6864
|
+
const keep = `(col != ${cell.col} || row != ${cell.row})`;
|
|
6865
|
+
const out = [...lines];
|
|
6866
|
+
if (whereLine >= 0) {
|
|
6867
|
+
const where = lines[whereLine].match(WHERE);
|
|
6868
|
+
if (where) {
|
|
6869
|
+
out[whereLine] = `${where[1]}where: (${where[2]}) && ${keep}`;
|
|
6870
|
+
return out;
|
|
6871
|
+
}
|
|
6872
|
+
}
|
|
6873
|
+
out.splice(lastProperty + 1, 0, `${header[1]} where: ${keep}`);
|
|
6874
|
+
return out;
|
|
6875
|
+
}
|
|
6876
|
+
return null;
|
|
6877
|
+
}
|
|
6878
|
+
|
|
6822
6879
|
// src/runtime/interaction/sflPatch/canvasObjectPatch/remove.ts
|
|
6823
6880
|
function removeCanvasObject(sfl, id, options = {}) {
|
|
6824
6881
|
const lines = sfl.split("\n");
|
|
6825
6882
|
const canvasObjectRange = findOwnerBlock(lines, id);
|
|
6826
6883
|
if (!canvasObjectRange) {
|
|
6827
|
-
return sfl;
|
|
6884
|
+
return excludeRepeatCell(lines, id)?.join("\n") ?? sfl;
|
|
6828
6885
|
}
|
|
6829
6886
|
const ranges = [canvasObjectRange];
|
|
6830
6887
|
if (options.alsoRemoveLinks ?? true) {
|