Opened 18 years ago

Closed 17 years ago

#207 closed New Feature (fixed)

Wrap an arbitrary html tag around a selection

Reported by: adamann2@… Owned by: Frederico Caldeira Knabben
Priority: Normal Milestone: FCKeditor 2.5 Beta
Component: Core : Styles Version:
Keywords: Cc:

Description

I would like to request a feature that would wrap html tags, with attributes, around a user's selection. For instance, if the user selects some text in the edit pane and presses a button, I want to wrap the selection in a span, with a class and title. We need this feature for adding instructor comments to student writing assignments.

I have found and tried several examples, and they work fine as long as the selection is just text. However, to be useful, the inserted tags need to work properly with other tags in the text.

A simple example, starting with this:

<p>Here's some text</p> <p>Here's some more text</p>

Now, if the user's selection starts with the word 'text' in the first paragraph, and ends with the word 'more' in the second paragraph, here's what I'd expect to see:

<p>Here's some <span class="foo" title="bar">text</span></p> <p><span class="foo" title="bar">Here's some more</span> text</p>

What I'm actually getting with the examples I've tried is something like this:

<p>Here's some <span class="foo" title="bar">textHere's some more</span> text</p>

I'd be happy to help work on this, if someone can help me out or point me in the right direction, or let me know anyone is already working on something similar.

Change History (3)

comment:1 Changed 18 years ago by Frederico Caldeira Knabben

Component: GeneralCore : Styles
Milestone: FCKeditor 2.5

This one is supposed to be fixed with the new style system planned for the 2.5.

comment:2 Changed 17 years ago by Frederico Caldeira Knabben

Owner: set to Frederico Caldeira Knabben
Status: newassigned

comment:3 Changed 17 years ago by Frederico Caldeira Knabben

Resolution: fixed
Status: assignedclosed

As a result of [774], we were able to provide this feature with [844]. It introduced the FCK.Selection.ApplyStyle( styleDefinition ) function, which applies an arbitrary style definition to the selection.

The style definition to be passed to this function is an object with the same structure used for the styles in the configuration file (see Components/Styles?).

So, for the example provided, we should have something like this (when called from outside FCKeditor):

editorInstance.Selection.ApplyStyle( 
	{ 
		Element : 'span', 
		Attributes : 
		{
			'class' : "foo",
			'title' : "bar"
		}
	} ) ;
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy