Rock
Rock copied to clipboard
Added HTML Snippets so that users can reuse common content.
Proposed Changes
Our users often need to store and reuse common messages in their emails or other places where the HTML editor is used. Well over a year ago we created a tool to help them do that right in the HTML editor. It allows them to create, reuse, copy, edit, and delete snippets of HTML. This tool utilizes the existing HTMLContent model with some modifications to store the content.
Types of changes
What types of changes does your code introduce to Rock?
Put an x
in the boxes that apply
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality, which has been approved by the core team)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist
Put an x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
- [x] This is a single-commit PR. (If not, please squash your commit and re-submit it.)
- [x] I verified my PR does not include whitespace/formatting changes -- because if it does it will be closed without merging.
- [x] I have read the Contributing to Rock doc
- [x] By contributing code, I agree to license my contribution under the Rock Community License Agreement
- [x] Unit tests pass locally with my changes
- [ ] I have added required tests that prove my fix is effective or that my feature works
- [ ] I have included updated language for the Rock Documentation (if appropriate)
Documentation
There doesn't seem to be much in terms of documenting the plugins of the HTML Editor but I might suggest something like:
Snippets
Snippets allow you to save commonly used content so you don't have to retype it over and over again. Think about: email signatures, your favorite lava, or messages you send frequently. You can create a new snippet by clicking the scissor icon and selecting "Save Content as New Snippet". Your content will be copied and become available to reuse under "My Snippets". If you would like to add, edit, or delete your snippet you can do so by clicking on "Manage Existing Snippets".
Migrations
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.rockrms.com/license
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//
namespace Rock.Migrations
{
using System;
using System.Data.Entity.Migrations;
/// <summary>
///
/// </summary>
public partial class HTMLSnippets : Rock.Migrations.RockMigration
{
/// <summary>
/// Operations to be performed during the upgrade process.
/// </summary>
public override void Up()
{
DropIndex( "dbo.HtmlContent", new[] { "BlockId" } );
AddColumn( "dbo.HtmlContent", "Name", c => c.String( maxLength: 100 ) );
AlterColumn( "dbo.HtmlContent", "BlockId", c => c.Int() );
CreateIndex( "dbo.HtmlContent", "BlockId" );
// Page: HtmlEditor Snippets Plugin Frame
RockMigrationHelper.AddPage( true, "E7BD353C-91A6-4C15-A6C8-F44D0B16D16E", "2E169330-D7D7-4ECA-B417-72C64BE150F0", "HtmlEditor Snippets Plugin Frame", "", "93953B4B-AA72-4904-AB6F-B4E41AC758A6", "" ); // Site:Rock RMS
RockMigrationHelper.AddPageRoute( "93953B4B-AA72-4904-AB6F-B4E41AC758A6", "htmleditorplugins/RockSnippets" );
RockMigrationHelper.UpdateBlockType( "HtmlEditor Snippets", "Block to be used as part of the Snippets HtmlEditor Plugin", "~/Blocks/Utility/HtmlEditorSnippets.ascx", "Utility", "BE83B6D0-B1AD-4CCE-AF17-5603B50E6DF4" );
// Add Block to Page: HtmlEditor Snippets Plugin Frame, Site: Rock RMS
RockMigrationHelper.AddBlock( true, "93953B4B-AA72-4904-AB6F-B4E41AC758A6", "", "BE83B6D0-B1AD-4CCE-AF17-5603B50E6DF4", "HtmlEditor Snippets", "Main", "", "", 0, "27280738-A3C5-495B-8F93-2948DC5217C8" );
// Page: HTML Snippet Editor Frame
RockMigrationHelper.AddPage( "93953B4B-AA72-4904-AB6F-B4E41AC758A6", "2E169330-D7D7-4ECA-B417-72C64BE150F0", "HTML Snippet Editor Frame", "", "8DE71170-E3BC-4CAC-AAE6-B9F1FF1389C8", "" ); // Site:Rock RMS
RockMigrationHelper.UpdateBlockType( "Html Snippet Editor", "Block to edit HTML Snippets", "~/Blocks/Utility/HtmlSnippetEditor.ascx", "Utility", "58A987C1-22A1-46DA-B420-7694819E2D8B" );
RockMigrationHelper.AddBlock( "8DE71170-E3BC-4CAC-AAE6-B9F1FF1389C8", "", "58A987C1-22A1-46DA-B420-7694819E2D8B", "Html Snippet Editor", "Main", "", "", 0, "F91E58EB-B5FB-4822-A49D-699D2F73A3CF" );
// Attrib Value for Block:HtmlEditor Snippets, Attribute:Goes By Page: HtmlEditor Snippets Plugin Frame, Site: Rock RMS
RockMigrationHelper.AddBlockTypeAttribute( "BE83B6D0-B1AD-4CCE-AF17-5603B50E6DF4", Rock.SystemGuid.FieldType.PAGE_REFERENCE, "Edit Page", "EditPage", "", "", 0, "", "C31FDA8A-8CAB-4A1C-B96D-275415B5BB1C", true );
RockMigrationHelper.AddBlockAttributeValue( "27280738-A3C5-495B-8F93-2948DC5217C8", "C31FDA8A-8CAB-4A1C-B96D-275415B5BB1C", "8DE71170-E3BC-4CAC-AAE6-B9F1FF1389C8" );
}
/// <summary>
/// Operations to be performed during the downgrade process.
/// </summary>
public override void Down()
{
Sql( "Delete from dbo.HtmlContent where [BlockId] is null" );
DropIndex( "dbo.HtmlContent", new[] { "BlockId" } );
AlterColumn( "dbo.HtmlContent", "BlockId", c => c.Int( nullable: false ) );
DropColumn( "dbo.HtmlContent", "Name" );
CreateIndex( "dbo.HtmlContent", "BlockId" );
RockMigrationHelper.DeleteBlock( "27280738-A3C5-495B-8F93-2948DC5217C8" );
RockMigrationHelper.DeleteBlockType( "BE83B6D0-B1AD-4CCE-AF17-5603B50E6DF4" );
RockMigrationHelper.DeletePage( "93953B4B-AA72-4904-AB6F-B4E41AC758A6" ); // Page: HtmlEditor Snippets Plugin Frame
RockMigrationHelper.DeleteBlock( "F91E58EB-B5FB-4822-A49D-699D2F73A3CF" );
RockMigrationHelper.DeletePage( "8DE71170-E3BC-4CAC-AAE6-B9F1FF1389C8" ); // Page: HTML Snippet Editor Frame
}
}
}
Assigned to MasonK for QA Testing
It sounds like this is the case, but just wanted to double check, these snippets are per-user correct? Meaning you and I would have different snippets from each other?
@cabal95 They are unique to each user.
@nairdo This is working as intended.
This is an awesome idea! Probably outside the scope of this PR, but it'd be amazing if you could assign Groups/RSRs to snippets to make the same ones available to multiple people at once.
@trydyingtolive Mark, With some renewed interest by several others, we would be in favor of this PR if it had share-ability in mind. If you're still interested, are you willing to collaborate with us on some redesign? If so, let me know and I'll email you the next steps.
This would be an awesome feature!
I see a few places where this would be used for us. Nice idea!
With the upcoming removal of Summernote from Rock's Html block and communications blocks along with the addition of the upcoming SnippetTypes and Snippets (example), we're going to close this PR.