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

Feature #1425: additional params for text webpart #2403

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `-Path` option to `Set-PnPList` which allows the url of a list to be changed within the same site [#2381](https://github.com/pnp/powershell/pull/2381)
- Added `-Force` option to `Set-PnPListem` to force it to update a list item even without changing something. Can be useful in i.e. triggering a webhook. [#2396](https://github.com/pnp/powershell/pull/2396)
- Added `ImageUrl`, `PageImageAlignment`, `ImageHeight` and `ImageWidth` parameters to `Add-PnPPageTextPart` cmdlet so that users can add an inline image into a text webpart. [#2401](https://github.com/pnp/powershell/pull/2401)
- Added `TextBeforeImage` and `TextAfterImage` parameters to `Add-PnPPageTextPart` cmdlet so that users can add before and after text for an inline image into a text webpart. [#2401](https://github.com/pnp/powershell/pull/2401)


### Changed
- Changed to no longer require `https://` to be prefixed when using `Connect-PnPOnline -Url tenant.sharepoint.com` [#2139](https://github.com/pnp/powershell/pull/2139)
Expand Down
36 changes: 36 additions & 0 deletions documentation/Add-PnPPageTextPart.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ Add-PnPPageTextPart -Page "MyPage" -Text "Hello World!" -ImageUrl "/sites/contos

Adds the text 'Hello World!' to the Page 'MyPage' with specified image as inline image.

### EXAMPLE 3
```powershell
Add-PnPPageTextPart -Page "MyPage" -Text "Hello World!" -ImageUrl "/sites/contoso/SiteAssets/test.png" -TextBeforeImage "Text before" -TextAfterImage "Text after"
```

Adds the text 'Hello World!' to the Page 'MyPage' with specified image as inline image with text specified before and after the inline image.


## PARAMETERS

### -Column
Expand Down Expand Up @@ -116,6 +124,20 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -TextBeforeImage
Specifies the text to display before the inline image.

```yaml
Type: String
Parameter Sets: (All)

Required: False
Position: Named
Default value: 150
Accept pipeline input: False
Accept wildcard characters: False
```

### -ImageUrl
Specifies the inline image to be added. Image will be added after the text content.

Expand Down Expand Up @@ -172,6 +194,20 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -TextAfterImage
Specifies the text to display after the inline image.

```yaml
Type: String
Parameter Sets: (All)

Required: False
Position: Named
Default value: 150
Accept pipeline input: False
Accept wildcard characters: False
```

### -Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Expand Down
10 changes: 9 additions & 1 deletion src/Commands/Pages/AddPageTextPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class AddTextPart : PnPWebCmdlet
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_POSITIONED)]
public int Column;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEFAULT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_POSITIONED)]
public string TextBeforeImage = string.Empty;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEFAULT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_POSITIONED)]
public string ImageUrl;
Expand All @@ -45,6 +49,10 @@ public class AddTextPart : PnPWebCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_POSITIONED)]
public int ImageHeight = 150;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEFAULT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_POSITIONED)]
public string TextAfterImage = string.Empty;

protected override void ExecuteCmdlet()
{
if (ParameterSpecified(nameof(Section)) && Section == 0)
Expand Down Expand Up @@ -77,7 +85,7 @@ protected override void ExecuteCmdlet()
Height = ImageHeight
});

textPartText = $"{Text}{inlineImage}";
textPartText = $"{Text}{TextBeforeImage}{inlineImage}{TextAfterImage}";
}

textControl.Text = textPartText;
Expand Down