Skip to content

Commit 6eb4b25

Browse files
committed
Merge branch 'staging' of https://github.com/SharePoint/sp-dev-docs into staging
2 parents 0f54a00 + e8a1c94 commit 6eb4b25

8 files changed

+63
-87
lines changed

docs/spfx/set-up-your-developer-tenant.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,8 @@ Choose **OK** to create the site collection.
5656

5757
SharePoint will create the developer site and you will be able to see its progress in the SharePoint admin center. After the site is created, you can browse to your developer site collection.
5858

59-
## Set up a document library
60-
In order to use the features of the SharePoint Framework, you will need to set up a document library with a new column and upload SharePoint workbench. This procedure uses the default document library in your developer site collection. This will be called **Documents** in the left navigation.
61-
62-
* Go to your developer site in a browser.
63-
* Choose the gears icon on the top right and then choose **Site settings** to open the settings page.
64-
* Choose **Site libraries and lists** under the **Site Administration** category.
65-
* Choose **Customize Documents**
66-
* Choose **Create column** under **Columns**
67-
* Enter **ClientSideApplicationId** as the column name and leave the other fields at their current values.
68-
* Choose **OK** to create the column.
69-
70-
## Put the SharePoint workbench in the document library
71-
You need the SharePoint Workbench on your developer site to test your web parts on SharePoint. This procedure uses the default document library in your site collection. This will be called **Documents** in the left navigation.
59+
## Put the SharePoint Workbench in the document library
60+
You need the SharePoint Workbench on your developer site to test your web parts on SharePoint. SharePoint workbench is a developer design surface that enables you to quickly preview and test web parts without deploying them in SharePoint. This procedure uses the default document library in your site collection. This will be called **Documents** in the left navigation.
7261

7362
* Download the [workbench.aspx](https://raw.githubusercontent.com/SharePoint/sp-dev-docs/master/workbench.aspx) file to your local computer. To do this:
7463
- Save opened workbench.aspx to your computer. Typically you'd do this by right clicking the page and chosing "Save as..."
@@ -80,7 +69,7 @@ You need the SharePoint Workbench on your developer site to test your web parts
8069

8170
You will get an error If you are using a SharePoint site that was provisioned using a self-service site creation. We recommend using a developer site collection or a SharePoint site that was not created using a self-service site creation.
8271

83-
If you get the following exception when moving to the workbench.aspx page:
72+
If you get the following exception when moving to the `workbench.aspx` page:
8473

8574
```
8675
"The requested operation is part of an experimental feature that is not supported in the current environment. The requested operation is part of an experimental feature that is not supported in the current environment."

docs/spfx/web-parts/get-started/add-jqueryui-accordion-to-web-part.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The `externals` section contains the libraries that are not bundled with the def
132132
```json
133133
"externals": {
134134
"@microsoft/sp-client-base": "node_modules/@microsoft/sp-client-base/dist/sp-client-base.js",
135-
"@microsoft/sp-client-preview": "node_modules/@microsoft/sp-client-preview/dist/sp-client-preview.js",
135+
"@microsoft/sp-webpart-base": "node_modules/@microsoft/sp-webpart-base/dist/sp-webpart-base.js",
136136
"@microsoft/sp-lodash-subset": "node_modules/@microsoft/sp-lodash-subset/dist/sp-lodash-subset.js",
137137
"office-ui-fabric-react": "node_modules/office-ui-fabric-react/dist/office-ui-fabric-react.js",
138138
"react": "node_modules/react/dist/react.min.js",

docs/spfx/web-parts/get-started/build-a-hello-world-web-part.md

Lines changed: 59 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ If you are new to gulp, you can read [Using Gulp](http://docs.asp.net/en/latest/
9898

9999
Visual Studio Code provides built-in support for gulp and other task runners. Choose **Ctrl+Shift+B** on Windows or **Cmd+Shift+B** on Mac to debug and preview your web part.
100100

101-
### SharePoint workbench
102-
SharePoint workbench is a developer design surface that enables you to quickly preview and test web parts without deploying them in SharePoint. SharePoint workbench includes the client-side page and the client-side canvas in which you can add, delete and test your web parts in development.
101+
### SharePoint Workbench
102+
SharePoint Workbench is a developer design surface that enables you to quickly preview and test web parts without deploying them in SharePoint. SharePoint Workbench includes the client-side page and the client-side canvas in which you can add, delete and test your web parts in development.
103103

104-
![SharePoint workbench running locally](../../../../images/sp-workbench.png)
104+
![SharePoint Workbench running locally](../../../../images/sp-workbench.png)
105105

106106
To add the HelloWorld web part, choose the **add** button. The add button opens the toolbox where you can see a list of web parts available for you to add. The list will include the **HelloWorld** web part as well other web parts available locally in your development environment.
107107

108-
![SharePoint workbench toolbox in localhost](../../../../images/sp-workbench-toolbox.png)
108+
![SharePoint Workbench toolbox in localhost](../../../../images/sp-workbench-toolbox.png)
109109

110110
Choose **HelloWorld** to add the web part to the page:
111111

@@ -189,19 +189,10 @@ public render(): void {
189189
}
190190
```
191191

192-
This model is flexible enough so that web parts can be built in any JavaScript framework and loaded into the DOM element. The following is an example of how you would load a React component instead of plain HTML.
193-
194-
```ts
195-
render(): void {
196-
let e = React.createElement(TodoComponent, this.properties);
197-
ReactDom.render(e, this.domElement);
198-
}
199-
```
200-
201-
>**Note:** The Yeoman SharePoint generator lets you choose **React** as your framework of choice when adding a new web part to the project.
192+
This model is flexible enough so that web parts can be built in any JavaScript framework and loaded into the DOM element.
202193

203194
#### Configure the Web part property pane
204-
The property pane is also defined in the **HelloWorldWebPart** class. The **propertyPaneSettings** property is where you need to define the property pane.
195+
The property pane is defined in the **HelloWorldWebPart** class. The **propertyPaneConfiguration** property is where you need to define the property pane.
205196

206197
When the properties are defined, you can access them in your web part using `this.properties.<property-value>`, as shown in the **render** method:
207198

@@ -211,10 +202,54 @@ When the properties are defined, you can access them in your web part using `thi
211202

212203
Read the [Integrating property pane with a web part](../basics/integrate-with-property-pane) article to learn more about how to work with the property pane and property pane field types.
213204

214-
Replace the **propertyPaneSettings** method with the code below which shows how to add property types other than TextField.
205+
Lets now add few more properties - a checkbox, dropdown and a toggle - to the property pane. We first start by importing the respective property pane fields from the framework.
206+
207+
Scroll to the top of the file and add the following to the import section from `@microsoft/sp-webpart-base`:
208+
209+
```ts
210+
PropertyPaneCheckbox,
211+
PropertyPaneDropdown,
212+
PropertyPaneToggle
213+
```
214+
215+
The complete import section will look like the following:
216+
217+
```ts
218+
import {
219+
BaseClientSideWebPart,
220+
IPropertyPaneSettings,
221+
IWebPartContext,
222+
PropertyPaneTextField,
223+
PropertyPaneCheckbox,
224+
PropertyPaneDropdown,
225+
PropertyPaneToggle
226+
} from '@microsoft/sp-webpart-base';
227+
```
228+
229+
Save the file.
230+
231+
Next, update the web part properties to include the new properties. This maps the fields to typed objects.
232+
233+
Open **IHelloWorldWebPartProps.ts** and replace the existing code with the following code.
234+
235+
```ts
236+
export interface IHelloWorldWebPartProps {
237+
description: string;
238+
test: string;
239+
test1: boolean;
240+
test2: string;
241+
test3: boolean;
242+
}
243+
```
244+
245+
Save the file.
246+
247+
Switch back to the **HelloWorldWebPart.ts** file.
248+
249+
Replace the **propertyPaneConfiguration** method with the code below which adds the new property pane fields and maps them to their respective typed objects.
215250

216251
```ts
217-
protected get propertyPaneSettings(): IPropertyPaneSettings {
252+
protected get propertyPaneConfiguration(): IPropertyPaneConfiguration {
218253
return {
219254
pages: [
220255
{
@@ -257,57 +292,14 @@ protected get propertyPaneSettings(): IPropertyPaneSettings {
257292
}
258293
```
259294

260-
Since we added new property fields, let's import those from the framework.
261295

262-
Scroll to the top of the file and add the following to the import section from `@microsoft/sp-client-preview`:
263-
264-
```ts
265-
PropertyPaneCheckbox,
266-
PropertyPaneDropdown,
267-
PropertyPaneToggle
268-
```
269-
270-
The complete import section will look like the following:
271-
272-
```ts
273-
import {
274-
BaseClientSideWebPart,
275-
IPropertyPaneSettings,
276-
IWebPartContext,
277-
PropertyPaneTextField,
278-
PropertyPaneCheckbox,
279-
PropertyPaneDropdown,
280-
PropertyPaneToggle
281-
} from '@microsoft/sp-client-preview';
282-
```
283-
284-
Save the file.
285-
286-
Now add these properties to the **IHelloWorldWebPartProps** interface that map to our fields we just added.
287-
288-
Open **IHelloWorldWebPartProps.ts** and replace the existing code with the following code:
289-
290-
```ts
291-
export interface IHelloWorldWebPartProps {
292-
description: string;
293-
test: string;
294-
test1: boolean;
295-
test2: string;
296-
test3: boolean;
297-
}
298-
```
299-
300-
Save the file.
301-
302-
Switch back to the **HelloWorldWebPart.ts** file.
303-
304-
After you add your properties to the web part properties, you can access the property in the same way you accessed the **description** property earlier:
296+
After you add your properties to the web part properties, you can now access the properties in the same way you accessed the **description** property earlier:
305297

306298
```ts
307299
<p class="ms-font-l ms-fontColor-white">${this.properties.test2}</p>
308300
```
309301

310-
To set the default value for the property, you will need to update the web part manifest's **properties** property bag:
302+
To set the default value for the properties, you will need to update the web part manifest's **properties** property bag:
311303

312304
Open `HelloWorldWebPart.manifest.json` and modify the `properties` to:
313305

@@ -321,6 +313,8 @@ Open `HelloWorldWebPart.manifest.json` and modify the `properties` to:
321313
}
322314
```
323315

316+
The web part property pane will now have these default values for those properties.
317+
324318
### Web part manifest
325319
The **HelloWorldWebPart.manifest.json** file defines the web part metadata such as version, id, display name, icon, and description. Every web part should contain this manifest.
326320

@@ -355,21 +349,14 @@ The **HelloWorldWebPart.manifest.json** file defines the web part metadata such
355349
]
356350
}
357351
```
352+
358353
### Preview the web part in SharePoint
359354

360-
SharePoint workbench is also hosted in SharePoint to preview and test your local web parts in development. The key advantage is that now you are running in SharePoint context and that you will be able to interact with SharePoint data.
355+
SharePoint Workbench is also hosted in SharePoint to preview and test your local web parts in development. The key advantage is that now you are running in SharePoint context and that you will be able to interact with SharePoint data.
361356

362357
Go to the following URL: 'https://your-sharepoint-site/Shared%20Documents/workbench.aspx'
363358

364-
By default, your browser is configured not to load scripts from localhost. Workbench will notify you if that is the case.
365-
366-
![Load unsafe scripts to run scripts from localhost](../../../../images/sp-workbench-o365-unsface-scripts.png)
367-
368-
In order to execute local scripts, you will need to configure the browser to load scripts from unauthenticated sources. This is due to loading scripts over HTTP while connected to a page via HTTPS. Depending on the browser you use, the options to enable this may vary. For example, in the Chrome browser, you can choose the grey shield in the right side of the address bar to load unsafe scripts.
369-
370-
![Allow browser to load unsafe scripts to run scripts from localhost](../../../../images/chrome-load-unsafe-scripts.png)
371-
372-
After you enable loading scripts, you should see the workbench load. Add the hello world web part to the canvas:
359+
>**Note:** If you do not have the SPFx developer certificate installed, then Workbench will notify you that it is configured not to load scripts from localhost. Execute `gulp trust-dev-cert` command in your project directory console to install the developer certificate.
373360
374361
![SharePoint Workbench running in a SharePoint Online site](../../../../images/sp-workbench-o365.png)
375362

images/sp-workbench-helloworld-pp.png

0 Bytes
Loading

images/sp-workbench-helloworld-wp.png

0 Bytes
Loading
0 Bytes
Loading

images/sp-workbench-o365.png

0 Bytes
Loading

images/sp-workbench.png

0 Bytes
Loading

0 commit comments

Comments
 (0)