+
{{ filesizeLabel(value?.size ?? uppyFile.size) }}
diff --git a/resources/js/form/types.ts b/resources/js/form/types.ts
index e8d7d1ce7..a538b7545 100644
--- a/resources/js/form/types.ts
+++ b/resources/js/form/types.ts
@@ -42,8 +42,9 @@ export type FormFieldEmitInputOptions = {
shouldRefresh?: boolean,
};
-export type FormFieldEmits
= {
+export type FormFieldEmits = {
(e: 'input', value: Data['value'], options?: FormFieldEmitInputOptions): void
(e: 'error', error: string): void
(e: 'clear'): void
+ (e: 'locale-change', locale: string): void
}
diff --git a/resources/js/show/components/fields/text/nodes/Embed.vue b/resources/js/show/components/fields/text/nodes/Embed.vue
index df2475567..0ad99efa0 100644
--- a/resources/js/show/components/fields/text/nodes/Embed.vue
+++ b/resources/js/show/components/fields/text/nodes/Embed.vue
@@ -9,7 +9,7 @@
}>();
const embedManager = inject>('embedManager');
- const embedData = embedManager.getEmbed(useAttrs()['data-key'] as string, props.embed);
+ const embedData = embedManager.getEmbed(props.embed, useAttrs()['data-key'] as string);
diff --git a/resources/js/types/generated.d.ts b/resources/js/types/generated.d.ts
index 158f4b24a..190d0591d 100644
--- a/resources/js/types/generated.d.ts
+++ b/resources/js/types/generated.d.ts
@@ -55,7 +55,6 @@ export type CommandFormConfigData = {
buttonLabel: string | null;
showSubmitAndReopenButton: boolean;
submitAndReopenButtonLabel: string | null;
- shouldRefresh: boolean;
};
export type CommandFormData = {
data: { [key: string]: FormFieldData["value"] };
@@ -135,7 +134,6 @@ export type EmbedData = {
};
export type EmbedFormData = {
data: { [key: string]: FormFieldData["value"] };
- config: { shouldRefresh: boolean };
fields: { [key: string]: FormFieldData };
layout: FormLayoutData | null;
};
@@ -307,7 +305,6 @@ export type FormConditionalDisplayData = {
};
export type FormConfigData = {
isSingle: boolean;
- shouldRefresh: boolean;
};
export type FormCustomFieldData = {
value?: any;
@@ -371,6 +368,7 @@ export type FormEditorFieldData = {
markdown: boolean;
inline: boolean;
showCharacterCount: boolean;
+ allowFullscreen: boolean;
uploads: FormEditorFieldUploadData | null;
embeds: { [embedKey: string]: EmbedData };
toolbar: Array;
@@ -469,8 +467,8 @@ export type FormHtmlFieldData = {
value?: { [key: string]: any } | null;
key: string;
liveRefresh: boolean;
- liveRefreshLinkedFields: Array | null;
type: "html";
+ liveRefreshLinkedFields: Array | null;
label: string | null;
readOnly: boolean | null;
conditionalDisplay: FormConditionalDisplayData | null;
diff --git a/src/Data/Form/Fields/FormAutocompleteLocalFieldData.php b/src/Data/Form/Fields/FormAutocompleteLocalFieldData.php
index 7c11e28de..980687841 100644
--- a/src/Data/Form/Fields/FormAutocompleteLocalFieldData.php
+++ b/src/Data/Form/Fields/FormAutocompleteLocalFieldData.php
@@ -34,7 +34,6 @@ public function __construct(
public ?array $templateData = null,
/** @var array */
public ?array $searchKeys = null,
- public ?bool $localized = null,
/** @var FormDynamicAttributeData[]|null */
public ?array $dynamicAttributes = null,
public ?string $label = null,
diff --git a/src/Data/Form/Fields/FormEditorFieldData.php b/src/Data/Form/Fields/FormEditorFieldData.php
index ec7d235fc..70101a7f4 100644
--- a/src/Data/Form/Fields/FormEditorFieldData.php
+++ b/src/Data/Form/Fields/FormEditorFieldData.php
@@ -31,6 +31,7 @@ public function __construct(
public bool $markdown,
public bool $inline,
public bool $showCharacterCount,
+ public bool $allowFullscreen,
#[LiteralTypeScriptType('FormEditorFieldUploadData | null')]
public ?array $uploads = null,
#[LiteralTypeScriptType('{ [embedKey:string]:EmbedData }')]
diff --git a/src/Data/Form/Fields/FormSelectFieldData.php b/src/Data/Form/Fields/FormSelectFieldData.php
index a0b37a4b3..6000b8ca9 100644
--- a/src/Data/Form/Fields/FormSelectFieldData.php
+++ b/src/Data/Form/Fields/FormSelectFieldData.php
@@ -33,7 +33,6 @@ public function __construct(
/** @var FormDynamicAttributeData[]|null */
public ?array $dynamicAttributes = null,
public ?int $maxSelected = null,
- public ?bool $localized = null,
public ?string $label = null,
public ?bool $readOnly = null,
public ?FormConditionalDisplayData $conditionalDisplay = null,
diff --git a/src/Data/Form/Fields/FormTagsFieldData.php b/src/Data/Form/Fields/FormTagsFieldData.php
index 67b858b00..17a0b6e5c 100644
--- a/src/Data/Form/Fields/FormTagsFieldData.php
+++ b/src/Data/Form/Fields/FormTagsFieldData.php
@@ -25,7 +25,6 @@ public function __construct(
public array $options,
public ?int $maxTagCount = null,
public ?string $placeholder = null,
- public ?bool $localized = null,
public ?string $label = null,
public ?bool $readOnly = null,
public ?FormConditionalDisplayData $conditionalDisplay = null,
diff --git a/src/Form/Fields/Formatters/EditorEmbedsFormatter.php b/src/Form/Fields/Formatters/EditorEmbedsFormatter.php
index 719f25014..7e5e74b46 100644
--- a/src/Form/Fields/Formatters/EditorEmbedsFormatter.php
+++ b/src/Form/Fields/Formatters/EditorEmbedsFormatter.php
@@ -74,6 +74,7 @@ function (string $content) use ($field, $value) {
}
}
$element->removeAttribute('data-key');
+ $element->removeAttribute('data-value');
}
}
diff --git a/src/Form/Fields/Formatters/EditorUploadsFormatter.php b/src/Form/Fields/Formatters/EditorUploadsFormatter.php
index 9f249e96f..04a834b7c 100644
--- a/src/Form/Fields/Formatters/EditorUploadsFormatter.php
+++ b/src/Form/Fields/Formatters/EditorUploadsFormatter.php
@@ -51,6 +51,7 @@ function (string $content) use ($field, $value) {
$element->setAttribute('legend', $legend);
}
$element->removeAttribute('data-key');
+ $element->removeAttribute('data-value');
}
return $this->toHtml($domDocument);
diff --git a/src/Form/Fields/SharpFormEditorField.php b/src/Form/Fields/SharpFormEditorField.php
index 30fb510e3..16f7bf86e 100644
--- a/src/Form/Fields/SharpFormEditorField.php
+++ b/src/Form/Fields/SharpFormEditorField.php
@@ -65,6 +65,7 @@ class SharpFormEditorField extends SharpFormField implements IsSharpFieldWithEmb
protected bool $renderAsMarkdown = false;
protected bool $withoutParagraphs = false;
protected bool $showCharacterCount = false;
+ protected bool $allowFullscreen = false;
protected function __construct(string $key, string $type, ?SharpFieldFormatter $formatter = null)
{
@@ -140,6 +141,13 @@ public function setRenderContentAsMarkdown(bool $renderAsMarkdown = true): self
return $this;
}
+ public function allowFullscreen(bool $allowFullscreen = true): self
+ {
+ $this->allowFullscreen = $allowFullscreen;
+
+ return $this;
+ }
+
public function allowUploads(SharpFormEditorUpload $formEditorUpload): self
{
$this->uploadsConfig = $formEditorUpload;
@@ -251,6 +259,7 @@ public function toArray(): array
'inline' => $this->withoutParagraphs,
'showCharacterCount' => $this->showCharacterCount,
'maxLength' => $this->maxLength,
+ 'allowFullscreen' => $this->allowFullscreen,
'uploads' => $this->innerComponentUploadsConfiguration(),
'embeds' => $this->innerComponentEmbedsConfiguration(),
],
diff --git a/src/Utils/Fields/Formatters/FormatsEditorEmbeds.php b/src/Utils/Fields/Formatters/FormatsEditorEmbeds.php
index 0f4f6fc96..c2257bdf8 100644
--- a/src/Utils/Fields/Formatters/FormatsEditorEmbeds.php
+++ b/src/Utils/Fields/Formatters/FormatsEditorEmbeds.php
@@ -24,7 +24,7 @@ protected function formatEditorEmbedsToFront(IsSharpFieldWithLocalization $field
$embeds = [];
- $text = $this->maybeLocalized($field, $value, function (string $content) use (&$embeds, $field) {
+ $text = $this->maybeLocalized($field, $value, function (string $content, ?string $locale) use (&$embeds, $field) {
$domDocument = $this->parseHtml($content);
foreach ($field->embeds() as $embed) {
@@ -42,6 +42,7 @@ protected function formatEditorEmbedsToFront(IsSharpFieldWithLocalization $field
? $this->tryJsonDecode($element->getAttribute(Str::kebab($fieldKey)))
: null;
})
+ ->when($locale)->merge(['_locale' => $locale])
->pipe(function ($collection) use ($embed) {
return $embed->transformDataWithRenderedTemplate(
$collection->toArray(),
diff --git a/src/Utils/Fields/Formatters/FormatsEditorUploads.php b/src/Utils/Fields/Formatters/FormatsEditorUploads.php
index eb7f4ee8f..93dae07a6 100644
--- a/src/Utils/Fields/Formatters/FormatsEditorUploads.php
+++ b/src/Utils/Fields/Formatters/FormatsEditorUploads.php
@@ -16,7 +16,7 @@ protected function formatEditorUploadsToFront(IsSharpFieldWithEmbeds&IsSharpFiel
{
$uploads = [];
- $text = $this->maybeLocalized($field, $value, function (string $content) use (&$uploads) {
+ $text = $this->maybeLocalized($field, $value, function (string $content, ?string $locale) use (&$uploads) {
if (! str_contains($content, ' $element->hasAttribute('legend')
? $element->getAttribute('legend')
: null,
+ '_locale' => $locale,
];
$element->setAttribute('data-key', count($uploads) - 1);
$element->removeAttribute('file');
diff --git a/src/Utils/Fields/Formatters/FormatsLocalizedValue.php b/src/Utils/Fields/Formatters/FormatsLocalizedValue.php
index 7f70310e2..f5b4a87d5 100644
--- a/src/Utils/Fields/Formatters/FormatsLocalizedValue.php
+++ b/src/Utils/Fields/Formatters/FormatsLocalizedValue.php
@@ -53,7 +53,7 @@ protected function guardAgainstInvalidLocalizedValue(SharpFormField|SharpShowFie
}
/**
- * @param ?Closure $transformContent
+ * @param ?Closure $transformContent
*/
protected function maybeLocalized(SharpFormField|SharpShowField $field, $value, ?Closure $transformContent = null): array|string|null
{
@@ -63,10 +63,10 @@ protected function maybeLocalized(SharpFormField|SharpShowField $field, $value,
return collect($this->dataLocalizations ?? [])
->mapWithKeys(fn ($locale) => [$locale => null])
->merge($value)
- ->map(fn ($content) => $content !== null ? $transformContent($content) : null)
+ ->map(fn ($content, $locale) => $content !== null ? $transformContent($content, $locale) : null)
->toArray();
}
- return $value === null ? null : $transformContent($value);
+ return $value === null ? null : $transformContent($value, null);
}
}
diff --git a/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php b/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php
index 4566d6d0e..0260fbcd6 100644
--- a/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php
+++ b/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php
@@ -162,6 +162,7 @@
'id' => null,
],
'legend' => 'Legendary',
+ '_locale' => null,
],
[
'file' => [
@@ -176,6 +177,7 @@
'id' => null,
],
'legend' => null,
+ '_locale' => null,
],
],
]);
diff --git a/tests/Unit/Form/Fields/SharpFormEditorFieldTest.php b/tests/Unit/Form/Fields/SharpFormEditorFieldTest.php
index 348eb789e..ef7e812ce 100644
--- a/tests/Unit/Form/Fields/SharpFormEditorFieldTest.php
+++ b/tests/Unit/Form/Fields/SharpFormEditorFieldTest.php
@@ -24,6 +24,7 @@
],
'markdown' => false,
'inline' => false,
+ 'allowFullscreen' => false,
]);
});
diff --git a/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php b/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php
index 4959e3a29..e7eb42253 100644
--- a/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php
+++ b/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php
@@ -68,6 +68,7 @@
'id' => null,
],
'legend' => 'Legendary',
+ '_locale' => null,
],
'1' => [
'file' => [
@@ -82,6 +83,7 @@
'id' => null,
],
'legend' => null,
+ '_locale' => null,
],
],
]);
diff --git a/vite.config.ts b/vite.config.ts
index 8e6c00ce9..208b42a95 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -24,7 +24,8 @@ export default defineConfig(({ mode, command }) => {
'vue': 'vue/dist/vue.esm-browser.js',
'ziggy-js': path.resolve(__dirname, 'vendor/tightenco/ziggy'),
// ...rekaAliases()
- }
+ },
+ // preserveSymlinks: true,
},
server: {
// hmr: false,