Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit frame component implementation #1342

Merged
merged 27 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
15fda95
Added EditFrame for react
mikejarosch-aw Dec 2, 2022
84864c0
Initial work on vue component.
mjarosch Dec 6, 2022
202371b
More work on EditFrame for Vue.
mikejarosch-aw Dec 7, 2022
bd24120
Fix markup for vue.
mikejarosch-aw Dec 8, 2022
ab638c6
Fix linting issues.
mikejarosch-aw Dec 8, 2022
f50266f
Fix more linting issues
mikejarosch-aw Dec 8, 2022
a05de30
More linting.
mikejarosch-aw Dec 8, 2022
010ddf0
Some more linting.
mikejarosch-aw Dec 8, 2022
eda7be9
Linting fixes.
mikejarosch-aw Dec 8, 2022
47964fe
Angular implementation
mikejarosch-aw Dec 9, 2022
7e1db85
Add commandBuilder tests
mjarosch Dec 14, 2022
55bdffa
Add tests for core and react. Added some comments.
mjarosch Dec 14, 2022
bf5a549
Edit frame code cleanup
mjarosch Dec 16, 2022
1cbb263
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/ed…
art-alexeyenko Feb 7, 2023
dded274
editframe example for nextjs styleguide - first draft
art-alexeyenko Feb 8, 2023
55516eb
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/ed…
art-alexeyenko Feb 8, 2023
cf4ee4e
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/ed…
art-alexeyenko Feb 9, 2023
cdc52ab
Edit frame productized
art-alexeyenko Feb 13, 2023
ce73851
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/ed…
art-alexeyenko Feb 13, 2023
ce99798
Consistency, lint, cleanup
art-alexeyenko Feb 13, 2023
da967a2
editframe - misc changes
art-alexeyenko Feb 14, 2023
4f4fcd4
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/ed…
art-alexeyenko Feb 15, 2023
c7a0f5e
finalize styleguide examples on all frameworks
art-alexeyenko Feb 15, 2023
1f761da
lint, cleanup
art-alexeyenko Feb 15, 2023
1c2ac56
re-lint vue package
art-alexeyenko Feb 15, 2023
e170164
ensure styleguide text is lint friendly
art-alexeyenko Feb 15, 2023
4fef890
address PR comments
art-alexeyenko Feb 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,12 @@ placeholders:
- componentName: StyleguideAngularLazyLoading
fields:
heading: Lazy Loading
- componentName: StyleguideSection
fields:
heading: Editing
placeholders:
<%- helper.getAppPrefix(appPrefix, appName) %>jss-styleguide-section:
- componentName: StyleguideEditFrame
fields:
heading: Edit Frame

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';

/**
* Adds the Styleguide-EditFrame component to the disconnected manifest.
* This function is invoked by convention (*.sitecore.ts) when `jss manifest` is run.
*/
export default function StyleguideEditFrame(manifest: Manifest) {
manifest.addComponent({
name: 'StyleguideEditFrame',
icon: SitecoreIcon.DocumentTag,
fields: [
{ name: 'heading', type: CommonFieldTypes.SingleLineText },
],
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<app-styleguide-specimen [rendering]="rendering" e2eId="styleguide-edit-frame">
<sc-edit-frame [dataSource]="editFrameProps.dataSource"
[buttons]="editFrameProps.buttons"
[title]="editFrameProps.title"
[tooltip]="editFrameProps.tooltip"
[cssClass]="editFrameProps.cssClass"
[parameters]="editFrameProps.parameters"
[sitecore]="context">
Who framed Roger Rabbit? Hard to say. <br />
But JSS now allows to edit frame any piece of content on a page in editing mode. <br />
You can add web edit or field edit buttons, modify edit frame style through CSS class and put the frame wherever you need it.
<ng-content></ng-content>
</sc-edit-frame>
</app-styleguide-specimen>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Component, OnInit, Input } from '@angular/core';
import {
ComponentRendering,
EditFrameDataSource,
FieldEditButton,
LayoutServiceContextData,
RouteData,
WebEditButton
} from '@sitecore-jss/sitecore-jss-angular';
import { JssContextService } from '../../jss-context.service';

interface EditFrameProps {
dataSource: EditFrameDataSource;
buttons: (FieldEditButton | WebEditButton | '|')[];
title: string;
tooltip: string;
cssClass: string;
parameters: object;
}

@Component({
selector: 'app-styleguide-edit-frame',
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
templateUrl: './styleguide-edit-frame.component.html',
})
export class StyleguideEditFrameComponent implements OnInit {
@Input() rendering: ComponentRendering;
context: LayoutServiceContextData & {
route: RouteData<unknown> | null;
};

editFrameProps: EditFrameProps;

editFrameButtons = [
{
header: 'WebEditButton',
icon: '/~/icon/Office/16x16/document_selection.png',
click: 'javascript:alert("An edit frame button was just clicked!")',
tooltip: 'Doesnt do much, just a web edit button example',
}, // use javascript:, webedit: or chrome: commands for webedit buttons
{
header: 'FieldEditButton',
icon: '/~/icon/Office/16x16/pencil.png',
fields: ['heading'],
tooltip: 'Allows you to open field editor for specified fields',
}, // or use field edit buttons to open Field Editor
];

constructor(private jssContext: JssContextService) { }

ngOnInit() {
this.jssContext.state.subscribe((state) => {
this.context = state.sitecore;
});
this.editFrameProps = this.getEditFrameProps(this.rendering.dataSource);
}

getEditFrameProps(dataSource: string) {
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
return {
dataSource: dataSource
? {
itemId: dataSource,
// databaseName: 'web',
// language: 'en', // optional params you can also set for datasource
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
}
: undefined, // datasource will set the item to be edited by edit frame
buttons: this.editFrameButtons, // add custom editing functionality or edit field sets with buttons
title: 'JSS edit frame',
tooltip: 'Perform editing anywhere while not tied to a rendering, placeholder or field',
cssClass: 'jss-edit-frame', // customize edit frame appearance through CSS
parameters: {}, // set additional parameters when needed
sitecore: this.context,
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,11 @@ placeholders:
fields:
heading: Translation Patterns
sample: This text can be translated in en.yml
- componentName: Styleguide-Section
fields:
heading: Editing
placeholders:
<%- helper.getAppPrefix(appPrefix, appName) %>jss-styleguide-section:
- componentName: Styleguide-EditFrame
fields:
heading: Edit Frame
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// eslint-disable-next-line no-unused-vars
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';

/**
* Adds the Styleguide-EditFrame component to the disconnected manifest.
* This function is invoked by convention (*.sitecore.ts) when 'jss manifest' is run.
* @param {Manifest} manifest Manifest instance to add components to
*/
export default function StyleguideEditFrame(manifest: Manifest): void {
manifest.addComponent({
name: 'Styleguide-EditFrame',
icon: SitecoreIcon.DocumentTag,
fields: [{ name: 'heading', type: CommonFieldTypes.SingleLineText }],
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-EditFrame',
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Field, withDatasourceCheck } from '@sitecore-jss/sitecore-jss-nextjs';
import { ComponentProps } from 'lib/component-props';
import { EditFrame } from '@sitecore-jss/sitecore-jss-nextjs';
import StyleguideSpecimen from './Styleguide-Specimen';

type StyleguideEditFrameProps = ComponentProps & {
fields: {
heading: Field<string>;
};
children: React.ReactNode;
};

const StyleguideEditFrame = (props: StyleguideEditFrameProps): JSX.Element => (
<StyleguideSpecimen {...props} e2eId="styleguide-editframe">
<EditFrame {...getEditFrameProps(props.rendering.dataSource)}>
Who framed Roger Rabbit? Hard to say. <br />
But JSS now allows to edit frame any piece of content on a page in editing mode. <br />
You can add web edit or field edit buttons, modify edit frames style through CSS class and put the frame wherever you need it.
{props.children}
</EditFrame>
</StyleguideSpecimen>
);

const getEditFrameProps = (dataSource?: string) => {
return {
dataSource: dataSource
? {
itemId: dataSource,
// databaseName: 'web',
// language: 'en', // optional params you can also set for datasource
}
: undefined, // datasource will set the item to be edited by edit frame
buttons: editFrameButtons, // add custom editing functionality or edit field sets with buttons
title: 'JSS edit frame',
tooltip: 'Perform editing anywhere while not tied to a rendering, placeholder or field',
cssClass: 'jss-edit-frame', // customize edit frame appearance through CSS
parameters: {}, // set additional parameters when needed
};
};

const editFrameButtons = [
{
header: 'WebEditButton',
icon: '/~/icon/Office/16x16/document_selection.png',
click: 'javascript:alert("An edit frame button was just clicked!")',
tooltip: 'Doesnt do much, just a web edit button example',
},
{
header: 'FieldEditButton',
icon: '/~/icon/Office/16x16/pencil.png',
fields: ['heading'],
tooltip: 'Allows you to open field editor for specified fields',
},
];

export default withDatasourceCheck()<StyleguideEditFrameProps>(StyleguideEditFrame);
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,12 @@ placeholders:
fields:
heading: Translation Patterns
sample: This text can be translated in en.yml
- componentName: Styleguide-Section
fields:
heading: Editing
placeholders:
React-jss-styleguide-section:
- componentName: Styleguide-EditFrame
fields:
heading: Edit Frame

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// eslint-disable-next-line no-unused-vars
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';

/**
* Adds the StyleguideEditFrame component to the disconnected manifest.
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
* @param {Manifest} manifest Manifest instance to add components to
*/
export default function (manifest) {
manifest.addComponent({
name: 'Styleguide-EditFrame',
icon: SitecoreIcon.DocumentTag,
fields: [{ name: 'heading', type: CommonFieldTypes.SingleLineText }],
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { EditFrame } from '@sitecore-jss/sitecore-jss-react';
import StyleguideSpecimen from '../Styleguide-Specimen';

const StyleguideEditFrame = (props) => (
<StyleguideSpecimen {...props} e2eId="styleguide-editframe">
<EditFrame {...getEditFrameProps(props.rendering.dataSource)}>
Who framed Roger Rabbit? Hard to say. <br />
But JSS now allows to edit frame any piece of content on a page in editing mode. <br />
You can add web edit or field edit buttons, modify edit frame style through CSS class and
put the frame wherever you need it.
{props.children}
</EditFrame>
</StyleguideSpecimen>
);

const getEditFrameProps = (dataSource) => {
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
return {
dataSource: dataSource
? {
itemId: dataSource,
// databaseName: 'web',
// language: 'en', // optional params you can also set for datasource
}
: undefined, // datasource will set the item to be edited by edit frame
buttons: editFrameButtons, // add custom editing functionality or edit field sets with buttons
title: 'JSS edit frame',
tooltip: 'Perform editing anywhere while not tied to a rendering, placeholder or field',
cssClass: 'jss-edit-frame', // customize edit frame appearance through CSS
parameters: {}, // set additional parameters when needed
};
};

const editFrameButtons = [
{
header: 'WebEditButton',
icon: '/~/icon/Office/16x16/document_selection.png',
click: 'javascript:alert("An edit frame button was just clicked!")',
tooltip: 'Doesnt do much, just a web edit button example',
}, // use javascript:, webedit: or chrome: commands for webedit buttons
{
header: 'FieldEditButton',
icon: '/~/icon/Office/16x16/pencil.png',
fields: ['heading'],
tooltip: 'Allows you to open field editor for specified fields',
}, // or use field edit buttons to open Field Editor
];

export default StyleguideEditFrame;
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,11 @@ placeholders:
fields:
heading: Translation Patterns
sample: This text can be translated in en.yml
- componentName: Styleguide-Section
fields:
heading: Editing
placeholders:
Vue-jss-styleguide-section:
- componentName: Styleguide-EditFrame
fields:
heading: Edit Frame
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// eslint-disable-next-line no-unused-vars
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';

/**
* Adds the Styleguide-EditFrame component to the disconnected manifest.
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
* @param {Manifest} manifest Manifest instance to add components to
*/
export default function (manifest) {
manifest.addComponent({
name: 'Styleguide-EditFrame',
templateName: 'Vue-Styleguide-EditFrame',
icon: SitecoreIcon.DocumentTag,
fields: [{ name: 'heading', type: CommonFieldTypes.SingleLineText }],
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<styleguide-specimen v-bind="$props" data-e2e-id="styleguide-edit-frame">
<sc-edit-frame v-bind="editFrameProps">
Who framed Roger Rabbit? Hard to say. <br />
But JSS now allows to edit frame any piece of content on a page in editing mode. <br />
You can add web edit or field edit buttons, modify edit frame style through CSS class and put the frame wherever you need it.
</sc-edit-frame>
</styleguide-specimen>
</template>

<script>
import { EditFrame } from '@sitecore-jss/sitecore-jss-vue';
import StyleguideSpecimen from './Styleguide-Specimen';

export default {
name: 'Styleguide-EditFrame',
data() {
return {
editFrameProps: {
dataSource: this.rendering.dataSource
? {
itemId: this.rendering.dataSource,
// databaseName: 'web',
// language: 'en', // optional params you can also set for datasource
}
: undefined, // datasource will set the item to be edited by edit frame
buttons: [
// add custom editing functionality or edit field sets with buttons
{
header: 'WebEditButton',
icon: '/~/icon/Office/16x16/document_selection.png',
click: 'javascript:alert("An edit frame button was just clicked!")',
tooltip: 'Doesnt do much, just a web edit button example',
}, // use javascript:, webedit: or chrome: commands for webedit buttons
{
header: 'FieldEditButton',
icon: '/~/icon/Office/16x16/pencil.png',
fields: ['heading'],
tooltip: 'Allows you to open field editor for specified fields',
}, // or use field edit buttons to open Field Editor
],
title: 'JSS edit frame',
tooltip: 'Perform editing anywhere while not tied to a rendering, placeholder or field',
cssClass: 'jss-edit-frame', // customize edit frame appearance through CSS
parameters: {}, // set additional parameters when needed
},
};
},
components: {
StyleguideSpecimen,
ScEditFrame: EditFrame,
},
props: {
fields: {
type: Object,
default: () => ({}),
},
rendering: {
type: Object,
},
},
};
</script>
Loading