@liiift-studio/sanity-font-manager 2.5.6 → 2.5.7
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.js +32 -0
- package/dist/index.mjs +31 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/schema/openTypeField.js +50 -0
package/dist/index.js
CHANGED
|
@@ -16844,6 +16844,7 @@ __export(index_exports, {
|
|
|
16844
16844
|
createFontDecisions: () => createFontDecisions,
|
|
16845
16845
|
createFontObject: () => createFontObject,
|
|
16846
16846
|
createInitialExecutionState: () => createInitialExecutionState,
|
|
16847
|
+
createOpenTypeField: () => createOpenTypeField,
|
|
16847
16848
|
createStylesField: () => createStylesField,
|
|
16848
16849
|
determineWeight: () => determineWeight,
|
|
16849
16850
|
escapeCssFontName: () => escapeCssFontName,
|
|
@@ -22452,6 +22453,36 @@ var openTypeField = {
|
|
|
22452
22453
|
}
|
|
22453
22454
|
]
|
|
22454
22455
|
};
|
|
22456
|
+
function createOpenTypeField({
|
|
22457
|
+
customText = false,
|
|
22458
|
+
customTextType = "string"
|
|
22459
|
+
} = {}) {
|
|
22460
|
+
if (!customText) return { ...openTypeField };
|
|
22461
|
+
const fields = openTypeField.fields.map((field2) => {
|
|
22462
|
+
if (field2.type !== "object" || !field2.fields) return field2;
|
|
22463
|
+
const updatedSubfields = field2.fields.map((subfield) => {
|
|
22464
|
+
if (subfield.name !== "customText") return subfield;
|
|
22465
|
+
const updated = { ...subfield, hidden: false };
|
|
22466
|
+
if (customTextType === "code") {
|
|
22467
|
+
updated.type = "code";
|
|
22468
|
+
updated.options = {
|
|
22469
|
+
language: "html",
|
|
22470
|
+
languageAlternatives: [
|
|
22471
|
+
{ title: "HTML", value: "html" }
|
|
22472
|
+
],
|
|
22473
|
+
withFilename: false
|
|
22474
|
+
};
|
|
22475
|
+
updated.description = 'Use the field below to input custom text to highlight the feature. Wrap featured characters in <span class="bold">CHARACTER</span>.';
|
|
22476
|
+
}
|
|
22477
|
+
return updated;
|
|
22478
|
+
});
|
|
22479
|
+
return { ...field2, fields: updatedSubfields };
|
|
22480
|
+
});
|
|
22481
|
+
return {
|
|
22482
|
+
...openTypeField,
|
|
22483
|
+
fields
|
|
22484
|
+
};
|
|
22485
|
+
}
|
|
22455
22486
|
|
|
22456
22487
|
// src/schema/styleCountField.js
|
|
22457
22488
|
var styleCountField = {
|
|
@@ -23069,6 +23100,7 @@ init_generateKeywords();
|
|
|
23069
23100
|
createFontDecisions,
|
|
23070
23101
|
createFontObject,
|
|
23071
23102
|
createInitialExecutionState,
|
|
23103
|
+
createOpenTypeField,
|
|
23072
23104
|
createStylesField,
|
|
23073
23105
|
determineWeight,
|
|
23074
23106
|
escapeCssFontName,
|
package/dist/index.mjs
CHANGED
|
@@ -22352,6 +22352,36 @@ var openTypeField = {
|
|
|
22352
22352
|
}
|
|
22353
22353
|
]
|
|
22354
22354
|
};
|
|
22355
|
+
function createOpenTypeField({
|
|
22356
|
+
customText = false,
|
|
22357
|
+
customTextType = "string"
|
|
22358
|
+
} = {}) {
|
|
22359
|
+
if (!customText) return { ...openTypeField };
|
|
22360
|
+
const fields = openTypeField.fields.map((field2) => {
|
|
22361
|
+
if (field2.type !== "object" || !field2.fields) return field2;
|
|
22362
|
+
const updatedSubfields = field2.fields.map((subfield) => {
|
|
22363
|
+
if (subfield.name !== "customText") return subfield;
|
|
22364
|
+
const updated = { ...subfield, hidden: false };
|
|
22365
|
+
if (customTextType === "code") {
|
|
22366
|
+
updated.type = "code";
|
|
22367
|
+
updated.options = {
|
|
22368
|
+
language: "html",
|
|
22369
|
+
languageAlternatives: [
|
|
22370
|
+
{ title: "HTML", value: "html" }
|
|
22371
|
+
],
|
|
22372
|
+
withFilename: false
|
|
22373
|
+
};
|
|
22374
|
+
updated.description = 'Use the field below to input custom text to highlight the feature. Wrap featured characters in <span class="bold">CHARACTER</span>.';
|
|
22375
|
+
}
|
|
22376
|
+
return updated;
|
|
22377
|
+
});
|
|
22378
|
+
return { ...field2, fields: updatedSubfields };
|
|
22379
|
+
});
|
|
22380
|
+
return {
|
|
22381
|
+
...openTypeField,
|
|
22382
|
+
fields
|
|
22383
|
+
};
|
|
22384
|
+
}
|
|
22355
22385
|
|
|
22356
22386
|
// src/schema/styleCountField.js
|
|
22357
22387
|
var styleCountField = {
|
|
@@ -22968,6 +22998,7 @@ export {
|
|
|
22968
22998
|
createFontDecisions,
|
|
22969
22999
|
createFontObject,
|
|
22970
23000
|
createInitialExecutionState,
|
|
23001
|
+
createOpenTypeField,
|
|
22971
23002
|
createStylesField,
|
|
22972
23003
|
determineWeight,
|
|
22973
23004
|
escapeCssFontName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liiift-studio/sanity-font-manager",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.7",
|
|
4
4
|
"description": "Sanity Studio plugin — full font management suite with batch upload, format conversion, metadata extraction, CSS generation, collection/pair generation, and script variant support. Supports Sanity v3, v4, and v5.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Liiift Studio",
|
package/src/index.js
CHANGED
|
@@ -106,7 +106,7 @@ export {
|
|
|
106
106
|
} from './utils/fontHelpers.js';
|
|
107
107
|
|
|
108
108
|
// Schema field definitions
|
|
109
|
-
export { openTypeField } from './schema/openTypeField.js';
|
|
109
|
+
export { openTypeField, createOpenTypeField } from './schema/openTypeField.js';
|
|
110
110
|
export { styleCountField } from './schema/styleCountField.js';
|
|
111
111
|
export { stylisticSetField } from './schema/stylisticSetField.js';
|
|
112
112
|
export { createStylesField } from './schema/stylesField.js';
|
|
@@ -1943,3 +1943,53 @@ export const openTypeField = {
|
|
|
1943
1943
|
|
|
1944
1944
|
],
|
|
1945
1945
|
};
|
|
1946
|
+
|
|
1947
|
+
/**
|
|
1948
|
+
* Factory function to create a customised OpenType field.
|
|
1949
|
+
* The static `openTypeField` export remains unchanged for backwards compatibility.
|
|
1950
|
+
*
|
|
1951
|
+
* @param {object} [options]
|
|
1952
|
+
* @param {boolean} [options.customText=false] - Unhide the customText field on each feature
|
|
1953
|
+
* @param {'string'|'code'} [options.customTextType='string'] - Type for customText field.
|
|
1954
|
+
* Use 'code' for an HTML code editor (requires @sanity/code-input plugin).
|
|
1955
|
+
* @returns {object} Sanity field definition
|
|
1956
|
+
*/
|
|
1957
|
+
export function createOpenTypeField({
|
|
1958
|
+
customText = false,
|
|
1959
|
+
customTextType = 'string',
|
|
1960
|
+
} = {}) {
|
|
1961
|
+
if (!customText) return { ...openTypeField };
|
|
1962
|
+
|
|
1963
|
+
// Deep clone fields and unhide/retype customText on each feature object
|
|
1964
|
+
const fields = openTypeField.fields.map(field => {
|
|
1965
|
+
// Skip the top-level 'features' checkbox array
|
|
1966
|
+
if (field.type !== 'object' || !field.fields) return field;
|
|
1967
|
+
|
|
1968
|
+
const updatedSubfields = field.fields.map(subfield => {
|
|
1969
|
+
if (subfield.name !== 'customText') return subfield;
|
|
1970
|
+
|
|
1971
|
+
const updated = { ...subfield, hidden: false };
|
|
1972
|
+
|
|
1973
|
+
if (customTextType === 'code') {
|
|
1974
|
+
updated.type = 'code';
|
|
1975
|
+
updated.options = {
|
|
1976
|
+
language: 'html',
|
|
1977
|
+
languageAlternatives: [
|
|
1978
|
+
{ title: 'HTML', value: 'html' },
|
|
1979
|
+
],
|
|
1980
|
+
withFilename: false,
|
|
1981
|
+
};
|
|
1982
|
+
updated.description = 'Use the field below to input custom text to highlight the feature. Wrap featured characters in <span class="bold">CHARACTER</span>.';
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
return updated;
|
|
1986
|
+
});
|
|
1987
|
+
|
|
1988
|
+
return { ...field, fields: updatedSubfields };
|
|
1989
|
+
});
|
|
1990
|
+
|
|
1991
|
+
return {
|
|
1992
|
+
...openTypeField,
|
|
1993
|
+
fields,
|
|
1994
|
+
};
|
|
1995
|
+
}
|