1 | /* |
---|
2 | * FCKeditor - The text editor for internet |
---|
3 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
7 | * |
---|
8 | * For further information visit: |
---|
9 | * http://www.fckeditor.net/ |
---|
10 | * |
---|
11 | * "Support Open Source software. What about a donation today?" |
---|
12 | * |
---|
13 | * File Name: fckregexlib.js |
---|
14 | * These are some Regular Expresions used by the editor. |
---|
15 | * |
---|
16 | * File Authors: |
---|
17 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
18 | */ |
---|
19 | |
---|
20 | var FCKRegexLib = { |
---|
21 | |
---|
22 | // This is the Regular expression used by the SetHTML method for the "'" entity. |
---|
23 | AposEntity : /'/gi , |
---|
24 | |
---|
25 | // Used by the Styles combo to identify styles that can't be applied to text. |
---|
26 | ObjectElements : /^(?:IMG|TABLE|TR|TD|TH|INPUT|SELECT|TEXTAREA|HR|OBJECT|A|UL|OL|LI)$/i , |
---|
27 | |
---|
28 | BlockElements : /^(?:P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TD|TH)$/i , |
---|
29 | |
---|
30 | // Elements marked as empty "Empty" in the XHTML DTD. |
---|
31 | EmptyElements : /^(?:BASE|META|LINK|HR|BR|PARAM|IMG|AREA|INPUT)$/i , |
---|
32 | |
---|
33 | // List all named commands (commands that can be interpreted by the browser "execCommand" method. |
---|
34 | NamedCommands : /^(?:Cut|Copy|Paste|Print|SelectAll|RemoveFormat|Unlink|Undo|Redo|Bold|Italic|Underline|StrikeThrough|Subscript|Superscript|JustifyLeft|JustifyCenter|JustifyRight|JustifyFull|Outdent|Indent|InsertOrderedList|InsertUnorderedList|InsertHorizontalRule)$/i , |
---|
35 | |
---|
36 | BodyContents : /([\s\S]*\<body[^\>]*\>)([\s\S]*)(\<\/body\>[\s\S]*)/i , |
---|
37 | |
---|
38 | // Temporary text used to solve some browser specific limitations. |
---|
39 | ToReplace : /___fcktoreplace:([\w]+)/ig , |
---|
40 | |
---|
41 | // Get the META http-equiv attribute from the tag. |
---|
42 | MetaHttpEquiv : /http-equiv\s*=\s*["']?([^"' ]+)/i , |
---|
43 | |
---|
44 | HasBaseTag : /<base /i , |
---|
45 | |
---|
46 | HtmlOpener : /<html\s?[^>]*>/i , |
---|
47 | HeadOpener : /<head\s?[^>]*>/i , |
---|
48 | HeadCloser : /<\/head\s*>/i , |
---|
49 | |
---|
50 | TableBorderClass : /\s*FCK__ShowTableBorders\s*/ , |
---|
51 | |
---|
52 | // Validate element names. |
---|
53 | ElementName : /(^[A-Za-z_:][\w.\-:]*\w$)|(^[A-Za-z_]$)/ , |
---|
54 | |
---|
55 | // Used in conjuction with the FCKConfig.ForceSimpleAmpersand configuration option. |
---|
56 | ForceSimpleAmpersand : /___FCKAmp___/g , |
---|
57 | |
---|
58 | // Get the closing parts of the tags with no closing tags, like <br/>... gets the "/>" part. |
---|
59 | SpaceNoClose : /\/>/g , |
---|
60 | |
---|
61 | EmptyParagraph : /^<(p|div)>\s*<\/\1>$/i , |
---|
62 | |
---|
63 | TagBody : /></ , |
---|
64 | |
---|
65 | StrongOpener : /<STRONG([ \>])/gi , |
---|
66 | StrongCloser : /<\/STRONG>/gi , |
---|
67 | EmOpener : /<EM([ \>])/gi , |
---|
68 | EmCloser : /<\/EM>/gi , |
---|
69 | AbbrOpener : /<ABBR([ \>])/gi , |
---|
70 | AbbrCloser : /<\/ABBR>/gi , |
---|
71 | |
---|
72 | GeckoEntitiesMarker : /#\?-\:/g , |
---|
73 | |
---|
74 | // We look for the "src" and href attribute with the " or ' or whithout one of |
---|
75 | // them. We have to do all in one, otherwhise we will have problems with URLs |
---|
76 | // like "thumbnail.php?src=someimage.jpg" (SF-BUG 1554141). |
---|
77 | ProtectUrlsImg : /(?:(<img(?=\s).*?\ssrc=)("|')(.*?)\2)|(?:(<img\s.*?src=)([^"'][^ >]+))/gi , |
---|
78 | ProtectUrlsA : /(?:(<a(?=\s).*?\shref=)("|')(.*?)\2)|(?:(<a\s.*?href=)([^"'][^ >]+))/gi , |
---|
79 | |
---|
80 | Html4DocType : /HTML 4\.0 Transitional/i , |
---|
81 | DocTypeTag : /<!DOCTYPE[^>]*>/i , |
---|
82 | |
---|
83 | // These regex are used to save the original event attributes in the HTML. |
---|
84 | TagsWithEvent : /<[^\>]+ on\w+[\s\r\n]*=[\s\r\n]*?('|")[\s\S]+?\>/g , |
---|
85 | EventAttributes : /\s(on\w+)[\s\r\n]*=[\s\r\n]*?('|")([\s\S]*?)\2/g, |
---|
86 | ProtectedEvents : /\s\w+_fckprotectedatt="([^"]+)"/g |
---|
87 | } |
---|