WYSIWYG Text Editor Examples

This page provides examples of the functionality of the WYSIWYG (What You See Is What You Get) rich text editor.

Text editor toolbar
WYSIWYG Rich Text Editor Toolbar

To see where the WYSIWYG paragraph can be used, see the Basic Page Example page. General information about the editor as well as all toolbar functions are displayed and explained below.

Copying Content

To prevent extraneous HTML and CSS code from being added to the page when copying content from an external source (ex: Word, PDF, etc.), as well as maintaining consistent CCSF content styling, editors should clean the content before pasting into the editor.

There are 3 basic ways to clean your content.

  1. Paste content into a simple text editor (ex: Notepad), re-copy the content, then paste into the editor.
  2. Run the content through an online HTML cleaning tool, then paste into the editor.
  3. Use the text editor built-in detection, which asks to automatically clean it before pasting.

    Clean text pop-up

Options 1 and 2 are recommended, as option 3 does not always do a good job of removing all styles, etc.

Embedding Content

You can display a Google calendar by copying and pasting an HTML code snippet into the Source view of the rich text editor.

  1. Load your Google Calendar in the browser.
  2. Click the 3 dots next to the name of the desired calendar, on the lower left of the page, and click on Settings and sharingCalendar options
  3. Click Integrate calendar under Calendar settings.
  4. Select and copy the Embed code field. You can also customize the display by clicking on the Customize button.
  5. Edit your CCSF page in Drupal and open the Source view in a WYSIWYG content area.
  6. Paste the copied Google code.
  7. Click the Source button again to view the embedded calendar.
  8. Save your page.

Example

 TIP: Customize the calendar display by editing attributes of the embedded code's <iframe> tag. The above calendar uses:

<iframe style="border:solid 1px #bbb; border-radius: 3px; margin: 5px;" width="100%"></iframe>

You can display a YouTube video by copying and pasting an HTML code snippet into the Source view of the rich text editor.

  1. Load the video in your browser.
  2. Click the Share link.
  3. Click the Embed button.
  4. Select the desired options and click the COPY link.
  5. Edit your CCSF page in Drupal and open the Source view in a WYSIWYG content area.
  6. Paste the copied YouTube code.
  7. Click the Source button again to view the embedded video.
  8. Save your page.

Example

 TIP: Customize the video display by editing attributes of the embedded code's <iframe> tag. The above video uses the following attributes (some removed for brevity):

<iframe frameborder="0" height="400" src="https://www.youtube.com/embed/ICMEjXve_kA" style="border: 1px solid #bbb; border-radius: 5px;" width="100%"></iframe>

Toolbar Options

Select a portion of text and use the icons at the top-left of the editor toolbar to format accordingly:

  •  Bold
  •  Italic
  •  Strikethrough
  •  Superscript
  •  Subscript
  •  Clear formatting from a text selection

Use the Paragraph Format dropdown to format selected text as HTML heading levels (1 - 6), Normal text, or Formatted text (HTML <pre></pre> tag).

Rich text editor toolbar with Links options circled

Select the text you would like to hyperlink and click the Link button (). In the dialog box enter the link URL.

Internal Links

When linking to pages on the CCSF website, search for the name of the page by typing in the URL field. A dropdown list will be displayed with matching pages. Click on the desired page from the list. The URL field is then populated with the Drupal node path (ex: /node/1).

Using Drupal node references ensures that links will not break when the target page URL has been changed.

When linking to documents on the CCSF website, enter the relative URL to the file as given by the Web Content team. The URL will be of the form /sites/default/files/<year>/document/<file_name>.

External Links

When linking to pages or documents on external sites, enter the absolute URL (ex: https://sf.gov/).

Advanced Options

In the ADVANCED section of the Add Link dialog there are two fields of interest: CSS classes and Open in new window/tab.

CSS classes

This allows you to add the name of a CSS class to the class attribute of the HTML anchor tag to style the link. CCSF has two predefined classes for styling links.

  • button - Formats link as a button
  • learn-more - Adds an arrow icon to the right of the text

Open in new window/tab

Check this box to open links in a new window/browser tab. Use this for document and external website links.

Remove Link

Select hyperlinked text and click the Unlink button () to remove the link from the text.

Rich text editor toolbar with object insert options circled

Block Quote

Click the Block Quote button (Block quote button) to format a section of text as a quote.

This is a section of quoted text.

Table

Click the Table button (Insert table button) to insert a table.

Example table
Date Description
2022-08-16 FlexDay Workshop
2022-08-17 1st day of instruction

Notes:

  • This is not the preferred table format. The preferred format is the Bootstrap Table option available via the Insert template button ().
  • Per accessibility guidelines, tables should not be used for layout, only for tabular data.

Horizontal Line

Click the Horizontal Line button (Horizontal line button) to insert a formatted horizontal divider line.


 TIP: When adding a horizontal line as the last content in the text editor, it will add an extra line break underneath it. If you want to remove it, click on the Source icon and remove the <p>&nbsp;</p> code immediately below the <hr /> tag.

Video Embed

Click the Video Embed button (Video Embed button) to insert an embedded video using a URL (YouTube, Vimeo, etc.).

 TIP: It's a good idea to uncheck the Autoplay option and check the Responsive Video option.

Document Embed

DO NOT USE the first E button (Document embed button). This option will be removed in the near future. To link to documents, insert an internal document link (see the Links accordion, above).

Media Embed

Use the Media Embed (second E) button () to insert an inline image.

Existing Image

John Adams location on map.
Embedded Image Example - John Adams map location

To use an existing image (an image that has already been uploaded to the server), in the Select Media tab...

  • Check the box above the image
  • Scroll down and click the Select entities button
  • Click the Next button

New Image

To upload your own image, use the Upload Image tab...

  • Click the Choose File button to select a file from your computer
  • Click the Select files button
  • Click the Next button

Image Properties

Set properties in the Embed Media Item dialog:

  • Link to (optional)
    Entering a URL in this field will create a link on the object pointing to the given URL.
  • Open in a new window? (optional)
    Check this box to open the link in a new browser tab/window.
  • Image style (optional)
    If your image has been resized to the actual size you would like it to be displayed, leave the default None (original image) selection in place. Otherwise, use a predefined setting to style the image. You may need to perform some trial and error with the different options to find the best fit.
  • Link image to
    Leave this set to Nothing.
  • Alternate text (required)
    Always enter descriptive text in this field. This is required for ADA-compliance.
  • Align (optional)
    Select the desired alignment for the image with respect to the surrounding text.
  • Caption (optional)
    Enter text in this field to display a caption below the image.

Click the Embed button to insert the image.

Text editor tollbar with Content Template & Editor View options curcled

Content Templates

Click the Content Templates button (Content Templates button) to view the available templates.

Alert Template

Alert template
 TIP: Alert templates may not add a trailing break, making it difficult to add content immediately after the alert. To add a break, click the Source button and add a <p></p> tag after the alert div (<div class="alert-card"></div>).

Anchor link

An Anchor link allows linking to an element within the page that has a specific HTML element id attribute. When a link is clicked that points to the ID of the Anchor link, the page will scroll to that location.

Anchor link - double click me to customize

Anchor link - double click me to customize
Screenshot of Anchor link within text editor

An Anchor link has a CSS class called anchor that hides the link in the published version of the page and an ID (set by default to anchor-link) that uniquely identifies the HTML element within the page. To allow scrolling the page to where the Anchor link code is placed, you create a normal link that specifies the ID in the link URL.

Scroll to the anchor link

Bootstrap Table

Bootstrap is a front-end styling toolkit that displays web-accessible tables in a responsive manner, making them viewable across different viewport sizes. For accessibility reasons, tables should only be used for tabular data and not for content layout. Using Bootstrap tables is the preferred method of adding tabular content on the CCSF website.

# First Last Handle
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter

 TIPS:

  • Right-click anywhere inside the table to display a pop-up to edit table options and properties.
  • To copy/paste tables from external sources (Excel, Word, Google Spreadsheets, etc.), first use an online tool like TableCleaner, then paste the table into the text editor. Afterwards, you will also need to add the table and table-striped CSS classes to the opening <table class="table table-striped"> tag in the Source view.

Border/Grey Card

Border Card template content.

 

Grey Card template content.

 

Padded Content

This template adds padding to the left and right of the example content, which consists of <H2> header text and italicized body text.

For every dream, there is a way

Rooted in the values of inclusiveness, integrity, innovation and creativity, we offer a high-quality education that’s uniquely San Francisco. We believe in opening doors and providing opportunities for each and every Bay Area resident.

Section Title

This template centers example content with an <H1> heading and normal body text.

Finibus Bonorum et Malorum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

 

Styled Intro Text

This template adds example content within an HTML tag (<em class="text-muted h4"></em>).

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.

Two/Three Column Templates

These templates use the Bootstrap Grid System to generate layouts with 2 or 3 columns.

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Quisque ultrices massa nec diam fringilla, quis posuere tellus commodo.
  • Maecenas eget metus consectetur, luctus odio eu, laoreet justo.
  1. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  2. Quisque ultrices massa nec diam fringilla, quis posuere tellus commodo.
  3. Maecenas eget metus consectetur, luctus odio eu, laoreet justo.
  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Quisque ultrices massa nec diam fringilla, quis posuere tellus commodo.
  • Maecenas eget metus consectetur, luctus odio eu, laoreet justo.

 TIP: The number of columns can be adjusted in the Source view using directions on the Page Editing page on the Documentation Intranet site.

Show Blocks

Click the Show Blocks button (Show Blocks) to view outlines of the different HTML elements within the editor content.

View Source

Click the Source button (Source code view button) to view and edit the HTML source code for the editor content. Click the button again to return to the WYSIWYG view.

Maximize

Click the Maximize button (View full screen button) to enlarge the editor frame to fill the entire browser window. Click the button again to return to the normal view.

Rich text editor toolbar with Styles circled

Block Styles

Intro Text

This is content formatted with the Intro Text style. It is the same font size as H4 headings.

Inline Styles

Learn More Link

DO NOT USE this style - it will be removed in the near future. Instead, use the learn-more CSS class attribute (ex: <a href="https://www.ccsf.edu" class="learn-more">CCSF Website</a>).

Rich text editor toolbar with alignment options circled

Text Alignment

 Left

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

 Center

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

 Right

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

 Justify

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Text editor toolbar with list buttons circled

List Styles

 Unordered List

  • This
  • That
  • The Other

 Ordered List

  1. First
  2. Second
  3. Third
Common Questions

If you see extra vertical whitespace (line breaks) in the WYSIWYG view of the text editor and are unable to remove it by using the Backspace or Delete buttons, click on the Source button (Source code view button) in the toolbar and remove the following code:

<p>&nbsp;</p>

Click on the Source button again to verify the space has been removed.

The <Enter> key inserts a <p></p> tag in the HTML source, which roughly translates to double line spacing. To use single line spaces, hold down the <Shift> key, then click <Enter> to break to the next line. This will add an HTML <br/> tag instead of enclosing the text in a <p></p> tag.

If you want to remove the Intro Text style formatting, or when you attempt to add a line break to add normal text in the next paragraph, the formatting still persists.

Content styled with Intro Text.

Hit <Enter> key to add a line break results in another paragraph with the same styling.

There are two options to remove the Intro Text style:

  1. Highlight the text and select Normal from the Format dropdown.
  2. Click the Source button and remove the following from the containing <p> tag:
class="text-muted h4"

 

Content styled with Intro Text.

Hit <Enter> key to add a line break results in another paragraph with the same styling. Reformatted as normal text.