You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/set-up-your-developer-tenant.md
+3-14Lines changed: 3 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -56,19 +56,8 @@ Choose **OK** to create the site collection.
56
56
57
57
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.
58
58
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.
72
61
73
62
* Download the [workbench.aspx](https://github.com/SharePoint/sp-dev-docs/blob/master/workbench.aspx) file to your local computer. To do this:
74
63
- Open the context menu (right-click) on the file content in the middle of the page and choose **Save Target As** or **Save Link As** (depending on your browser) to save the file as **workbench.aspx** to your local computer.
@@ -80,7 +69,7 @@ You need the SharePoint Workbench on your developer site to test your web parts
80
69
81
70
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.
82
71
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:
84
73
85
74
```
86
75
"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."
Copy file name to clipboardExpand all lines: docs/spfx/web-parts/get-started/build-a-hello-world-web-part.md
+59-72Lines changed: 59 additions & 72 deletions
Original file line number
Diff line number
Diff line change
@@ -98,14 +98,14 @@ If you are new to gulp, you can read [Using Gulp](http://docs.asp.net/en/latest/
98
98
99
99
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.
100
100
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.
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.
107
107
108
-

108
+

109
109
110
110
Choose **HelloWorld** to add the web part to the page:
111
111
@@ -189,19 +189,10 @@ public render(): void {
189
189
}
190
190
```
191
191
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.
202
193
203
194
#### 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.
205
196
206
197
When the properties are defined, you can access them in your web part using `this.properties.<property-value>`, as shown in the **render** method:
207
198
@@ -211,10 +202,54 @@ When the properties are defined, you can access them in your web part using `thi
211
202
212
203
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.
213
204
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
+
exportinterfaceIHelloWorldWebPartProps {
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.
@@ -257,57 +292,14 @@ protected get propertyPaneSettings(): IPropertyPaneSettings {
257
292
}
258
293
```
259
294
260
-
Since we added new property fields, let's import those from the framework.
261
295
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
-
exportinterfaceIHelloWorldWebPartProps {
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:
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:
311
303
312
304
Open `HelloWorldWebPart.manifest.json` and modify the `properties` to:
313
305
@@ -321,6 +313,8 @@ Open `HelloWorldWebPart.manifest.json` and modify the `properties` to:
321
313
}
322
314
```
323
315
316
+
The web part property pane will now have these default values for those properties.
317
+
324
318
### Web part manifest
325
319
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.
326
320
@@ -355,21 +349,14 @@ The **HelloWorldWebPart.manifest.json** file defines the web part metadata such
355
349
]
356
350
}
357
351
```
352
+
358
353
### Preview the web part in SharePoint
359
354
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.
361
356
362
357
Go to the following URL: 'https://your-sharepoint-site/Shared%20Documents/workbench.aspx'
363
358
364
-
By default, your browser is configured not to load scripts from localhost. Workbench will notify you if that is the case.
365
-
366
-

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
-

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.
373
360
374
361

0 commit comments