diff --git a/packages/form-js-editor/src/features/properties-panel/entries/SpacerEntry.js b/packages/form-js-editor/src/features/properties-panel/entries/HeightEntry.js similarity index 77% rename from packages/form-js-editor/src/features/properties-panel/entries/SpacerEntry.js rename to packages/form-js-editor/src/features/properties-panel/entries/HeightEntry.js index a2870534e..985277093 100644 --- a/packages/form-js-editor/src/features/properties-panel/entries/SpacerEntry.js +++ b/packages/form-js-editor/src/features/properties-panel/entries/HeightEntry.js @@ -3,30 +3,34 @@ import { NumberFieldEntry, isNumberFieldEntryEdited } from '@bpmn-io/properties- import { get } from 'min-dash'; import { useService } from '../hooks'; -export default function SpacerEntry(props) { +export default function HeightEntry(props) { const { editField, field, - id + id, + description, + isDefaultVisible = () => {} } = props; const entries = []; entries.push({ id: id + '-height', - component: SpacerHeight, + component: Height, + description, isEdited: isNumberFieldEntryEdited, editField, field, - isDefaultVisible: (field) => field.type === 'spacer' + isDefaultVisible: (field) => field.type === 'spacer' || isDefaultVisible(field) }); return entries; } -function SpacerHeight(props) { +function Height(props) { const { + description, editField, field, id @@ -46,6 +50,7 @@ function SpacerHeight(props) { return NumberFieldEntry({ debounce, + description, label: 'Height', element: field, id, diff --git a/packages/form-js-editor/src/features/properties-panel/entries/IFrameHeightEntry.js b/packages/form-js-editor/src/features/properties-panel/entries/IFrameHeightEntry.js new file mode 100644 index 000000000..96e5f7346 --- /dev/null +++ b/packages/form-js-editor/src/features/properties-panel/entries/IFrameHeightEntry.js @@ -0,0 +1,11 @@ +import HeightEntry from './HeightEntry'; + +export default function IFrameHeightEntry(props) { + return [ + ...HeightEntry({ + ...props, + description: 'Height of the container in pixels.', + isDefaultVisible: (field) => field.type === 'iframe' + }) + ]; +} \ No newline at end of file diff --git a/packages/form-js-editor/src/features/properties-panel/entries/IFrameUrlEntry.js b/packages/form-js-editor/src/features/properties-panel/entries/IFrameUrlEntry.js new file mode 100644 index 000000000..3db0b23bd --- /dev/null +++ b/packages/form-js-editor/src/features/properties-panel/entries/IFrameUrlEntry.js @@ -0,0 +1,74 @@ +import { get } from 'min-dash'; + +import { useService, useVariables } from '../hooks'; + +import { FeelTemplatingEntry, isFeelEntryEdited } from '@bpmn-io/properties-panel'; + +export default function IFrameUrlEntry(props) { + const { + editField, + field + } = props; + + const entries = []; + entries.push({ + id: 'url', + component: Url, + editField: editField, + field: field, + isEdited: isFeelEntryEdited, + isDefaultVisible: (field) => field.type === 'iframe' + }); + + return entries; +} + +function Url(props) { + const { + editField, + field, + id + } = props; + + const debounce = useService('debounce'); + + const variables = useVariables().map(name => ({ name })); + + const path = [ 'url' ]; + + const getValue = () => { + return get(field, path, ''); + }; + + const setValue = (value) => { + return editField(field, path, value); + }; + + return FeelTemplatingEntry({ + debounce, + element: field, + feel: 'optional', + getValue, + id, + label: 'URL', + setValue, + singleLine: true, + tooltip: getTooltip(), + variables + }); +} + +// helper ////////////////////// + +function getTooltip() { + return ( + <> +

+ Enter a URL to an external source or populate it dynamically via a template or a FEEL expression (e.g., to pass a value from the variable). +

+

+ However, not all external sources can be displayed. Read more about it in the X-FRAME-OPTIONS documentation. +

+ + ); +} \ No newline at end of file diff --git a/packages/form-js-editor/src/features/properties-panel/entries/LabelEntry.js b/packages/form-js-editor/src/features/properties-panel/entries/LabelEntry.js index b565dec3e..8b704016b 100644 --- a/packages/form-js-editor/src/features/properties-panel/entries/LabelEntry.js +++ b/packages/form-js-editor/src/features/properties-panel/entries/LabelEntry.js @@ -51,7 +51,12 @@ export default function LabelEntry(props) { editField, field, isEdited: isFeelEntryEdited, - isDefaultVisible: (field) => INPUTS.includes(field.type) || field.type === 'button' || field.type === 'group' + isDefaultVisible: (field) => ( + INPUTS.includes(field.type) || + field.type === 'button' || + field.type === 'group' || + field.type === 'iframe' + ) } ); @@ -79,7 +84,7 @@ function Label(props) { return editField(field, path, value || ''); }; - const label = field.type === 'group' ? 'Group label' : 'Field label'; + const label = getLabelText(field); return FeelTemplatingEntry({ debounce, @@ -157,4 +162,20 @@ function TimeLabel(props) { setValue, variables }); +} + +// helpers ////////// + +function getLabelText(field) { + const { type } = field; + + if (type === 'group') { + return 'Group label'; + } + + if (type === 'iframe') { + return 'Title'; + } + + return 'Field label'; } \ No newline at end of file diff --git a/packages/form-js-editor/src/features/properties-panel/entries/index.js b/packages/form-js-editor/src/features/properties-panel/entries/index.js index d643e5f60..91c87916c 100644 --- a/packages/form-js-editor/src/features/properties-panel/entries/index.js +++ b/packages/form-js-editor/src/features/properties-panel/entries/index.js @@ -9,9 +9,11 @@ export { default as KeyEntry } from './KeyEntry'; export { default as PathEntry } from './PathEntry'; export { default as GroupEntries } from './GroupEntries'; export { default as LabelEntry } from './LabelEntry'; +export { default as IFrameHeightEntry } from './IFrameHeightEntry'; +export { default as IFrameUrlEntry } from './IFrameUrlEntry'; export { default as ImageSourceEntry } from './ImageSourceEntry'; export { default as TextEntry } from './TextEntry'; -export { default as SpacerEntry } from './SpacerEntry'; +export { default as HeightEntry } from './HeightEntry'; export { default as NumberEntries } from './NumberEntries'; export { default as NumberSerializationEntry } from './NumberSerializationEntry'; export { default as DateTimeEntry } from './DateTimeEntry'; diff --git a/packages/form-js-editor/src/features/properties-panel/groups/GeneralGroup.js b/packages/form-js-editor/src/features/properties-panel/groups/GeneralGroup.js index 4aac5bf3b..8b5c96ccb 100644 --- a/packages/form-js-editor/src/features/properties-panel/groups/GeneralGroup.js +++ b/packages/form-js-editor/src/features/properties-panel/groups/GeneralGroup.js @@ -5,6 +5,8 @@ import { DefaultValueEntry, DisabledEntry, IdEntry, + IFrameUrlEntry, + IFrameHeightEntry, ImageSourceEntry, KeyEntry, PathEntry, @@ -13,7 +15,7 @@ import { ReadonlyEntry, SelectEntries, TextEntry, - SpacerEntry, + HeightEntry, NumberEntries, DateTimeEntry } from '../entries'; @@ -32,7 +34,9 @@ export default function GeneralGroup(field, editField, getService) { ...ActionEntry({ field, editField }), ...DateTimeEntry({ field, editField }), ...TextEntry({ field, editField, getService }), - ...SpacerEntry({ field, editField }), + ...IFrameUrlEntry({ field, editField }), + ...IFrameHeightEntry({ field, editField }), + ...HeightEntry({ field, editField }), ...NumberEntries({ field, editField }), ...ImageSourceEntry({ field, editField }), ...AltTextEntry({ field, editField }), diff --git a/packages/form-js-editor/src/render/components/editor-form-fields/EditorIFrame.js b/packages/form-js-editor/src/render/components/editor-form-fields/EditorIFrame.js new file mode 100644 index 000000000..086d90505 --- /dev/null +++ b/packages/form-js-editor/src/render/components/editor-form-fields/EditorIFrame.js @@ -0,0 +1,14 @@ +import { + IFrame +} from '@bpmn-io/form-js-viewer'; + + +export default function EditorIFrame(props) { + const { field } = props; + + // remove url to display placeholder + return