@strapi/content-manager 5.33.3 → 5.33.4

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.
Files changed (86) hide show
  1. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js +23 -1
  2. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js.map +1 -1
  3. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs +23 -1
  4. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs.map +1 -1
  5. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +14 -1
  6. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
  7. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +14 -1
  8. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
  9. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.js +157 -7
  10. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.js.map +1 -1
  11. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs +154 -5
  12. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs.map +1 -1
  13. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +28 -20
  14. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +25 -17
  16. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
  17. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +6 -3
  18. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  19. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +7 -4
  20. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +12 -12
  22. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +13 -13
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +2 -2
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +1 -1
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.js +4 -8
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.js.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.mjs +4 -7
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +2 -12
  34. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +2 -12
  36. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +48 -1
  38. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +49 -2
  40. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +47 -13
  42. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +49 -15
  44. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +1 -0
  46. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +1 -0
  48. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +10 -1
  50. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +10 -1
  52. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js +5 -1
  54. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
  55. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs +5 -1
  56. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
  57. package/dist/admin/pages/EditView/components/InputRenderer.js +6 -2
  58. package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
  59. package/dist/admin/pages/EditView/components/InputRenderer.mjs +6 -2
  60. package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
  61. package/dist/admin/pages/EditView/utils/data.js +22 -0
  62. package/dist/admin/pages/EditView/utils/data.js.map +1 -1
  63. package/dist/admin/pages/EditView/utils/data.mjs +22 -1
  64. package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
  65. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.d.ts +9 -1
  66. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +9 -1
  67. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.d.ts +1 -1
  68. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.d.ts +2 -4
  69. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +2 -1
  70. package/dist/admin/src/pages/EditView/utils/data.d.ts +6 -1
  71. package/package.json +7 -7
  72. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.js +0 -17
  73. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.js.map +0 -1
  74. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.mjs +0 -15
  75. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.mjs.map +0 -1
  76. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.js +0 -75
  77. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.js.map +0 -1
  78. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.mjs +0 -73
  79. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.mjs.map +0 -1
  80. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.js +0 -88
  81. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.js.map +0 -1
  82. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.mjs +0 -84
  83. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.mjs.map +0 -1
  84. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.d.ts +0 -11
  85. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.d.ts +0 -9
  86. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/links.d.ts +0 -12
@@ -7,6 +7,27 @@ const BLOCK_LIST_ATTRIBUTE_KEYS = [
7
7
  '__component',
8
8
  '__temp_key__'
9
9
  ];
10
+ /**
11
+ * @internal
12
+ * @description Returns the direct parent object for a dot-separated path.
13
+ */ const getDirectParent = (data, path)=>{
14
+ if (!path) return undefined;
15
+ const isNumericIndex = (value)=>/^\d+$/.test(value);
16
+ const segments = path.split('.');
17
+ const parentPath = segments.slice(0, -1);
18
+ let current = data;
19
+ for (const segment of parentPath){
20
+ if (current == null) return undefined;
21
+ if (isNumericIndex(segment)) {
22
+ if (!Array.isArray(current)) return undefined;
23
+ current = current[Number(segment)];
24
+ continue;
25
+ }
26
+ if (typeof current !== 'object') return undefined;
27
+ current = current[segment];
28
+ }
29
+ return current;
30
+ };
10
31
  /**
11
32
  * @internal This function is used to traverse the data and transform the values.
12
33
  * Given a predicate function, it will transform the value (using the given transform function)
@@ -327,5 +348,5 @@ const BLOCK_LIST_ATTRIBUTE_KEYS = [
327
348
  };
328
349
  };
329
350
 
330
- export { handleInvisibleAttributes, prepareRelations, prepareTempKeys, removeFieldsThatDontExistOnSchema, removeProhibitedFields, transformDocument };
351
+ export { getDirectParent, handleInvisibleAttributes, prepareRelations, prepareTempKeys, removeFieldsThatDontExistOnSchema, removeProhibitedFields, transformDocument };
331
352
  //# sourceMappingURL=data.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"data.mjs","sources":["../../../../../admin/src/pages/EditView/utils/data.ts"],"sourcesContent":["import { createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\n\nimport { DOCUMENT_META_FIELDS } from '../../../constants/attributes';\n\nimport type { ComponentsDictionary, Document } from '../../../hooks/useDocument';\nimport type { Schema, UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * traverseData\n * -----------------------------------------------------------------------------------------------*/\n\n// Make only attributes required since it's the only one Content History has\ntype PartialSchema = Partial<Schema.Schema> & Pick<Schema.Schema, 'attributes'>;\n\ntype Predicate = <TAttribute extends Schema.Attribute.AnyAttribute>(\n attribute: TAttribute,\n value: Schema.Attribute.Value<TAttribute>\n) => boolean;\ntype Transform = <TAttribute extends Schema.Attribute.AnyAttribute>(\n value: any,\n attribute: TAttribute\n) => any;\ntype AnyData = Omit<Document, 'id'>;\n\nconst BLOCK_LIST_ATTRIBUTE_KEYS = ['__component', '__temp_key__'];\n\n/**\n * @internal This function is used to traverse the data and transform the values.\n * Given a predicate function, it will transform the value (using the given transform function)\n * if the predicate returns true. If it finds that the attribute is a component or dynamiczone,\n * it will recursively traverse those data structures as well.\n *\n * It is possible to break the ContentManager by using this function incorrectly, for example,\n * if you transform a number into a string but the attribute type is a number, the ContentManager\n * will not be able to save the data and the Form will likely crash because the component it's\n * passing the data too won't succesfully be able to handle the value.\n */\nconst traverseData =\n (predicate: Predicate, transform: Transform) =>\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (data: AnyData = {}) => {\n const traverse = (datum: AnyData, attributes: Schema.Schema['attributes']) => {\n return Object.entries(datum).reduce<AnyData>((acc, [key, value]) => {\n const attribute = attributes[key];\n\n /**\n * If the attribute is a block list attribute, we don't want to transform it.\n * We also don't want to transform null or undefined values.\n */\n if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === undefined) {\n acc[key] = value;\n return acc;\n }\n\n if (attribute.type === 'component') {\n if (attribute.repeatable) {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n acc[key] = componentValue.map((componentData) =>\n traverse(componentData, components[attribute.component]?.attributes ?? {})\n );\n } else {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, false>>;\n\n acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});\n }\n } else if (attribute.type === 'dynamiczone') {\n const dynamicZoneValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n acc[key] = dynamicZoneValue.map((componentData) =>\n traverse(componentData, components[componentData.__component]?.attributes ?? {})\n );\n } else if (predicate(attribute, value)) {\n acc[key] = transform(value, attribute);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, {});\n };\n\n return traverse(data, schema.attributes);\n };\n\n/* -------------------------------------------------------------------------------------------------\n * removeProhibitedFields\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal Removes all the fields that are not allowed.\n */\nconst removeProhibitedFields = (prohibitedFields: Schema.Attribute.Kind[]) =>\n traverseData(\n (attribute) => prohibitedFields.includes(attribute.type),\n () => ''\n );\n\n/* -------------------------------------------------------------------------------------------------\n * prepareRelations\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Sets all relation values to an empty array.\n */\nconst prepareRelations = traverseData(\n (attribute) => attribute.type === 'relation',\n () => ({\n connect: [],\n disconnect: [],\n })\n);\n\n/* -------------------------------------------------------------------------------------------------\n * prepareTempKeys\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each component and dynamiczone item. This gives us\n * a stable identifier regardless of its ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = traverseData(\n (attribute) =>\n (attribute.type === 'component' && attribute.repeatable) || attribute.type === 'dynamiczone',\n (data) => {\n if (Array.isArray(data) && data.length > 0) {\n const keys = generateNKeysBetween(undefined, undefined, data.length);\n\n return data.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n }\n\n return data;\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * removeFieldsThatDontExistOnSchema\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Fields that don't exist in the schema like createdAt etc. are only on the first level (not nested),\n * as such we don't need to traverse the components to remove them.\n */\nconst removeFieldsThatDontExistOnSchema = (schema: PartialSchema) => (data: AnyData) => {\n const schemaKeys = Object.keys(schema.attributes);\n const dataKeys = Object.keys(data);\n\n const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));\n\n const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {\n delete acc[key];\n\n return acc;\n }, structuredClone(data));\n\n return revisedData;\n};\n\n/**\n * @internal\n * @description We need to remove null fields from the data-structure because it will pass it\n * to the specific inputs breaking them as most would prefer empty strings or `undefined` if\n * they're controlled / uncontrolled. However, Boolean fields should preserve null values.\n */\nconst removeNullValues = (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n traverseData(\n (attribute, value) => value === null && attribute.type !== 'boolean',\n () => undefined\n )(schema, components);\n\n/* -------------------------------------------------------------------------------------------------\n * transformDocuments\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Takes a document data structure (this could be from the API or a default form structure)\n * and applies consistent data transformations to it. This is also used when we add new components to the\n * form to ensure the data is correctly prepared from their default state e.g. relations are set to an empty array.\n */\nconst transformDocument =\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (document: AnyData) => {\n const transformations = pipe(\n removeFieldsThatDontExistOnSchema(schema),\n removeProhibitedFields(['password'])(schema, components),\n removeNullValues(schema, components),\n prepareRelations(schema, components),\n prepareTempKeys(schema, components)\n );\n\n return transformations(document);\n };\n\ntype HandleOptions = {\n schema?: Schema.ContentType | Schema.Component;\n initialValues?: AnyData;\n components?: Record<string, Schema.Component>;\n};\n\ntype RemovedFieldPath = string;\n\n/**\n * @internal\n * @description Finds the initial value for a component or dynamic zone item (based on its __temp_key__ and not its index).\n * @param initialValue - The initial values object.\n * @param item - The item to find the initial value for.\n * @returns The initial value for the item.\n */\nconst getItemInitialValue = (initialValue: AnyData, item: AnyData) => {\n if (initialValue && Array.isArray(initialValue)) {\n const matchingInitialItem = initialValue.find(\n (initialItem) => initialItem.__temp_key__ === item.__temp_key__\n );\n if (matchingInitialItem) {\n return matchingInitialItem;\n }\n }\n return {};\n};\n\n/**\n * @internal\n * @description Collects paths of attributes that should be removed based on visibility conditions.\n * This function only evaluates conditions.visible (JSON Logic), not the visible boolean property.\n *\n * @param data - The data object to evaluate\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param path - Current path in the data structure (for nested components/dynamiczones)\n * @returns Array of field paths that should be removed\n */\nconst collectInvisibleAttributes = (\n data: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n path: string[] = []\n): RemovedFieldPath[] => {\n if (!schema?.attributes) return [];\n\n const rulesEngine = createRulesEngine();\n const removedPaths: RemovedFieldPath[] = [];\n const evaluatedData: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...path, attrName].join('.');\n\n // Skip fields with visible: false - they're managed by backend\n if ('visible' in attrDef && attrDef.visible === false) {\n continue;\n }\n\n const condition = attrDef?.conditions?.visible;\n const isVisible = condition\n ? rulesEngine.evaluate(condition, { ...data, ...evaluatedData })\n : true;\n\n if (!isVisible) {\n removedPaths.push(fullPath);\n continue;\n }\n\n // Track this field for future condition evaluations\n if (attrName in data) {\n evaluatedData[attrName] = data[attrName];\n }\n\n // Recursively process components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = data[attrName];\n\n if (attrDef.repeatable && Array.isArray(value)) {\n value.forEach((item) => {\n const nestedPaths = collectInvisibleAttributes(item, compSchema, components, [\n ...path,\n `${attrName}[${item.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n } else if (value && typeof value === 'object') {\n const nestedPaths = collectInvisibleAttributes(value, compSchema, components, [\n ...path,\n attrName,\n ]);\n removedPaths.push(...nestedPaths);\n }\n }\n\n // Recursively process dynamic zones\n if (attrDef.type === 'dynamiczone' && Array.isArray(data[attrName])) {\n data[attrName].forEach((dzItem: AnyData) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const nestedPaths = collectInvisibleAttributes(dzItem, compSchema, components, [\n ...path,\n `${attrName}[${dzItem.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n }\n }\n\n return removedPaths;\n};\n\n/**\n * @internal\n * @description Removes attributes from data based on the list of paths to remove.\n * Preserves fields with visible: false from data or initialValues.\n *\n * @param data - The data object to filter\n * @param initialValues - Initial values to fall back to\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param removedPaths - Array of field paths to remove\n * @param currentPath - Current path in the data structure\n * @returns Filtered data object\n */\nconst filterDataByRemovedPaths = (\n data: AnyData,\n initialValues: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n removedPaths: RemovedFieldPath[],\n currentPath: string[] = []\n): AnyData => {\n if (!schema?.attributes) return data;\n\n const result: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...currentPath, attrName].join('.');\n\n // Check if this field should be removed\n if (removedPaths.includes(fullPath)) {\n continue;\n }\n\n // Handle fields with visible: false - preserve from data or initialValues\n if ('visible' in attrDef && attrDef.visible === false) {\n const userProvided = Object.hasOwn(data, attrName);\n if (userProvided) {\n result[attrName] = data[attrName];\n } else if (attrName in initialValues) {\n result[attrName] = initialValues[attrName];\n }\n continue;\n }\n\n const userProvided = Object.hasOwn(data, attrName);\n const currentValue = userProvided ? data[attrName] : undefined;\n const initialValue = initialValues?.[attrName];\n\n // Handle components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = currentValue === undefined ? initialValue : currentValue;\n\n if (!value) {\n result[attrName] = attrDef.repeatable ? [] : null;\n continue;\n }\n\n if (attrDef.repeatable && Array.isArray(value)) {\n result[attrName] = value.map((item) => {\n const componentInitialValue = getItemInitialValue(initialValue, item);\n return filterDataByRemovedPaths(\n item,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${item.__temp_key__}]`]\n );\n });\n } else {\n result[attrName] = filterDataByRemovedPaths(\n value,\n initialValue ?? {},\n compSchema,\n components,\n removedPaths,\n [...currentPath, attrName]\n );\n }\n\n continue;\n }\n\n // Handle dynamic zones\n if (attrDef.type === 'dynamiczone') {\n if (!Array.isArray(currentValue)) {\n result[attrName] = [];\n continue;\n }\n\n result[attrName] = currentValue.map((dzItem) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const componentInitialValue = getItemInitialValue(initialValue, dzItem);\n\n const cleaned = filterDataByRemovedPaths(\n dzItem,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${dzItem.__temp_key__}]`]\n );\n\n // For newly created components, ensure id is undefined (in case of reordering)\n const processedItem =\n dzItem.id === undefined || dzItem.id === null\n ? { __component: compUID, ...cleaned, id: undefined }\n : { __component: compUID, ...cleaned };\n\n return processedItem;\n });\n\n continue;\n }\n\n // Regular fields - preserve from data or initialValues\n if (currentValue !== undefined) {\n result[attrName] = currentValue;\n } else if (initialValue !== undefined) {\n result[attrName] = initialValue;\n }\n }\n\n // Pass through any fields from data that aren't in the schema\n for (const [key, value] of Object.entries(data)) {\n if (!(key in result) && !(key in (schema?.attributes || {}))) {\n result[key] = value;\n }\n }\n\n return result;\n};\n\n/**\n * Removes values from the data object if their corresponding attribute has a\n * visibility condition that evaluates to false.\n *\n * @param data - The data object to filter based on visibility\n * @param options - Schema, initialValues, and components\n * @returns Object with filtered data and list of removed attribute paths\n */\nconst handleInvisibleAttributes = (\n data: AnyData,\n { schema, initialValues = {}, components = {} }: HandleOptions\n): {\n data: AnyData;\n removedAttributes: RemovedFieldPath[];\n} => {\n if (!schema?.attributes) return { data, removedAttributes: [] };\n\n const removedAttributes = collectInvisibleAttributes(data, schema, components);\n\n const filteredData = filterDataByRemovedPaths(\n data,\n initialValues,\n schema,\n components,\n removedAttributes\n );\n\n return {\n data: filteredData,\n removedAttributes,\n };\n};\n\nexport {\n removeProhibitedFields,\n prepareRelations,\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n transformDocument,\n handleInvisibleAttributes,\n};\nexport type { AnyData };\n"],"names":["BLOCK_LIST_ATTRIBUTE_KEYS","traverseData","predicate","transform","schema","components","data","traverse","datum","attributes","Object","entries","reduce","acc","key","value","attribute","includes","undefined","type","repeatable","componentValue","map","componentData","component","dynamicZoneValue","__component","removeProhibitedFields","prohibitedFields","prepareRelations","connect","disconnect","prepareTempKeys","Array","isArray","length","keys","generateNKeysBetween","index","__temp_key__","removeFieldsThatDontExistOnSchema","schemaKeys","dataKeys","keysToRemove","filter","revisedData","DOCUMENT_META_FIELDS","structuredClone","removeNullValues","transformDocument","document","transformations","pipe","getItemInitialValue","initialValue","item","matchingInitialItem","find","initialItem","collectInvisibleAttributes","path","rulesEngine","createRulesEngine","removedPaths","evaluatedData","attrName","attrDef","fullPath","join","visible","condition","conditions","isVisible","evaluate","push","compSchema","forEach","nestedPaths","dzItem","compUID","filterDataByRemovedPaths","initialValues","currentPath","result","userProvided","hasOwn","currentValue","componentInitialValue","cleaned","processedItem","id","handleInvisibleAttributes","removedAttributes","filteredData"],"mappings":";;;;;AA0BA,MAAMA,yBAA4B,GAAA;AAAC,IAAA,aAAA;AAAe,IAAA;AAAe,CAAA;AAEjE;;;;;;;;;;AAUC,IACD,MAAMC,YAAAA,GACJ,CAACC,SAAAA,EAAsBC,YACvB,CAACC,MAAAA,EAAuBC,UAAmC,GAAA,EAAE,GAC7D,CAACC,IAAAA,GAAgB,EAAE,GAAA;YACjB,MAAMC,QAAAA,GAAW,CAACC,KAAgBC,EAAAA,UAAAA,GAAAA;gBAChC,OAAOC,MAAAA,CAAOC,OAAO,CAACH,KAAOI,CAAAA,CAAAA,MAAM,CAAU,CAACC,GAAAA,EAAK,CAACC,GAAAA,EAAKC,KAAM,CAAA,GAAA;oBAC7D,MAAMC,SAAAA,GAAYP,UAAU,CAACK,GAAI,CAAA;AAEjC;;;YAIA,IAAId,0BAA0BiB,QAAQ,CAACH,QAAQC,KAAU,KAAA,IAAA,IAAQA,UAAUG,SAAW,EAAA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AAA,CAAAA;AAEnE,IAAA,MAAMwF,YAAeb,GAAAA,wBAAAA,CACnB1E,IACA2E,EAAAA,aAAAA,EACA7E,QACAC,UACAuF,EAAAA,iBAAAA,CAAAA;IAGF,OAAO;QACLtF,IAAMuF,EAAAA,YAAAA;AACND,QAAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"data.mjs","sources":["../../../../../admin/src/pages/EditView/utils/data.ts"],"sourcesContent":["import { createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\n\nimport { DOCUMENT_META_FIELDS } from '../../../constants/attributes';\n\nimport type { ComponentsDictionary, Document } from '../../../hooks/useDocument';\nimport type { Schema, UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * traverseData\n * -----------------------------------------------------------------------------------------------*/\n\n// Make only attributes required since it's the only one Content History has\ntype PartialSchema = Partial<Schema.Schema> & Pick<Schema.Schema, 'attributes'>;\n\ntype Predicate = <TAttribute extends Schema.Attribute.AnyAttribute>(\n attribute: TAttribute,\n value: Schema.Attribute.Value<TAttribute>\n) => boolean;\ntype Transform = <TAttribute extends Schema.Attribute.AnyAttribute>(\n value: any,\n attribute: TAttribute\n) => any;\ntype AnyData = Omit<Document, 'id'>;\n\nconst BLOCK_LIST_ATTRIBUTE_KEYS = ['__component', '__temp_key__'];\n\n/**\n * @internal\n * @description Returns the direct parent object for a dot-separated path.\n */\nconst getDirectParent = (data: unknown, path: string): unknown => {\n if (!path) return undefined;\n const isNumericIndex = (value: string) => /^\\d+$/.test(value);\n const segments = path.split('.');\n const parentPath = segments.slice(0, -1);\n let current: unknown = data;\n\n for (const segment of parentPath) {\n if (current == null) return undefined;\n\n if (isNumericIndex(segment)) {\n if (!Array.isArray(current)) return undefined;\n current = current[Number(segment)];\n continue;\n }\n\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n};\n\n/**\n * @internal This function is used to traverse the data and transform the values.\n * Given a predicate function, it will transform the value (using the given transform function)\n * if the predicate returns true. If it finds that the attribute is a component or dynamiczone,\n * it will recursively traverse those data structures as well.\n *\n * It is possible to break the ContentManager by using this function incorrectly, for example,\n * if you transform a number into a string but the attribute type is a number, the ContentManager\n * will not be able to save the data and the Form will likely crash because the component it's\n * passing the data too won't succesfully be able to handle the value.\n */\nconst traverseData =\n (predicate: Predicate, transform: Transform) =>\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (data: AnyData = {}) => {\n const traverse = (datum: AnyData, attributes: Schema.Schema['attributes']) => {\n return Object.entries(datum).reduce<AnyData>((acc, [key, value]) => {\n const attribute = attributes[key];\n\n /**\n * If the attribute is a block list attribute, we don't want to transform it.\n * We also don't want to transform null or undefined values.\n */\n if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === undefined) {\n acc[key] = value;\n return acc;\n }\n\n if (attribute.type === 'component') {\n if (attribute.repeatable) {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n acc[key] = componentValue.map((componentData) =>\n traverse(componentData, components[attribute.component]?.attributes ?? {})\n );\n } else {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, false>>;\n\n acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});\n }\n } else if (attribute.type === 'dynamiczone') {\n const dynamicZoneValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n acc[key] = dynamicZoneValue.map((componentData) =>\n traverse(componentData, components[componentData.__component]?.attributes ?? {})\n );\n } else if (predicate(attribute, value)) {\n acc[key] = transform(value, attribute);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, {});\n };\n\n return traverse(data, schema.attributes);\n };\n\n/* -------------------------------------------------------------------------------------------------\n * removeProhibitedFields\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal Removes all the fields that are not allowed.\n */\nconst removeProhibitedFields = (prohibitedFields: Schema.Attribute.Kind[]) =>\n traverseData(\n (attribute) => prohibitedFields.includes(attribute.type),\n () => ''\n );\n\n/* -------------------------------------------------------------------------------------------------\n * prepareRelations\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Sets all relation values to an empty array.\n */\nconst prepareRelations = traverseData(\n (attribute) => attribute.type === 'relation',\n () => ({\n connect: [],\n disconnect: [],\n })\n);\n\n/* -------------------------------------------------------------------------------------------------\n * prepareTempKeys\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each component and dynamiczone item. This gives us\n * a stable identifier regardless of its ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = traverseData(\n (attribute) =>\n (attribute.type === 'component' && attribute.repeatable) || attribute.type === 'dynamiczone',\n (data) => {\n if (Array.isArray(data) && data.length > 0) {\n const keys = generateNKeysBetween(undefined, undefined, data.length);\n\n return data.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n }\n\n return data;\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * removeFieldsThatDontExistOnSchema\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Fields that don't exist in the schema like createdAt etc. are only on the first level (not nested),\n * as such we don't need to traverse the components to remove them.\n */\nconst removeFieldsThatDontExistOnSchema = (schema: PartialSchema) => (data: AnyData) => {\n const schemaKeys = Object.keys(schema.attributes);\n const dataKeys = Object.keys(data);\n\n const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));\n\n const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {\n delete acc[key];\n\n return acc;\n }, structuredClone(data));\n\n return revisedData;\n};\n\n/**\n * @internal\n * @description We need to remove null fields from the data-structure because it will pass it\n * to the specific inputs breaking them as most would prefer empty strings or `undefined` if\n * they're controlled / uncontrolled. However, Boolean fields should preserve null values.\n */\nconst removeNullValues = (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n traverseData(\n (attribute, value) => value === null && attribute.type !== 'boolean',\n () => undefined\n )(schema, components);\n\n/* -------------------------------------------------------------------------------------------------\n * transformDocuments\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Takes a document data structure (this could be from the API or a default form structure)\n * and applies consistent data transformations to it. This is also used when we add new components to the\n * form to ensure the data is correctly prepared from their default state e.g. relations are set to an empty array.\n */\nconst transformDocument =\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (document: AnyData) => {\n const transformations = pipe(\n removeFieldsThatDontExistOnSchema(schema),\n removeProhibitedFields(['password'])(schema, components),\n removeNullValues(schema, components),\n prepareRelations(schema, components),\n prepareTempKeys(schema, components)\n );\n\n return transformations(document);\n };\n\ntype HandleOptions = {\n schema?: Schema.ContentType | Schema.Component;\n initialValues?: AnyData;\n components?: Record<string, Schema.Component>;\n};\n\ntype RemovedFieldPath = string;\n\n/**\n * @internal\n * @description Finds the initial value for a component or dynamic zone item (based on its __temp_key__ and not its index).\n * @param initialValue - The initial values object.\n * @param item - The item to find the initial value for.\n * @returns The initial value for the item.\n */\nconst getItemInitialValue = (initialValue: AnyData, item: AnyData) => {\n if (initialValue && Array.isArray(initialValue)) {\n const matchingInitialItem = initialValue.find(\n (initialItem) => initialItem.__temp_key__ === item.__temp_key__\n );\n if (matchingInitialItem) {\n return matchingInitialItem;\n }\n }\n return {};\n};\n\n/**\n * @internal\n * @description Collects paths of attributes that should be removed based on visibility conditions.\n * This function only evaluates conditions.visible (JSON Logic), not the visible boolean property.\n *\n * @param data - The data object to evaluate\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param path - Current path in the data structure (for nested components/dynamiczones)\n * @returns Array of field paths that should be removed\n */\nconst collectInvisibleAttributes = (\n data: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n path: string[] = []\n): RemovedFieldPath[] => {\n if (!schema?.attributes) return [];\n\n const rulesEngine = createRulesEngine();\n const removedPaths: RemovedFieldPath[] = [];\n const evaluatedData: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...path, attrName].join('.');\n\n // Skip fields with visible: false - they're managed by backend\n if ('visible' in attrDef && attrDef.visible === false) {\n continue;\n }\n\n const condition = attrDef?.conditions?.visible;\n const isVisible = condition\n ? rulesEngine.evaluate(condition, { ...data, ...evaluatedData })\n : true;\n\n if (!isVisible) {\n removedPaths.push(fullPath);\n continue;\n }\n\n // Track this field for future condition evaluations\n if (attrName in data) {\n evaluatedData[attrName] = data[attrName];\n }\n\n // Recursively process components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = data[attrName];\n\n if (attrDef.repeatable && Array.isArray(value)) {\n value.forEach((item) => {\n const nestedPaths = collectInvisibleAttributes(item, compSchema, components, [\n ...path,\n `${attrName}[${item.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n } else if (value && typeof value === 'object') {\n const nestedPaths = collectInvisibleAttributes(value, compSchema, components, [\n ...path,\n attrName,\n ]);\n removedPaths.push(...nestedPaths);\n }\n }\n\n // Recursively process dynamic zones\n if (attrDef.type === 'dynamiczone' && Array.isArray(data[attrName])) {\n data[attrName].forEach((dzItem: AnyData) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const nestedPaths = collectInvisibleAttributes(dzItem, compSchema, components, [\n ...path,\n `${attrName}[${dzItem.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n }\n }\n\n return removedPaths;\n};\n\n/**\n * @internal\n * @description Removes attributes from data based on the list of paths to remove.\n * Preserves fields with visible: false from data or initialValues.\n *\n * @param data - The data object to filter\n * @param initialValues - Initial values to fall back to\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param removedPaths - Array of field paths to remove\n * @param currentPath - Current path in the data structure\n * @returns Filtered data object\n */\nconst filterDataByRemovedPaths = (\n data: AnyData,\n initialValues: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n removedPaths: RemovedFieldPath[],\n currentPath: string[] = []\n): AnyData => {\n if (!schema?.attributes) return data;\n\n const result: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...currentPath, attrName].join('.');\n\n // Check if this field should be removed\n if (removedPaths.includes(fullPath)) {\n continue;\n }\n\n // Handle fields with visible: false - preserve from data or initialValues\n if ('visible' in attrDef && attrDef.visible === false) {\n const userProvided = Object.hasOwn(data, attrName);\n if (userProvided) {\n result[attrName] = data[attrName];\n } else if (attrName in initialValues) {\n result[attrName] = initialValues[attrName];\n }\n continue;\n }\n\n const userProvided = Object.hasOwn(data, attrName);\n const currentValue = userProvided ? data[attrName] : undefined;\n const initialValue = initialValues?.[attrName];\n\n // Handle components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = currentValue === undefined ? initialValue : currentValue;\n\n if (!value) {\n result[attrName] = attrDef.repeatable ? [] : null;\n continue;\n }\n\n if (attrDef.repeatable && Array.isArray(value)) {\n result[attrName] = value.map((item) => {\n const componentInitialValue = getItemInitialValue(initialValue, item);\n return filterDataByRemovedPaths(\n item,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${item.__temp_key__}]`]\n );\n });\n } else {\n result[attrName] = filterDataByRemovedPaths(\n value,\n initialValue ?? {},\n compSchema,\n components,\n removedPaths,\n [...currentPath, attrName]\n );\n }\n\n continue;\n }\n\n // Handle dynamic zones\n if (attrDef.type === 'dynamiczone') {\n if (!Array.isArray(currentValue)) {\n result[attrName] = [];\n continue;\n }\n\n result[attrName] = currentValue.map((dzItem) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const componentInitialValue = getItemInitialValue(initialValue, dzItem);\n\n const cleaned = filterDataByRemovedPaths(\n dzItem,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${dzItem.__temp_key__}]`]\n );\n\n // For newly created components, ensure id is undefined (in case of reordering)\n const processedItem =\n dzItem.id === undefined || dzItem.id === null\n ? { __component: compUID, ...cleaned, id: undefined }\n : { __component: compUID, ...cleaned };\n\n return processedItem;\n });\n\n continue;\n }\n\n // Regular fields - preserve from data or initialValues\n if (currentValue !== undefined) {\n result[attrName] = currentValue;\n } else if (initialValue !== undefined) {\n result[attrName] = initialValue;\n }\n }\n\n // Pass through any fields from data that aren't in the schema\n for (const [key, value] of Object.entries(data)) {\n if (!(key in result) && !(key in (schema?.attributes || {}))) {\n result[key] = value;\n }\n }\n\n return result;\n};\n\n/**\n * Removes values from the data object if their corresponding attribute has a\n * visibility condition that evaluates to false.\n *\n * @param data - The data object to filter based on visibility\n * @param options - Schema, initialValues, and components\n * @returns Object with filtered data and list of removed attribute paths\n */\nconst handleInvisibleAttributes = (\n data: AnyData,\n { schema, initialValues = {}, components = {} }: HandleOptions\n): {\n data: AnyData;\n removedAttributes: RemovedFieldPath[];\n} => {\n if (!schema?.attributes) return { data, removedAttributes: [] };\n\n const removedAttributes = collectInvisibleAttributes(data, schema, components);\n\n const filteredData = filterDataByRemovedPaths(\n data,\n initialValues,\n schema,\n components,\n removedAttributes\n );\n\n return {\n data: filteredData,\n removedAttributes,\n };\n};\n\nexport {\n removeProhibitedFields,\n prepareRelations,\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n transformDocument,\n handleInvisibleAttributes,\n getDirectParent,\n};\nexport type { AnyData };\n"],"names":["BLOCK_LIST_ATTRIBUTE_KEYS","getDirectParent","data","path","undefined","isNumericIndex","value","test","segments","split","parentPath","slice","current","segment","Array","isArray","Number","traverseData","predicate","transform","schema","components","traverse","datum","attributes","Object","entries","reduce","acc","key","attribute","includes","type","repeatable","componentValue","map","componentData","component","dynamicZoneValue","__component","removeProhibitedFields","prohibitedFields","prepareRelations","connect","disconnect","prepareTempKeys","length","keys","generateNKeysBetween","index","__temp_key__","removeFieldsThatDontExistOnSchema","schemaKeys","dataKeys","keysToRemove","filter","revisedData","DOCUMENT_META_FIELDS","structuredClone","removeNullValues","transformDocument","document","transformations","pipe","getItemInitialValue","initialValue","item","matchingInitialItem","find","initialItem","collectInvisibleAttributes","rulesEngine","createRulesEngine","removedPaths","evaluatedData","attrName","attrDef","fullPath","join","visible","condition","conditions","isVisible","evaluate","push","compSchema","forEach","nestedPaths","dzItem","compUID","filterDataByRemovedPaths","initialValues","currentPath","result","userProvided","hasOwn","currentValue","componentInitialValue","cleaned","processedItem","id","handleInvisibleAttributes","removedAttributes","filteredData"],"mappings":";;;;;AA0BA,MAAMA,yBAA4B,GAAA;AAAC,IAAA,aAAA;AAAe,IAAA;AAAe,CAAA;AAEjE;;;IAIA,MAAMC,eAAkB,GAAA,CAACC,IAAeC,EAAAA,IAAAA,GAAAA;IACtC,IAAI,CAACA,MAAM,OAAOC,SAAAA;AAClB,IAAA,MAAMC,cAAiB,GAAA,CAACC,KAAkB,GAAA,OAAA,CAAQC,IAAI,CAACD,KAAAA,CAAAA;IACvD,MAAME,QAAAA,GAAWL,IAAKM,CAAAA,KAAK,CAAC,GAAA,CAAA;AAC5B,IAAA,MAAMC,UAAaF,GAAAA,QAAAA,CAASG,KAAK,CAAC,GAAG,CAAC,CAAA,CAAA;AACtC,IAAA,IAAIC,OAAmBV,GAAAA,IAAAA;IAEvB,KAAK,MAAMW,WAAWH,UAAY,CAAA;QAChC,IAAIE,OAAAA,IAAW,MAAM,OAAOR,SAAAA;AAE5B,QAAA,IAAIC,eAAeQ,OAAU,CAAA,EAAA;AAC3B,YAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACH,UAAU,OAAOR,SAAAA;YACpCQ,OAAUA,GAAAA,OAAO,CAACI,MAAAA,CAAOH,OAAS,CAAA,CAAA;AAClC,YAAA;AACF;QAEA,IAAI,OAAOD,OAAY,KAAA,QAAA,EAAU,OAAOR,SAAAA;QACxCQ,OAAU,GAACA,OA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AAA,CAAA;AAC/C,QAAA,IAAI,EAAE2B,GAAOgE,IAAAA,MAAK,KAAM,EAAEhE,GAAQT,KAAAA,MAAQI,EAAAA,UAAAA,IAAc,EAAC,CAAC,CAAI,EAAA;YAC5DqE,MAAM,CAAChE,IAAI,GAAGvB,KAAAA;AAChB;AACF;IAEA,OAAOuF,MAAAA;AACT,CAAA;AAEA;;;;;;;AAOC,IACKQ,MAAAA,yBAAAA,GAA4B,CAChCnG,IAAAA,EACA,EAAEkB,MAAM,EAAEuE,aAAgB,GAAA,EAAE,EAAEtE,UAAa,GAAA,EAAE,EAAiB,GAAA;IAK9D,IAAI,CAACD,MAAQI,EAAAA,UAAAA,EAAY,OAAO;AAAEtB,QAAAA,IAAAA;AAAMoG,QAAAA,iBAAAA,EAAmB;AAAG,KAAA;IAE9D,MAAMA,iBAAAA,GAAoBhC,0BAA2BpE,CAAAA,IAAAA,EAAMkB,MAAQC,EAAAA,UAAAA,CAAAA;AAEnE,IAAA,MAAMkF,YAAeb,GAAAA,wBAAAA,CACnBxF,IACAyF,EAAAA,aAAAA,EACAvE,QACAC,UACAiF,EAAAA,iBAAAA,CAAAA;IAGF,OAAO;QACLpG,IAAMqG,EAAAA,YAAAA;AACND,QAAAA;AACF,KAAA;AACF;;;;"}
@@ -1,3 +1,11 @@
1
+ import { BaseEditor, Editor, Path } from 'slate';
1
2
  import { type BlocksStore } from '../BlocksEditor';
3
+ declare const insertLink: (editor: Editor, { url }: {
4
+ url: string;
5
+ }) => void;
2
6
  declare const linkBlocks: Pick<BlocksStore, 'link'>;
3
- export { linkBlocks };
7
+ export interface LinkEditor extends BaseEditor {
8
+ lastInsertedLinkPath: Path | null;
9
+ shouldSaveLinkPath: boolean;
10
+ }
11
+ export { linkBlocks, insertLink };
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { type FieldValue } from '@strapi/admin/strapi-admin';
3
3
  import { MessageDescriptor } from 'react-intl';
4
- import { Editor, type Descendant } from 'slate';
4
+ import { Editor, type Descendant, Element } from 'slate';
5
5
  import { type RenderElementProps } from 'slate-react';
6
6
  import { type CSSProperties } from 'styled-components';
7
7
  import { type BlocksContentProps } from './BlocksContent';
@@ -9,13 +9,21 @@ import { type ModifiersStore } from './Modifiers';
9
9
  import type { Schema } from '@strapi/types';
10
10
  interface BaseBlock {
11
11
  renderElement: (props: RenderElementProps) => React.JSX.Element;
12
+ /** Function to check if a given node is of this type of block */
12
13
  matchNode: (node: Schema.Attribute.BlocksNode) => boolean;
13
14
  handleConvert?: (editor: Editor) => void | (() => React.JSX.Element);
14
15
  handleEnterKey?: (editor: Editor) => void;
15
16
  handleBackspaceKey?: (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => void;
16
17
  handleTab?: (editor: Editor) => void;
17
18
  snippets?: string[];
19
+ /** Adjust the vertical positioning of the drag-to-reorder grip icon */
18
20
  dragHandleTopMargin?: CSSProperties['marginTop'];
21
+ /** A Slate plugin: function that will wrap the editor creation */
22
+ plugin?: (editor: Editor) => Editor;
23
+ /**
24
+ * Function that checks if an element should be draggable
25
+ * @default () => true */
26
+ isDraggable?: (element: Element) => boolean;
19
27
  }
20
28
  interface NonSelectorBlock extends BaseBlock {
21
29
  isInBlocksSelector: false;
@@ -2,7 +2,7 @@ import { Editor } from 'slate';
2
2
  /**
3
3
  * This plugin is used to normalize the Slate document to match the Strapi schema.
4
4
  */
5
- declare const withStrapiSchema: (editor: Editor) => Omit<import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor & import("./withLinks").LinkEditor, "children"> & {
5
+ declare const withStrapiSchema: (editor: Editor) => Omit<import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor & import("../Blocks/Link").LinkEditor, "children"> & {
6
6
  children: import("@strapi/types/dist/schema/attribute").BlocksValue;
7
7
  };
8
8
  export { withStrapiSchema };
@@ -1,10 +1,8 @@
1
- import type { Schema } from '@strapi/types';
2
1
  import type { Element, Node } from 'slate';
3
2
  type Block<T extends Element['type']> = Extract<Node, {
4
3
  type: T;
5
4
  }>;
6
5
  declare const getEntries: <T extends object>(object: T) => [keyof T, T[keyof T]][];
7
6
  declare const getKeys: <T extends object>(object: T) => (keyof T)[];
8
- declare const isLinkNode: (element: Element) => element is Schema.Attribute.LinkInlineNode;
9
- declare const isListNode: (element: Element) => element is Schema.Attribute.ListBlockNode;
10
- export { type Block, getEntries, getKeys, isLinkNode, isListNode };
7
+ declare function isNonNullable<T>(value: T): value is NonNullable<T>;
8
+ export { type Block, getEntries, getKeys, isNonNullable };
@@ -10,8 +10,9 @@ interface DynamicComponentProps extends Pick<UseDragAndDropOptions, 'onGrabItem'
10
10
  onAddComponent: (componentUid: string, index: number) => void;
11
11
  onRemoveComponentClick: () => void;
12
12
  onMoveComponent: (dragIndex: number, hoverIndex: number) => void;
13
+ totalLength: number;
13
14
  children?: (props: InputRendererProps) => React.ReactNode;
14
15
  }
15
- declare const DynamicComponent: ({ componentUid, disabled, index, name, onRemoveComponentClick, onMoveComponent, onGrabItem, onDropItem, onCancel, dynamicComponentsByCategory, onAddComponent, children, }: DynamicComponentProps) => import("react/jsx-runtime").JSX.Element;
16
+ declare const DynamicComponent: ({ componentUid, disabled, index, name, onRemoveComponentClick, onMoveComponent, onGrabItem, onDropItem, onCancel, dynamicComponentsByCategory, onAddComponent, totalLength, children, }: DynamicComponentProps) => import("react/jsx-runtime").JSX.Element;
16
17
  export { DynamicComponent };
17
18
  export type { DynamicComponentProps };
@@ -2,6 +2,11 @@ import type { ComponentsDictionary, Document } from '../../../hooks/useDocument'
2
2
  import type { Schema } from '@strapi/types';
3
3
  type PartialSchema = Partial<Schema.Schema> & Pick<Schema.Schema, 'attributes'>;
4
4
  type AnyData = Omit<Document, 'id'>;
5
+ /**
6
+ * @internal
7
+ * @description Returns the direct parent object for a dot-separated path.
8
+ */
9
+ declare const getDirectParent: (data: unknown, path: string) => unknown;
5
10
  /**
6
11
  * @internal Removes all the fields that are not allowed.
7
12
  */
@@ -48,5 +53,5 @@ declare const handleInvisibleAttributes: (data: AnyData, { schema, initialValues
48
53
  data: AnyData;
49
54
  removedAttributes: RemovedFieldPath[];
50
55
  };
51
- export { removeProhibitedFields, prepareRelations, prepareTempKeys, removeFieldsThatDontExistOnSchema, transformDocument, handleInvisibleAttributes, };
56
+ export { removeProhibitedFields, prepareRelations, prepareTempKeys, removeFieldsThatDontExistOnSchema, transformDocument, handleInvisibleAttributes, getDirectParent, };
52
57
  export type { AnyData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/content-manager",
3
- "version": "5.33.3",
3
+ "version": "5.33.4",
4
4
  "description": "A powerful UI to easily manage your data.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,10 +67,10 @@
67
67
  "@radix-ui/react-toolbar": "1.0.4",
68
68
  "@reduxjs/toolkit": "1.9.7",
69
69
  "@sindresorhus/slugify": "1.1.0",
70
- "@strapi/design-system": "2.0.1",
71
- "@strapi/icons": "2.0.1",
72
- "@strapi/types": "5.33.3",
73
- "@strapi/utils": "5.33.3",
70
+ "@strapi/design-system": "2.1.2",
71
+ "@strapi/icons": "2.1.2",
72
+ "@strapi/types": "5.33.4",
73
+ "@strapi/utils": "5.33.4",
74
74
  "codemirror5": "npm:codemirror@^5.65.11",
75
75
  "date-fns": "2.30.0",
76
76
  "fractional-indexing": "3.2.0",
@@ -104,8 +104,8 @@
104
104
  "yup": "0.32.9"
105
105
  },
106
106
  "devDependencies": {
107
- "@strapi/admin": "5.33.3",
108
- "@strapi/database": "5.33.3",
107
+ "@strapi/admin": "5.33.4",
108
+ "@strapi/database": "5.33.4",
109
109
  "@testing-library/react": "16.3.0",
110
110
  "@types/jest": "29.5.2",
111
111
  "@types/lodash": "^4.14.191",
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Images are void elements. They handle the rendering of their children instead of Slate.
5
- * See the Slate documentation for more information:
6
- * - https://docs.slatejs.org/api/nodes/element#void-vs-not-void
7
- * - https://docs.slatejs.org/api/nodes/element#rendering-void-elements
8
- */ const withImages = (editor)=>{
9
- const { isVoid } = editor;
10
- editor.isVoid = (element)=>{
11
- return element.type === 'image' ? true : isVoid(element);
12
- };
13
- return editor;
14
- };
15
-
16
- exports.withImages = withImages;
17
- //# sourceMappingURL=withImages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withImages.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.ts"],"sourcesContent":["import { type Editor } from 'slate';\n\n/**\n * Images are void elements. They handle the rendering of their children instead of Slate.\n * See the Slate documentation for more information:\n * - https://docs.slatejs.org/api/nodes/element#void-vs-not-void\n * - https://docs.slatejs.org/api/nodes/element#rendering-void-elements\n */\nconst withImages = (editor: Editor) => {\n const { isVoid } = editor;\n\n editor.isVoid = (element) => {\n return element.type === 'image' ? true : isVoid(element);\n };\n\n return editor;\n};\n\nexport { withImages };\n"],"names":["withImages","editor","isVoid","element","type"],"mappings":";;AAEA;;;;;IAMA,MAAMA,aAAa,CAACC,MAAAA,GAAAA;IAClB,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAAA;IAEnBA,MAAOC,CAAAA,MAAM,GAAG,CAACC,OAAAA,GAAAA;AACf,QAAA,OAAOA,OAAQC,CAAAA,IAAI,KAAK,OAAA,GAAU,OAAOF,MAAOC,CAAAA,OAAAA,CAAAA;AAClD,KAAA;IAEA,OAAOF,MAAAA;AACT;;;;"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Images are void elements. They handle the rendering of their children instead of Slate.
3
- * See the Slate documentation for more information:
4
- * - https://docs.slatejs.org/api/nodes/element#void-vs-not-void
5
- * - https://docs.slatejs.org/api/nodes/element#rendering-void-elements
6
- */ const withImages = (editor)=>{
7
- const { isVoid } = editor;
8
- editor.isVoid = (element)=>{
9
- return element.type === 'image' ? true : isVoid(element);
10
- };
11
- return editor;
12
- };
13
-
14
- export { withImages };
15
- //# sourceMappingURL=withImages.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withImages.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.ts"],"sourcesContent":["import { type Editor } from 'slate';\n\n/**\n * Images are void elements. They handle the rendering of their children instead of Slate.\n * See the Slate documentation for more information:\n * - https://docs.slatejs.org/api/nodes/element#void-vs-not-void\n * - https://docs.slatejs.org/api/nodes/element#rendering-void-elements\n */\nconst withImages = (editor: Editor) => {\n const { isVoid } = editor;\n\n editor.isVoid = (element) => {\n return element.type === 'image' ? true : isVoid(element);\n };\n\n return editor;\n};\n\nexport { withImages };\n"],"names":["withImages","editor","isVoid","element","type"],"mappings":"AAEA;;;;;IAMA,MAAMA,aAAa,CAACC,MAAAA,GAAAA;IAClB,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAAA;IAEnBA,MAAOC,CAAAA,MAAM,GAAG,CAACC,OAAAA,GAAAA;AACf,QAAA,OAAOA,OAAQC,CAAAA,IAAI,KAAK,OAAA,GAAU,OAAOF,MAAOC,CAAAA,OAAAA,CAAAA;AAClD,KAAA;IAEA,OAAOF,MAAAA;AACT;;;;"}
@@ -1,75 +0,0 @@
1
- 'use strict';
2
-
3
- var slate = require('slate');
4
- var links = require('../utils/links.js');
5
-
6
- const withLinks = (editor)=>{
7
- const { isInline, apply, insertText, insertData } = editor;
8
- // Links are inline elements, so we need to override the isInline method for slate
9
- editor.isInline = (element)=>{
10
- return element.type === 'link' ? true : isInline(element);
11
- };
12
- // We keep a track of the last inserted link path
13
- // So we can show the popover on the link component if that link is the last one inserted
14
- editor.lastInsertedLinkPath = null;
15
- // We intercept the apply method, so everytime we insert a new link, we save its path
16
- editor.apply = (operation)=>{
17
- if (operation.type === 'insert_node') {
18
- if (!slate.Editor.isEditor(operation.node) && operation.node.type === 'link' && editor.shouldSaveLinkPath) {
19
- editor.lastInsertedLinkPath = operation.path;
20
- }
21
- } else if (operation.type === 'move_node') {
22
- // We need to update the last inserted link path when link is moved
23
- // If link is the first word in the paragraph we dont need to update the path
24
- if (slate.Path.hasPrevious(operation.path) && editor.lastInsertedLinkPath && editor.shouldSaveLinkPath) {
25
- editor.lastInsertedLinkPath = slate.Path.transform(editor.lastInsertedLinkPath, operation);
26
- }
27
- }
28
- apply(operation);
29
- };
30
- editor.insertText = (text)=>{
31
- // When selection is at the end of a link and user types a space, we want to break the link
32
- if (editor.selection && slate.Range.isCollapsed(editor.selection) && text === ' ') {
33
- const linksInSelection = Array.from(slate.Editor.nodes(editor, {
34
- at: editor.selection,
35
- match: (node)=>!slate.Editor.isEditor(node) && node.type === 'link'
36
- }));
37
- const selectionIsInLink = editor.selection && linksInSelection.length > 0;
38
- const selectionIsAtEndOfLink = selectionIsInLink && slate.Point.equals(editor.selection.anchor, slate.Editor.end(editor, linksInSelection[0][1]));
39
- if (selectionIsAtEndOfLink) {
40
- slate.Transforms.insertNodes(editor, {
41
- text: ' ',
42
- type: 'text'
43
- }, {
44
- at: slate.Path.next(linksInSelection[0][1]),
45
- select: true
46
- });
47
- return;
48
- }
49
- }
50
- insertText(text);
51
- };
52
- // Add data as a clickable link if its a valid URL
53
- editor.insertData = (data)=>{
54
- const pastedText = data.getData('text/plain');
55
- if (pastedText) {
56
- try {
57
- // eslint-disable-next-line no-new
58
- new URL(pastedText);
59
- // Do not show link popup on copy-paste a link, so do not save its path
60
- editor.shouldSaveLinkPath = false;
61
- links.insertLink(editor, {
62
- url: pastedText
63
- });
64
- return;
65
- } catch (error) {
66
- // continue normal data insertion
67
- }
68
- }
69
- insertData(data);
70
- };
71
- return editor;
72
- };
73
-
74
- exports.withLinks = withLinks;
75
- //# sourceMappingURL=withLinks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withLinks.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.ts"],"sourcesContent":["import { type BaseEditor, Path, Transforms, Range, Point, Editor } from 'slate';\n\nimport { insertLink } from '../utils/links';\n\ninterface LinkEditor extends BaseEditor {\n lastInsertedLinkPath: Path | null;\n shouldSaveLinkPath: boolean;\n}\n\nconst withLinks = (editor: Editor) => {\n const { isInline, apply, insertText, insertData } = editor;\n\n // Links are inline elements, so we need to override the isInline method for slate\n editor.isInline = (element) => {\n return element.type === 'link' ? true : isInline(element);\n };\n\n // We keep a track of the last inserted link path\n // So we can show the popover on the link component if that link is the last one inserted\n editor.lastInsertedLinkPath = null;\n\n // We intercept the apply method, so everytime we insert a new link, we save its path\n editor.apply = (operation) => {\n if (operation.type === 'insert_node') {\n if (\n !Editor.isEditor(operation.node) &&\n operation.node.type === 'link' &&\n editor.shouldSaveLinkPath\n ) {\n editor.lastInsertedLinkPath = operation.path;\n }\n } else if (operation.type === 'move_node') {\n // We need to update the last inserted link path when link is moved\n // If link is the first word in the paragraph we dont need to update the path\n if (\n Path.hasPrevious(operation.path) &&\n editor.lastInsertedLinkPath &&\n editor.shouldSaveLinkPath\n ) {\n editor.lastInsertedLinkPath = Path.transform(editor.lastInsertedLinkPath, operation);\n }\n }\n\n apply(operation);\n };\n\n editor.insertText = (text) => {\n // When selection is at the end of a link and user types a space, we want to break the link\n if (editor.selection && Range.isCollapsed(editor.selection) && text === ' ') {\n const linksInSelection = Array.from(\n Editor.nodes(editor, {\n at: editor.selection,\n match: (node) => !Editor.isEditor(node) && node.type === 'link',\n })\n );\n\n const selectionIsInLink = editor.selection && linksInSelection.length > 0;\n const selectionIsAtEndOfLink =\n selectionIsInLink &&\n Point.equals(editor.selection.anchor, Editor.end(editor, linksInSelection[0][1]));\n\n if (selectionIsAtEndOfLink) {\n Transforms.insertNodes(\n editor,\n { text: ' ', type: 'text' },\n { at: Path.next(linksInSelection[0][1]), select: true }\n );\n\n return;\n }\n }\n\n insertText(text);\n };\n\n // Add data as a clickable link if its a valid URL\n editor.insertData = (data) => {\n const pastedText = data.getData('text/plain');\n\n if (pastedText) {\n try {\n // eslint-disable-next-line no-new\n new URL(pastedText);\n // Do not show link popup on copy-paste a link, so do not save its path\n editor.shouldSaveLinkPath = false;\n insertLink(editor, { url: pastedText });\n return;\n } catch (error) {\n // continue normal data insertion\n }\n }\n\n insertData(data);\n };\n\n return editor;\n};\n\nexport { withLinks, type LinkEditor };\n"],"names":["withLinks","editor","isInline","apply","insertText","insertData","element","type","lastInsertedLinkPath","operation","Editor","isEditor","node","shouldSaveLinkPath","path","Path","hasPrevious","transform","text","selection","Range","isCollapsed","linksInSelection","Array","from","nodes","at","match","selectionIsInLink","length","selectionIsAtEndOfLink","Point","equals","anchor","end","Transforms","insertNodes","next","select","data","pastedText","getData","URL","insertLink","url","error"],"mappings":";;;;;AASA,MAAMA,YAAY,CAACC,MAAAA,GAAAA;IACjB,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGJ,MAAAA;;IAGpDA,MAAOC,CAAAA,QAAQ,GAAG,CAACI,OAAAA,GAAAA;AACjB,QAAA,OAAOA,OAAQC,CAAAA,IAAI,KAAK,MAAA,GAAS,OAAOL,QAASI,CAAAA,OAAAA,CAAAA;AACnD,KAAA;;;AAIAL,IAAAA,MAAAA,CAAOO,oBAAoB,GAAG,IAAA;;IAG9BP,MAAOE,CAAAA,KAAK,GAAG,CAACM,SAAAA,GAAAA;QACd,IAAIA,SAAAA,CAAUF,IAAI,KAAK,aAAe,EAAA;AACpC,YAAA,IACE,CAACG,YAAAA,CAAOC,QAAQ,CAACF,UAAUG,IAAI,CAAA,IAC/BH,SAAUG,CAAAA,IAAI,CAACL,IAAI,KAAK,MACxBN,IAAAA,MAAAA,CAAOY,kBAAkB,EACzB;gBACAZ,MAAOO,CAAAA,oBAAoB,GAAGC,SAAAA,CAAUK,IAAI;AAC9C;AACF,SAAA,MAAO,IAAIL,SAAAA,CAAUF,IAAI,KAAK,WAAa,EAAA;;;YAGzC,IACEQ,UAAAA,CAAKC,WAAW,CAACP,SAAUK,CAAAA,IAAI,CAC/Bb,IAAAA,MAAAA,CAAOO,oBAAoB,IAC3BP,MAAOY,CAAAA,kBAAkB,EAC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A;AAAK,iBAAA,CAAA;AAGxD,gBAAA;AACF;AACF;QAEAlC,UAAWc,CAAAA,IAAAA,CAAAA;AACb,KAAA;;IAGAjB,MAAOI,CAAAA,UAAU,GAAG,CAACkC,IAAAA,GAAAA;QACnB,MAAMC,UAAAA,GAAaD,IAAKE,CAAAA,OAAO,CAAC,YAAA,CAAA;AAEhC,QAAA,IAAID,UAAY,EAAA;YACd,IAAI;;AAEF,gBAAA,IAAIE,GAAIF,CAAAA,UAAAA,CAAAA;;AAERvC,gBAAAA,MAAAA,CAAOY,kBAAkB,GAAG,KAAA;AAC5B8B,gBAAAA,gBAAAA,CAAW1C,MAAQ,EAAA;oBAAE2C,GAAKJ,EAAAA;AAAW,iBAAA,CAAA;AACrC,gBAAA;AACF,aAAA,CAAE,OAAOK,KAAO,EAAA;;AAEhB;AACF;QAEAxC,UAAWkC,CAAAA,IAAAA,CAAAA;AACb,KAAA;IAEA,OAAOtC,MAAAA;AACT;;;;"}
@@ -1,73 +0,0 @@
1
- import { Editor, Path, Range, Point, Transforms } from 'slate';
2
- import { insertLink } from '../utils/links.mjs';
3
-
4
- const withLinks = (editor)=>{
5
- const { isInline, apply, insertText, insertData } = editor;
6
- // Links are inline elements, so we need to override the isInline method for slate
7
- editor.isInline = (element)=>{
8
- return element.type === 'link' ? true : isInline(element);
9
- };
10
- // We keep a track of the last inserted link path
11
- // So we can show the popover on the link component if that link is the last one inserted
12
- editor.lastInsertedLinkPath = null;
13
- // We intercept the apply method, so everytime we insert a new link, we save its path
14
- editor.apply = (operation)=>{
15
- if (operation.type === 'insert_node') {
16
- if (!Editor.isEditor(operation.node) && operation.node.type === 'link' && editor.shouldSaveLinkPath) {
17
- editor.lastInsertedLinkPath = operation.path;
18
- }
19
- } else if (operation.type === 'move_node') {
20
- // We need to update the last inserted link path when link is moved
21
- // If link is the first word in the paragraph we dont need to update the path
22
- if (Path.hasPrevious(operation.path) && editor.lastInsertedLinkPath && editor.shouldSaveLinkPath) {
23
- editor.lastInsertedLinkPath = Path.transform(editor.lastInsertedLinkPath, operation);
24
- }
25
- }
26
- apply(operation);
27
- };
28
- editor.insertText = (text)=>{
29
- // When selection is at the end of a link and user types a space, we want to break the link
30
- if (editor.selection && Range.isCollapsed(editor.selection) && text === ' ') {
31
- const linksInSelection = Array.from(Editor.nodes(editor, {
32
- at: editor.selection,
33
- match: (node)=>!Editor.isEditor(node) && node.type === 'link'
34
- }));
35
- const selectionIsInLink = editor.selection && linksInSelection.length > 0;
36
- const selectionIsAtEndOfLink = selectionIsInLink && Point.equals(editor.selection.anchor, Editor.end(editor, linksInSelection[0][1]));
37
- if (selectionIsAtEndOfLink) {
38
- Transforms.insertNodes(editor, {
39
- text: ' ',
40
- type: 'text'
41
- }, {
42
- at: Path.next(linksInSelection[0][1]),
43
- select: true
44
- });
45
- return;
46
- }
47
- }
48
- insertText(text);
49
- };
50
- // Add data as a clickable link if its a valid URL
51
- editor.insertData = (data)=>{
52
- const pastedText = data.getData('text/plain');
53
- if (pastedText) {
54
- try {
55
- // eslint-disable-next-line no-new
56
- new URL(pastedText);
57
- // Do not show link popup on copy-paste a link, so do not save its path
58
- editor.shouldSaveLinkPath = false;
59
- insertLink(editor, {
60
- url: pastedText
61
- });
62
- return;
63
- } catch (error) {
64
- // continue normal data insertion
65
- }
66
- }
67
- insertData(data);
68
- };
69
- return editor;
70
- };
71
-
72
- export { withLinks };
73
- //# sourceMappingURL=withLinks.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withLinks.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.ts"],"sourcesContent":["import { type BaseEditor, Path, Transforms, Range, Point, Editor } from 'slate';\n\nimport { insertLink } from '../utils/links';\n\ninterface LinkEditor extends BaseEditor {\n lastInsertedLinkPath: Path | null;\n shouldSaveLinkPath: boolean;\n}\n\nconst withLinks = (editor: Editor) => {\n const { isInline, apply, insertText, insertData } = editor;\n\n // Links are inline elements, so we need to override the isInline method for slate\n editor.isInline = (element) => {\n return element.type === 'link' ? true : isInline(element);\n };\n\n // We keep a track of the last inserted link path\n // So we can show the popover on the link component if that link is the last one inserted\n editor.lastInsertedLinkPath = null;\n\n // We intercept the apply method, so everytime we insert a new link, we save its path\n editor.apply = (operation) => {\n if (operation.type === 'insert_node') {\n if (\n !Editor.isEditor(operation.node) &&\n operation.node.type === 'link' &&\n editor.shouldSaveLinkPath\n ) {\n editor.lastInsertedLinkPath = operation.path;\n }\n } else if (operation.type === 'move_node') {\n // We need to update the last inserted link path when link is moved\n // If link is the first word in the paragraph we dont need to update the path\n if (\n Path.hasPrevious(operation.path) &&\n editor.lastInsertedLinkPath &&\n editor.shouldSaveLinkPath\n ) {\n editor.lastInsertedLinkPath = Path.transform(editor.lastInsertedLinkPath, operation);\n }\n }\n\n apply(operation);\n };\n\n editor.insertText = (text) => {\n // When selection is at the end of a link and user types a space, we want to break the link\n if (editor.selection && Range.isCollapsed(editor.selection) && text === ' ') {\n const linksInSelection = Array.from(\n Editor.nodes(editor, {\n at: editor.selection,\n match: (node) => !Editor.isEditor(node) && node.type === 'link',\n })\n );\n\n const selectionIsInLink = editor.selection && linksInSelection.length > 0;\n const selectionIsAtEndOfLink =\n selectionIsInLink &&\n Point.equals(editor.selection.anchor, Editor.end(editor, linksInSelection[0][1]));\n\n if (selectionIsAtEndOfLink) {\n Transforms.insertNodes(\n editor,\n { text: ' ', type: 'text' },\n { at: Path.next(linksInSelection[0][1]), select: true }\n );\n\n return;\n }\n }\n\n insertText(text);\n };\n\n // Add data as a clickable link if its a valid URL\n editor.insertData = (data) => {\n const pastedText = data.getData('text/plain');\n\n if (pastedText) {\n try {\n // eslint-disable-next-line no-new\n new URL(pastedText);\n // Do not show link popup on copy-paste a link, so do not save its path\n editor.shouldSaveLinkPath = false;\n insertLink(editor, { url: pastedText });\n return;\n } catch (error) {\n // continue normal data insertion\n }\n }\n\n insertData(data);\n };\n\n return editor;\n};\n\nexport { withLinks, type LinkEditor };\n"],"names":["withLinks","editor","isInline","apply","insertText","insertData","element","type","lastInsertedLinkPath","operation","Editor","isEditor","node","shouldSaveLinkPath","path","Path","hasPrevious","transform","text","selection","Range","isCollapsed","linksInSelection","Array","from","nodes","at","match","selectionIsInLink","length","selectionIsAtEndOfLink","Point","equals","anchor","end","Transforms","insertNodes","next","select","data","pastedText","getData","URL","insertLink","url","error"],"mappings":";;;AASA,MAAMA,YAAY,CAACC,MAAAA,GAAAA;IACjB,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGJ,MAAAA;;IAGpDA,MAAOC,CAAAA,QAAQ,GAAG,CAACI,OAAAA,GAAAA;AACjB,QAAA,OAAOA,OAAQC,CAAAA,IAAI,KAAK,MAAA,GAAS,OAAOL,QAASI,CAAAA,OAAAA,CAAAA;AACnD,KAAA;;;AAIAL,IAAAA,MAAAA,CAAOO,oBAAoB,GAAG,IAAA;;IAG9BP,MAAOE,CAAAA,KAAK,GAAG,CAACM,SAAAA,GAAAA;QACd,IAAIA,SAAAA,CAAUF,IAAI,KAAK,aAAe,EAAA;AACpC,YAAA,IACE,CAACG,MAAAA,CAAOC,QAAQ,CAACF,UAAUG,IAAI,CAAA,IAC/BH,SAAUG,CAAAA,IAAI,CAACL,IAAI,KAAK,MACxBN,IAAAA,MAAAA,CAAOY,kBAAkB,EACzB;gBACAZ,MAAOO,CAAAA,oBAAoB,GAAGC,SAAAA,CAAUK,IAAI;AAC9C;AACF,SAAA,MAAO,IAAIL,SAAAA,CAAUF,IAAI,KAAK,WAAa,EAAA;;;YAGzC,IACEQ,IAAAA,CAAKC,WAAW,CAACP,SAAUK,CAAAA,IAAI,CAC/Bb,IAAAA,MAAAA,CAAOO,oBAAoB,IAC3BP,MAAOY,CAAAA,kBAAkB,EACzB;AACAZ,gBAAAA,MAAAA,CAAOO,oBAAoB,GAAGO,IAAAA,CAAKE,SAAS,CAAChB,MAAAA,CAAOO,oBAAoB,EAAEC,SAAAA,CAAAA;AAC5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