ooxml-core 1.10.0 → 1.11.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/dist/PptxHandler-DNZHAHUY.cjs +12 -0
- package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
- package/dist/{PptxHandler-ADEFY476.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
- package/dist/automation/index.cjs +3293 -2867
- package/dist/automation/index.mjs +3293 -2867
- package/dist/{chunk-3N6XMMTT.cjs → chunk-2UVH6RHI.cjs} +1138 -996
- package/dist/{chunk-ZOUGMAZG.mjs → chunk-7DSZI7S6.mjs} +1 -1
- package/dist/{chunk-S6DOCMQC.cjs → chunk-7QZGRB3T.cjs} +0 -10
- package/dist/chunk-ANZ4Q6I3.cjs +21 -0
- package/dist/{chunk-5NVJN4E6.mjs → chunk-EC2W2MDY.mjs} +1 -1
- package/dist/chunk-EGTRL3QJ.mjs +19 -0
- package/dist/chunk-GXHKNSZX.mjs +9 -0
- package/dist/{chunk-CCHYFCPD.mjs → chunk-HCXUI5UC.mjs} +296 -103
- package/dist/chunk-HDQXPSHY.cjs +17 -0
- package/dist/chunk-KTYBFGEY.mjs +14 -0
- package/dist/chunk-QOO36KG4.cjs +42 -0
- package/dist/chunk-R2KZXD6U.mjs +39 -0
- package/dist/{chunk-A6P7G3UK.mjs → chunk-U2DF3EGK.mjs} +1 -1
- package/dist/{chunk-R6KSBNKX.mjs → chunk-UAY26XOI.mjs} +1 -9
- package/dist/{chunk-WUE5ZHU3.mjs → chunk-W5ARCUJB.mjs} +3 -3
- package/dist/chunk-XZPZHXV4.cjs +12 -0
- package/dist/{chunk-ZE53K7DH.mjs → chunk-YB5SRNFS.mjs} +244 -102
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +125 -56
- package/dist/docx/layout/index.mjs +125 -56
- package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
- package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
- package/dist/docx/layout/result.d.ts +7 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/table-border-layout.d.ts +1 -1
- package/dist/docx/layout/table-border-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-frames.d.ts.map +1 -1
- package/dist/docx/layout/table-layout.d.ts +1 -1
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +266 -114
- package/dist/pptx/automation/index.d.ts +5 -4
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{text-operations-BqHmLaLA.d.ts → elements-DD3UGOMd.d.ts} +17 -3262
- package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DUCGeZh7.d.ts → index-BZrFyNtU.d.ts} +53 -5
- package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-Cuxtr76Y.d.ts → index-DdX02BSm.d.ts} +5 -3
- package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +266 -114
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +17 -16
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +2 -1
- package/dist/pptx/editor/render/font-family-update.cjs +14 -0
- package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
- package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
- package/dist/pptx/editor/render/font-family-update.mjs +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
- package/dist/pptx/editor/render/slide-operations.cjs +9 -8
- package/dist/pptx/editor/render/slide-operations.mjs +3 -2
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.cjs +18 -0
- package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
- package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-content-style.mjs +5 -0
- package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
- package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
- package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
- package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
- package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
- package/dist/pptx/index.cjs +329 -114
- package/dist/pptx/index.d.ts +7 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +112 -16
- package/dist/teams/index.mjs +112 -16
- package/dist/visio/edit-commands.d.ts +3 -3
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-text-field-commands.d.ts +15 -0
- package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
- package/dist/visio/edit-text-field.d.ts +2 -2
- package/dist/visio/edit-text-field.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +382 -210
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +382 -210
- package/dist/visio/model.d.ts +6 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/style.d.ts +1 -1
- package/dist/visio/style.d.ts.map +1 -1
- package/dist/visio/text-field-display.d.ts +3 -0
- package/dist/visio/text-field-display.d.ts.map +1 -1
- package/dist/visio/text-field-editability.d.ts +6 -0
- package/dist/visio/text-field-editability.d.ts.map +1 -0
- package/dist/visio/text-field-independent.d.ts +4 -0
- package/dist/visio/text-field-independent.d.ts.map +1 -0
- package/dist/visio/text-field-source.d.ts +6 -0
- package/dist/visio/text-field-source.d.ts.map +1 -0
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +394 -211
- package/dist/visio/ui/index.mjs +394 -211
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +773 -514
- package/dist/xlsx/index.mjs +772 -515
- package/dist/xlsx/load/index.cjs +541 -292
- package/dist/xlsx/load/index.mjs +541 -292
- package/dist/xlsx/model-pivots.d.ts +8 -0
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +2 -2
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/index.d.ts +2 -0
- package/dist/xlsx/pivot/index.d.ts.map +1 -1
- package/dist/xlsx/pivot/measures.d.ts +1 -1
- package/dist/xlsx/pivot/measures.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
- package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
- package/dist/xlsx/pivot/page-filter.d.ts +11 -0
- package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +4 -1
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +95 -12
- package/dist/xlsx/ui/index.mjs +95 -12
- package/package.json +2 -2
- package/dist/PptxHandler-5UURGJEV.mjs +0 -2
- package/dist/PptxHandler-U5XB2HUE.cjs +0 -11
- package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts +0 -2980
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BqHmLaLA.d.ts.map +0 -1
package/dist/visio/ui/index.mjs
CHANGED
|
@@ -3814,6 +3814,208 @@ function takeDeferredTextSizes(root2) {
|
|
|
3814
3814
|
return shapes;
|
|
3815
3815
|
}
|
|
3816
3816
|
|
|
3817
|
+
// visio/text-fields.ts
|
|
3818
|
+
var PROPERTY_FUNCTIONS = {
|
|
3819
|
+
TITLE: "title",
|
|
3820
|
+
SUBJECT: "subject",
|
|
3821
|
+
CREATOR: "creator",
|
|
3822
|
+
KEYWORDS: "keywords",
|
|
3823
|
+
DESCRIPTION: "description",
|
|
3824
|
+
CATEGORY: "category",
|
|
3825
|
+
COMPANY: "company",
|
|
3826
|
+
MANAGER: "manager"
|
|
3827
|
+
};
|
|
3828
|
+
var DATE_FUNCTIONS = {
|
|
3829
|
+
NOW: void 0,
|
|
3830
|
+
DOCCREATION: "created",
|
|
3831
|
+
DOCLASTSAVE: "modified",
|
|
3832
|
+
DOCLASTEDIT: "modified",
|
|
3833
|
+
DOCLASTPRINT: "lastPrinted"
|
|
3834
|
+
};
|
|
3835
|
+
var VISIO_FIELD_FUNCTIONS = [
|
|
3836
|
+
...Object.keys(PROPERTY_FUNCTIONS),
|
|
3837
|
+
...Object.keys(DATE_FUNCTIONS),
|
|
3838
|
+
"PAGENAME"
|
|
3839
|
+
];
|
|
3840
|
+
function visioWallClock(date2) {
|
|
3841
|
+
return new Date(
|
|
3842
|
+
Date.UTC(
|
|
3843
|
+
date2.getFullYear(),
|
|
3844
|
+
date2.getMonth(),
|
|
3845
|
+
date2.getDate(),
|
|
3846
|
+
date2.getHours(),
|
|
3847
|
+
date2.getMinutes(),
|
|
3848
|
+
date2.getSeconds()
|
|
3849
|
+
)
|
|
3850
|
+
);
|
|
3851
|
+
}
|
|
3852
|
+
var EPOCH = Date.UTC(1899, 11, 30);
|
|
3853
|
+
var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
|
|
3854
|
+
function evaluateVisioTextField(formula, context) {
|
|
3855
|
+
let ast;
|
|
3856
|
+
try {
|
|
3857
|
+
ast = parseVisioFormula(formula, { maxLength: 4096 });
|
|
3858
|
+
} catch {
|
|
3859
|
+
return void 0;
|
|
3860
|
+
}
|
|
3861
|
+
if (ast.kind === "call") {
|
|
3862
|
+
const name3 = ast.name;
|
|
3863
|
+
if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
|
|
3864
|
+
const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
|
|
3865
|
+
return value === void 0 ? void 0 : { kind: "string", text: value };
|
|
3866
|
+
}
|
|
3867
|
+
if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
|
|
3868
|
+
if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
|
|
3869
|
+
const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
|
|
3870
|
+
const time = stamp ? Date.parse(stamp) : Number.NaN;
|
|
3871
|
+
return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
|
|
3872
|
+
}
|
|
3873
|
+
if (name3 === "PAGENAME" && ast.args.length <= 1)
|
|
3874
|
+
return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
|
|
3875
|
+
}
|
|
3876
|
+
try {
|
|
3877
|
+
const result = evaluateVisioFormula(
|
|
3878
|
+
ast,
|
|
3879
|
+
context.resolve ?? (() => {
|
|
3880
|
+
throw new Error("No cell context");
|
|
3881
|
+
}),
|
|
3882
|
+
{
|
|
3883
|
+
...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
|
|
3884
|
+
...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
|
|
3885
|
+
}
|
|
3886
|
+
);
|
|
3887
|
+
return { kind: "number", value: result.value, unit: result.unit };
|
|
3888
|
+
} catch {
|
|
3889
|
+
return void 0;
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
var MONTHS = [
|
|
3893
|
+
"January",
|
|
3894
|
+
"February",
|
|
3895
|
+
"March",
|
|
3896
|
+
"April",
|
|
3897
|
+
"May",
|
|
3898
|
+
"June",
|
|
3899
|
+
"July",
|
|
3900
|
+
"August",
|
|
3901
|
+
"September",
|
|
3902
|
+
"October",
|
|
3903
|
+
"November",
|
|
3904
|
+
"December"
|
|
3905
|
+
];
|
|
3906
|
+
var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
3907
|
+
var pad = (value, length = 2) => String(value).padStart(length, "0");
|
|
3908
|
+
function dateToken(date2, token) {
|
|
3909
|
+
const hours = date2.getUTCHours();
|
|
3910
|
+
switch (token) {
|
|
3911
|
+
case "yyyy":
|
|
3912
|
+
return pad(date2.getUTCFullYear(), 4);
|
|
3913
|
+
case "yy":
|
|
3914
|
+
return pad(date2.getUTCFullYear() % 100);
|
|
3915
|
+
case "MMMM":
|
|
3916
|
+
return MONTHS[date2.getUTCMonth()];
|
|
3917
|
+
case "MMM":
|
|
3918
|
+
return MONTHS[date2.getUTCMonth()].slice(0, 3);
|
|
3919
|
+
case "MM":
|
|
3920
|
+
return pad(date2.getUTCMonth() + 1);
|
|
3921
|
+
case "M":
|
|
3922
|
+
return String(date2.getUTCMonth() + 1);
|
|
3923
|
+
case "dddd":
|
|
3924
|
+
return DAYS[date2.getUTCDay()];
|
|
3925
|
+
case "ddd":
|
|
3926
|
+
return DAYS[date2.getUTCDay()].slice(0, 3);
|
|
3927
|
+
case "dd":
|
|
3928
|
+
return pad(date2.getUTCDate());
|
|
3929
|
+
case "d":
|
|
3930
|
+
return String(date2.getUTCDate());
|
|
3931
|
+
case "HH":
|
|
3932
|
+
return pad(hours);
|
|
3933
|
+
case "H":
|
|
3934
|
+
return String(hours);
|
|
3935
|
+
case "hh":
|
|
3936
|
+
return pad(hours % 12 || 12);
|
|
3937
|
+
case "h":
|
|
3938
|
+
return String(hours % 12 || 12);
|
|
3939
|
+
case "mm":
|
|
3940
|
+
return pad(date2.getUTCMinutes());
|
|
3941
|
+
case "ss":
|
|
3942
|
+
return pad(date2.getUTCSeconds());
|
|
3943
|
+
case "tt":
|
|
3944
|
+
return hours < 12 ? "AM" : "PM";
|
|
3945
|
+
default:
|
|
3946
|
+
return void 0;
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
function formatDate(date2, picture) {
|
|
3950
|
+
return picture.replace(
|
|
3951
|
+
/yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
|
|
3952
|
+
(token) => {
|
|
3953
|
+
if (token.startsWith('"')) return token.slice(1, -1);
|
|
3954
|
+
return dateToken(date2, token) ?? token;
|
|
3955
|
+
}
|
|
3956
|
+
);
|
|
3957
|
+
}
|
|
3958
|
+
function formatNumber(value, picture) {
|
|
3959
|
+
const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
|
|
3960
|
+
if (!match) return void 0;
|
|
3961
|
+
const decimals = match[2]?.length ?? 0;
|
|
3962
|
+
const optional = match[2]?.startsWith("#") ?? false;
|
|
3963
|
+
const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
|
|
3964
|
+
const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
|
|
3965
|
+
const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
|
|
3966
|
+
let text7 = (Math.sign(value) * rounded).toFixed(decimals);
|
|
3967
|
+
if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
|
|
3968
|
+
if (match[1]) {
|
|
3969
|
+
const [whole, fraction] = text7.split(".");
|
|
3970
|
+
text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
|
|
3971
|
+
}
|
|
3972
|
+
return text7 === "-0" ? "0" : text7;
|
|
3973
|
+
}
|
|
3974
|
+
var VISIO_FIELD_FORMATS = {
|
|
3975
|
+
shortDate: "{{M/d/yyyy}}",
|
|
3976
|
+
isoDate: "{{yyyy-MM-dd}}",
|
|
3977
|
+
longDate: "{{dddd, MMMM d, yyyy}}",
|
|
3978
|
+
time: "{{h:mm tt}}",
|
|
3979
|
+
dateTime: "{{M/d/yyyy h:mm tt}}",
|
|
3980
|
+
text: "@",
|
|
3981
|
+
integer: "0",
|
|
3982
|
+
decimal: "0.00",
|
|
3983
|
+
decimalUnits: "0.00 u",
|
|
3984
|
+
integerUnits: "0 u"
|
|
3985
|
+
};
|
|
3986
|
+
function formatVisioFieldValue(value, format4 = "") {
|
|
3987
|
+
const picture = format4.trim();
|
|
3988
|
+
if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
|
|
3989
|
+
if (value.kind === "date") {
|
|
3990
|
+
const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
|
|
3991
|
+
return date2 === void 0 ? void 0 : formatDate(value.date, date2);
|
|
3992
|
+
}
|
|
3993
|
+
const units2 = / u$/.test(picture);
|
|
3994
|
+
const body = picture.replace(/ u$/, "");
|
|
3995
|
+
let number5 = value.value, suffix = "";
|
|
3996
|
+
if (value.unit === "angle") {
|
|
3997
|
+
number5 = number5 * 180 / Math.PI;
|
|
3998
|
+
suffix = " deg.";
|
|
3999
|
+
} else if (value.unit === "length") suffix = " in.";
|
|
4000
|
+
else if (value.unit !== "scalar") return void 0;
|
|
4001
|
+
const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
|
|
4002
|
+
if (text7 === void 0) return void 0;
|
|
4003
|
+
return units2 || body === "" ? `${text7}${suffix}` : text7;
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
// visio/text-field-independent.ts
|
|
4007
|
+
function independentTextFieldFormula(cell, formula) {
|
|
4008
|
+
const row2 = cell.parentNode, section3 = row2?.parentNode;
|
|
4009
|
+
if (cell.localName !== "Cell" || row2?.localName !== "Row" || section3?.localName !== "Section" || attribute2(section3, "N") !== "Field" || row2.hasAttribute("Del") || section3.hasAttribute("Del") || row2.hasAttribute("N") || row2.hasAttribute("T") || !/^(0|[1-9]\d*)$/.test(attribute2(row2, "IX") ?? "0") || (attribute2(section3, "IX") ?? "0") !== "0" || cell.hasAttribute("E"))
|
|
4010
|
+
return false;
|
|
4011
|
+
if (attribute2(cell, "N") === "Format")
|
|
4012
|
+
return /^\s*FIELDPICTURE\(\s*(2|37|204)\s*\)\s*$/i.test(formula);
|
|
4013
|
+
if (attribute2(cell, "N") !== "Value") return false;
|
|
4014
|
+
if (/^\s*DATE\(\s*\d{1,4}\s*,\s*\d{1,2}\s*,\s*\d{1,2}\s*\)\s*$/i.test(formula)) return true;
|
|
4015
|
+
const direct = /^\s*([A-Z]+)\(\s*\)\s*$/i.exec(formula)?.[1]?.toUpperCase();
|
|
4016
|
+
return direct !== void 0 && VISIO_FIELD_FUNCTIONS.includes(direct);
|
|
4017
|
+
}
|
|
4018
|
+
|
|
3817
4019
|
// visio/edit-connector-glue.ts
|
|
3818
4020
|
var VISIO_WALK_GLUE = "_WALKGLUE(BegTrigger,EndTrigger,WalkPreference)";
|
|
3819
4021
|
var walkGlue = /^\s*_WALKGLUE\((?:BegTrigger,EndTrigger|EndTrigger,BegTrigger),WalkPreference\)\s*$/i;
|
|
@@ -3923,7 +4125,7 @@ function indexCells(roots2, options) {
|
|
|
3923
4125
|
unit: cellUnit(cell, relative)
|
|
3924
4126
|
};
|
|
3925
4127
|
const source = attribute2(node2, "F");
|
|
3926
|
-
if (executableCellFormula(source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
|
|
4128
|
+
if (executableCellFormula(source) && !independentTextFieldFormula(node2, source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
|
|
3927
4129
|
// (Visio's freshly dropped connector names its own sheet).
|
|
3928
4130
|
!(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
|
|
3929
4131
|
try {
|
|
@@ -9760,6 +9962,77 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
|
|
|
9760
9962
|
}
|
|
9761
9963
|
}
|
|
9762
9964
|
|
|
9965
|
+
// visio/text-field-source.ts
|
|
9966
|
+
var proofs = /* @__PURE__ */ new WeakMap();
|
|
9967
|
+
function textFieldSourceKey(cells4) {
|
|
9968
|
+
if (proofs.has(cells4)) return proofs.get(cells4);
|
|
9969
|
+
if (cells4.size > 64) {
|
|
9970
|
+
proofs.set(cells4, void 0);
|
|
9971
|
+
return void 0;
|
|
9972
|
+
}
|
|
9973
|
+
const key2 = JSON.stringify(
|
|
9974
|
+
[...cells4].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name3, cell]) => [
|
|
9975
|
+
name3,
|
|
9976
|
+
cell.value ?? null,
|
|
9977
|
+
cell.formula ?? null,
|
|
9978
|
+
cell.unit ?? null,
|
|
9979
|
+
cell.error ?? null
|
|
9980
|
+
])
|
|
9981
|
+
);
|
|
9982
|
+
const bounded6 = key2.length <= 2048 ? key2 : void 0;
|
|
9983
|
+
proofs.set(cells4, bounded6);
|
|
9984
|
+
return bounded6;
|
|
9985
|
+
}
|
|
9986
|
+
|
|
9987
|
+
// visio/text-field-editability.ts
|
|
9988
|
+
function assertEditableFieldRow(existing) {
|
|
9989
|
+
for (const name3 of ["Calendar", "ObjectKind"]) {
|
|
9990
|
+
const cell = children2(existing, "Cell").find((cell2) => attribute2(cell2, "N") === name3);
|
|
9991
|
+
if (cell && (attribute2(cell, "V") !== "0" || cell.hasAttribute("F") || cell.hasAttribute("E")))
|
|
9992
|
+
fail(
|
|
9993
|
+
"UNSUPPORTED_TEXT_FIELD",
|
|
9994
|
+
"Nonstandard field calendar or object profiles cannot be edited."
|
|
9995
|
+
);
|
|
9996
|
+
}
|
|
9997
|
+
for (const cell of children2(existing, "Cell")) {
|
|
9998
|
+
const name3 = attribute2(cell, "N") ?? "";
|
|
9999
|
+
if (/^(value|format|type|calendar|objectkind)$/i.test(name3) && !["Value", "Format", "Type", "Calendar", "ObjectKind"].includes(name3))
|
|
10000
|
+
fail("UNSUPPORTED_TEXT_FIELD", "Noncanonical field cell names cannot be edited.");
|
|
10001
|
+
if (["Value", "Format", "Type"].includes(attribute2(cell, "N") ?? "") && (cell.hasAttribute("E") || /^\s*(Inh|GUARD\s*\()/i.test(attribute2(cell, "F") ?? "")))
|
|
10002
|
+
fail("UNSUPPORTED_TEXT_FIELD", "Protected or inherited field cells cannot be edited.");
|
|
10003
|
+
}
|
|
10004
|
+
}
|
|
10005
|
+
function assertEditableFieldShape(shape) {
|
|
10006
|
+
if (shape.localName !== "Shape" || shape.parentNode?.parentNode?.localName !== "PageContents" || shape.hasAttribute("Master") || shape.hasAttribute("MasterShape") || attribute2(shape, "Type") === "Group" || ["Shapes", "ForeignData", "Rel"].some((name3) => children2(shape, name3).length))
|
|
10007
|
+
fail("UNSUPPORTED_TEXT_FIELD", "Existing field edits require a top-level plain local shape.");
|
|
10008
|
+
}
|
|
10009
|
+
function editableTextFieldIndices(text7, allowed) {
|
|
10010
|
+
const result = /* @__PURE__ */ new Set();
|
|
10011
|
+
if (!allowed || !text7) return result;
|
|
10012
|
+
const shape = text7.parentNode;
|
|
10013
|
+
try {
|
|
10014
|
+
assertEditableFieldShape(shape);
|
|
10015
|
+
assertFormattingText(shape);
|
|
10016
|
+
const rows = formattingRows(shape, "Field");
|
|
10017
|
+
const markers = children2(text7, "fld");
|
|
10018
|
+
const counts = /* @__PURE__ */ new Map();
|
|
10019
|
+
for (const marker2 of markers) {
|
|
10020
|
+
const index = attribute2(marker2, "IX");
|
|
10021
|
+
counts.set(index, (counts.get(index) ?? 0) + 1);
|
|
10022
|
+
}
|
|
10023
|
+
for (const [index, row2] of rows) {
|
|
10024
|
+
if (counts.get(index) !== 1 || textFieldSourceKey(readCells(row2)) === void 0) continue;
|
|
10025
|
+
try {
|
|
10026
|
+
assertEditableFieldRow(row2);
|
|
10027
|
+
result.add(index);
|
|
10028
|
+
} catch {
|
|
10029
|
+
}
|
|
10030
|
+
}
|
|
10031
|
+
} catch {
|
|
10032
|
+
}
|
|
10033
|
+
return result;
|
|
10034
|
+
}
|
|
10035
|
+
|
|
9763
10036
|
// geometry/svg-path-curves.ts
|
|
9764
10037
|
function sampleCubic(p0, p1, p2, p3, segments, out) {
|
|
9765
10038
|
for (let i = 1; i <= segments; i++) {
|
|
@@ -12175,195 +12448,6 @@ function visioFieldCase(text7, upper) {
|
|
|
12175
12448
|
}).join("");
|
|
12176
12449
|
}
|
|
12177
12450
|
|
|
12178
|
-
// visio/text-fields.ts
|
|
12179
|
-
var PROPERTY_FUNCTIONS = {
|
|
12180
|
-
TITLE: "title",
|
|
12181
|
-
SUBJECT: "subject",
|
|
12182
|
-
CREATOR: "creator",
|
|
12183
|
-
KEYWORDS: "keywords",
|
|
12184
|
-
DESCRIPTION: "description",
|
|
12185
|
-
CATEGORY: "category",
|
|
12186
|
-
COMPANY: "company",
|
|
12187
|
-
MANAGER: "manager"
|
|
12188
|
-
};
|
|
12189
|
-
var DATE_FUNCTIONS = {
|
|
12190
|
-
NOW: void 0,
|
|
12191
|
-
DOCCREATION: "created",
|
|
12192
|
-
DOCLASTSAVE: "modified",
|
|
12193
|
-
DOCLASTEDIT: "modified",
|
|
12194
|
-
DOCLASTPRINT: "lastPrinted"
|
|
12195
|
-
};
|
|
12196
|
-
var VISIO_FIELD_FUNCTIONS = [
|
|
12197
|
-
...Object.keys(PROPERTY_FUNCTIONS),
|
|
12198
|
-
...Object.keys(DATE_FUNCTIONS),
|
|
12199
|
-
"PAGENAME"
|
|
12200
|
-
];
|
|
12201
|
-
function visioWallClock(date2) {
|
|
12202
|
-
return new Date(
|
|
12203
|
-
Date.UTC(
|
|
12204
|
-
date2.getFullYear(),
|
|
12205
|
-
date2.getMonth(),
|
|
12206
|
-
date2.getDate(),
|
|
12207
|
-
date2.getHours(),
|
|
12208
|
-
date2.getMinutes(),
|
|
12209
|
-
date2.getSeconds()
|
|
12210
|
-
)
|
|
12211
|
-
);
|
|
12212
|
-
}
|
|
12213
|
-
var EPOCH = Date.UTC(1899, 11, 30);
|
|
12214
|
-
var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
|
|
12215
|
-
function evaluateVisioTextField(formula, context) {
|
|
12216
|
-
let ast;
|
|
12217
|
-
try {
|
|
12218
|
-
ast = parseVisioFormula(formula, { maxLength: 4096 });
|
|
12219
|
-
} catch {
|
|
12220
|
-
return void 0;
|
|
12221
|
-
}
|
|
12222
|
-
if (ast.kind === "call") {
|
|
12223
|
-
const name3 = ast.name;
|
|
12224
|
-
if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
|
|
12225
|
-
const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
|
|
12226
|
-
return value === void 0 ? void 0 : { kind: "string", text: value };
|
|
12227
|
-
}
|
|
12228
|
-
if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
|
|
12229
|
-
if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
|
|
12230
|
-
const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
|
|
12231
|
-
const time = stamp ? Date.parse(stamp) : Number.NaN;
|
|
12232
|
-
return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
|
|
12233
|
-
}
|
|
12234
|
-
if (name3 === "PAGENAME" && ast.args.length <= 1)
|
|
12235
|
-
return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
|
|
12236
|
-
}
|
|
12237
|
-
try {
|
|
12238
|
-
const result = evaluateVisioFormula(
|
|
12239
|
-
ast,
|
|
12240
|
-
context.resolve ?? (() => {
|
|
12241
|
-
throw new Error("No cell context");
|
|
12242
|
-
}),
|
|
12243
|
-
{
|
|
12244
|
-
...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
|
|
12245
|
-
...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
|
|
12246
|
-
}
|
|
12247
|
-
);
|
|
12248
|
-
return { kind: "number", value: result.value, unit: result.unit };
|
|
12249
|
-
} catch {
|
|
12250
|
-
return void 0;
|
|
12251
|
-
}
|
|
12252
|
-
}
|
|
12253
|
-
var MONTHS = [
|
|
12254
|
-
"January",
|
|
12255
|
-
"February",
|
|
12256
|
-
"March",
|
|
12257
|
-
"April",
|
|
12258
|
-
"May",
|
|
12259
|
-
"June",
|
|
12260
|
-
"July",
|
|
12261
|
-
"August",
|
|
12262
|
-
"September",
|
|
12263
|
-
"October",
|
|
12264
|
-
"November",
|
|
12265
|
-
"December"
|
|
12266
|
-
];
|
|
12267
|
-
var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
12268
|
-
var pad = (value, length = 2) => String(value).padStart(length, "0");
|
|
12269
|
-
function dateToken(date2, token) {
|
|
12270
|
-
const hours = date2.getUTCHours();
|
|
12271
|
-
switch (token) {
|
|
12272
|
-
case "yyyy":
|
|
12273
|
-
return pad(date2.getUTCFullYear(), 4);
|
|
12274
|
-
case "yy":
|
|
12275
|
-
return pad(date2.getUTCFullYear() % 100);
|
|
12276
|
-
case "MMMM":
|
|
12277
|
-
return MONTHS[date2.getUTCMonth()];
|
|
12278
|
-
case "MMM":
|
|
12279
|
-
return MONTHS[date2.getUTCMonth()].slice(0, 3);
|
|
12280
|
-
case "MM":
|
|
12281
|
-
return pad(date2.getUTCMonth() + 1);
|
|
12282
|
-
case "M":
|
|
12283
|
-
return String(date2.getUTCMonth() + 1);
|
|
12284
|
-
case "dddd":
|
|
12285
|
-
return DAYS[date2.getUTCDay()];
|
|
12286
|
-
case "ddd":
|
|
12287
|
-
return DAYS[date2.getUTCDay()].slice(0, 3);
|
|
12288
|
-
case "dd":
|
|
12289
|
-
return pad(date2.getUTCDate());
|
|
12290
|
-
case "d":
|
|
12291
|
-
return String(date2.getUTCDate());
|
|
12292
|
-
case "HH":
|
|
12293
|
-
return pad(hours);
|
|
12294
|
-
case "H":
|
|
12295
|
-
return String(hours);
|
|
12296
|
-
case "hh":
|
|
12297
|
-
return pad(hours % 12 || 12);
|
|
12298
|
-
case "h":
|
|
12299
|
-
return String(hours % 12 || 12);
|
|
12300
|
-
case "mm":
|
|
12301
|
-
return pad(date2.getUTCMinutes());
|
|
12302
|
-
case "ss":
|
|
12303
|
-
return pad(date2.getUTCSeconds());
|
|
12304
|
-
case "tt":
|
|
12305
|
-
return hours < 12 ? "AM" : "PM";
|
|
12306
|
-
default:
|
|
12307
|
-
return void 0;
|
|
12308
|
-
}
|
|
12309
|
-
}
|
|
12310
|
-
function formatDate(date2, picture) {
|
|
12311
|
-
return picture.replace(
|
|
12312
|
-
/yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
|
|
12313
|
-
(token) => {
|
|
12314
|
-
if (token.startsWith('"')) return token.slice(1, -1);
|
|
12315
|
-
return dateToken(date2, token) ?? token;
|
|
12316
|
-
}
|
|
12317
|
-
);
|
|
12318
|
-
}
|
|
12319
|
-
function formatNumber(value, picture) {
|
|
12320
|
-
const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
|
|
12321
|
-
if (!match) return void 0;
|
|
12322
|
-
const decimals = match[2]?.length ?? 0;
|
|
12323
|
-
const optional = match[2]?.startsWith("#") ?? false;
|
|
12324
|
-
const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
|
|
12325
|
-
const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
|
|
12326
|
-
const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
|
|
12327
|
-
let text7 = (Math.sign(value) * rounded).toFixed(decimals);
|
|
12328
|
-
if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
|
|
12329
|
-
if (match[1]) {
|
|
12330
|
-
const [whole, fraction] = text7.split(".");
|
|
12331
|
-
text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
|
|
12332
|
-
}
|
|
12333
|
-
return text7 === "-0" ? "0" : text7;
|
|
12334
|
-
}
|
|
12335
|
-
var VISIO_FIELD_FORMATS = {
|
|
12336
|
-
shortDate: "{{M/d/yyyy}}",
|
|
12337
|
-
isoDate: "{{yyyy-MM-dd}}",
|
|
12338
|
-
longDate: "{{dddd, MMMM d, yyyy}}",
|
|
12339
|
-
time: "{{h:mm tt}}",
|
|
12340
|
-
dateTime: "{{M/d/yyyy h:mm tt}}",
|
|
12341
|
-
text: "@",
|
|
12342
|
-
integer: "0",
|
|
12343
|
-
decimal: "0.00",
|
|
12344
|
-
decimalUnits: "0.00 u",
|
|
12345
|
-
integerUnits: "0 u"
|
|
12346
|
-
};
|
|
12347
|
-
function formatVisioFieldValue(value, format4 = "") {
|
|
12348
|
-
const picture = format4.trim();
|
|
12349
|
-
if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
|
|
12350
|
-
if (value.kind === "date") {
|
|
12351
|
-
const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
|
|
12352
|
-
return date2 === void 0 ? void 0 : formatDate(value.date, date2);
|
|
12353
|
-
}
|
|
12354
|
-
const units2 = / u$/.test(picture);
|
|
12355
|
-
const body = picture.replace(/ u$/, "");
|
|
12356
|
-
let number5 = value.value, suffix = "";
|
|
12357
|
-
if (value.unit === "angle") {
|
|
12358
|
-
number5 = number5 * 180 / Math.PI;
|
|
12359
|
-
suffix = " deg.";
|
|
12360
|
-
} else if (value.unit === "length") suffix = " in.";
|
|
12361
|
-
else if (value.unit !== "scalar") return void 0;
|
|
12362
|
-
const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
|
|
12363
|
-
if (text7 === void 0) return void 0;
|
|
12364
|
-
return units2 || body === "" ? `${text7}${suffix}` : text7;
|
|
12365
|
-
}
|
|
12366
|
-
|
|
12367
12451
|
// visio/text-field-fraction.ts
|
|
12368
12452
|
function fractionalFieldNumber(value, maxDenominator) {
|
|
12369
12453
|
if (!Number.isFinite(value) || Math.abs(value) > 1e15) return void 0;
|
|
@@ -12520,7 +12604,12 @@ function textFieldDisplay(element2, sheet, context) {
|
|
|
12520
12604
|
const row2 = sectionRows(sheet, "Field").find((candidate) => candidate.index === index);
|
|
12521
12605
|
const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
|
|
12522
12606
|
const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
|
|
12523
|
-
const
|
|
12607
|
+
const sourceKey = row2 ? textFieldSourceKey(row2.cells) : void 0;
|
|
12608
|
+
const result = {
|
|
12609
|
+
cached: cached5,
|
|
12610
|
+
...formula ? { formula } : {},
|
|
12611
|
+
...sourceKey !== void 0 ? { index, format: format4?.value ?? "", sourceKey } : {}
|
|
12612
|
+
};
|
|
12524
12613
|
if (!row2 || !context) return { text: cached5, ...result };
|
|
12525
12614
|
const picture = format4?.value ?? "";
|
|
12526
12615
|
const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
|
|
@@ -13305,7 +13394,8 @@ function runStyle(cells4, resources, report, themeCells) {
|
|
|
13305
13394
|
...characterExtras(cells4, report)
|
|
13306
13395
|
};
|
|
13307
13396
|
}
|
|
13308
|
-
function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph) {
|
|
13397
|
+
function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph, allowFieldEditing = false) {
|
|
13398
|
+
const editableFields = editableTextFieldIndices(node2, allowFieldEditing);
|
|
13309
13399
|
const cells4 = sheet.cells;
|
|
13310
13400
|
const characters = new Map(sectionRows(sheet, "Character").map((row2) => [row2.index, row2.cells]));
|
|
13311
13401
|
const defaultCells = characters.get("0") ?? /* @__PURE__ */ new Map();
|
|
@@ -13340,7 +13430,9 @@ function shapeText(sheet, node2, width, height, resources, report, consume, cons
|
|
|
13340
13430
|
start: textOffset,
|
|
13341
13431
|
end: textOffset + field3.text.length,
|
|
13342
13432
|
cached: field3.cached,
|
|
13343
|
-
...field3.
|
|
13433
|
+
...field3.index !== void 0 && editableFields.has(field3.index) ? { editable: true } : {},
|
|
13434
|
+
...field3.formula ? { formula: field3.formula } : {},
|
|
13435
|
+
...field3.index === void 0 ? {} : { index: field3.index, format: field3.format, sourceKey: field3.sourceKey }
|
|
13344
13436
|
});
|
|
13345
13437
|
append(field3.text);
|
|
13346
13438
|
} else if (element2.localName !== "pp" && element2.localName !== "tp") {
|
|
@@ -14381,7 +14473,8 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
|
|
|
14381
14473
|
context.resources,
|
|
14382
14474
|
report,
|
|
14383
14475
|
context.consumeText,
|
|
14384
|
-
context.consumeParagraph
|
|
14476
|
+
context.consumeParagraph,
|
|
14477
|
+
depth === 0 && masterId === void 0 && !sheet.cells.get("LockTextEdit")?.error && !sheet.cells.get("LockTextEdit")?.formula && number(sheet.cells, "LockTextEdit", 0, report) === 0
|
|
14385
14478
|
),
|
|
14386
14479
|
hidden: membership.hidden || type === "Guide" || number(sheet.cells, "NoShow", 0, report) !== 0,
|
|
14387
14480
|
visibility: {
|
|
@@ -16101,6 +16194,35 @@ function snapshotGuideEdit(edit) {
|
|
|
16101
16194
|
}
|
|
16102
16195
|
|
|
16103
16196
|
// visio/edit-text-field-commands.ts
|
|
16197
|
+
function snapshotTextFieldUpdate(edit) {
|
|
16198
|
+
const insert = snapshotTextFieldInsert({
|
|
16199
|
+
pageId: edit.pageId,
|
|
16200
|
+
shapeId: edit.shapeId,
|
|
16201
|
+
formula: edit.formula,
|
|
16202
|
+
...edit.format === void 0 ? {} : { format: edit.format }
|
|
16203
|
+
});
|
|
16204
|
+
if (analyzeVisioFormula(parseVisioFormula(insert.formula)).references.some(
|
|
16205
|
+
(ref) => /^fields?\./i.test(ref.cell)
|
|
16206
|
+
))
|
|
16207
|
+
fail("UNSUPPORTED_TEXT_FIELD", "Existing field formulas cannot reference Field rows.");
|
|
16208
|
+
if (typeof edit.fieldIndex !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.fieldIndex) || Number(edit.fieldIndex) > 4294967295)
|
|
16209
|
+
fail("INVALID_EDIT", "An existing field needs a canonical row index.");
|
|
16210
|
+
if ([edit.expectedText, edit.expectedCached, edit.expectedSourceKey].some(
|
|
16211
|
+
(value) => typeof value !== "string" || value.length > 1e6
|
|
16212
|
+
) || !edit.expectedSourceKey)
|
|
16213
|
+
fail("INVALID_EDIT", "An existing field needs its source text and row identity.");
|
|
16214
|
+
return {
|
|
16215
|
+
type: "update-text-field",
|
|
16216
|
+
pageId: insert.pageId,
|
|
16217
|
+
shapeId: insert.shapeId,
|
|
16218
|
+
fieldIndex: edit.fieldIndex,
|
|
16219
|
+
formula: insert.formula,
|
|
16220
|
+
format: insert.format,
|
|
16221
|
+
expectedText: edit.expectedText,
|
|
16222
|
+
expectedCached: edit.expectedCached,
|
|
16223
|
+
expectedSourceKey: edit.expectedSourceKey
|
|
16224
|
+
};
|
|
16225
|
+
}
|
|
16104
16226
|
function snapshotTextFieldInsert(edit) {
|
|
16105
16227
|
const { pageId: pageId2, shapeId: shapeId2 } = edit;
|
|
16106
16228
|
if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
|
|
@@ -16835,6 +16957,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
|
|
|
16835
16957
|
return { ...target2, type: edit.type, text: text7(edit.text) };
|
|
16836
16958
|
if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text7);
|
|
16837
16959
|
if (edit.type === "insert-text-field") return snapshotTextFieldInsert(edit);
|
|
16960
|
+
if (edit.type === "update-text-field") {
|
|
16961
|
+
const update = snapshotTextFieldUpdate(edit);
|
|
16962
|
+
update.formula = text7(update.formula);
|
|
16963
|
+
update.expectedText = text7(update.expectedText);
|
|
16964
|
+
update.expectedCached = text7(update.expectedCached);
|
|
16965
|
+
update.expectedSourceKey = text7(update.expectedSourceKey);
|
|
16966
|
+
return update;
|
|
16967
|
+
}
|
|
16838
16968
|
if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
|
|
16839
16969
|
if (edit.type === "reorder-shape") {
|
|
16840
16970
|
if (!["front", "back", "forward", "backward"].includes(edit.order))
|
|
@@ -17042,6 +17172,8 @@ function snapshotEdits(edits) {
|
|
|
17042
17172
|
return snapshotTextRanges(command2, text7);
|
|
17043
17173
|
case "insert-text-field":
|
|
17044
17174
|
return snapshotTextFieldInsert(command2);
|
|
17175
|
+
case "update-text-field":
|
|
17176
|
+
return snapshotTextFieldUpdate(command2);
|
|
17045
17177
|
case "delete-shape":
|
|
17046
17178
|
return { type: command2.type, ...target2 };
|
|
17047
17179
|
case "rotate-shape":
|
|
@@ -17687,6 +17819,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, sha
|
|
|
17687
17819
|
continue;
|
|
17688
17820
|
const source = executableCellFormula(attribute2(node2, "F"));
|
|
17689
17821
|
if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
|
|
17822
|
+
if (independentTextFieldFormula(node2, source)) continue;
|
|
17690
17823
|
if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
|
|
17691
17824
|
if (isConnectedGlueCell(node2, source)) continue;
|
|
17692
17825
|
const owner = node2.parentNode;
|
|
@@ -21496,9 +21629,23 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
|
|
|
21496
21629
|
effectiveFormattingRows(shape, document, "Paragraph")
|
|
21497
21630
|
);
|
|
21498
21631
|
const rows = formattingRows(shape, "Field");
|
|
21499
|
-
const
|
|
21500
|
-
if (
|
|
21632
|
+
const updating = edit.type === "update-text-field";
|
|
21633
|
+
if (updating) assertEditableFieldShape(shape);
|
|
21634
|
+
const point2 = insertionPoint(text7, updating ? void 0 : edit.offset);
|
|
21635
|
+
if ((updating || edit.offset !== void 0) && point2.logical !== edit.expectedText)
|
|
21501
21636
|
fail("EDIT_STALE_TEXT", "The shape text changed since the field position was chosen.");
|
|
21637
|
+
const existing = updating ? rows.get(edit.fieldIndex) : void 0;
|
|
21638
|
+
const markers = updating ? children2(text7, "fld").filter((field4) => attribute2(field4, "IX") === edit.fieldIndex) : [];
|
|
21639
|
+
if (updating) {
|
|
21640
|
+
if (!existing || markers.length !== 1)
|
|
21641
|
+
fail(
|
|
21642
|
+
"UNSUPPORTED_TEXT_FIELD",
|
|
21643
|
+
"Existing fields require one live local row and unique text marker."
|
|
21644
|
+
);
|
|
21645
|
+
if (markers[0].textContent !== edit.expectedCached || textFieldSourceKey(readCells(existing)) !== edit.expectedSourceKey)
|
|
21646
|
+
fail("EDIT_STALE_TEXT", "The field source changed since it was selected.");
|
|
21647
|
+
assertEditableFieldRow(existing);
|
|
21648
|
+
}
|
|
21502
21649
|
const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
|
|
21503
21650
|
let value;
|
|
21504
21651
|
try {
|
|
@@ -21511,9 +21658,19 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
|
|
|
21511
21658
|
"UNSUPPORTED_TEXT_FIELD",
|
|
21512
21659
|
`This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
|
|
21513
21660
|
);
|
|
21514
|
-
const
|
|
21661
|
+
const format4 = edit.format ?? "";
|
|
21662
|
+
const display = formatVisioFieldValue(value, format4);
|
|
21515
21663
|
if (display === void 0)
|
|
21516
21664
|
fail("UNSUPPORTED_TEXT_FIELD", "The field format does not suit the field value.");
|
|
21665
|
+
const prepared = valueCell(value);
|
|
21666
|
+
if (existing && markers[0].textContent === display) {
|
|
21667
|
+
const same5 = (name3, v, u, f) => {
|
|
21668
|
+
const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
|
|
21669
|
+
return attribute2(cell2, "V") === v && attribute2(cell2, "U") === u && attribute2(cell2, "F") === f;
|
|
21670
|
+
};
|
|
21671
|
+
if (same5("Value", prepared.v, prepared.u, edit.formula) && same5("Format", format4, "STR", `"${format4.replaceAll('"', '""')}"`) && same5("Type", String(prepared.type), void 0, void 0))
|
|
21672
|
+
return false;
|
|
21673
|
+
}
|
|
21517
21674
|
if (texts[0])
|
|
21518
21675
|
await assertFormattingDependencies(
|
|
21519
21676
|
pkg,
|
|
@@ -21521,32 +21678,49 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
|
|
|
21521
21678
|
roots2,
|
|
21522
21679
|
edit.pageId,
|
|
21523
21680
|
shape,
|
|
21524
|
-
|
|
21681
|
+
new Map([
|
|
21682
|
+
["TheText", text7],
|
|
21683
|
+
...existing ? ["Value", "Format", "Type"].flatMap((name3) => {
|
|
21684
|
+
const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
|
|
21685
|
+
return [
|
|
21686
|
+
[`Field.${updating ? edit.fieldIndex : ""}.${name3}`, cell2],
|
|
21687
|
+
[`Fields.${name3}`, cell2]
|
|
21688
|
+
];
|
|
21689
|
+
}) : []
|
|
21690
|
+
]),
|
|
21525
21691
|
check
|
|
21526
21692
|
);
|
|
21527
21693
|
check();
|
|
21528
|
-
const index = String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
|
|
21694
|
+
const index = updating ? edit.fieldIndex : String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
|
|
21529
21695
|
let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
|
|
21530
21696
|
if (!section3) {
|
|
21531
21697
|
section3 = owner.createElementNS(ns, "Section");
|
|
21532
21698
|
section3.setAttribute("N", "Field");
|
|
21533
21699
|
shape.insertBefore(section3, texts[0] ?? null);
|
|
21534
21700
|
}
|
|
21535
|
-
const row2 = owner.createElementNS(ns, "Row");
|
|
21536
|
-
row2.setAttribute("IX", index);
|
|
21701
|
+
const row2 = existing ?? owner.createElementNS(ns, "Row");
|
|
21702
|
+
if (!existing) row2.setAttribute("IX", index);
|
|
21537
21703
|
const cell = (name3, v, extra = {}) => {
|
|
21538
|
-
const node2 = owner.createElementNS(ns, "Cell");
|
|
21704
|
+
const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
|
|
21539
21705
|
node2.setAttribute("N", name3);
|
|
21540
21706
|
node2.setAttribute("V", v);
|
|
21707
|
+
if (updating) {
|
|
21708
|
+
node2.removeAttribute("U");
|
|
21709
|
+
node2.removeAttribute("F");
|
|
21710
|
+
}
|
|
21541
21711
|
for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
|
|
21542
|
-
row2.appendChild(node2);
|
|
21712
|
+
if (!node2.parentNode) row2.appendChild(node2);
|
|
21543
21713
|
};
|
|
21544
|
-
const stored =
|
|
21714
|
+
const stored = prepared;
|
|
21545
21715
|
cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
|
|
21546
|
-
if (
|
|
21547
|
-
cell("Format",
|
|
21716
|
+
if (format4 || updating)
|
|
21717
|
+
cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
|
|
21548
21718
|
cell("Type", String(stored.type));
|
|
21549
|
-
section3.appendChild(row2);
|
|
21719
|
+
if (!row2.parentNode) section3.appendChild(row2);
|
|
21720
|
+
if (updating) {
|
|
21721
|
+
markers[0].textContent = display;
|
|
21722
|
+
return true;
|
|
21723
|
+
}
|
|
21550
21724
|
const field3 = owner.createElementNS(ns, "fld");
|
|
21551
21725
|
field3.setAttribute("IX", index);
|
|
21552
21726
|
field3.appendChild(owner.createTextNode(display));
|
|
@@ -26898,7 +27072,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
26898
27072
|
const dirty = /* @__PURE__ */ new Map();
|
|
26899
27073
|
const roots2 = /* @__PURE__ */ new Map();
|
|
26900
27074
|
const geometryCommands = commands.filter(
|
|
26901
|
-
(command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
|
|
27075
|
+
(command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "update-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
|
|
26902
27076
|
);
|
|
26903
27077
|
let document;
|
|
26904
27078
|
let masterMovePins = emptyMasterMoveProof();
|
|
@@ -26906,7 +27080,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
26906
27080
|
let instanceDeletes = /* @__PURE__ */ new Set();
|
|
26907
27081
|
let groupMembers = /* @__PURE__ */ new Map();
|
|
26908
27082
|
if (geometryCommands.length || commands.some(
|
|
26909
|
-
(command2) => command2.type === "replace-plain-text" || command2.type === "replace-text-ranges" || command2.type === "insert-text-field" || isVisioFormatEdit(command2) || isVisioMetadataEdit(command2) || command2.type === "set-shape-data" || command2.type === "reorder-shape" || command2.type === "duplicate-shapes" || command2.type === "paste-shapes" || command2.type === "change-shape" || isVisioGroupEdit(command2) || isVisioDiagramPartEdit(command2) || isVisioGuideEdit(command2)
|
|
27083
|
+
(command2) => command2.type === "replace-plain-text" || command2.type === "replace-text-ranges" || command2.type === "insert-text-field" || command2.type === "update-text-field" || isVisioFormatEdit(command2) || isVisioMetadataEdit(command2) || command2.type === "set-shape-data" || command2.type === "reorder-shape" || command2.type === "duplicate-shapes" || command2.type === "paste-shapes" || command2.type === "change-shape" || isVisioGroupEdit(command2) || isVisioDiagramPartEdit(command2) || isVisioGuideEdit(command2)
|
|
26910
27084
|
)) {
|
|
26911
27085
|
for (const [pageId2, path2] of pages) {
|
|
26912
27086
|
const sourceRoot = await visioXml(pkg, path2, "PageContents");
|
|
@@ -27017,7 +27191,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
27017
27191
|
textChanged = true;
|
|
27018
27192
|
await noteTextSize(command2, root2);
|
|
27019
27193
|
}
|
|
27020
|
-
} else if (command2.type === "insert-text-field") {
|
|
27194
|
+
} else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
|
|
27021
27195
|
if (await insertVisioTextField(pkg, new Set(pages.values()), roots2, document, command2, check)) {
|
|
27022
27196
|
dirty.set(path, root2);
|
|
27023
27197
|
textChanged = true;
|
|
@@ -28208,7 +28382,16 @@ function copySnapshotScene(model) {
|
|
|
28208
28382
|
source.fields,
|
|
28209
28383
|
"text fields",
|
|
28210
28384
|
1e4,
|
|
28211
|
-
(field3) => fields(field3, [
|
|
28385
|
+
(field3) => fields(field3, [
|
|
28386
|
+
"start",
|
|
28387
|
+
"end",
|
|
28388
|
+
"cached",
|
|
28389
|
+
"formula",
|
|
28390
|
+
"index",
|
|
28391
|
+
"format",
|
|
28392
|
+
"sourceKey",
|
|
28393
|
+
"editable"
|
|
28394
|
+
])
|
|
28212
28395
|
)
|
|
28213
28396
|
},
|
|
28214
28397
|
runs: list2(source.runs, "text runs", 1e5, (run) => ({
|