diff --git a/src/api/article.js b/src/api/article.js index 682cc3ab..1519cb9c 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -6,3 +6,11 @@ export function getList() { method: 'get' }); } + +export function getArticle() { + return fetch({ + url: '/article/detail', + method: 'get' + }); +} + diff --git a/src/api/remoteSearch.js b/src/api/remoteSearch.js new file mode 100644 index 00000000..0e3c341d --- /dev/null +++ b/src/api/remoteSearch.js @@ -0,0 +1,9 @@ +import { fetch } from 'utils/fetch'; + +export function userSearch(name) { + return fetch({ + url: '/search/user', + method: 'get', + params: { name } + }); +} diff --git a/src/components/Tinymce/index.vue b/src/components/Tinymce/index.vue index 3be1ea7d..7bacbde1 100644 --- a/src/components/Tinymce/index.vue +++ b/src/components/Tinymce/index.vue @@ -75,7 +75,7 @@ // language_url: '/static/tinymce/langs/zh_CN.js', toolbar: this.toolbar, menubar: this.menubar, - plugins: 'advlist,autolink,code,powerpaste,textcolor, colorpicker,fullscreen,link,lists,media,wordcount, imagetools,watermark', + plugins: 'advlist,autolink,code,paste,textcolor, colorpicker,fullscreen,link,lists,media,wordcount, imagetools,watermark', end_container_on_empty_block: true, powerpaste_word_import: 'clean', code_dialog_height: 450, diff --git a/src/mock/article.js b/src/mock/article.js new file mode 100644 index 00000000..029b1555 --- /dev/null +++ b/src/mock/article.js @@ -0,0 +1,49 @@ +import Mock from 'mockjs'; + + +const List = []; +const count = 20; + + +for (let i = 0; i < count; i++) { + List.push(Mock.mock({ + id: '@id', + title: '@ctitle(10, 20)', + 'status|1': ['published', 'draft'], + author: '@cname', + display_time: '@datetime', + pageviews: '@integer(300, 5000)' + })); +} + +export default { + getList: () => new Promise(resolve => { + setTimeout(() => { + resolve([200, { + data: List + }]); + }, 100); + }), + getArticle: () => new Promise(resolve => { + setTimeout(() => { + resolve([200, { + data: { + id: 120000000001, + author: { key: 'mockPan' }, + source_name: '原创作者', + category_item: [{ key: 'global', name: '全球' }], + comment_disabled: false, + content: '

我是测试数据我是测试数据

"', + content_short: '我是测试数据', + display_time: +new Date(), + image_uri: 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3', + platforms: ['a-platform'], + source_uri: 'https://github.com/PanJiaChen/vue-element-admin', + status: 'published', + tags: [], + title: '' + } + }]); + }, 100); + }) +}; diff --git a/src/mock/index.js b/src/mock/index.js index f1312f7b..b82820c3 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -1,26 +1,19 @@ import axios from 'axios'; -import Mock from 'mockjs'; import MockAdapter from 'axios-mock-adapter'; -import article_tableAPI from './article_table' +import articleAPI from './article'; +import article_tableAPI from './article_table'; +import remoteSearchAPI from './remoteSearch'; const mock = new MockAdapter(axios); -const articleList = { - 'data|20': [{ - id: '@id', - title: '@ctitle(10, 20)', - 'status|1': ['published', 'draft'], - author: '@cname', - display_time: '@datetime', - pageviews: '@integer(300, 5000)' - }] -} -const data = JSON.stringify(Mock.mock(articleList)) -mock.onGet('/article/list').reply(200, data); +mock.onGet('/article/list').reply(articleAPI.getList); +mock.onGet('/article/detail').reply(articleAPI.getArticle); mock.onGet('/article_table/list').reply(article_tableAPI.getList); mock.onGet('/article_table/pv').reply(article_tableAPI.getPv); +mock.onGet('/search/user').reply(remoteSearchAPI.searchUser); + export default mock; diff --git a/src/mock/remoteSearch.js b/src/mock/remoteSearch.js new file mode 100644 index 00000000..b5429562 --- /dev/null +++ b/src/mock/remoteSearch.js @@ -0,0 +1,29 @@ +import Mock from 'mockjs'; + +const NameList = []; +const count = 100; + +for (let i = 0; i < count; i++) { + NameList.push(Mock.mock({ + name: '@first' + })); +} +NameList.push({ name: 'mockPan' }) + +export default { + searchUser: config => { + const { name } = config.params; + const mockNameList = NameList.filter(item => { + const lowerCaseName = item.name.toLowerCase() + if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false; + return true; + }); + return new Promise(resolve => { + setTimeout(() => { + resolve([200, { + items: mockNameList + }]); + }, 100); + }) + } +}; diff --git a/src/router/index.js b/src/router/index.js index 1f7d593e..0550c5b9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -51,6 +51,8 @@ const Theme = resolve => require(['../views/theme/index'], resolve); /* example*/ const DynamicTable = resolve => require(['../views/example/dynamictable'], resolve); const Table = resolve => require(['../views/example/table'], resolve); +const Form1 = resolve => require(['../views/example/form1'], resolve); +const Form2 = resolve => require(['../views/example/form2'], resolve); /* admin*/ @@ -170,7 +172,9 @@ export default new Router({ icon: 'zonghe', children: [ { path: 'dynamictable', component: DynamicTable, name: '动态table' }, - { path: 'table', component: Table, name: '综合table' } + { path: 'table', component: Table, name: '综合table' }, + { path: 'form1', component: Form1, name: '综合form1' } + // { path: 'form2', component: Form2, name: '综合form2' } ] }, // { diff --git a/src/styles/element-ui.scss b/src/styles/element-ui.scss index a6670d59..382aff13 100644 --- a/src/styles/element-ui.scss +++ b/src/styles/element-ui.scss @@ -59,3 +59,25 @@ margin: 0 auto; } + +//文章页textarea修改样式 +.article-textarea { + textarea { + padding-right: 40px; + resize: none; + border: none; + border-radius: 0px; + border-bottom: 1px solid #bfcbd9; + } +} + +//element ui upload +.upload-container { + .el-upload { + width: 100%; + .el-upload-dragger { + width: 100%; + height: 200px; + } + } +} diff --git a/src/views/example/form1.vue b/src/views/example/form1.vue new file mode 100644 index 00000000..d41cf9f2 --- /dev/null +++ b/src/views/example/form1.vue @@ -0,0 +1,291 @@ + + + + + diff --git a/src/views/example/form2.vue b/src/views/example/form2.vue new file mode 100644 index 00000000..e69de29b diff --git a/static/tinymce1.3/plugins/powerpaste/License.txt b/static/tinymce1.3/plugins/powerpaste/License.txt deleted file mode 100644 index b639f891..00000000 --- a/static/tinymce1.3/plugins/powerpaste/License.txt +++ /dev/null @@ -1,15 +0,0 @@ -TinyMCE PowerPaste -Copyright (C) 2015 Ephox Corporation - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . \ No newline at end of file diff --git a/static/tinymce1.3/plugins/powerpaste/agpl-3.0.txt b/static/tinymce1.3/plugins/powerpaste/agpl-3.0.txt deleted file mode 100644 index 2def0e88..00000000 --- a/static/tinymce1.3/plugins/powerpaste/agpl-3.0.txt +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. \ No newline at end of file diff --git a/static/tinymce1.3/plugins/powerpaste/css/editorcss.css b/static/tinymce1.3/plugins/powerpaste/css/editorcss.css deleted file mode 100644 index 73a95afa..00000000 --- a/static/tinymce1.3/plugins/powerpaste/css/editorcss.css +++ /dev/null @@ -1,4 +0,0 @@ -.ephox-salmon-upload-image-container img -{ - opacity: 0.5 -} diff --git a/static/tinymce1.3/plugins/powerpaste/flash/textboxpaste.swf b/static/tinymce1.3/plugins/powerpaste/flash/textboxpaste.swf deleted file mode 100644 index 6a2a35a0..00000000 Binary files a/static/tinymce1.3/plugins/powerpaste/flash/textboxpaste.swf and /dev/null differ diff --git a/static/tinymce1.3/plugins/powerpaste/img/spinner_96.gif b/static/tinymce1.3/plugins/powerpaste/img/spinner_96.gif deleted file mode 100644 index 24af6375..00000000 Binary files a/static/tinymce1.3/plugins/powerpaste/img/spinner_96.gif and /dev/null differ diff --git a/static/tinymce1.3/plugins/powerpaste/js/wordimport.js b/static/tinymce1.3/plugins/powerpaste/js/wordimport.js deleted file mode 100644 index 0c05b1a7..00000000 --- a/static/tinymce1.3/plugins/powerpaste/js/wordimport.js +++ /dev/null @@ -1,381 +0,0 @@ -/** - * Word Import JavaScript Library - * Copyright (c) 2013-2015 Ephox Corp. All rights reserved. - * This software is provided "AS IS," without a warranty of any kind. - */ -function com_ephox_keurig_Keurig(){var Pb='',Qb='" for "gwt:onLoadErrorFn"',Rb='" for "gwt:onPropertyErrorFn"',Sb='"><\/script>',Tb='#',Ub='&',Vb='/',Wb='90BA12EED4B8175F02A135767FCD6360',Xb=':',Yb=':1',Zb=':2',$b=':3',_b=':4',ac=':5',bc=':6',cc=':7',dc=':8',ec=':9',fc='' + - ''); - frameLoad.unbind(); - }); - - Ready.execute(function () { - Insert.append(Body.body(), container); - Insert.append(container, iframe); - }); - }); - - var cleanDocument = function (wordHTML, merge) { - return cleanFunction.map(function (f) { - // TODO: This should probably do something with the log instead of throwing it away in the Java side - return f(wordHTML, merge); - }); - }; - - var ready = function () { - return cleanFunction.isSome(); - }; - - return { - load: load, - cleanDocument: cleanDocument, - ready: ready - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.keurig.api.WordCleaner', - - [ - 'ephox.keurig.loader.GWTLoader' - ], - - function (GWTLoader) { - return function (baseUrl) { - if (!GWTLoader.ready()) GWTLoader.load(baseUrl); - - return { - cleanDocument: GWTLoader.cleanDocument - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.photon.Sandbox', - - [ - 'ephox.peanut.Fun', - 'ephox.photon.Writer', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.DomEvent', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.Remove', - 'global!setTimeout' - ], - - function (Fun, Writer, Css, DomEvent, Element, Insert, Remove, setTimeout) { - return function (uiContainer) { - /** - * Creates a sandbox to play in. - * - * Asynchronously creates an iframe, runs the synchronous function `f` on the DOM, and then passes the result to the callback. - * - * This is done so that the sandbox can guarantee the iframe has been removed from the page, and available for garbage collection, before the callback is executed. - * - * html: - * source to load into the iframe - * f: (document -> body -> A) - * function that operates on the iframe DOM, passed both document reference and body element - * callback: (A -> Unit) - * function that receives the output of `f` when the iframe has been cleaned up - */ - var play = function (html, f, callback) { - var outputContainer = Element.fromTag('div'); - var iframe = Element.fromTag('iframe'); - - Css.setAll(outputContainer, { - display: 'none' - }); - - var load = DomEvent.bind(iframe, 'load', function () { - Writer.write(iframe, html); - - var rawDoc = iframe.dom().contentWindow.document; - if (rawDoc === undefined) throw "sandbox iframe load event did not fire correctly"; - var doc = Element.fromDom(rawDoc); - - var rawBody = rawDoc.body; - if (rawBody === undefined) throw "sandbox iframe does not have a body"; - var body = Element.fromDom(rawBody); - - // cache - var result = f(doc, body); - - // unbind and remove everything - load.unbind(); - Remove.remove(outputContainer); - - // setTimeout should allow the garbage collector to cleanup if necessary - setTimeout(Fun.curry(callback, result), 0); - }); - Insert.append(outputContainer, iframe); - Insert.append(uiContainer, outputContainer); - }; - - return { - play: play - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.impl.NodeValue', - - [ - 'ephox.perhaps.Option', - 'global!Error' - ], - - function (Option, Error) { - return function (is, name) { - var get = function (element) { - if (!is(element)) throw new Error('Can only get ' + name + ' value of a ' + name + ' node'); - return getOption(element).getOr(''); - }; - - var getOption = function (element) { - try { - return is(element) ? Option.some(element.dom().nodeValue) : Option.none(); - } catch (e) { - return Option.none(); // Prevent IE10 from throwing exception when setting parent innerHTML clobbers (TBIO-451). - } - }; - - var set = function (element, value) { - if (!is(element)) throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node'); - element.dom().nodeValue = value; - }; - - return { - get: get, - getOption: getOption, - set: set - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.Comment', - - [ - 'ephox.sugar.api.Node', - 'ephox.sugar.impl.NodeValue' - ], - - function (Node, NodeValue) { - var api = NodeValue(Node.isComment, 'comment'); - - var get = function (element) { - return api.get(element); - }; - - var getOption = function (element) { - return api.getOption(element); - }; - - var set = function (element, value) { - api.set(element, value); - }; - - return { - get: get, - getOption: getOption, - set: set - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.Html', - - [ - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert' - ], - - function ( Element, Insert) { - var get = function (element) { - return element.dom().innerHTML; - }; - - var set = function (element, content) { - element.dom().innerHTML = content; - }; - - var getOuter = function (element) { - var container = Element.fromTag('div'); - var clone = Element.fromDom(element.dom().cloneNode(true)); - Insert.append(container, clone); - return get(container); - }; - - return { - get: get, - set: set, - getOuter: getOuter - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.vogue.css.Set', - - [ - 'ephox.sugar.api.Insert' - ], - - function (Insert) { - - var setCss = function (style, css, element) { - if (style.dom().styleSheet) - style.dom().styleSheet.cssText = css; // IE - else - Insert.append(style, element); - }; - - return { - setCss: setCss - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.vogue.util.Regex', - - [ - ], - - function () { - var escape = function (text) { - return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); - }; - - return { - escape: escape - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -ephox.bolt.module.api.define("global!RegExp", [], function () { return RegExp; }); -(function (define, require, demand) { -define( - 'ephox.vogue.css.Url', - - [ - 'ephox.compass.Obj', - 'ephox.vogue.util.Regex', - 'global!RegExp' - ], - - function (Obj, Regex, RegExp) { - var replace = function (css, urlPrefix, replacement) { - var r = new RegExp('url\\(\\s*[\'"]?' + Regex.escape(urlPrefix) + '(.*?)[\'"]?\\s*\\)', 'g'); - return css.replace(r, 'url("' + replacement + '$1")'); - }; - - var replaceMany = function (css, replacements) { - var current = css; - Obj.each(replacements, function (value, key) { - current = replace(current, key, value); - }); - return current; - }; - - return { - replace: replace, - replaceMany: replaceMany - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.vogue.api.DocStyle', - - [ - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.SelectorFind', - 'ephox.vogue.css.Set', - 'ephox.vogue.css.Url', - 'global!Array' - ], - - function (Attr, Element, Insert, SelectorFind, Set, Url, Array) { - - var styletag = function (doc) { - var style = Element.fromTag('style', doc.dom()); - Attr.set(style, 'type', 'text/css'); - return style; - }; - - var setCss = function (style, css, doc) { - Set.setCss(style, css, Element.fromText(css, doc.dom())); - }; - - var inject = function (css, replacements, doc) { - var style = styletag(doc); - var replacedCss = replacements === undefined ? css : Url.replaceMany(css, replacements); - setCss(style, replacedCss, doc); - var head = SelectorFind.descendant(doc, 'head').getOrDie(); - Insert.append(head, style); - }; - - var stylesheets = function (doc) { - var domStyleSheets = doc.dom().styleSheets; - return Array.prototype.slice.call(domStyleSheets); - }; - - return { - stylesheets: stylesheets, - inject: inject - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.vogue.css.Rules', - - [ - 'ephox.compass.Arr', - 'ephox.scullion.Struct' - ], - - function (Arr, Struct) { - var ruleStruct = Struct.immutable('selector', 'style'); - - var extract = function (stylesheet) { - var domRules = stylesheet.cssRules; - return Arr.map(domRules, function (rule) { - var selector = rule.selectorText; - var style = rule.style.cssText; - if (style === undefined) { - // This should be picked up in testing, and perhaps delete the check eventually - throw "WARNING: Browser does not support cssText property"; - } - return ruleStruct(selector, style); - }); - }; - - var extractAll = function (stylesheets) { - return Arr.bind(stylesheets, extract); - }; - - return { - extract: extract, - extractAll: extractAll - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.vogue.api.Rules', - - [ - 'ephox.vogue.css.Rules' - ], - - function (Rules) { - var extract = function (stylesheet) { - return Rules.extract(stylesheet); - }; - - var extractAll = function (stylesheets) { - return Rules.extractAll(stylesheets); - }; - - return { - extract: extract, - extractAll: extractAll - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.html.HtmlPaste', - - [ - 'ephox.cement.html.Transform', - 'ephox.cement.images.ImageReference', - 'ephox.classify.Type', - 'ephox.compass.Arr', - 'ephox.keurig.api.WordCleaner', - 'ephox.peanut.Fun', - 'ephox.photon.Sandbox', - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Class', - 'ephox.sugar.api.Comment', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Elements', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.SelectorFilter', - 'ephox.sugar.api.Traverse', - 'ephox.vogue.api.DocStyle', - 'ephox.vogue.api.Rules', - 'global!document' - ], - - function (Transform, ImageReference, Type, Arr, WordCleaner, Fun, Sandbox, Event, Events, Attr, Class, Comment, Element, Elements, Html, Remove, SelectorFilter, Traverse, DocStyle, Rules, document) { - var flagAttribute = 'data-textbox-image'; - - var emptyString = function (s) { - return s === undefined || s === null || s.length === 0; - }; - - var stripImageSources = function (html) { - var count = 1; - return html.replace(/(]*)src=".*?"/g, function (match, p1, offset) { - // the actual contents are irrelevant, it just needs to be unique - return p1 + flagAttribute + '="' + count++ + '"'; - }); - }; - - var removeFragmentComments = function (body) { - var bodyChildren = Traverse.children(body); - Arr.each(bodyChildren, function (c) { - Comment.getOption(c).each(function (commentText) { - if (commentText === 'StartFragment' || commentText === 'EndFragment') { - Remove.remove(c); - } - }); - }); - }; - - var insertRtfCorrelation = function (sourceImageList, tordImages) { - Arr.each(tordImages, function (img) { - var imageCounter = Attr.get(img, flagAttribute); - Arr.each(sourceImageList, function (imgData) { - var imgAttrs = imgData.img(); - var vshapeAttrs = imgData.vshape(); - if (imgAttrs[flagAttribute] == imageCounter) { - // NOTE: If we discover more than 2 possible attributes, de-dupe with RtfImage somehow - var spid = vshapeAttrs['o:spid']; - var vshapeId = spid === undefined ? vshapeAttrs.id : spid; - - Transform.rotateImage(img, vshapeAttrs); - - Class.add(img, 'rtf-data-image'); - Attr.set(img, 'data-image-id', vshapeId.substr('_x0000_'.length)); - Attr.set(img, 'data-image-type', 'code'); - Attr.remove(img, flagAttribute); - } - }); - }); - }; - - var mergeInlineStyles = function (body, stylesheets) { - var rules = Rules.extractAll(stylesheets); - Arr.each(rules, function (rule) { - - var matchingElements = SelectorFilter.descendants(body, rule.selector()); - - Arr.each(matchingElements, function (element) { - Attr.remove(element, 'class'); - Attr.set(element, 'style', rule.style()); - }); - }); - }; - - var tordPostProcessor = function (sourceImageList, mergeStyles) { - var sandbox = Sandbox(Element.fromDom(document.body)); - return function (dump, callback) { - // loading dump into the sandbox *will* perform some built-in browser cleanup operations, - // we are hoping this is a suitable replacement for the use of HTML Tidy in ELJ. - sandbox.play(dump, function (iframeDoc, body) { - var images = SelectorFilter.descendants(body, 'img'); - - // post-tord DOM filters - removeFragmentComments(body); - insertRtfCorrelation(sourceImageList, images); - if (mergeStyles) { - mergeInlineStyles(body, DocStyle.stylesheets(iframeDoc)); - } - - return Html.get(body); - }, callback); - }; - }; - - var cleanEnd = function (raw) { - // Trim any weirdness that exists after the closing HTML tag. - var i = raw.indexOf(''); - return (i > -1) ? raw.substr(0, i + ''.length) : raw; - }; - - return function (mergeSettings, pasteSettings) { - var cleaner = WordCleaner(pasteSettings.baseUrl); - - var events = Events.create({ - paste: Event(['elements', 'assets']), - error: Event(['message']) - }); - - var handler = function (raw) { - var html = cleanEnd(raw); - // This will only be called if we have word styles, so force true - mergeSettings.get(true, function (settings) { - var mergeStyles = settings.mergeOfficeStyles; - - // remove local file references, so that loading the HTML into a DOM does not trigger console warnings - var safeHtml = stripImageSources(html); - - var sourceImageList = ImageReference.extract(safeHtml); - - var postProcess = tordPostProcessor(sourceImageList, mergeStyles); - - cleaner.cleanDocument(safeHtml, mergeStyles).fold(function () { - events.trigger.error('errors.paste.word.notready'); - }, function (dump) { - if (emptyString(dump)) events.trigger.paste([], []); - else { - // postProcess is basically String -> Future (String) - postProcess(dump, function (tordHtml) { - var elements = Elements.fromHtml(tordHtml); - events.trigger.paste(elements, []); - }); - } - - }); - }); - return true; - }; - - return { - handler: handler, - isSupported: Fun.constant(true), - events: events.registry - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.images.ImagePaste', - - [ - 'ephox.compass.Arr', - 'ephox.fred.PlatformDetection', - 'ephox.hermes.api.ImageAsset', - 'ephox.hermes.api.ImageExtract', - 'ephox.peanut.Fun', - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Element', - 'global!console' - ], - - function (Arr, PlatformDetection, ImageAsset, ImageExtract, Fun, Event, Events, Attr, Element, console) { - return function (pasteSettings) { - var platform = PlatformDetection.detect(); - var CAPTUTED_EVENT = true; - - //IE & FF handle image paste conversion into base64 data URIs automatically - var isSupported = !platform.browser.isIE() && !platform.browser.isFirefox(); - - var events = Events.create({ - paste: Event(['elements', 'assets']), - error: Event(['message']) - }); - - var readImages = function (assets) { - return Arr.bind(assets, function (asset) { - return ImageAsset.cata(asset, - function (id, file, objurl, data) { - // create an image and inject it at the current selection - var image = Element.fromTag('img'); - Attr.set(image, 'src', objurl); - return image; - }, - function (id, url, raw) { - // TODO: Is this the best way? - console.log('Internal error: Paste operation produced an image URL instead of a Data URI: ', url); - } - ); - }); - }; - - var actualHandler = function (clipboardItems) { - var images = Arr.filter(clipboardItems, function (item) { - return item.kind === 'file' && /image/.test(item.type); - }); - - var files = Arr.map(images, function (image) { - return image.getAsFile(); - }); - - ImageExtract.toAssets(files, function (assets) { - // perform the insert (SmartPaste handles undo and focus trickery) - var elements = readImages(assets); - events.trigger.paste(elements, assets); - }); - //prevent other content from coming through - return CAPTUTED_EVENT; - }; - - var safariHandler = function () { - events.trigger.error('safari.imagepaste'); - // prevent default paste - return CAPTUTED_EVENT; - }; - - var imageDisabled = function () { - events.trigger.error('errors.local.images.disallowed'); - return CAPTUTED_EVENT; - }; - - var imageHandler = platform.browser.isSafari() ? safariHandler : actualHandler; - - var handler = pasteSettings.allowLocalImages ? imageHandler : imageDisabled; - - return { - handler: handler, - isSupported: Fun.constant(isSupported), - events: events.registry - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.api.CementConstants', - - [ - 'ephox.cement.style.Styles', - 'ephox.peanut.Fun' - ], - - function (Styles, Fun) { - - /* - The filter history may not quite work as I would hope. The problem it is likely to - have is that it might be the content's selection as well, which means that we are - changing what is about to used as serialisation ... likely leading to issues. I think - it just only sets valid selections, so it will probably be ok .. but the cursor will - be jarring. - - The paste bin class is added when the paste event is being triggered in the setTimeout. - That may be too late for it not to end up in the undo history, but currently it seems - like it will possibly work. Adding the class directly to the element would be more reliable, - but I haven't thought of a clean enough way to do that yet. - */ - var bin = Styles.resolve('smartpaste-eph-bin'); - - return { - binStyle: Fun.constant(bin) - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.knoch.core.Bounce', - - [ - 'global!Array' - ], - - function (Array) { - - var bounce = function(f) { - return function() { - var args = Array.prototype.slice.call(arguments); - var me = this; - setTimeout(function() { - f.apply(me, args); - }, 0); - }; - }; - - return { - bounce: bounce - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.knoch.core.FutureOps', - - [ - ], - - function () { - - return function (nu, get) { - - /** map :: this Future a -> (a -> b) -> Future b */ - var map = function(fab) { - return nu(function(callback) { - get(function(a) { - callback(fab(a)); - }); - }); - }; - - /** bind :: this Future a -> (a -> Future b) -> Future b */ - var bind = function(aFutureB) { - return nu(function(callback) { - get(function(a) { - aFutureB(a).get(callback); - }); - }); - }; - - /** anonBind :: this Future a -> Future b -> Future b - * Returns a future, which evaluates the first future, ignores the result, then evaluates the second. - */ - var anonBind = function(futureB) { - return nu(function(callback) { - get(function(a) { - futureB.get(callback); - }); - }); - }; - - return { - get: get, - map: map, - bind: bind, - anonBind: anonBind - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.knoch.future.Future', - - [ - 'ephox.compass.Arr', - 'ephox.knoch.core.Bounce', - 'ephox.knoch.core.FutureOps' - ], - - /** A future value that is evaluated on demand. The base function is re-evaluated each time 'get' is called. */ - function (Arr, Bounce, FutureOps) { - - // baseFn is a function(callback) { ... } - var nu = function(baseFn) { - - var get = function(callback) { - baseFn(Bounce.bounce(callback)); - }; - - return FutureOps(nu, get); - }; - - /** [Future a] -> Future [a] */ - var par = function(futures) { - return nu(function(callback) { - var r = []; - var count = 0; - - var cb = function(i) { - return function(value) { - r[i] = value; - count++; - if (count >= futures.length) { - callback(r); - } - }; - }; - - if (futures.length === 0) { - callback([]); - } else { - Arr.each(futures, function(future, i) { - future.get(cb(i)); - }); - } - }); - }; - - /** [a] -> (a -> Future b) -> Future [b] */ - var mapM = function(as, fn) { - return par(Arr.map(as, fn)); - }; - - /** (Future a, Future b) -> ((a, b) -> c) -> Future C - * Executes the two futures in "parallel" with respect to browser JS threading. - */ - var lift2 = function(fa, fb, abc) { - return nu(function(callback) { - var completeA = false; - var completeB = false; - var valueA = undefined; - var valueB = undefined; - - var done = function() { - if (completeA && completeB) { - var c = abc(valueA, valueB); - callback(c); - } - }; - - fa.get(function(a) { - valueA = a; - completeA = true; - done(); - }); - - fb.get(function(b) { - valueB = b; - completeB = true; - done(); - }); - }); - }; - - return { - nu: nu, - par: par, - mapM: mapM, - lift2: lift2 - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.knoch.future.CachedFuture', - - [ - 'ephox.compass.Arr', - 'ephox.highway.Merger', - 'ephox.knoch.core.Bounce', - 'ephox.knoch.core.FutureOps', - 'ephox.knoch.future.Future', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option' - ], - - /** - * A future value. - * The base function is evaluated eagerly, and only evaluated once. - * Each call to 'get' queues a callback, which is invoked when the value is available. - */ - function (Arr, Merger, Bounce, FutureOps, Future, Fun, Option) { - - // f is a function(callback) { ... } - var nu = function (baseFn) { - - var data = Option.none(); - var callbacks = []; - - var get = function (callback) { - isSet() ? call(callback) : callbacks.push(callback); - }; - - var set = function (x) { - data = Option.some(x); - run(callbacks); - callbacks = []; - }; - - var isSet = function() { - return data.isSome(); - }; - - var run = function (cbs) { - Arr.each(cbs, call); - }; - - var call = function(cb) { - data.each(function(x) { - Bounce.bounce(cb)(x); - }); - }; - - Future.nu(baseFn).get(set); - - var ops = FutureOps(nu, get); - - return Merger.merge(ops, { - isSet: isSet - }); - }; - - return { - nu: nu - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.pastiche.IeBlob', - - [ - 'ephox.compass.Arr', - 'ephox.epithet.Resolve', - 'ephox.hermes.api.ImageExtract', - 'ephox.knoch.future.CachedFuture', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option' - ], - - function (Arr, Resolve, ImageExtract, CachedFuture, Fun, Option) { - var convertURL = function (raw) { - return raw.convertURL !== undefined ? raw.convertURL // Use standard if available. - : raw.msConvertURL !== undefined ? raw.msConvertURL - : undefined; - }; - - var convert = function (raw) { - // IE11 defines data on the window, but requires the event to convert... /headdesk - var files = Resolve.resolve('window.clipboardData.files'); - - var convert = convertURL(raw); - - if (files !== undefined && convert !== undefined && files.length > 0) { - var blobs = Arr.map(files, function (file) { - var blob = ImageExtract.blob(file); - convert.apply(raw, [file, 'specified', blob.objurl()]); - - return blob; - }); - - // do the async operation in a future - var future = CachedFuture.nu(function (callback) { - ImageExtract.fromBlobs(blobs, callback); - }); - - // initiate the conversion immediately - future.get(Fun.noop); - - return Option.some(future); - } else { - return Option.none(); - } - }; - - return { - convert: convert - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.api.Situ', - - [ - ], - - function () { - var on = function (element, offset) { - return folder(function (b, o, a) { - return o(element, offset); - }); - }; - - var before = function (element) { - return folder(function (b, o, a) { - return b(element); - }); - }; - - var after = function (element) { - return folder(function (b, o, a) { - return a(element); - }); - }; - - - var folder = function(fold) { - return { - fold: fold - }; - }; - - return { - on: on, - before: before, - after: after - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.api.SelectionRange', - - [ - 'ephox.fussy.api.Situ', - 'ephox.scullion.Struct', - 'ephox.sugar.api.Element' - ], - - function (Situ, Struct, Element) { - var read = Struct.immutable('start', 'soffset', 'finish', 'foffset'); - var general = Struct.immutable('start', 'soffset', 'finish', 'foffset'); - var write = Struct.immutable('start', 'finish'); - - var writeFromNative = function (range) { - var start = Element.fromDom(range.startContainer); - var finish = Element.fromDom(range.endContainer); - return write( - Situ.on(start, range.startOffset), - Situ.on(finish, range.endOffset) - ); - }; - - return { - read: read, - general: general, - write: write, - writeFromNative: writeFromNative - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.api.Supported', - - [ - ], - - function () { - var run = function (win, w3c) { - // this is scaffolding for what was an alternate selection model. - // We now only have one but the concept could be useful later. - if (win.getSelection) return w3c(win, win.getSelection()); - else throw 'No selection model supported.'; - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.DocumentPosition', - - [ - 'ephox.sugar.api.Compare', - 'ephox.sugar.api.Traverse' - ], - - function (Compare, Traverse ) { - var after = function (start, soffset, finish, foffset) { - var doc = Traverse.owner(start); - - // TODO: Find a sensible place to put the native range creation code. - var rng = doc.dom().createRange(); - rng.setStart(start.dom(), soffset); - rng.setEnd(finish.dom(), foffset); - - var same = Compare.eq(start, finish) && soffset === foffset; - return rng.collapsed && !same; - }; - - return { - after: after - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.wwwc.Directions', - - [ - 'ephox.fussy.api.SelectionRange', - 'ephox.sugar.api.DocumentPosition', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Traverse' - ], - - function (SelectionRange, DocumentPosition, Element, Traverse) { - var isReversed = function (model) { - return DocumentPosition.after(Element.fromDom(model.anchorNode), model.anchorOffset, Element.fromDom(model.focusNode), model.focusOffset); - }; - - var flipGet = function (model, range) { - var start = Element.fromDom(range.startContainer); - var finish = Element.fromDom(range.endContainer); - return isReversed(model) ? - SelectionRange.read(finish, range.endOffset, start, range.startOffset) : - SelectionRange.read(start, range.startOffset, finish, range.endOffset); - }; - - var isRtlGet = function (model) { - return isReversed(model); - }; - - var flipSet = function (start, startOffset, end, endOffset) { - return function (model) { - if (model.extend) { - model.collapse(start.dom(), startOffset); - model.extend(end.dom(), endOffset); - } else { - // this is IE... we can’t have a backwards range, so reverse it. - var range = Traverse.owner(start).dom().createRange(); - range.setStart(end.dom(), endOffset); - range.setEnd(start.dom(), startOffset); - model.removeAllRanges(); - model.addRange(range); - } - }; - }; - - var isRtlSet = function (start, startOffset, end, endOffset) { - return DocumentPosition.after(start, startOffset, end, endOffset); - }; - - var read = function () { - return { - flip: flipGet, - isRtl: isRtlGet - }; - }; - - var write = function () { - return { - flip: flipSet, - isRtl: isRtlSet - }; - }; - - return { - read: read, - write: write - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.wwwc.DomRange', - - [ - 'ephox.fussy.api.SelectionRange', - 'ephox.fussy.wwwc.Directions', - 'ephox.perhaps.Option', - 'ephox.sugar.api.DocumentPosition', - 'ephox.sugar.api.Element' - ], - - function (SelectionRange, Directions, Option, DocumentPosition, Element) { - - /* - * The approach here is to create a range using the selection. If it collapses, - * and the inverse of the selection does not collapse ... then it is a backwards - * selection. - */ - var reversed = function (win, selection) { - // Calculate the range going from start -> finish - var startToFinish = toNativeFrom(win, selection.start(), selection.finish()); - // If it is collapsed, there is a chance that it only collapsed because it was RTL - if (startToFinish.collapsed === true) { - // Check that the inverted selection isn't collapsed. - // If the inverted selection is not collapsed ... it is a backwards selection, otherwise it is just collapsed anyway - var finishToStart = toNativeFrom(win, selection.finish(), selection.start()); - return finishToStart.collapsed === true ? Option.none() : Option.some(SelectionRange.general( - Element.fromDom(finishToStart.endContainer), - finishToStart.endOffset, - Element.fromDom(finishToStart.startContainer), - finishToStart.startOffset - )); - } else { - return Option.none(); - } - }; - - var forceRange = function (win, selection) { - var range = toNativeFrom(win, selection.start(), selection.finish()); - return range.collapsed === true ? toNativeFrom(win, selection.finish(), selection.start()) : range; - }; - - var toNativeFrom = function (win, start, finish) { - var range = create(win); - - start.fold(function (e) { - range.setStartBefore(e.dom()); - }, function (e, o) { - range.setStart(e.dom(), o); - }, function (e) { - range.setStartAfter(e.dom()); - }); - - finish.fold(function (e) { - range.setEndBefore(e.dom()); - }, function (e, o) { - range.setEnd(e.dom(), o); - }, function (e) { - range.setEndAfter(e.dom()); - }); - - return range; - }; - - var toNative = function (win, selection) { - return toNativeFrom(win, selection.start(), selection.finish()); - }; - - var toExactNative = function (win, s, so, e, eo) { - var backwards = DocumentPosition.after(s, so, e, eo); - var range = win.document.createRange(); - if (backwards) { - range.setStart(e.dom(), eo); - range.setEnd(s.dom(), so); - } else { - range.setStart(s.dom(), so); - range.setEnd(e.dom(), eo); - } - return range; - }; - - var forwards = function (win, selection) { - var range = toNative(win, selection); - - return function (model) { - model.addRange(range); - }; - }; - - var build = function (win, selection) { - var backwards = reversed(win, selection); - return backwards.fold(function () { - return forwards(win, selection); - }, function (range) { - return Directions.write().flip(range.start(), range.soffset(), range.finish(), range.foffset()); - }); - }; - - var create = function (win) { - return win.document.createRange(); - }; - - return { - create: create, - build: build, - toNative: toNative, - forceRange: forceRange, - toExactNative: toExactNative - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.search.Within', - - [ - 'ephox.compass.Arr', - 'ephox.fussy.wwwc.DomRange', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Node', - 'ephox.sugar.api.SelectorFilter', - 'ephox.sugar.api.Selectors' - ], - - function (Arr, DomRange, Element, Node, SelectorFilter, Selectors) { - // Adapted from: http://stackoverflow.com/questions/5605401/insert-link-in-contenteditable-element - var inRange = function (tempRange, range, element) { - tempRange.selectNodeContents(element.dom()); - return tempRange.compareBoundaryPoints(range.END_TO_START, range) < 1 && tempRange.compareBoundaryPoints(range.START_TO_END, range) > -1; - }; - - var withinContainer = function (win, container, range, selector) { - var tempRange = win.document.createRange(); - var self = Selectors.is(container, selector) ? [ container ] : []; - var elements = self.concat(SelectorFilter.descendants(container, selector)); - return Arr.filter(elements, function (elem) { - return inRange(tempRange, range, elem); - }); - }; - - var find = function (win, raw, selector) { - // Reverse the selection if it is RTL when doing the comparison - var range = DomRange.forceRange(win, raw); - var container = Element.fromDom(range.commonAncestorContainer); - // Note, this might need to change when we have to start looking for non elements. - return Node.isElement(container) ? withinContainer(win, container, range, selector) : []; - }; - - return { - find: find - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.wwwc.Prefilter', - - [ - 'ephox.fussy.api.SelectionRange', - 'ephox.fussy.api.Situ', - 'ephox.sugar.api.Node' - ], - - function (SelectionRange, Situ, Node) { - var beforeBr = function (element, offset) { - return Node.name(element) === 'br' ? Situ.before(element) : Situ.on(element, offset); - }; - - var preprocess = function (selection) { - var start = selection.start().fold(Situ.before, beforeBr, Situ.after); - var finish = selection.finish().fold(Situ.before, beforeBr, Situ.after); - return SelectionRange.write(start, finish); - }; - - return { - preprocess: preprocess - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.Fragment', - - [ - 'ephox.compass.Arr', - 'ephox.sugar.api.Element', - 'global!document' - ], - - function (Arr, Element, document) { - var fromElements = function (elements, scope) { - var doc = scope || document; - var fragment = doc.createDocumentFragment(); - Arr.each(elements, function (element) { - fragment.appendChild(element.dom()); - }); - return Element.fromDom(fragment); - }; - - return { - fromElements: fromElements - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.wwwc.WwwcModel', - - [ - 'ephox.fussy.api.SelectionRange', - 'ephox.fussy.wwwc.Directions', - 'ephox.fussy.wwwc.DomRange', - 'ephox.fussy.wwwc.Prefilter', - 'ephox.perhaps.Option', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Fragment' - ], - - function (SelectionRange, Directions, DomRange, Prefilter, Option, Element, Fragment) { - var set = function (raw) { - return function (win, model) { - var selection = Prefilter.preprocess(raw); - var modifier = DomRange.build(win, selection); - if (model !== undefined && model !== null) { - model.removeAllRanges(); - modifier(model); - } - }; - }; - - var selectElementContents = function (element) { - return function (win, model) { - var rng = DomRange.create(win); - rng.selectNodeContents(element.dom()); - model.removeAllRanges(); - model.addRange(rng); - }; - }; - - var normaliseRange = function (win, model) { - // In a multiple rangeset we take the first and the last item in the range, and create a new range model - var first = model.getRangeAt(0); - var last = model.getRangeAt(model.rangeCount - 1); - var range = win.document.createRange(); - range.setStart(first.startContainer, first.startOffset); - range.setEnd(last.endContainer, last.endOffset); - return range; - }; - - var fromNative = function (model, range) { - var start = Element.fromDom(range.startContainer); - var finish = Element.fromDom(range.endContainer); - - return Directions.read().isRtl(model) ? - Directions.read().flip(model, range) : - SelectionRange.read(start, range.startOffset, finish, range.endOffset); - }; - - var getNative = function (win, model) { - return model !== undefined && model !== null && model.rangeCount > 0 ? Option.from(normaliseRange(win, model)) : Option.none(); - }; - - var get = function (win, model) { - var range = getNative(win, model); - return range.map(function (r) { - return fromNative(model, r); - }); - }; - - var replace = function (elements) { - return function (win, model) { - var selection = getNative(win, model); - selection.each(function (range) { - doReplaceRange(win, range, elements); - }); - }; - }; - - var doReplaceRange = function (win, range, elements) { - // Note: this document fragment approach may not work on IE9. - var fragment = Fragment.fromElements(elements, win.document); - range.deleteContents(); - range.insertNode(fragment.dom()); - }; - - var replaceRange = function (raw, elements) { - return function (win, model) { - var selection = Prefilter.preprocess(raw); - // NOTE: This selection has to be LTR, or the range will collapse. - var range = DomRange.toNative(win, selection); - doReplaceRange(win, range, elements); - }; - }; - - var deleteRange = function (s, so, e, eo) { - return function (win, model) { - var rng = DomRange.toExactNative(win, s, so, e, eo); - rng.deleteContents(); - }; - }; - - var cloneFragment = function (s, so, e, eo) { - return function (win, model) { - var rng = DomRange.toExactNative(win, s, so, e, eo); - var fragment = rng.cloneContents(); - return Element.fromDom(fragment); - }; - }; - - var rectangleAt = function (s, so, e, eo) { - return function (win, model) { - var rng = DomRange.toExactNative(win, s, so, e, eo); - var rects = rng.getClientRects(); - // ASSUMPTION: The first rectangle is the start of the selection - var bounds = rects.length > 0 ? rects[0] : rng.getBoundingClientRect(); - return bounds.width > 0 || bounds.height > 0 ? Option.some(bounds) : Option.none(); - }; - }; - - var clearSelection = function (win, model) { - win.getSelection().removeAllRanges(); - }; - - return { - get: get, - set: set, - selectElementContents: selectElementContents, - replace: replace, - replaceRange: replaceRange, - deleteRange: deleteRange, - cloneFragment: cloneFragment, - rectangleAt: rectangleAt, - clearSelection: clearSelection - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.fussy.api.WindowSelection', - - [ - 'ephox.fussy.api.SelectionRange', - 'ephox.fussy.api.Situ', - 'ephox.fussy.api.Supported', - 'ephox.fussy.search.Within', - 'ephox.fussy.wwwc.DomRange', - 'ephox.fussy.wwwc.WwwcModel', - 'ephox.sugar.api.Compare', - 'ephox.sugar.api.Element' - ], - - function (SelectionRange, Situ, Supported, Within, DomRange, WwwcModel, Compare, Element) { - var get = function (win) { - return Supported.run(win, WwwcModel.get); - }; - - var set = function (win, raw) { - Supported.run(win, WwwcModel.set(raw)); - }; - - var setExact = function (win, s, so, e, eo) { - var raw = SelectionRange.write( - Situ.on(s, so), - Situ.on(e, eo) - ); - set(win, raw); - }; - - var selectElementContents = function (win, element) { - Supported.run(win, WwwcModel.selectElementContents(element)); - }; - - var replace = function (win, elements) { - Supported.run(win, WwwcModel.replace(elements)); - }; - - var replaceRange = function (win, raw, elements) { - Supported.run(win, WwwcModel.replaceRange(raw, elements)); - }; - - var deleteRange = function (win, s, so, e, eo) { - Supported.run(win, WwwcModel.deleteRange(s, so, e, eo)); - }; - - var cloneFragment = function (win, s, so, e, eo) { - return Supported.run(win, WwwcModel.cloneFragment(s, so, e, eo)); - }; - - var isCollapsed = function (s, so, e, eo) { - return Compare.eq(s, e) && so === eo; - }; - - var rectangleAt = function (win, s, so, e, eo) { - return Supported.run(win, WwwcModel.rectangleAt(s, so, e, eo)); - }; - - var findWithin = function (win, raw, selector) { - // Note, we don't need the getSelection() model for this. - return Within.find(win, raw, selector); - }; - - var findWithinExact = function (win, s, so, e, eo, selector) { - var raw = SelectionRange.write( - Situ.on(s, so), - Situ.on(e, eo) - ); - // Note, we don't need the getSelection() model for this. - return findWithin(win, raw, selector); - }; - - var deriveExact = function (win, raw) { - var rng = DomRange.forceRange(win, raw); - return SelectionRange.general(Element.fromDom(rng.startContainer), rng.startOffset, Element.fromDom(rng.endContainer), rng.endOffset); - }; - - var clearAll = function (win) { - Supported.run(win, WwwcModel.clearSelection); - }; - - return { - get: get, - set: set, - setExact: setExact, - selectElementContents: selectElementContents, - replace: replace, - replaceRange: replaceRange, - deleteRange: deleteRange, - isCollapsed: isCollapsed, - cloneFragment: cloneFragment, - rectangleAt: rectangleAt, - findWithin: findWithin, - findWithinExact: findWithinExact, - deriveExact: deriveExact, - clearAll: clearAll - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.api.HtmlPatterns', - - [ - - ], - - function () { - return { - validStyles: function () { - return /^(mso-.*|tab-stops|tab-interval|language|text-underline|text-effect|text-line-through|font-color|horiz-align|list-image-[0-9]+|separator-image|table-border-color-(dark|light)|vert-align|vnd\..*)$/; - }, - specialInline: function () { - return /^(font|em|strong|samp|acronym|cite|code|dfn|kbd|tt|b|i|u|s|sub|sup|ins|del|var|span)$/; - } - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.violin.StringMatch', - - [ - - ], - - function () { - var starts = function (value) { - return folder(function (s, p, c, e, a, n) { - return s(value); - }); - }; - - var pattern = function (regex) { - return folder(function (s, p, c, e, a, n) { - return p(regex); - }); - }; - - var contains = function (value) { - return folder(function (s, p, c, e, a, n) { - return c(value); - }); - }; - - var exact = function (value) { - return folder(function (s, p, c, e, a, n) { - return e(value); - }); - }; - - var all = function () { - return folder(function (s, p, c, e, a, n) { - return a(); - }); - }; - - var not = function (sm) { - return folder(function (s, p, c, e, a, n) { - return n(sm); - }); - }; - - var folder = function (fold) { - var matches = function (str) { - return fold(function (value) { - return str.toLowerCase().indexOf(value.toLowerCase()) === 0; - }, function (regex) { - return regex.test(str.toLowerCase()); - }, function (value) { - return str.toLowerCase().indexOf(value.toLowerCase()) >= 0; - }, function (value) { - return str.toLowerCase() === value.toLowerCase(); - }, function () { - return true; - }, function (other) { - return !other.matches(str); - }); - }; - - return { - fold: fold, - matches: matches - }; - }; - - var cata = function (subject, s, p, c, e, a, n) { - return subject.fold(s, p, c, e, a, n); - }; - - return { - starts: starts, - pattern: pattern, - contains: contains, - exact: exact, - all: all, - not: not, - cata: cata - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.api.RuleMatch', - - [ - 'ephox.peanut.Fun', - 'ephox.sugar.api.Node', - 'ephox.violin.StringMatch' - ], - - function (Fun, Node, StringMatch) { - var keyval = function (element, value, key, rule) { - var ruleName = rule.name; - var ruleCondition = rule.condition !== undefined ? rule.condition : Fun.constant(true); - var ruleValue = rule.value !== undefined ? rule.value : StringMatch.all(); - return ruleName.matches(key) && ruleValue.matches(value) && ruleCondition(element); - }; - - var name = function (element, rule) { - var tag = Node.name(element); - var ruleName = rule.name; - var ruleCondition = rule.condition !== undefined ? rule.condition : Fun.constant(true); - return ruleName.matches(tag) && ruleCondition(element); - }; - - return { - keyval: keyval, - name: name - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.cleanup.AttributeAccess', - - [ - 'ephox.compass.Arr', - 'ephox.compass.Obj', - 'ephox.peanut.Fun', - 'ephox.sugar.api.Attr' - ], - - function (Arr, Obj, Fun, Attr) { - var filter = function (element, predicate) { - var r = {}; - Arr.each(element.dom().attributes, function (a) { - if (!predicate(a.value, a.name)) r[a.name] = a.value; - }); - return r; - }; - - var update = function (element, names, keepers) { - Arr.each(names, function (name) { - Attr.remove(element, name); - }); - - Obj.each(keepers, function (v, k) { - Attr.set(element, k, v); - }); - }; - - var clobber = function (element, supported, _unsupported) { - var names = Arr.map(element.dom().attributes, function (attribute) { - return attribute.name; - }); - - if (Obj.size(supported) !== names.length) update(element, names, supported); - }; - - return { - filter: filter, - clobber: clobber, - // There are no hidden attributes that I know about. - scan: Fun.constant({}) - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.cleanup.StyleAccess', - - [ - 'ephox.compass.Arr', - 'ephox.compass.Obj', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Css', - 'ephox.violin.Strings' - ], - - function (Arr, Obj, Attr, Css, Strings) { - var separate = function (style) { - var css = {}; - var bits = style !== undefined && style !== null ? style.split(';') : []; - Arr.each(bits, function (bit) { - var parts = bit.split(':'); - if (parts.length === 2) { - css[Strings.trim(parts[0])] = Strings.trim(parts[1]); - } - }); - return css; - }; - - var get = function (element, property) { - return element.dom().style.getPropertyValue(property); - }; - - var filter = function (element, predicate) { - var r = {}; - Arr.each(element.dom().style, function (property) { - var value = get(element, property); - if (!predicate(value, property)) r[property] = value; - }); - return r; - }; - - var set = function (element, property, value) { - Css.set(element, property, value); - }; - - // Find the style for any special styles. - var scan = function (element, special, predicate) { - var style = element.dom().getAttribute('style'); - var css = separate(style); - - var before = {}; - Arr.each(special, function (property) { - var value = css[property]; - if (value !== undefined && !predicate(value, property)) before[property] = value; - }); - - return before; - }; - - var serialise = function (unsupported) { - var preserved = Obj.keys(unsupported); - return Arr.map(preserved, function (pre) { - return pre + ': ' + unsupported[pre]; - }).join('; '); - }; - - var clobber = function (element, supported, unsupported) { - Attr.set(element, 'style', ''); - - var numSupported = Obj.size(supported); - var numUnsupported = Obj.size(unsupported); - - if (numSupported === 0 && numUnsupported === 0) Attr.remove(element, 'style'); - else if (numSupported === 0) Attr.set(element, 'style', serialise(unsupported)); - else { - Obj.each(supported, function (v, k) { - set(element, k, v); - }); - - var base = Attr.get(element, 'style'); - var extra = numUnsupported > 0 ? serialise(unsupported) + '; ' : ''; - Attr.set(element, 'style', extra + base); - } - }; - - return { - filter: filter, - clobber: clobber, - scan: scan - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.cleanup.Cleaners', - - [ - 'ephox.pastiche.cleanup.AttributeAccess', - 'ephox.pastiche.cleanup.StyleAccess', - 'ephox.peanut.Fun', - 'ephox.sugar.api.Element' - ], - - function (AttributeAccess, StyleAccess, Fun, Element) { - var special = [ 'mso-list' ]; - - var style = function (element, predicate) { - var unsupported = StyleAccess.scan(element, special, predicate); - var supported = StyleAccess.filter(element, predicate); - StyleAccess.clobber(element, supported, unsupported); - }; - - var attribute = function (element, predicate) { - var keepers = AttributeAccess.filter(element, predicate); - AttributeAccess.clobber(element, keepers, {}); - }; - - var validateStyles = function (element) { - var supported = StyleAccess.filter(element, Fun.constant(false)); - StyleAccess.clobber(element, supported, {}); - }; - - var styleDom = function (dom, predicate) { - style(Element.fromDom(dom), predicate); - }; - - var attributeDom = function (dom, predicate) { - attribute(Element.fromDom(dom), predicate); - }; - - return { - style: style, - attribute: attribute, - styleDom: styleDom, - attributeDom: attributeDom, - validateStyles: validateStyles - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.Classes', - - [ - 'ephox.compass.Arr', - 'ephox.sugar.api.Class', - 'global!Array' - ], - - function (Arr, Class, Array) { - /* - * ClassList is IE10 minimum: - * https://developer.mozilla.org/en-US/docs/Web/API/Element.classList - */ - - var add = function (element, classes) { - Arr.each(classes, function (x) { - Class.add(element, x); - }); - }; - - var remove = function (element, classes) { - Arr.each(classes, function (x) { - Class.remove(element, x); - }); - }; - - var toggle = function (element, classes) { - Arr.each(classes, function (x) { - Class.toggle(element, x); - }); - }; - - var hasAll = function (element, classes) { - return Arr.forall(classes, function (clazz) { - return Class.has(element, clazz); - }); - }; - - var hasAny = function (element, classes) { - return Arr.exists(classes, function (clazz) { - return Class.has(element, clazz); - }); - }; - - var get = function (element) { - var classList = element.dom().classList; - var r = new Array(classList.length); - for (var i = 0; i < classList.length; i++) { - r[i] = classList.item(i); - } - return r; - }; - - // set deleted, risks bad performance. Be deterministic. - - return { - add: add, - remove: remove, - toggle: toggle, - hasAll: hasAll, - hasAny: hasAny, - get: get - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.Pipeless', - - [ - 'ephox.compass.Arr', - 'ephox.highway.Merger', - 'ephox.pastiche.api.RuleMatch', - 'ephox.pastiche.cleanup.Cleaners', - 'ephox.peanut.Fun', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Class', - 'ephox.sugar.api.Classes', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.SelectorFilter' - ], - - function (Arr, Merger, RuleMatch, Cleaners, Fun, Attr, Class, Classes, Remove, SelectorFilter) { - var cleaner = function (type, rules, element) { - // Use Cleaners.style or Cleaners.attribute as "type". - type(element, function (value, key) { - return Arr.exists(rules, function (rule) { - return RuleMatch.keyval(element, value, key, rule); - }); - }); - }; - - var remover = function (container, strat) { - var strategy = Merger.merge({ styles: [], attributes: [], classes: [], tags: [] }, strat); - - var elements = SelectorFilter.descendants(container, '*'); - Arr.each(elements, function (element) { - cleaner(Cleaners.style, strategy.styles, element); - cleaner(Cleaners.attribute, strategy.attributes, element); - - Arr.each(strategy.classes, function (rule) { - var actual = Attr.has(element, 'class') ? Classes.get(element) : []; - Arr.each(actual, function (act) { - if (rule.name.matches(act)) Class.remove(element, act); - }); - }); - }); - - // Now, remove the tags. - var postElements = SelectorFilter.descendants(container, '*'); - Arr.each(postElements, function (element) { - var matching = Arr.exists(strategy.tags, Fun.curry(RuleMatch.name, element)); - if (matching) Remove.remove(element); - }); - }; - - var unwrapper = function (container, strat) { - var strategy = Merger.merge({ tags: [] }, strat); - - var elements = SelectorFilter.descendants(container, '*'); - Arr.each(elements, function (element) { - var matching = Arr.exists(strategy.tags, Fun.curry(RuleMatch.name, element)); - if (matching) Remove.unwrap(element); - }); - }; - - var transformer = function (container, strat) { - var strategy = Merger.merge({ tags: [] }, strat); - - var elements = SelectorFilter.descendants(container, '*'); - Arr.each(elements, function (element) { - var rule = Arr.find(strategy.tags, Fun.curry(RuleMatch.name, element)); - if (rule !== undefined && rule !== null) rule.mutate(element); - }); - }; - - var validator = function (container) { - var elements = SelectorFilter.descendants(container, '*'); - Arr.each(elements, function (element) { - Cleaners.validateStyles(element); - }); - }; - - return { - remover: remover, - unwrapper: unwrapper, - transformer: transformer, - validator: validator - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.Token', - - [ - 'ephox.compass.Obj', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.Element' - ], - - function (Obj, Css, Element) { - var START_ELEMENT_TYPE = 'startElement'; - var END_ELEMENT_TYPE = 'endElement'; - var TEXT_TYPE = 'text'; - var COMMENT_TYPE = 'comment'; - - var token = function(node, endNode, syntheticStyles) { - var tokenType; - var tagName; - var tokenText; - - var element = Element.fromDom(node); - - switch (node.nodeType) { - case 1: - if (endNode) { - tokenType = END_ELEMENT_TYPE; - } else { - tokenType = START_ELEMENT_TYPE; - - Css.setAll(element, syntheticStyles || {}); - } - if (node.scopeName !== "HTML" && node.scopeName && node.tagName && node.tagName.indexOf(':') <= 0) { - tagName = (node.scopeName + ":" + node.tagName).toUpperCase(); - } else { - tagName = node.tagName; - } - - break; - case 3: - tokenType = TEXT_TYPE; - tokenText = node.nodeValue; - break; - case 8: - tokenType = COMMENT_TYPE; - tokenText = node.nodeValue; - break; - default: - console.log("WARNING: Unsupported node type encountered: " + node.nodeType); - break; - } - - var getNode = function() { - return node; - }; - - var tag = function() { - return tagName; - }; - - var type = function() { - return tokenType; - }; - - var text = function() { - return tokenText; - }; - - return { - getNode: getNode, - tag: tag, - type: type, - text: text - }; - }; - - var createStartElement = function(tag, attributes, styles, document) { - var node = document.createElement(tag), css = ""; - - Obj.each(attributes, function(value, name) { - node.setAttribute(name, value); - }); - - return token(node, false, styles); - }; - - var createEndElement = function(tag, document) { - return token(document.createElement(tag), true); - }; - - var createComment = function(text, document) { - return token(document.createComment(text), false); - }; - - var createText = function(text, document) { - return token(document.createTextNode(text)); - }; - - var FINISHED = createEndElement('HTML', window.document); - - return { - START_ELEMENT_TYPE: START_ELEMENT_TYPE, - END_ELEMENT_TYPE: END_ELEMENT_TYPE, - TEXT_TYPE: TEXT_TYPE, - COMMENT_TYPE: COMMENT_TYPE, - FINISHED: FINISHED, - token: token, - createStartElement: createStartElement, - createEndElement: createEndElement, - createComment: createComment, - createText: createText - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.Serialiser', - - [ - 'ephox.pastiche.engine.Token' - ], - - function (Token) { - var create = function (doc) { - var currentNode = doc.createDocumentFragment(); - var initialNode = currentNode; - - var push = function(node) { - append(node); - currentNode = node; - }; - - var pop = function() { - currentNode = currentNode.parentNode; - }; - - var append = function(node) { - currentNode.appendChild(node); - }; - - var receive = function(token) { - var startElement = function(token) { - var node = token.getNode().cloneNode(false); - push(node); - }; - - var text = function(token, serializer) { - // IE7 will crash if you clone a text node that's a URL. - // IE8 throws an invalid argument error. - // So while cloning may be faster, we have to create a new node here. - var node = doc.createTextNode(token.text()); - append(node); - }; - - switch (token.type()) { - case Token.START_ELEMENT_TYPE: - startElement(token); - break; - case Token.TEXT_TYPE: - text(token); - break; - case Token.END_ELEMENT_TYPE: - pop(); - break; - case Token.COMMENT_TYPE: - // Ignore. - break; - default: - throw { message: 'Unsupported token type: ' + token.type() }; - } - }; - - return { - dom: initialNode, - receive: receive, - label: 'SERIALISER' - }; - }; - - return { - create: create - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.Tokeniser', - - [ - 'ephox.pastiche.engine.Token' - ], - - function (Token) { - var tokenise = function(html, document) { - var container; - document = document || window.document; - container = document.createElement('div'); - document.body.appendChild(container); - container.style.position = 'absolute'; - container.style.left = '-10000px'; - container.innerHTML = html; - - nextNode = container.firstChild || Token.FINISHED; - - var nodeStack = []; - endNode = false; - - var getTokenForNode = function(node, endTag) { - if (node === Token.FINISHED) { - return node; - } else if (node) { - return Token.token(node, endTag); - } else { - return undefined; - } - }; - - var next = function() { - var currentNode = nextNode; - var currentEndNode = endNode; - if (!endNode && nextNode.firstChild) { - nodeStack.push(nextNode); - nextNode = nextNode.firstChild; - } else if (!endNode && nextNode.nodeType === 1) { - // Empty element. - endNode = true; - } else if (nextNode.nextSibling) { - nextNode = nextNode.nextSibling; - endNode = false; - } else { - nextNode = nodeStack.pop(); - endNode = true; - } - - if (currentNode !== Token.FINISHED && !nextNode) { - document.body.removeChild(container); - nextNode = Token.FINISHED; - } - - return getTokenForNode(currentNode, currentEndNode); - }; - - var hasNext = function() { - return nextNode !== undefined; - }; - - return { - hasNext: hasNext, - next: next - }; - }; - - return { - tokenise: tokenise - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.Pipeline', - - [ - 'ephox.pastiche.engine.Serialiser', - 'ephox.pastiche.engine.Tokeniser' - ], - - function (Serialiser, Tokeniser) { - var build = function(doc, filters, sink) { - var i, filter = sink; - for (i = filters.length - 1; i >= 0; i--) { - //This is calling the function defined by Filter.createFilter(). - //The best description I can come up with is "function composition using CPS". - //Filters are run in reverse order to the loop, which is reversed so the arrays below define the order. - //And then the sink comes last (which means it's injected on the first pass of the loop). - // filter = filters[i](doc, filter); - - // TEMPORARY: - filter = filters[i](filter, {}, doc); - } - return filter; - }; - - var run = function(doc, content, filters) { - var sink = Serialiser.create(doc); - var tokeniser = Tokeniser.tokenise(content, doc); - var pipeline = build(doc, filters, sink); - while (tokeniser.hasNext()) { - var token = tokeniser.next(); - pipeline.receive(token); - } - return sink.dom; - }; - - return { - build: build, - run: run - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.api.HybridAction', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.engine.Pipeless', - 'ephox.pastiche.engine.Pipeline', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.Traverse' - ], - - function (Arr, Pipeless, Pipeline, Element, Html, Remove, Traverse) { - var removal = function (spec) { - return function (container) { - Pipeless.remover(container, spec); - }; - }; - - var unwrapper = function (spec) { - return function (container) { - Pipeless.unwrapper(container, spec); - }; - }; - - var transformer = function (spec) { - return function (container) { - Pipeless.transformer(container, spec); - }; - }; - - var validate = function () { - return function (container) { - Pipeless.validator(container); - }; - }; - - var pipeline = function (pipes) { - return function (container) { - var html = Html.get(container); - var doc = Traverse.owner(container); - var sink = Pipeline.run(doc.dom(), html, pipes); - Remove.empty(container); - container.dom().appendChild(sink); - }; - }; - - var go = function (doc, input, actions) { - var container = Element.fromTag('div', doc.dom()); - container.dom().innerHTML = input; - Arr.each(actions, function (action) { - action(container); - }); - return Html.get(container); - }; - - var isWordContent = function (content) { - return content.indexOf('') >= 0 || // IE, Safari, Opera - content.indexOf('p.MsoNormal, li.MsoNormal, div.MsoNormal') >= 0 || // Firefox Mac - content.indexOf('MsoListParagraphCxSpFirst') >= 0 || // Windows list only selection - content.indexOf('') >= 0; // Firefox Windows - }; - - return { - removal: removal, - unwrapper: unwrapper, - transformer: transformer, - validate: validate, - pipeline: pipeline, - isWordContent: isWordContent, - go: go - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.api.RuleConditions', - - [ - 'ephox.compass.Arr', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Node', - 'ephox.sugar.api.PredicateExists' - ], - - function (Arr, Attr, Html, Node, PredicateExists) { - var isNotImage = function (elem) { - return Node.name(elem) !== 'img'; - }; - - var isImportantSpan = function (elem) { - var attrs = elem.dom().attributes; - var hasAttrs = attrs !== undefined && attrs !== null && attrs.length > 0; - return Node.name(elem) === 'span' ? hasAttrs : true; - }; - - var hasContent = function (elem) { - if (!hasNoAttributes(elem)) return true; - else { - return isImportantSpan(elem) && PredicateExists.descendant(elem, function (e) { - var hasAttributes = !hasNoAttributes(e); - var isContentTag = !Arr.contains([ - 'font', 'em', 'strong', 'samp', 'acronym', 'cite', 'code', 'dfn', 'kbd', 'tt', 'b', 'i', - 'u', 's', 'sub', 'sup', 'ins', 'del', 'var', 'span' - ], Node.name(e)); - - return Node.isText(e) || hasAttributes || isContentTag; - }); - } - }; - - var isList = function (elem) { - return Node.name(elem) === 'ol' || Node.name(elem) === 'ul'; - }; - - var isLocal = function (element) { - var src = Attr.get(element, 'src'); - return (/^file:/).test(src); - }; - - var hasNoAttributes = function (elem) { - if (elem.dom().attributes === undefined || elem.dom().attributes === null) return true; - return elem.dom().attributes.length === 0 || (elem.dom().attributes.length === 1 && elem.dom().attributes[0].name === 'style'); - }; - - var isEmpty = function (elem) { - // Note, this means that things with zero width cursors are NOT considered empty - return Html.get(elem).length === 0; - }; - - return { - isNotImage: isNotImage, - hasContent: hasContent, - isList: isList, - isLocal: isLocal, - hasNoAttributes: hasNoAttributes, - isEmpty: isEmpty - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.api.RuleMutations', - - [ - 'ephox.compass.Arr', - 'ephox.compass.Obj', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.InsertAll', - 'ephox.sugar.api.Node', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.Traverse' - ], - - function (Arr, Obj, Attr, Css, Element, Html, Insert, InsertAll, Node, Remove, Traverse) { - var changeTag = function (tag, element) { - // We cannot use replication because it uses innerHTML rather than setting the children. - // Which means that any further transformations done to the children are not represented - // in the final output. - var replica = Element.fromTag(tag); - Insert.before(element, replica); - - var attributes = element.dom().attributes; - Arr.each(attributes, function (attr) { - replica.dom().setAttribute(attr.name, attr.value); - }); - - var children = Traverse.children(element); - InsertAll.append(replica, children); - Remove.remove(element); - return replica; - }; - - // Adds a
tag to any

tags that are empty - var addBrTag = function (element) { - if (Html.get(element).length === 0) { - Insert.append(element, Element.fromTag('br')); - } - }; - - var properlyNest = function (element) { - Traverse.parent(element).each(function (parent) { - var tag = Node.name(parent); - if (Arr.contains([ 'ol', 'ul' ], tag)) { - var li = Element.fromTag('li'); - Css.set(li, 'list-style-type', 'none'); - Insert.wrap(element, li); - } - }); - }; - - var fontToSpan = function (element) { - var span = changeTag('span', element); - var conversions = { - face: 'font-family', - size: 'font-size', - color: 'font-color' - }; - - var values = { - 'font-size': { - '1': '8pt', - '2': '10pt', - '3': '12pt', - '4': '14pt', - '5': '18pt', - '6': '24pt', - '7': '36pt' - } - }; - - Obj.each(conversions, function (style, attribute) { - if (Attr.has(span, attribute)) { - var value = Attr.get(span, attribute); - var cssValue = values[style] !== undefined && values[style][value] !== undefined ? values[style][value] : value; - Css.set(span, style, cssValue); - Attr.remove(span, attribute); - } - }); - }; - - return { - changeTag: changeTag, - addBrTag: addBrTag, - properlyNest: properlyNest, - fontToSpan: fontToSpan - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.Filter', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.engine.Token' - ], - - function (Arr, Token) { - var createFilter = function(actualReceiver, clientReset, label) { - var filter = function(nextFilter, settings, document, _logger) { - var logger = _logger !== undefined ? _logger : []; - - var deferred; - var receivedTokens, emittedTokens, inTransaction = false; - - var resetState = function() { - if (clientReset) clientReset(api); - inTransaction = false; - receivedTokens = []; - emittedTokens = []; - }; - - var emitTokens = function(tokens) { - Arr.each(tokens, function(tok) { - nextFilter.receive(tok); - }); - }; - - var emit = function(token) { - if (inTransaction) { - emittedTokens.push(token); - } else { - nextFilter.receive(token); - } - }; - - var receive = function(token) { - if (clientReset) receivedTokens.push(token); - actualReceiver(api, token); - if (token === Token.FINISHED) { - commit(); - } - }; - - var startTransaction = function() { - inTransaction = true; - }; - - var rollback = function() { - emitTokens(receivedTokens); - resetState(); - }; - - var commit = function() { - emitDeferred(); - emitTokens(emittedTokens); - resetState(); - }; - - var defer = function(token) { - deferred = deferred || []; - deferred.push(token); - }; - - var hasDeferred = function() { - return deferred && deferred.length > 0; - }; - - var emitDeferred = function() { - Arr.each(deferred || [], function(token) { - emit(token); - }); - dropDeferred(); - }; - - var dropDeferred = function() { - deferred = []; - }; - - var api = { - document: document || window.document, - settings: settings || {}, - emit: emit, - receive: receive, - startTransaction: startTransaction, - rollback: rollback, - commit: commit, - defer: defer, - hasDeferred: hasDeferred, - emitDeferred: emitDeferred, - dropDeferred: dropDeferred, - label: label - }; - - resetState(); - return api; - }; - return filter; - }; - - return { - createFilter: createFilter - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.engine.TokenUtil', - - [ - 'ephox.pastiche.cleanup.StyleAccess', - 'ephox.pastiche.engine.Token', - 'ephox.peanut.Fun', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.Element' - ], - - function (StyleAccess, Token, Fun, Attr, Css, Element) { - var getAttribute = function (token, property) { - var element = Element.fromDom(token.getNode()); - return Attr.get(element, property); - }; - - var getStyle = function (token, property) { - var element = Element.fromDom(token.getNode()); - return Css.get(element, property); - }; - - var isWhitespace = function (token) { - return token.type() === Token.TEXT_TYPE && /^[\s\u00A0]*$/.test(token.text()); - }; - - var getMsoList = function (token) { - var element = Element.fromDom(token.getNode()); - var styles = StyleAccess.scan(element, [ 'mso-list' ], Fun.constant(false)); - return styles['mso-list']; - }; - - return { - getAttribute: getAttribute, - getStyle: getStyle, - isWhitespace: isWhitespace, - getMsoList: getMsoList - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.detect.ListSymbols', - - [ - 'ephox.compass.Arr', - 'ephox.highway.Merger' - ], - - function (Arr, Merger) { - - var orderedListTypes = [ - { regex: /^\(?[dc][\.\)]$/, type: { tag: 'OL', type: 'lower-alpha' } }, - { regex: /^\(?[DC][\.\)]$/, type: { tag: 'OL', type: 'upper-alpha' } }, - { regex: /^\(?M*(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})[\.\)]$/, type: { tag: 'OL', type: 'upper-roman' } }, - { regex: /^\(?m*(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})[\.\)]$/, type: { tag: 'OL', type: 'lower-roman' } }, - { regex: /^\(?[0-9]+[\.\)]$/, type: { tag: 'OL' } }, - { regex: /^([0-9]+\.)*[0-9]+\.?$/, type: { tag: 'OL', variant: 'outline' } }, - { regex: /^\(?[a-z]+[\.\)]$/, type: { tag: 'OL', type: 'lower-alpha' } }, - { regex: /^\(?[A-Z]+[\.\)]$/, type: { tag: 'OL', type: 'upper-alpha' } } - ]; - - var ulChars = { - '\u2022': { tag: 'UL', type: 'disc' }, - '\u00B7': { tag: 'UL', type: 'disc' }, - '\u00A7': { tag: 'UL', type: 'square' } - }; - - var ulNonSymbolChars = { - 'o': { tag: 'UL', type: 'circle' }, - '-': { tag: 'UL', type: 'disc' }, - '\u25CF': { tag: 'UL', type: 'disc' }, - '�': { tag: 'UL', type: 'circle' } - }; - - var getVariant = function (type, text) { - if (type.variant !== undefined) return type.variant; - else if (text.charAt(0) === '(') return '()'; - else if (text.charAt(text.length - 1) === ')') return ')'; - else return '.'; - }; - - var getStart = function (text) { - var number = parseInt(text, 10); - return isNaN(number) ? { } : { start: number }; - }; - - var match = function (text, inSymbol) { - var nonSymbols = ulNonSymbolChars[text] ? [ ulNonSymbolChars[text] ] : []; - var symbols = inSymbol && ulChars[text] ? [ ulChars[text] ] : inSymbol ? [{ tag: 'UL', variant: text }] : []; - var ordered = Arr.bind(orderedListTypes, function (o) { - return o.regex.test(text) ? [ Merger.merge(o.type, getStart(text), { - variant: getVariant(o.type, text) - })] : []; - }); - - var result = nonSymbols.concat(symbols).concat(ordered); - return Arr.map(result, function (x) { - return x.variant !== undefined ? x : Merger.merge(x, { - variant: text - }); - }); - }; - - return { - match: match - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.detect.ListGuess', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.list.detect.ListSymbols', - 'ephox.perhaps.Option', - 'ephox.violin.Strings' - ], - - function (Arr, ListSymbols, Option, Strings) { - - var guess = function(bulletInfo, preferredType) { - var text = bulletInfo ? Strings.trim(bulletInfo.text) : ''; - var symbolFont = bulletInfo ? !!bulletInfo.symbolFont : false; - var candidates = ListSymbols.match(text, symbolFont); - var preferred = Arr.find(candidates, function (c) { - // The original code only ran preferred types for ordered lists. I have - // no idea whether this is a condition that we want preserved, but one - // of the QUnit tests implicitly stated it is. - return c.tag === 'UL' || (preferredType && eqListType(c, preferredType, true)); - }); - return preferred !== undefined ? Option.some(preferred) : - candidates.length > 0 ? Option.some(candidates[0]) : Option.none(); - }; - - var eqListType = function(t1, t2, ignoreVariant) { - return t1 === t2 || - (t1 && t2 && t1.tag === t2.tag && t1.type === t2.type && - (ignoreVariant || t1.variant === t2.variant)); - }; - - return { - guess: guess, - eqListType: eqListType - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.detect.ListTypes', - - [ - 'ephox.pastiche.engine.Token', - 'ephox.pastiche.engine.TokenUtil', - 'ephox.pastiche.list.detect.ListGuess' - ], - - function (Token, TokenUtil, ListGuess) { - - var guess = function(bulletInfo, preferredType, originalToken) { - var candidate = ListGuess.guess(bulletInfo, preferredType); - return candidate.fold(function () { - return null; - }, function (c) { - if (c.tag === 'OL' && originalToken && (originalToken.tag() !== 'P' || /^MsoHeading/.test(TokenUtil.getAttribute(originalToken, 'class')))) { - // Don't convert numbered headings but do convert bulleted headings. - listType = null; - } else { - return c; - } - }); - }; - - var eqListType = ListGuess.eqListType; - - var checkFont = function(token, symbolFont) { - if (token.type() == Token.START_ELEMENT_TYPE) { - font = TokenUtil.getStyle(token, 'font-family'); - if (font) { - symbolFont = (font === 'Wingdings' || font === 'Symbol'); - } else if (/^(P|H[1-6]|DIV)$/.test(token.tag())) { - symbolFont = false; - } - } - return symbolFont; - }; - - return { - guess: guess, - eqListType: eqListType, - checkFont: checkFont - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Microsoft', - - [ - 'ephox.pastiche.engine.Token', - 'ephox.pastiche.engine.TokenUtil' - ], - - function (Token, TokenUtil) { - var isList = function (state, token) { - var style = TokenUtil.getMsoList(token); - return style && style !== 'skip'; - }; - - var isIgnore = function (state, token) { - return token.type() == Token.START_ELEMENT_TYPE && TokenUtil.getMsoList(token) === 'Ignore'; - }; - - return { - isList: isList, - isIgnore: isIgnore - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Tags', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.engine.Token', - 'ephox.violin.Strings' - ], - - function (Arr, Token, Strings) { - var isStart = function (state, token) { - return token.type() === Token.START_ELEMENT_TYPE; - }; - - var isEnd = function (state, token) { - return token.type() === Token.END_ELEMENT_TYPE; - }; - - var isTag = function (tag) { - return function (state, token) { - return token.tag() === tag; - }; - }; - - var isWhitespace = function (tag) { - return function (state, token) { - return isTag(tag)(state, token) && Strings.trim(token.getNode().textContent) === ''; - }; - }; - - var isStartOf = function (tag) { - return function (state, token) { - return isStart(state, token) && token.tag() === tag; - }; - }; - - var isEndOf = function (tag) { - return function (state, token) { - return isEnd(state, token) && token.tag() === tag; - }; - }; - - var isStartAny = function (tags) { - return function (state, token) { - return isStart(state, token) && Arr.contains(tags, token.tag()); - }; - }; - - var isEndAny = function (tags) { - return function (state, token, tags) { - return isEnd(state, token) && Arr.contains(tags, token.tag()); - }; - }; - - return { - isStart: isStart, - isEnd: isEnd, - isTag: isTag, - isStartOf: isStartOf, - isEndOf: isEndOf, - isStartAny: isStartAny, - isEndAny: isEndAny, - isWhitespace: isWhitespace - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Paragraphs', - - [ - 'ephox.pastiche.inspect.Microsoft', - 'ephox.pastiche.inspect.Tags' - ], - - function (Microsoft, Tags) { - // MOVE ME. - var isNormal = function (state, token) { - return !state.skippedPara.get() && Tags.isStart(state, token, 'P') && !Microsoft.isList(state, token); - }; - - return { - isNormal: isNormal - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Texts', - - [ - 'ephox.pastiche.engine.Token', - 'ephox.pastiche.engine.TokenUtil', - 'ephox.violin.Strings' - ], - - function (Token, TokenUtil, Strings) { - var isWhitespace = function (state, token) { - return is(state, token) && TokenUtil.isWhitespace(token); - }; - - var is = function (state, token) { - return token.type() === Token.TEXT_TYPE; - }; - - var eq = function (value) { - return function (state, token) { - return is(state, token) && token.text() === value; - }; - }; - - var matches = function (value) { - return function (state, token) { - return is(state, token) && value.test(token.text()); - }; - }; - - // CHECK: Is this equivalent to isWhitespace? - var isBlank = function (state, token) { - return is(state, token) && Strings.trim(token.text()) === ''; - }; - - return { - isWhitespace: isWhitespace, - is: is, - isBlank: isBlank, - eq: eq, - matches: matches - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.Handler', - - [ - 'ephox.peanut.Fun' - ], - - function (Fun) { - return function (pred, action, label) { - return { - pred: pred, - action: action, - label: Fun.constant(label) - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.Handlers', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option' - ], - - function (Arr, Fun, Option) { - var logger = function (label, action) { - return function (api, state, token) { - // console.log('LOGGER: ', label, token.getNode().cloneNode(false)); - return action(api, state, token); - }; - }; - - return function (name, handlers, fallback) { - var logFallback = logger(name + ' :: FALLBACK --- ', fallback); - - var r = function (api, state, token) { - // console.log('token: ', token.getNode().cloneNode(true)); - var match = Option.from(Arr.find(handlers, function (x) { - return x.pred(state, token); - })); - - var action = match.fold(Fun.constant(logFallback), function (m) { - var label = m.label(); - return label === undefined ? m.action : logger(name + ' :: ' + label, m.action); - }); - action(api, state, token); - }; - - r.toString = function () { return 'Handlers for ' + name; }; - return r; - }; - - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.state.Transitions', - - [ - ], - - function () { - var next = function (state, listState) { - if (state === undefined || listState === undefined) { - console.trace(); - throw 'brick'; - } - state.nextFilter.set(listState); - }; - - var setNext = function (listState) { - return function (api, state, token) { - next(state, listState); - }; - }; - - var go = function (api, state, token) { - var nextFilter = state.nextFilter.get(); - nextFilter(api, state, token); - }; - - var jump = function (listState) { - return function (api, state, token) { - next(state, listState); - go(api, state, token); - }; - }; - - var isNext = function (state, listState) { - return state.nextFilter.get() === listState; - }; - - return { - next: next, - go: go, - jump: jump, - isNext: isNext, - setNext: setNext - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.AfterListState', - - [ - 'ephox.pastiche.inspect.Paragraphs', - 'ephox.pastiche.inspect.Texts', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Transitions' - ], - - function (Paragraphs, Texts, Handler, Handlers, Transitions) { - var run = function (skipEmptyParaState, noListState) { - - var blankAction = function (api, state, token) { - api.defer(token); - }; - - var normalParaAction = function (api, state, token) { - state.openedTag.set(token); - api.defer(token); - Transitions.next(state, skipEmptyParaState); - }; - - var fallback = function (api, state, token) { - noListState(api, state, token); - }; - - return Handlers('AfterListState', [ - Handler(Texts.isBlank, blankAction, 'blank text'), - Handler(Paragraphs.isNormal, normalParaAction, 'normal paragraph') - ], fallback); - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.States', - - [ - 'ephox.pastiche.engine.Token' - ], - - function (Token) { - // MOVE ME? - var isCloser = function (state, token) { - return token.type() === Token.END_ELEMENT_TYPE && state.originalToken.get() && token.tag() === state.originalToken.get().tag(); - }; - - return { - isCloser: isCloser - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.AfterNoBulletListState', - - [ - 'ephox.pastiche.inspect.States', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Transitions' - ], - - function (States, Handler, Handlers, Transitions) { - var run = function (afterListState) { - - var action = function (api, state, token) { - Transitions.next(state, afterListState); - /* - I think that this should be 0, but it breaks qUnit test cases in powerpaste if it isn't -1. Probably - need to look into it in more detail. The level 0 check in ListModel in the emitter should - take care of it anyway. - */ - state.styleLevelAdjust.set(-1); - api.emit(token); - }; - - var fallback = function (api, state, token) { - api.emit(token); - }; - - return Handlers('AfterNoBullet', [ - Handler(States.isCloser, action, ' closing open tag') - ], fallback); - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Images', - - [ - 'ephox.pastiche.inspect.Tags' - ], - - function (Tags) { - - var isEnd = Tags.isEndOf('IMG'); - var isStart = Tags.isStartOf('IMG'); - - return { - isStart: isStart, - isEnd: isEnd - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Markers', - - [ - 'ephox.pastiche.engine.Token' - ], - - function (Token) { - - var is = function (state, token) { - return token.tag() === 'A' || token.tag() === 'SPAN'; - }; - - var isStart = function (state, token) { - return token.type() === Token.START_ELEMENT_TYPE && is(state, token); - }; - - var isEnd = function (state, token) { - return token.type() === Token.END_ELEMENT_TYPE && is(state, token); - }; - - return { - isStart: isStart, - isEnd: isEnd, - is: is - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.state.Spans', - - [ - 'ephox.pastiche.list.state.Transitions' - ], - - function (Transitions) { - var deferAndPop = function (api, state, token) { - api.defer(token); - pop(api, state, token); - }; - - var deferAndPush = function (api, state, token) { - api.defer(token); - push(api, state, token); - }; - - var push = function (api, state, token) { - state.spanCount.get().push(token); - }; - - var pop = function (api, state, token) { - state.spanCount.get().pop(); - }; - - var pushThen = function (listState) { - return function (api, state, token) { - push(api, state, token); - Transitions.next(state, listState); - }; - }; - - var popThen = function (listState) { - return function (api, state, token) { - pop(api, state, token); - Transitions.next(state, listState); - }; - }; - - return { - deferAndPush: deferAndPush, - deferAndPop: deferAndPop, - push: push, - pop: pop, - pushThen: pushThen, - popThen: popThen - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.BeforeSpacerState', - - [ - 'ephox.pastiche.inspect.Images', - 'ephox.pastiche.inspect.Markers', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Spans', - 'ephox.peanut.Fun' - ], - - function (Images, Markers, Handler, Handlers, Spans, Fun) { - var run = function (spacerState, closeSpansState, unexpectedToken) { - - var fallback = function (api, state, token) { - unexpectedToken(api, token); - }; - - return Handlers('BeforeSpacer', [ - Handler(Markers.isStart, Spans.pushThen(spacerState), 'start marker'), - Handler(Markers.isEnd, Spans.popThen(closeSpansState), 'end marker'), - Handler(Images.isEnd, Fun.noop, 'end image') - ], fallback); - - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Comments', - - [ - 'ephox.pastiche.engine.Token' - ], - - function (Token) { - - var is = function (state, token) { - return token.type() === Token.COMMENT_TYPE; - }; - - var isNotEndIf = function (state, token) { - return is(state, token) && token.text() !== '[endif]'; - }; - - var isEndIf = function (state, token) { - return is(state, token) && token.text() === '[endif]'; - }; - - var isListSupport = function (state, token) { - return is(state, token) && token.text() === '[if !supportLists]'; - }; - - return { - is: is, - isNotEndIf: isNotEndIf, - isEndIf: isEndIf, - isListSupport: isListSupport - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Logic', - - [ - 'ephox.compass.Arr' - ], - - function (Arr) { - var any = function (conditions) { - return function (state, token) { - return Arr.exists(conditions, function (c) { - return c(state, token); - }); - }; - }; - - var all = function (conditions) { - return function (state, token) { - return Arr.forall(conditions, function (c) { - return c(state, token); - }); - }; - }; - - return { - any: any, - all: all - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.CloseSpansState', - - [ - 'ephox.pastiche.inspect.Comments', - 'ephox.pastiche.inspect.Logic', - 'ephox.pastiche.inspect.Markers', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.inspect.Texts', - 'ephox.pastiche.list.detect.ListTypes', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Spans', - 'ephox.pastiche.list.state.Transitions', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option', - 'ephox.perhaps.Result' - ], - - function (Comments, Logic, Markers, Tags, Texts, ListTypes, Handler, Handlers, Spans, Transitions, Fun, Option, Result) { - var run = function (itemContentState, unexpectedToken) { - - var getListType = function (state) { - var currentType = state.emitter.getCurrentListType(); - var currentLevel = state.emitter.getCurrentLevel(); - // FIX: Don't coerce types. - var preferred = currentLevel == state.itemLevel.get() ? currentType : null; - return Option.from(ListTypes.guess(state.bulletInfo.get(), preferred, state.originalToken.get())); - }; - - var openItem = function (api, state, token) { - state.emitter.openItem(state.itemLevel.get(), state.originalToken.get(), state.listType.get(), state.skippedPara.get()); - api.emitDeferred(); - while (state.spanCount.get().length > 0) { - api.emit(state.spanCount.get().shift()); - } - }; - - var updateState = function (state, token) { - Transitions.next(state, itemContentState); - if (state.commentMode.get()) { - var indent = state.indentGuesser.guessIndentLevel(token, state.originalToken.get(), state.styles, state.bulletInfo.get()); - state.itemLevel.set(indent); - } - }; - - var tryItem = function (api, state, token) { - var listType = getListType(state); - return listType.fold(function () { - state.listType.set(null); - return Result.error("Unknown list type: " + state.bulletInfo.get().text + " Symbol font? " + state.bulletInfo.get().symbolFont); - }, function (type) { - state.listType.set(type); - return Result.value(openItem); - }); - }; - - var updateAndEmit = function (api, state, token) { - updateState(state, token); - var emitter = tryItem(api, state, token); - emitter.fold(function (msg) { - console.log(msg); - api.rollback(); - }, function (x) { - x(api, state, token); - api.emit(token); - }); - }; - - var skipComment = function (api, state, token) { - updateState(state, token); - var emitter = tryItem(api, state, token); - emitter.fold(function (msg) { - console.log(msg); - api.rollback(); - }, function (x) { - x(api, state, token); - }); - }; - - var handlers = [ - Handler(Logic.any([ Texts.is, Tags.isStart ]), updateAndEmit, 'text or start tag'), - Handler(Comments.isNotEndIf, updateAndEmit, 'non-endif comment'), - Handler(Comments.isEndIf, skipComment, 'endif comment'), - Handler(Markers.isEnd, Spans.pop, 'end marker'), - Handler(Tags.isEnd, Fun.noop, 'end tag') - ]; - - return Handlers('CloseSpans', handlers, function (api, state, token) { - unexpectedToken(api, token); - }); - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.FindListTypeState', - - [ - 'ephox.pastiche.inspect.Images', - 'ephox.pastiche.inspect.Markers', - 'ephox.pastiche.inspect.Texts', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Spans', - 'ephox.pastiche.list.state.Transitions', - 'ephox.peanut.Fun' - ], - - function (Images, Markers, Texts, Handler, Handlers, Spans, Transitions, Fun) { - var run = function (beforeSpacerState, unexpectedToken) { - var action = function (bullets) { - return function (api, state, token) { - Transitions.next(state, beforeSpacerState); - state.bulletInfo.set(bullets(state, token)); - }; - }; - - var textAction = action(function (state, token) { - return { - text: token.text(), - symbolFont: state.symbolFont.get() - }; - }); - - var imageAction = action(function (state, token) { - // Custom list image type. We can't access the image so use a normal bullet instead. - // EditLive! may want this to come through as a CSS reference. - return { - text: '\u2202', - symbolFont: true - }; - }); - - var fallback = function (api, state, token) { - unexpectedToken(api, token); - }; - - return Handlers('FindListType', [ - Handler(Texts.isWhitespace, Fun.noop, 'text is whitespace'), - Handler(Texts.is, textAction, 'text'), - Handler(Markers.isStart, Spans.push, 'start marker'), - Handler(Markers.isEnd, Spans.pop, 'end marker'), - Handler(Images.isStart, imageAction, 'start image') - ], fallback); - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.ItemContentState', - - [ - 'ephox.pastiche.inspect.States', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Transitions' - ], - - function (States, Handler, Handlers, Transitions) { - var run = function (afterListState) { - - var closeItem = function (api, state, token) { - Transitions.next(state, afterListState); - state.skippedPara.set(false); - }; - - var handlers = [ - Handler(States.isCloser, closeItem, 'Closing open tag') - ]; - - return Handlers('ItemContentState', handlers, function (api, state, token) { - api.emit(token); - }); - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.state.CommentOff', - - [ - 'ephox.pastiche.inspect.Comments', - 'ephox.pastiche.inspect.Texts' - ], - - function (Comments, Texts) { - var isText = function (state, token) { - return !state.commentMode.get() && Texts.is(state, token); - }; - - var isComment = function (state, token) { - return !state.commentMode.get() && Comments.is(state, token); - }; - - return { - isText: isText, - isComment: isComment - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.state.CommentOn', - - [ - 'ephox.pastiche.engine.TokenUtil', - 'ephox.pastiche.inspect.Comments', - 'ephox.pastiche.inspect.Texts' - ], - - function (TokenUtil, Comments, Texts) { - var isText = function (state, token) { - return state.commentMode.get() && Texts.is(state, token); - }; - - var isComment = function (state, token) { - return state.commentMode.get() && Comments.is(state, token); - }; - - var isUnstyled = function (state, token) { - var style = TokenUtil.getAttribute(token, 'style'); - return state.commentMode.get() && style === "" || style === null; - }; - - return { - isText: isText, - isComment: isComment, - isUnstyled: isUnstyled - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.ListStartState', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.inspect.Logic', - 'ephox.pastiche.inspect.Microsoft', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.inspect.Texts', - 'ephox.pastiche.list.detect.ListSymbols', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.CommentOff', - 'ephox.pastiche.list.state.CommentOn', - 'ephox.pastiche.list.state.Spans', - 'ephox.pastiche.list.state.Transitions', - 'ephox.peanut.Fun' - ], - - function (Arr, Logic, Microsoft, Tags, Texts, ListSymbols, Handler, Handlers, CommentOff, CommentOn, Spans, Transitions, Fun) { - var run = function (findListTypeState, afterNoBulletListState, unexpectedToken) { - - /* In one of the adhoc tests on Word 2007, Win XP ... a span with a massive number of nbsp was - added at the ListStart stage. This was added to jump to the end of it. */ - var skipWhitespace = function () { - return Handlers('TESTER', [ - Handler(Tags.isEndOf('SPAN'), Transitions.setNext(result), 'Finishing span'), - Handler(Texts.isWhitespace, Fun.noop, 'Is whitespace') - ], function (api, state, token) { - unexpectedToken(api, token); - }); - }; - - var noBullet = function (api, state, token) { - // List type without a bullet, we should treat it as a paragraph. - - // What about if it is 1. or something similar? - var start = state.originalToken.get(); - var spans = state.spanCount.get(); - state.emitter.closeAllLists(); - api.emit(start); - Arr.each(spans, api.emit); - api.emit(token); - api.commit(); - state.originalToken.set(start); - Transitions.next(state, afterNoBulletListState); - }; - - var isBulletSymbol = function (s, t) { - return Texts.is(s, t) && ListSymbols.match(t.text(), s.symbolFont.get()).length > 0; - }; - - var result = function (api, state, token) { - if (Microsoft.isIgnore(state, token)) { - Transitions.next(state, findListTypeState); - } - - var r = Handlers('ListStartState', [ - Handler( - Logic.all([ Tags.isStartOf('SPAN'), CommentOn.isUnstyled ]), - Spans.pushThen(findListTypeState), - 'unstyled span' - ), - - // This handler was added due to adhoc Word 2007 XP content. It breaks QUnit tests. - /* Handler(Logic.all([ Tags.isStart, Tags.isWhitespace('SPAN') ]), Transitions.setNext(skipWhitespace()), 'a whitespace tag'), */ - Handler(Tags.isStartOf('SPAN'), Spans.push, 'starting span'), - Handler(Tags.isStartOf('A'), Spans.push, 'starting a'), - Handler(Tags.isEndOf('A'), Spans.pop, 'ending a'), - Handler(CommentOn.isText, Transitions.jump(findListTypeState), 'commentOn -> text'), - // This handler is new. It may be a problem. - Handler(isBulletSymbol, Transitions.jump(findListTypeState), 'mogran :: text is [1-9].'), - Handler(Texts.is, noBullet, 'text'), - Handler(CommentOff.isComment, Fun.noop, 'commentOff -> comment'), - - // This was added to handle more gracefully the images in some of the test data. May be wrong. - Handler(Tags.isStartOf('IMG'), Transitions.jump(findListTypeState), 'mogran :: start image tag') - ], function (api, state, token) { - unexpectedToken(api, token); - }); - - return r(api, state, token); - }; - - result.toString = function () { return 'Handlers for ListStartState'; }; - return result; - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Browser', - - [ - 'ephox.pastiche.engine.Token', - 'ephox.pastiche.inspect.Microsoft', - 'global!document', - 'global!navigator' - ], - - function (Token, Microsoft, document, navigator) { - var supportsCustomStyles = function () { - // Firefox 4 preserves these styles in the DOM, but strips them when pasting. - // Since we can't trigger a paste there's no way to detect this situation apart from sniffing. - if (navigator.userAgent.indexOf('Gecko') > 0 && navigator.userAgent.indexOf('WebKit') < 0) return false; - var div = document.createElement('div'); - try { - div.innerHTML = '

 

'; - } catch (ex) { - // Can't set innerHTML if we're in XHTML mode so just assume we don't get custom styles. - return false; - } - - var token = Token.token(div.firstChild); - // INVESTIGATE: Does this need to be lowercased? - return Microsoft.isIgnore({}/*state*/, token); - }; - - return { - supportsCustomStyles: supportsCustomStyles - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.detect.ImageList', - - [ - ], - - function () { - var is = function (state, node, symbol) { - var alt = node !== undefined && node !== null && node.getAttribute !== undefined && node.getAttribute !== null ? node.getAttribute('alt') : ''; - // The check here for === * is because we are disabling image lists as they - // interfere with regular images. The one exception where it is reasonable - // to assume it is a list is if the alt text is *. - return !!node && node.tagName === 'IMG' && alt === '*'; - }; - - return { - is: is - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.detect.TextList', - - [ - 'ephox.pastiche.list.detect.ListTypes', - 'ephox.violin.Strings' - ], - - function (ListTypes, Strings) { - var is = function (state, rawNode, symbol) { - var node = rawNode; - var value = node.nodeValue; - if (!Strings.trim(value)) { - // This handles the case where there's a SPAN with nbsps before the bullet such as with roman numerals. - node = node.parentNode.nextSibling; - value = node ? node.nodeValue : ''; - } - - // Real lists have the bullet with NBSPs either side surrounded in a SPAN. If there's anything else, it's not a list. - if (!node || Strings.trim(node.parentNode.textContent) != value) { - return false; - } - listType = ListTypes.guess({ text: value, symbolFont: symbol }, null, state.originalToken.get()); - - if (listType) { - - // Don't convert numbered headings to lists. - var r = !!node.nextSibling && node.nextSibling.tagName === 'SPAN' && /^[\u00A0\s]/.test(node.nextSibling.firstChild.nodeValue) && - (state.openedTag.get().tag() === 'P' || listType.tag === 'UL'); - return r; - } else { - return false; - } - }; - - return { - is: is - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.detect.ListDetect', - - [ - 'ephox.highway.Merger', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.list.detect.ImageList', - 'ephox.pastiche.list.detect.TextList' - ], - - function (Merger, Tags, ImageList, TextList) { - - var update = function (output) { - var node = output.node; - var font = node.style.fontFamily; - return font ? Merger.merge(output, { symbol: (font === 'Wingdings' || font === 'Symbol') }) : output; - }; - - var hasMarkerFirst = function (node) { - return !!node.firstChild && (node.firstChild.tagName === 'SPAN' || node.firstChild.tagName === 'A'); - }; - - var findItem = function (node) { - var output = update({ node: node }); - - var initialEmptyA = node.childNodes.length > 1 && output.node.firstChild.tagName === 'A' && output.node.firstChild.textContent === ''; - output = initialEmptyA ? { node: output.node.childNodes[1], symbol: output.symbol } : output; - - while (hasMarkerFirst(output.node)) { - output = update({ node: output.node.firstChild, symbol: output.symbol }); - } - - return { - node: output.node.firstChild, - symbol: output.symbol - }; - }; - - var isUnofficialList = function (state, token) { - if (!Tags.isStartOf('SPAN')(state, token) || !state.openedTag.get()) return false; - var node = state.openedTag.get().getNode(); - var item = findItem(node); - var detector = item.node && item.node.nodeType === 3 ? TextList : ImageList; - return detector.is(state, item.node, item.symbol); - }; - - return { - isUnofficialList: isUnofficialList - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.inspect.Lists', - - [ - 'ephox.pastiche.engine.TokenUtil', - 'ephox.pastiche.inspect.Browser', - 'ephox.pastiche.inspect.Comments', - 'ephox.pastiche.inspect.Microsoft', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.list.detect.ListDetect', - 'ephox.perhaps.Option' - ], - - function (TokenUtil, Browser, Comments, Microsoft, Tags, ListDetect, Option) { - var getLevel = function (token) { - var msoList = TokenUtil.getMsoList(token); - var lvl = / level([0-9]+)/.exec(msoList); - return lvl && lvl[1] ? Option.some(parseInt(lvl[1], 10)) : Option.none(); - }; - - var isStart = function (state, token) { - return Tags.isStart(state, token) && Microsoft.isList(state, token) && token.tag() !== 'LI'; - }; - - var isValidStart = function (state, token) { - return isStart(state, token) && getLevel(token).isSome(); - }; - - var isInvalidStart = function (state, token) { - return isStart(state, token) && getLevel(token).isNone(); - }; - - var isSpecial = function (state, token) { - var custom = Browser.supportsCustomStyles(); - return !custom && Comments.isListSupport(state, token) || ListDetect.isUnofficialList(state, token); - }; - - return { - getLevel: getLevel, - isStart: isStart, - isValidStart: isValidStart, - isInvalidStart: isInvalidStart, - isSpecial: isSpecial - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.NoListState', - - [ - 'ephox.pastiche.inspect.Lists', - 'ephox.pastiche.inspect.Markers', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Spans', - 'ephox.pastiche.list.state.Transitions' - ], - - function (Lists, Markers, Tags, Handler, Handlers, Spans, Transitions) { - var run = function (lazyListStartState) { - - var startList = function (api, state, token) { - var level = Lists.getLevel(token); - level.each(function (l) { - state.itemLevel.set(l + state.styleLevelAdjust.get()); - // Tokens between lists should be dropped (they're just whitespace anyway) - // however, tokens before a list should be emitted if we find an mso-list style - // since this is the very first token of the list. - var deferring = Transitions.isNext(state, result) ? api.emitDeferred : api.dropDeferred; - deferring(); - - Transitions.next(state, lazyListStartState()); - api.startTransaction(); - state.originalToken.set(token); - state.commentMode.set(false); - }); - }; - - var specialList = function (api, state, token) { - if (Tags.isStartOf('SPAN')(state, token)) { - Spans.push(api, state, token); - } - Transitions.next(state, lazyListStartState()); - api.startTransaction(); - state.originalToken.set(state.openedTag.get()); - state.commentMode.set(true); - state.openedTag.set(null); - api.dropDeferred(); - }; - - var startTag = function (api, state, token) { - if (state.openedTag.get()) { - state.emitter.closeAllLists(); - api.emitDeferred(); - } - state.openedTag.set(token); - api.defer(token); - }; - - var closeOutLists = function (api, state, token) { - state.emitter.closeAllLists(); - api.emitDeferred(); - state.openedTag.set(null); - api.emit(token); - Transitions.next(state, result); - }; - - var result = Handlers('NoListState', [ - Handler(Lists.isValidStart, startList, 'valid list so start it'), - Handler(Lists.isInvalidStart, closeOutLists, 'invalid list so close lists'), - Handler(Lists.isSpecial, specialList, 'special list'), - Handler(Markers.isEnd, Spans.deferAndPop, 'closing marker'), - Handler(Markers.isStart, Spans.deferAndPush, 'starting marker'), - Handler(Tags.isStart, startTag, 'starting tag') - ], closeOutLists); - - return result; - }; - - return { - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.SkipEmptyParaState', - - [ - 'ephox.pastiche.inspect.Browser', - 'ephox.pastiche.inspect.Logic', - 'ephox.pastiche.inspect.Microsoft', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.inspect.Texts', - 'ephox.pastiche.list.detect.ListDetect', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Spans', - 'ephox.pastiche.list.state.Transitions' - ], - - function (Browser, Logic, Microsoft, Tags, Texts, ListDetect, Handler, Handlers, Spans, Transitions) { - var run = function (noListState, lazyAfterListState) { - - var isFirstMarker = function (state, token) { - return Tags.isStartOf('SPAN')(state, token) && state.spanCount.get().length === 0; - }; - - var isNotList = function (state, token) { - return (Browser.supportsCustomStyles() || !ListDetect.isUnofficialList(state, token)) && !Microsoft.isList(state, token); - }; - - var skip = function (api, state, token) { - api.defer(token); - state.skippedPara.set(true); - state.openedTag.set(null); - Transitions.next(state, lazyAfterListState()); - }; - - var defer = function (api, state, token) { - api.defer(token); - }; - - return Handlers('SkipEmptyPara', [ - Handler(Logic.all([ isFirstMarker, isNotList ]), Spans.deferAndPush, 'first marker or not list'), - Handler(Tags.isEndOf('SPAN'), Spans.deferAndPop, 'end span'), - Handler(Tags.isEndOf('P'), skip, 'end p'), - Handler(Tags.isEnd, Transitions.jump(noListState), 'end tag'), - Handler(Texts.isWhitespace, defer, 'whitespace') - ], Transitions.jump(noListState)); - }; - - return { - run: run - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.stage.SpacerState', - - [ - 'ephox.pastiche.inspect.Markers', - 'ephox.pastiche.inspect.Tags', - 'ephox.pastiche.list.stage.Handler', - 'ephox.pastiche.list.stage.Handlers', - 'ephox.pastiche.list.state.Spans', - 'ephox.pastiche.list.state.Transitions', - 'ephox.peanut.Fun' - ], - - function (Markers, Tags, Handler, Handlers, Spans, Transitions, Fun) { - var run = function (closeSpansState) { - return Handlers('Spacer', [ - Handler(Markers.isEnd, Spans.popThen(closeSpansState), 'end marker'), - Handler(Tags.isEnd, Transitions.setNext(closeSpansState), 'end tag') - ], Fun.noop); - }; - - return { - run: run - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.Emission', - - [ - 'ephox.scullion.Struct' - ], - - function (Struct) { - var result = Struct.immutable('state', 'result'); - var value = Struct.immutable('state', 'value'); - var state = Struct.immutable('level', 'type', 'types', 'items'); - - return { - state: state, - value: value, - result: result - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.ItemStack', - - [ - 'ephox.pastiche.list.emit.Emission', - 'ephox.perhaps.Option' - ], - - function (Emission, Option) { - var finish = function (state) { - var stack = state.items().slice(0); - if (stack.length > 0 && stack[stack.length - 1] !== 'P') { - var item = stack[stack.length - 1]; - stack[stack.length - 1] = 'P'; - var newState = Emission.state(state.level(), state.type(), state.types(), stack); - return Emission.value(newState, Option.some(item)); - } else { - return Emission.value(state, Option.none()); - } - }; - - var start = function (state, tag) { - var stack = state.items().slice(0); - var value = tag !== undefined && tag !== 'P' ? Option.some(tag) : Option.none(); - - value.fold(function () { - stack.push('P'); - }, function (v) { - stack.push(v); - }); - - var newState = Emission.state(state.level(), state.type(), state.types(), stack); - return Emission.value(newState, value); - }; - - return { - start: start, - finish: finish - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.ListLevels', - - [ - 'ephox.pastiche.list.emit.Emission' - ], - - function (Emission) { - var moveUntil = function (state, predicate, f) { - var tokens = []; - - var current = state; - while (predicate(current)) { - var acc = f(current); - current = acc.state(); - tokens = tokens.concat(acc.result()); - } - return Emission.result(current, tokens); - }; - - var moveRight = function (state, level, open) { - var predicate = function (s) { - return s.level() < level; - }; - - return moveUntil(state, predicate, open); - }; - - var moveLeft = function (state, level, close) { - var predicate = function (state) { - return state.level() > level; - }; - - return moveUntil(state, predicate, close); - }; - - return { - moveRight: moveRight, - moveLeft: moveLeft, - moveUntil: moveUntil - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.ListItemStyles', - - [ - 'ephox.pastiche.engine.TokenUtil' - ], - - function (TokenUtil) { - - var unsafeFrom = function (token) { - var leftMargin = TokenUtil.getStyle(token, 'margin-left'); - return leftMargin !== undefined && leftMargin !== '0px' ? { 'margin-left': leftMargin } : {}; - }; - - var from = function (token) { - var noToken = { - 'list-style-type': 'none' - }; - - return !token ? noToken : unsafeFrom(token); - }; - - return { - from: from - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.SkippedTokens', - - [ - 'ephox.pastiche.engine.Token', - 'ephox.peanut.Fun' - ], - - function (Token, Fun) { - var para = function (doc) { - return [ - Fun.curry(Token.createStartElement, 'P', {}, {}), - Fun.curry(Token.createText, '\u00A0'), - Fun.curry(Token.createEndElement, 'P') - ]; - }; - - return { - para: para - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.ListTokens', - - [ - 'ephox.pastiche.cleanup.Cleaners', - 'ephox.pastiche.engine.Token', - 'ephox.pastiche.list.detect.ListTypes', - 'ephox.pastiche.list.emit.Emission', - 'ephox.pastiche.list.emit.ItemStack', - 'ephox.pastiche.list.emit.ListItemStyles', - 'ephox.pastiche.list.emit.SkippedTokens', - 'ephox.peanut.Fun' - ], - - function (Cleaners, Token, ListTypes, Emission, ItemStack, ListItemStyles, SkippedTokens, Fun) { - var open = function(state, type, style) { - var attributes = type.start && type.start > 1 ? { start: type.start } : {}; - var level = state.level() + 1; - var listType = type; - var listTypes = state.types().concat([type]); - var result = [ Fun.curry(Token.createStartElement, type.tag, attributes, style) ]; - var newState = Emission.state(level, listType, listTypes, state.items()); - return Emission.result(newState, result); - }; - - var close = function(state) { - var listTypes = state.types().slice(0); - var result = [ Fun.curry(Token.createEndElement, listTypes.pop().tag) ]; - var level = state.level() - 1; - var listType = listTypes[listTypes.length - 1]; - var newState = Emission.state(level, listType, listTypes, state.items()); - return Emission.result(newState, result); - }; - - var shuffle = function (state, type, skippedPara) { - var e1 = close(state); - var extra = skippedPara ? SkippedTokens.para() : []; - var e2 = open(e1.state(), type, type.type ? { 'list-style-type': type.type } : {}); - return Emission.result(e2.state(), e1.result().concat(extra).concat(e2.result())); - }; - - var openItem = function(state, paragraphToken, type, skippedPara) { - var attributes = {}; - var style = ListItemStyles.from(paragraphToken); - - var e1 = state.type() && !ListTypes.eqListType(state.type(), type) ? - shuffle(state, type, skippedPara) : - Emission.result(state, []); - var tokens = [ Fun.curry(Token.createStartElement, 'LI', attributes, style) ]; - - var e2 = ItemStack.start(e1.state(), paragraphToken && paragraphToken.tag()); - var moreTokens = e2.value().map(function (v) { - Cleaners.styleDom(paragraphToken.getNode(), Fun.constant(true)); - return [ Fun.constant(paragraphToken) ]; - }).getOr([]); - - return Emission.result(e2.state(), e1.result().concat(tokens).concat(moreTokens)); - }; - - var closeItem = function(state) { - var li = Fun.curry(Token.createEndElement, 'LI'); - var e1 = ItemStack.finish(state); - var r = e1.value().fold(function () { - return [ li ]; - }, function (item) { - return [ Fun.curry(Token.createEndElement, item), li ]; - }); - return Emission.result(e1.state(), r); - }; - - return { - open: open, - openItem: openItem, - close: close, - closeItem: closeItem - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.ListModel', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.engine.Token', - 'ephox.pastiche.list.emit.Emission', - 'ephox.pastiche.list.emit.ItemStack', - 'ephox.pastiche.list.emit.ListLevels', - 'ephox.pastiche.list.emit.ListTokens', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option' - ], - - function (Arr, Token, Emission, ItemStack, ListLevels, ListTokens, Fun, Option) { - var compose = function (emissions) { - if (emissions.length === 0) throw 'Compose must have at least one element in the list'; - var last = emissions[emissions.length - 1]; - var tokens = Arr.bind(emissions, function (emission) { - return emission.result(); - }); - return Emission.result(last.state(), tokens); - }; - - var closeLevel = function (state) { - var e1 = ListTokens.closeItem(state); - var e2 = ListTokens.close(e1.state()); - return compose([ e1, e2 ]); - }; - - var openLevel = function (state, type, level, paragraphToken) { - var style = state.level() === level - 1 && type.type ? { 'list-style-type': type.type } : {}; - var e1 = ListTokens.open(state, type, style); - var e2 = ListTokens.openItem(e1.state(), e1.state().level() == level ? paragraphToken : undefined, type); - return compose([ e1, e2 ]); - }; - - var sameLevel = function (state, type, paragraphToken, skippedPara) { - var e1 = state.level() > 0 ? ListTokens.closeItem(state) : Emission.result(state, []); - var e2 = ListTokens.openItem(e1.state(), paragraphToken, type, skippedPara); - return compose([ e1, e2 ]); - }; - - var openLevels = function (state, type, level, paragraphToken) { - return ListLevels.moveRight(state, level, function (s) { - return openLevel(s, type, level, paragraphToken); - }); - }; - - var closeLevels = function (state, level) { - return ListLevels.moveLeft(state, level, closeLevel); - }; - - var jumpToLevel = function (state, type, level, paragraphToken) { - var e1 = level > 1 ? ItemStack.finish(state) : Emission.value(state, Option.none()); - var tokens = e1.value().map(function (tag) { - return [ Fun.curry(Token.createEndElement, tag) ]; - }).getOr([]); - - var numLevels = level - e1.state().level(); - var e2 = openLevels(e1.state(), type, level, paragraphToken); - return Emission.result(e2.state(), tokens.concat(e2.result())); - }; - - var openItem = function(state, level, paragraphToken, type, skippedPara) { - var e1 = state.level() > level ? closeLevels(state, level) : Emission.result(state, []); - var e2 = e1.state().level() === level ? - sameLevel(e1.state(), type, paragraphToken, skippedPara) : - jumpToLevel(e1.state(), type, level, paragraphToken); - return compose([ e1, e2 ]); - }; - - var closeAllLists = closeLevels; - - return { - openItem: openItem, - closeAllLists: closeAllLists - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.emit.Emitter', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.list.emit.Emission', - 'ephox.pastiche.list.emit.ListModel' - ], - - function (Arr, Emission, ListModel) { - var impliedULatLevel = [ 'disc', 'circle', 'square' ]; - - var removeImpliedListType = function(type, level) { - if (type.tag === 'UL') { - if (impliedULatLevel[level - 1] === type.type) { - type = { tag: 'UL' }; - } - } - return type; - }; - - return function (api, doc) { - - var state = Emission.state(0, undefined, [], []); - - var emit = function (emission) { - Arr.each(emission.result(), function (x) { - var token = x(doc); - api.emit(token); - }); - }; - - var closeAllLists = function() { - var e1 = ListModel.closeAllLists(state, 0); - state = e1.state(); - emit(e1); - api.commit(); - }; - - var openItem = function(level, paragraphToken, type, skippedPara) { - var style = {}, token; - if (!type) return; - var cleanType = removeImpliedListType(type, level); - var e1 = ListModel.openItem(state, level, paragraphToken, cleanType, skippedPara); - state = e1.state(); - emit(e1); - }; - - var getCurrentLevel = function() { - return state.level(); - }; - var getCurrentListType = function() { - return state.type(); - }; - - return { - closeAllLists: closeAllLists, - openItem: openItem, - getCurrentListType: getCurrentListType, - getCurrentLevel: getCurrentLevel - }; - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.indent.ListIndent', - - [ - 'ephox.compass.Arr', - 'ephox.pastiche.engine.TokenUtil', - 'ephox.violin.Strings', - 'global!Math' - ], - - function (Arr, TokenUtil, Strings, Math) { - var getLeftOffset = function(node, paragraph) { - var parent, child, offset = 0; - parent = node.parentNode; - while (parent !== null && parent !== paragraph.parentNode) { - offset += parent.offsetLeft; - parent = parent.offsetParent; - } - return offset; - }; - - var ephoxGetComputedStyle = function(node) { - if (node.ownerDocument.defaultView) { - return node.ownerDocument.defaultView.getComputedStyle(node, null); - } - return node.currentStyle || {}; - }; - - - /** A simplified memoize function which only supports one or two function parameters. - * - * @param fn - * @param param the funtion p - * @returns - */ - var memoize2 = function(fn) { - var cache = {}; - return function(param1, param2) { - var result, key = param1 + "," + param2; - if (cache.hasOwnProperty(key)) { - return cache[key]; - } - result = fn.call(null, param1, param2); - cache[key] = result; - return result; - }; - }; - - var findStyles = memoize2(function(css, className) { - var results, matcher = /([^{]+){([^}]+)}/g, match, el, computedStyle; - matcher.lastIndex = 0; // Firefox Mac reuses the same regex so we need to reset it. - while ((results = matcher.exec(css)) !== null && !match) { - Arr.each(results[1].split(','), function(selector) { - var dotIndex = selector.indexOf('.'); - if (dotIndex >= 0 && Strings.trim(selector.substring(dotIndex + 1)) === className) { - match = results[2]; - return false; - } - }); - } - if (match) { - el = document.createElement('p'); - el.setAttribute("style", match); - computedStyle = ephoxGetComputedStyle(el); - return computedStyle ? "" + computedStyle.marginLeft : false; - } - return false; - }); - - var indentGuesser = function() { - - var listIndentAdjust; - var listIndentAmount; - var guessIndentLevel = function(currentToken, token, styles, bulletInfo) { - var indentAmount, itemIndent, el, level = 1; - - if (bulletInfo && /^([0-9]+\.)+[0-9]+\.?$/.test(bulletInfo.text)) { - // Outline list type so we can just count the number of sections. - return bulletInfo.text.replace(/([0-9]+|\.$)/g, '').length + 1; - } - indentAmount = listIndentAmount || parseInt(findStyles(styles, TokenUtil.getAttribute(token, 'class'))); - - itemIndent = getLeftOffset(currentToken.getNode(), token.getNode()); - if (!indentAmount) { - indentAmount = 48; - } else { - // We might get a 0 item indent if the list CSS code wasn't pasted as happens on Windows. - if (listIndentAdjust) { - itemIndent += listIndentAdjust; - } else if (itemIndent === 0) { - listIndentAdjust = indentAmount; - itemIndent += indentAmount; - } - } - listIndentAmount = indentAmount = Math.min(itemIndent, indentAmount); - level = Math.max(1, Math.floor(itemIndent / indentAmount)) || 1; - return level; - }; - return { - guessIndentLevel: guessIndentLevel - }; - }; - - return { - indentGuesser: indentGuesser - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.state.ListStyles', - - [ - 'ephox.pastiche.engine.Token' - ], - - function (Token) { - return function () { - var inStyle = false; - var styles = ""; - var check = function(token) { - if (inStyle && token.type() === Token.TEXT_TYPE) { - styles += token.text(); - return true; - } else if (token.type() === Token.START_ELEMENT_TYPE && token.tag() === 'STYLE') { - inStyle = true; - return true; - } else if (token.type() === Token.END_ELEMENT_TYPE && token.tag() === 'STYLE') { - inStyle = false; - return true; - } - return false; - }; - return { - check: check - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.scullion.Cell', - - [ - ], - - function () { - var Cell = function (initial) { - var value = initial; - - var get = function () { - return value; - }; - - var set = function (v) { - value = v; - }; - - var clone = function () { - return Cell(get()); - }; - - return { - get: get, - set: set, - clone: clone - }; - }; - - return Cell; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.list.state.ListState', - - [ - 'ephox.pastiche.list.emit.Emitter', - 'ephox.pastiche.list.indent.ListIndent', - 'ephox.pastiche.list.state.ListStyles', - 'ephox.peanut.Fun', - 'ephox.scullion.Cell' - ], - - function (Emitter, ListIndent, ListStyles, Fun, Cell) { - - var indentGuesser = ListIndent.indentGuesser(); - var styles = ListStyles(); - - - var emitter = { - getCurrentListType: function () { - return lazyEmitter().getCurrentListType(); - }, - getCurrentLevel: function () { - return lazyEmitter().getCurrentLevel(); - }, - closeAllLists: function () { - return lazyEmitter().closeAllLists.apply(undefined, arguments); - }, - openItem: function () { - return lazyEmitter().openItem.apply(undefined, arguments); - } - }; - - var lazyEmitter = function () { - return { - getCurrentListType: Fun.constant({}), - getCurrentLevel: Fun.constant(1), - closeAllLists: Fun.identity, - openItem: Fun.identity - }; - }; - - return function (initialState) { - var nextFilter = Cell(initialState); - var itemLevel = Cell(0); - var originalToken = Cell(null); - var commentMode = Cell(false); - var openedTag = Cell(null); - var symbolFont = Cell(false); - var listType = Cell(null); - var spanCount = Cell([]); - var skippedPara = Cell(false); - var styleLevelAdjust = Cell(0); - var bulletInfo = Cell(undefined); - var logger = Cell([]); - - var reset = function (api) { - nextFilter.set(initialState); - itemLevel.set(0); - originalToken.set(null); - commentMode.set(false); - openedTag.set(null); - symbolFont.set(false); - listType.set(null); - spanCount.set([]); - skippedPara.set(false); - styleLevelAdjust.set(0); - bulletInfo.set(undefined); - logger.set([]); - - // ASSUMPTION: I think this approach in the past also papered over the stack needing resetting in the emitter. - _emitter = Emitter(api, api.document); - lazyEmitter = Fun.constant(_emitter); - }; - - return { - reset: reset, - nextFilter: nextFilter, - itemLevel: itemLevel, - originalToken: originalToken, - commentMode: commentMode, - openedTag: openedTag, - symbolFont: symbolFont, - listType: listType, - spanCount: spanCount, - skippedPara: skippedPara, - styleLevelAdjust: styleLevelAdjust, - bulletInfo: bulletInfo, - logger: logger, - - emitter: emitter, - styles: styles, - indentGuesser: indentGuesser - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.pastiche.filter.Lists', - - [ - 'ephox.pastiche.engine.Filter', - 'ephox.pastiche.list.detect.ListTypes', - 'ephox.pastiche.list.stage.AfterListState', - 'ephox.pastiche.list.stage.AfterNoBulletListState', - 'ephox.pastiche.list.stage.BeforeSpacerState', - 'ephox.pastiche.list.stage.CloseSpansState', - 'ephox.pastiche.list.stage.FindListTypeState', - 'ephox.pastiche.list.stage.ItemContentState', - 'ephox.pastiche.list.stage.ListStartState', - 'ephox.pastiche.list.stage.NoListState', - 'ephox.pastiche.list.stage.SkipEmptyParaState', - 'ephox.pastiche.list.stage.SpacerState', - 'ephox.pastiche.list.state.ListState', - 'ephox.pastiche.list.state.Transitions' - ], - - function (Filter, ListTypes, AfterListState, AfterNoBulletListState, BeforeSpacerState, CloseSpansState, FindListTypeState, ItemContentState, ListStartState, NoListState, SkipEmptyParaState, SpacerState, ListState, Transitions) { - var unexpectedToken = function(api, token) { - var info = 'Type: ' + token.type() + ', Tag: ' + token.tag() + ' Text: ' + token.text(); - console.log('Unexpected token in list conversion: ' + info, activeState.nextFilter.get()); - api.rollback(); - }; - - var noListState = NoListState.run(function () { - return listStartState; - }); - var skipEmptyParaState = SkipEmptyParaState.run(noListState, function () { - return afterListState; - }); - var afterListState = AfterListState.run(skipEmptyParaState, noListState); - var itemContentState = ItemContentState.run(afterListState); - var closeSpansState = CloseSpansState.run(itemContentState, unexpectedToken); - var spacerState = SpacerState.run(closeSpansState); - var beforeSpacerState = BeforeSpacerState.run(spacerState, closeSpansState, unexpectedToken); - var findListTypeState = FindListTypeState.run(beforeSpacerState, unexpectedToken); - var afterNoBulletListState = AfterNoBulletListState.run(afterListState); - var listStartState = ListStartState.run(findListTypeState, afterNoBulletListState, unexpectedToken); - - var activeState = ListState(noListState); - - var receive = function(api, token) { - if (activeState.styles && activeState.styles.check(token)) { - return; - } - - activeState.symbolFont.set(ListTypes.checkFont(token, activeState.symbolFont.get())); - Transitions.go(api, activeState, token); - }; - - return Filter.createFilter(receive, activeState.reset, 'lists'); - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.limbo.process.Strategies', - - [ - 'ephox.pastiche.api.HtmlPatterns', - 'ephox.pastiche.api.HybridAction', - 'ephox.pastiche.api.RuleConditions', - 'ephox.pastiche.api.RuleMutations', - 'ephox.pastiche.filter.Lists', - 'ephox.peanut.Fun', - 'ephox.sugar.api.Class', - 'ephox.sugar.api.Css', - 'ephox.violin.StringMatch' - ], - - function (HtmlPatterns, HybridAction, RuleConditions, RuleMutations, Lists, Fun, Class, Css, StringMatch) { - // This will UNWRAP! tags such as and - // Context: Word copy and paste. - var unwrapWordTags = HybridAction.unwrapper({ - tags: [ - { name: StringMatch.pattern(/^([OVWXP]|U[0-9]+|ST[0-9]+):/i) } - ] - }); - - // This will try and turn p tags into ol,ul and li tags where appropriate - // Context: Word copy and paste. - var parseLists = HybridAction.pipeline([ Lists ]); - - // This will remove attributes matching: v:.., href with #_toc|#_mso, xmlns:, align - // and type on lists. - // Context: Word copy and paste. - var removeWordAttributes = HybridAction.removal({ - attributes: [ - { name: StringMatch.pattern(/^v:/) }, - { name: StringMatch.exact('href'), value: StringMatch.contains('#_toc') }, - { name: StringMatch.exact('href'), value: StringMatch.contains('#_mso') }, - { name: StringMatch.pattern(/^xmlns(:|$)/) }, - { name: StringMatch.exact('align') }, - { name: StringMatch.exact('type'), condition: RuleConditions.isList } - ] - }); - - // This will remove script,meta,link,empty-style tags and on,id,name,lang attributes - // or styles containing OLE_LINK - // Context: All - var removeExcess = HybridAction.removal({ - tags: [ - { name: StringMatch.exact('script') }, - { name: StringMatch.exact('meta') }, - { name: StringMatch.exact('link') }, - { name: StringMatch.exact('style'), condition: RuleConditions.isEmpty } - ], - attributes: [ - { name: StringMatch.starts('on') }, - { name: StringMatch.exact('"') }, - { name: StringMatch.exact('id') }, - { name: StringMatch.exact('name') }, - { name: StringMatch.exact('lang') }, - { name: StringMatch.exact('language') } - // INVESTIGATE: Should language go here as well ? - ], - styles: [ - { name: StringMatch.all(), value: StringMatch.pattern(/OLE_LINK/i) } - ] - }); - - var isNotTransformed = function (element) { - return !Class.has(element, 'ephox-limbo-transform'); - }; - - // This will remove any styles that are not list-style-type for all tags, and keep the width and height - // styles only for images. - // Context: Clean copy and paste. - var cleanStyles = HybridAction.removal({ - styles: [ - { - name: StringMatch.not( - StringMatch.pattern(/width|height|list-style-type/) - ), - condition: isNotTransformed - }, - { name: StringMatch.pattern(/width|height/), condition: RuleConditions.isNotImage } - ] - }); - - // This will remove all classes that are not 'rtf-data-image' - // Context: Clean copy and paste. - var cleanClasses = HybridAction.removal({ - classes: [ - { - name: StringMatch.not( - StringMatch.exact('rtf-data-image') - ) - } - ] - }); - - // This will remove all styles that are not considered valid. - // Context: Merge copy and paste. - var mergeStyles = HybridAction.removal({ - styles: [ - { name: StringMatch.pattern(HtmlPatterns.validStyles()) } - ] - }); - - // This will remove all classes that have mso in them. - // Context: Merge copy and paste. - var mergeClasses = HybridAction.removal({ - classes: [ - { name: StringMatch.pattern(/mso/i) } - ] - }); - - // This will remove (unwrap) all images that have a file protocol - // Context: Copy and paste with images. - var removeLocalImages = HybridAction.unwrapper({ - tags: [ - { name: StringMatch.exact('img'), condition: RuleConditions.isLocal }, - // OLE_LINK exact part. - { name: StringMatch.exact('a'), condition: RuleConditions.hasNoAttributes } - ] - }); - - // This will unwrap any tags that have no attributes (i.e. are essentially useless) - // Context: Any - var removeVacantLinks = HybridAction.unwrapper({ - tags: [ - { name: StringMatch.exact('a'), condition: RuleConditions.hasNoAttributes } - ] - }); - - // This will remove any style attribute that has no content. - // Context: Any - var removeEmptyStyle = HybridAction.removal({ - attributes: [ - { name: StringMatch.exact('style'), value: StringMatch.exact(''), debug: true } - ] - }); - - // This will remove any style attribute that has no content. - // Context: Any - var removeEmptyClass = HybridAction.removal({ - attributes: [ - { name: StringMatch.exact('class'), value: StringMatch.exact(''), debug: true } - ] - }); - - // This will remove any inline elements that no longer serve a purpose: - // Fancy inline elements: contain no content - // Span inline elements: have no attributes - // Context: Any - var pruneInlineTags = HybridAction.unwrapper({ - tags: [ - { - name: StringMatch.pattern(HtmlPatterns.specialInline()), - condition: Fun.not(RuleConditions.hasContent) - } - ] - }); - - var addPlaceholders = HybridAction.transformer({ - tags: [ - { name: StringMatch.exact('p'), mutate: RuleMutations.addBrTag } - ] - }); - - var toUnderline = function (element) { - var span = RuleMutations.changeTag('span', element); - Class.add(span, 'ephox-limbo-transform'); - Css.set(span, 'text-decoration', 'underline'); - }; - - var nestedListFixes = HybridAction.transformer({ - tags: [ - { name: StringMatch.pattern(/ol|ul/), mutate: RuleMutations.properlyNest } - ] - }); - - var inlineTagFixes = HybridAction.transformer({ - tags: [ - { name: StringMatch.exact('b'), mutate: Fun.curry(RuleMutations.changeTag, 'strong') }, - { name: StringMatch.exact('i'), mutate: Fun.curry(RuleMutations.changeTag, 'em') }, - { name: StringMatch.exact('u'), mutate: toUnderline }, - { name: StringMatch.exact('s'), mutate: Fun.curry(RuleMutations.changeTag, 'strike') }, - { name: StringMatch.exact('font'), mutate: RuleMutations.fontToSpan, debug: true } - ] - }); - - // This will remove all classes that were put in to preserve transformations. - // Context: Any - var cleanupFlags = HybridAction.removal({ - classes: [ - { name: StringMatch.exact('ephox-limbo-transform') } - ] - }); - - // This will remove any href attributes of a tags that are local. - // Context: Any - var removeLocalLinks = HybridAction.removal({ - attributes: [ - { name: StringMatch.exact('href'), value: StringMatch.starts('file:///'), debug: true } - ] - }); - - return { - unwrapWordTags: unwrapWordTags, - removeWordAttributes: removeWordAttributes, - parseLists: parseLists, - removeExcess: removeExcess, - cleanStyles: cleanStyles, - cleanClasses: cleanClasses, - mergeStyles: mergeStyles, - mergeClasses: mergeClasses, - removeLocalImages: removeLocalImages, - removeVacantLinks: removeVacantLinks, - removeEmptyStyle: removeEmptyStyle, - removeEmptyClass: removeEmptyClass, - pruneInlineTags: pruneInlineTags, - addPlaceholders: addPlaceholders, - nestedListFixes: nestedListFixes, - inlineTagFixes: inlineTagFixes, - cleanupFlags: cleanupFlags, - removeLocalLinks: removeLocalLinks, - none: Fun.noop - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.limbo.process.PasteFilters', - - [ - 'ephox.compass.Arr', - 'ephox.limbo.api.RtfImage', - 'ephox.limbo.process.Strategies', - 'ephox.pastiche.api.HybridAction', - 'ephox.pastiche.engine.Filter', - 'ephox.pastiche.engine.Token', - 'ephox.sugar.api.Element' - ], - - function (Arr, RtfImage, Strategies, HybridAction, Filter, Token, Element) { - var isIE11 = function (platform) { - return platform.browser.isIE() && platform.browser.version.major >= 11; - }; - - var transform = function (f) { - // TODO: Move this to API in pastiche or change how this works. - // I think the reason I want to keep it in the tokenizer is because - // it needs to access comments. - return Filter.createFilter(function (api, token) { - var next = f(Element.fromDom(token.getNode())).fold(function () { - return token; - }, function (sugared) { - var node = sugared.dom(); - return Token.token(node, token.type() === Token.END_ELEMENT_TYPE, {}); - }); - api.emit(next); - }); - }; - - var images = function (isWord, merging, platform) { - var searcher = platform.browser.isFirefox() ? RtfImage.local : RtfImage.vshape; - var transformer = isIE11(platform) ? Strategies.none : HybridAction.pipeline([ transform(searcher) ]); - var local = searcher === RtfImage.local ? Strategies.none : Strategies.removeLocalImages; - var annotate = isWord ? transformer : Strategies.none; - - return { - annotate: [ annotate ], - local: [ local ] - }; - }; - - var styling = function (isWord, merging, platform) { - var merge = [ Strategies.mergeStyles, Strategies.mergeClasses ]; - var clean = [ Strategies.cleanStyles, Strategies.cleanClasses ]; - return merging ? merge : clean; - }; - - var word = function (isWord, merging, platform) { - if (!isWord) return Strategies.none; - var base = [ Strategies.unwrapWordTags ]; - var lists = isIE11(platform) ? [] : Strategies.parseLists; - return base.concat(lists); - }; - - var derive = function (isWord, merging, platform) { - var imageFilters = images(isWord, merging, platform); - - return Arr.flatten([ - imageFilters.annotate, - [ Strategies.inlineTagFixes ], - word(isWord, merging, platform), - [ Strategies.nestedListFixes ], - [ Strategies.removeExcess ], - imageFilters.local, - styling(isWord, merging, platform), - [ Strategies.removeLocalLinks, Strategies.removeVacantLinks ], - [ Strategies.removeEmptyStyle ], - [ Strategies.removeEmptyClass ], - [ Strategies.pruneInlineTags ], - [ Strategies.addPlaceholders ], - [ Strategies.cleanupFlags ] - ]); - }; - - return { - derive: derive - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.boss.common.TagBoundaries', - - [ - - ], - - function () { - // TODO: We need to consolidate this list. I think when we get rid of boss/universe, we can do it then. - return [ - 'body', - 'p', - 'div', - 'article', - 'aside', - 'figcaption', - 'figure', - 'footer', - 'header', - 'nav', - 'section', - 'ol', - 'ul', - 'li', - 'table', - 'thead', - 'tbody', - 'caption', - 'tr', - 'td', - 'th', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'blockquote', - 'pre', - 'address' - ]; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.Text', - - [ - 'ephox.sugar.api.Node', - 'ephox.sugar.impl.NodeValue' - ], - - function (Node, NodeValue) { - var api = NodeValue(Node.isText, 'text'); - - var get = function (element) { - return api.get(element); - }; - - var getOption = function (element) { - return api.getOption(element); - }; - - var set = function (element, value) { - api.set(element, value); - }; - - return { - get: get, - getOption: getOption, - set: set - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.boss.api.DomUniverse', - - [ - 'ephox.boss.common.TagBoundaries', - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Compare', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.InsertAll', - 'ephox.sugar.api.Node', - 'ephox.sugar.api.PredicateFilter', - 'ephox.sugar.api.PredicateFind', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.SelectorFilter', - 'ephox.sugar.api.SelectorFind', - 'ephox.sugar.api.Text', - 'ephox.sugar.api.Traverse' - ], - - function (TagBoundaries, Arr, Fun, Attr, Compare, Css, Element, Insert, InsertAll, Node, PredicateFilter, PredicateFind, Remove, SelectorFilter, SelectorFind, Text, Traverse) { - return function () { - var clone = function (element) { - return Element.fromDom(element.dom().cloneNode(false)); - }; - - var isBoundary = function (element) { - if (!Node.isElement(element)) return false; - if (Node.name(element) === 'body') return true; - var display = Css.get(element, 'display'); - // When the read display value is empty, we need to check the node name. - return display !== undefined && display.length > 0 ? - Arr.contains(['block', 'table-cell', 'table-row', 'table', 'list-item'], display) : - Arr.contains(TagBoundaries, Node.name(element)); - }; - - var isEmptyTag = function (element) { - if (!Node.isElement(element)) return false; - return Arr.contains(['br', 'img', 'hr'], Node.name(element)); - }; - - var comparePosition = function (element, other) { - return element.dom().compareDocumentPosition(other.dom()); - }; - - var copyAttributesTo = function (source, destination) { - var as = Attr.clone(source); - Attr.setAll(destination, as); - }; - - return { - up: Fun.constant({ - selector: SelectorFind.ancestor, - closest: SelectorFind.closest, - predicate: PredicateFind.ancestor, - all: Traverse.parents - }), - down: Fun.constant({ - selector: SelectorFilter.descendants, - predicate: PredicateFilter.descendants - }), - styles: Fun.constant({ - get: Css.get, - set: Css.set, - remove: Css.remove - }), - attrs: Fun.constant({ - get: Attr.get, - set: Attr.set, - remove: Attr.remove, - copyTo: copyAttributesTo - }), - insert: Fun.constant({ - before: Insert.before, - after: Insert.after, - afterAll: InsertAll.after, - append: Insert.append, - appendAll: InsertAll.append, - prepend: Insert.prepend, - wrap: Insert.wrap - }), - remove: Fun.constant({ - unwrap: Remove.unwrap, - remove: Remove.remove - }), - create: Fun.constant({ - nu: Element.fromTag, - clone: clone, - text: Element.fromText - }), - query: Fun.constant({ - comparePosition: comparePosition, - prevSibling: Traverse.prevSibling, - nextSibling: Traverse.nextSibling - }), - property: Fun.constant({ - children: Traverse.children, - name: Node.name, - parent: Traverse.parent, - isText: Node.isText, - isElement: Node.isElement, - getText: Text.get, - setText: Text.set, - isBoundary: isBoundary, - isEmptyTag: isEmptyTag - }), - eq: Compare.eq, - is: Compare.is - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.api.data.NamedPattern', - - [ - 'ephox.scullion.Struct' - ], - - function (Struct) { - return Struct.immutable('word', 'pattern'); - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.api.data.Spot', - - [ - 'ephox.scullion.Struct' - ], - - function (Struct) { - var point = Struct.immutable('element', 'offset'); - var delta = Struct.immutable('element', 'deltaOffset'); - var range = Struct.immutable('element', 'start', 'finish'); - var points = Struct.immutable('begin', 'end'); - var text = Struct.immutable('element', 'text'); - - return { - point: point, - delta: delta, - range: range, - points: points, - text: text - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.extract.TypedItem', - - [ - 'ephox.peanut.Fun', - 'ephox.perhaps.Option' - ], - - /** - * Church encoded ADT representing whether an element is: - * - boundary (block tag or inline tag with block CSS display) - * - empty - * - text - */ - function (Fun, Option) { - var no = Fun.constant(false); - var yes = Fun.constant(true); - - var boundary = function (item, universe) { - return folder(function (b, e, t) { - return b(item, universe); - }); - }; - - var empty = function (item, universe) { - return folder(function (b, e, t) { - return e(item, universe); - }); - }; - - var text = function (item, universe) { - return folder(function (b, e, t) { - return t(item, universe); - }); - }; - - var folder = function (fold) { - var isBoundary = function () { - return fold(yes, no, no); - }; - - var toText = function () { - return fold(Option.none, Option.none, function (item, universe) { - return Option.some(item); - }); - }; - - var is = function (other) { - return fold(no, no, function (item, universe) { - return universe.eq(item, other); - }); - }; - - var len = function () { - return fold(Fun.constant(0), Fun.constant(1), function (item, universe) { - return universe.property().getText(item).length; - }); - }; - - return { - isBoundary: isBoundary, - fold: fold, - toText: toText, - is: is, - len: len - }; - }; - - return { - text: text, - boundary: boundary, - empty: empty - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.array.Boundaries', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun' - ], - - function (Arr, Fun) { - var boundAt = function (xs, left, right, comparator) { - var leftIndex = Arr.findIndex(xs, Fun.curry(comparator, left)); - var first = leftIndex > -1 ? leftIndex : 0; - var rightIndex = Arr.findIndex(xs, Fun.curry(comparator, right)); - var last = rightIndex > -1 ? rightIndex + 1 : xs.length; - return xs.slice(first, last); - }; - - return { - boundAt: boundAt - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.array.Slice', - - [ - 'ephox.compass.Arr' - ], - - function (Arr) { - /** - * Slice an array at the first item matched by the predicate - */ - var sliceby = function (list, pred) { - var index = Arr.findIndex(list, pred); - return list.slice(0, index); - }; - - return { - sliceby: sliceby - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.array.Split', - - [ - 'ephox.compass.Arr' - ], - - function (Arr) { - /** - * Split an array into chunks matched by the predicate - */ - var splitby = function (xs, pred) { - var r = []; - var part = []; - Arr.each(xs, function (x) { - if (pred(x)) { - r.push(part); - part = []; - } else { - part.push(x); - } - }); - - if (part.length > 0) r.push(part); - return r; - }; - - return { - splitby: splitby - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.api.Arrays', - - [ - 'ephox.polaris.array.Boundaries', - 'ephox.polaris.array.Slice', - 'ephox.polaris.array.Split' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Boundaries, Slice, Split) { - var boundAt = function (xs, left, right, comparator) { - return Boundaries.boundAt(xs, left, right, comparator); - }; - - var splitby = function (array, predicate) { - return Split.splitby(array, predicate); - }; - - var sliceby = function (array, predicate) { - return Slice.sliceby(array, predicate); - }; - - return { - splitby: splitby, - sliceby: sliceby, - boundAt: boundAt - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.extract.TypedList', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option', - 'ephox.phoenix.api.data.Spot', - 'ephox.polaris.api.Arrays' - ], - - /** - * Extracts various information from a list of TypedItem - */ - function (Arr, Fun, Option, Spot, Arrays) { - - var count = function (parray) { - return Arr.foldr(parray, function (b, a) { - return a.len() + b; - }, 0); - }; - - var dropUntil = function (parray, target) { - return Arrays.sliceby(parray, function (x) { - return x.is(target); - }); - }; - - /** - * Transform a TypedItem into a range representing that item from the start position. - * - * The generation function for making a PositionArray out of a list of TypedItems. - */ - var gen = function (unit, start) { - return unit.fold(Option.none, function (e) { - return Option.some(Spot.range(e, start, start + 1)); - }, function (t) { - return Option.some(Spot.range(t, start, start + unit.len())); - }); - }; - - var justText = function (parray) { - return Arr.bind(parray, function (x) { - return x.fold(Fun.constant([]), Fun.constant([]), Fun.identity); - }); - }; - - return { - count: count, - dropUntil: dropUntil, - gen: gen, - justText: justText - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.extract.Extract', - - [ - 'ephox.compass.Arr', - 'ephox.phoenix.api.data.Spot', - 'ephox.phoenix.extract.TypedItem', - 'ephox.phoenix.extract.TypedList' - ], - - function (Arr, Spot, TypedItem, TypedList) { - /** - * Flattens the item tree into TypedItem representations. - * - * Boundaries are returned twice, before and after their children. - */ - var typed = function (universe, item, optimise) { - if (universe.property().isText(item)) { - return [ TypedItem.text(item, universe) ]; - } else if (universe.property().isEmptyTag(item)) { - return [ TypedItem.empty(item, universe) ]; - } else if (universe.property().isElement(item)) { - var children = universe.property().children(item); - var boundary = universe.property().isBoundary(item) ? [TypedItem.boundary(item, universe)] : []; - var rest = optimise !== undefined && optimise(item) ? [] : Arr.bind(children, function (child) { - return typed(universe, child, optimise); - }); - return boundary.concat(rest).concat(boundary); - } else { - return []; - } - }; - - /** - * Returns just the actual elements from a call to typed(). - */ - var items = function (universe, item, optimise) { - var typedItemList = typed(universe, item, optimise); - - var raw = function (item, universe) { return item; }; - - return Arr.map(typedItemList, function (typedItem) { - return typedItem.fold(raw, raw, raw); - }); - }; - - var extractToElem = function (universe, child, offset, item, optimise) { - var extractions = typed(universe, item, optimise); - var prior = TypedList.dropUntil(extractions, child); - var count = TypedList.count(prior); - return Spot.point(item, count + offset); - }; - - /** - * Generates an absolute point in the child's parent - * that can be used to reference the offset into child later. - * - * To find the exact reference later, use Find. - */ - var extract = function (universe, child, offset, optimise) { - return universe.property().parent(child).fold(function () { - return Spot.point(child, offset); - }, function (parent) { - return extractToElem(universe, child, offset, parent, optimise); - }); - }; - - /** - * Generates an absolute point that can be used to reference the offset into child later. - * This absolute point will be relative to a parent node (specified by predicate). - * - * To find the exact reference later, use Find. - */ - var extractTo = function (universe, child, offset, pred, optimise) { - return universe.up().predicate(child, pred).fold(function () { - return Spot.point(child, offset); - }, function (v) { - return extractToElem(universe, child, offset, v, optimise); - }); - }; - - return { - typed: typed, - items: items, - extractTo: extractTo, - extract: extract - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.extract.ExtractText', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.phoenix.extract.Extract' - ], - - function (Arr, Fun, Extract) { - var newline = '\n'; - var space = ' '; - - var onEmpty = function (item, universe) { - return universe.property().name(item) === 'img' ? space : newline; - }; - - var from = function (universe, item, optimise) { - var typed = Extract.typed(universe, item, optimise); - return Arr.map(typed, function (t) { - return t.fold(Fun.constant(newline), onEmpty, universe.property().getText); - }).join(''); - }; - - return { - from: from - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.parray.Generator', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun' - ], - - function (Arr, Fun) { - - /** - * Generate a PositionArray - * - * xs: list of thing - * f: thing -> Optional unit - * _start: sets the start position to search at - */ - var make = function (xs, f, _start) { - - var init = { - len: _start !== undefined ? _start : 0, - list: [] - }; - - var r = Arr.foldl(xs, function (b, a) { - var value = f(a, b.len); - return value.fold(Fun.constant(b), function (v) { - return { - len: v.finish(), - list: b.list.concat([v]) - }; - }); - }, init); - - return r.list; - }; - - return { - make: make - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.parray.Query', - - [ - 'ephox.compass.Arr', - 'ephox.perhaps.Option' - ], - - function (Arr, Option) { - - /** - * Simple "is position within unit" utility function - */ - var inUnit = function (unit, position) { - return position >= unit.start() && position <= unit.finish(); - }; - - /** - * Finds the unit in the PositionArray that contains this offset (if there is one) - */ - var get = function (parray, offset) { - var unit = Arr.find(parray, function (x) { - return inUnit(x, offset); - }); - - return Option.from(unit); - }; - - var startindex = function (parray, offset) { - return Arr.findIndex(parray, function (unit) { - return unit.start() === offset; - }); - }; - - var tryend = function (parray, finish) { - var finishes = parray[parray.length - 1] && parray[parray.length - 1].finish() === finish; - return finishes ? parray.length + 1 : -1; - }; - - - /** - * Extracts the pieces of the PositionArray that are bounded *exactly* on the start and finish offsets - */ - var sublist = function (parray, start, finish) { - var first = startindex(parray, start); - var rawlast = startindex(parray, finish); - var last = rawlast > -1 ? rawlast : tryend(parray, finish); - - return first > -1 && last > -1 ? parray.slice(first, last) : []; - }; - - var find = function (parray, pred) { - return Option.from(Arr.find(parray, pred)); - }; - - return { - get: get, - find: find, - inUnit: inUnit, - sublist: sublist - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.parray.Translate', - - [ - 'ephox.compass.Arr', - 'ephox.highway.Merger', - 'ephox.peanut.Fun' - ], - - function (Arr, Merger, Fun) { - /** Adjust a PositionArray positions by an offset */ - var translate = function (parray, offset) { - return Arr.map(parray, function (unit) { - return Merger.merge(unit, { - start: Fun.constant(unit.start() + offset), - finish: Fun.constant(unit.finish() + offset) - }); - }); - }; - - return { - translate: translate - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.parray.Split', - - [ - 'ephox.compass.Arr', - 'ephox.polaris.parray.Query', - 'ephox.polaris.parray.Translate' - ], - - function (Arr, Query, Translate) { - /** - * After subdivide has split the unit, update the resulting PositionArray based on the unit start position. - */ - var divide = function (unit, positions, subdivide) { - var mini = subdivide(unit, positions); - return Translate.translate(mini, unit.start()); - }; - - /** - * Adds extra split points into a PositionArray, using subdivide to split if necessary - */ - var splits = function (parray, positions, subdivide) { - if (positions.length === 0) return parray; - - return Arr.bind(parray, function (unit) { - var relevant = Arr.bind(positions, function (pos) { - return Query.inUnit(unit, pos) ? [ pos - unit.start() ] : []; - }); - - return relevant.length > 0 ? divide(unit, relevant, subdivide) : [ unit ]; - }); - }; - - return { - splits: splits - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.api.PositionArray', - - [ - 'ephox.polaris.parray.Generator', - 'ephox.polaris.parray.Query', - 'ephox.polaris.parray.Split', - 'ephox.polaris.parray.Translate' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Generator, Query, Split, Translate) { - var generate = function (items, generator, _start) { - return Generator.make(items, generator, _start); - }; - - var get = function (parray, offset) { - return Query.get(parray, offset); - }; - - var find = function (parray, pred) { - return Query.find(parray, pred); - }; - - var splits = function (parray, positions, subdivide) { - return Split.splits(parray, positions, subdivide); - }; - - var translate = function (parray, amount) { - return Translate.translate(parray, amount); - }; - - var sublist = function (parray, start, finish) { - return Query.sublist(parray, start, finish); - }; - - return { - generate: generate, - get: get, - find: find, - splits: splits, - translate: translate, - sublist: sublist - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.extract.Find', - - [ - 'ephox.phoenix.api.data.Spot', - 'ephox.phoenix.extract.Extract', - 'ephox.phoenix.extract.TypedList', - 'ephox.polaris.api.PositionArray' - ], - - function (Spot, Extract, TypedList, PositionArray) { - - /** - * Finds an exact reference to a document point generated by Extract - */ - var find = function (universe, parent, offset, optimise) { - var extractions = Extract.typed(universe, parent, optimise); - - var parray = PositionArray.generate(extractions, TypedList.gen); - var spot = PositionArray.get(parray, offset); - return spot.map(function (v) { - return Spot.point(v.element(), offset - v.start()); - }); - }; - - return { - find: find - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.api.general.Extract', - - [ - 'ephox.phoenix.extract.Extract', - 'ephox.phoenix.extract.ExtractText', - 'ephox.phoenix.extract.Find' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Extract, ExtractText, Find) { - - var from = function (universe, item, optimise) { - return Extract.typed(universe, item, optimise); - }; - - var all = function (universe, item, optimise) { - return Extract.items(universe, item, optimise); - }; - - var extract = function (universe, child, offset, optimise) { - return Extract.extract(universe, child, offset, optimise); - }; - - var extractTo = function (universe, child, offset, pred, optimise) { - return Extract.extractTo(universe, child, offset, pred, optimise); - }; - - var find = function (universe, parent, offset, optimise) { - return Find.find(universe, parent, offset, optimise); - }; - - var toText = function (universe, item, optimise) { - return ExtractText.from(universe, item, optimise); - }; - - return { - extract: extract, - extractTo: extractTo, - all: all, - from: from, - find: find, - toText: toText - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.family.Group', - - [ - 'ephox.compass.Arr', - 'ephox.phoenix.api.general.Extract', - 'ephox.polaris.api.Arrays' - ], - - function (Arr, Extract, Arrays) { - /** - * Return an array of arrays split by boundaries - */ - var group = function (universe, items, optimise) { - var extractions = Arr.bind(items, function (item) { - return Extract.from(universe, item, optimise); - }); - - var segments = Arrays.splitby(extractions, function (item) { - return item.isBoundary(); - }); - - return Arr.filter(segments, function (x) { return x.length > 0; }); - }; - - return { - group: group - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.family.Parents', - - [ - 'ephox.compass.Arr', - 'ephox.perhaps.Option' - ], - - function (Arr, Option) { - /** - * Search the parents of both items for a common element - */ - var common = function (universe, item1, item2) { - var item1parents = [item1].concat(universe.up().all(item1)); - var item2parents = [item2].concat(universe.up().all(item2)); - - var r = Arr.find(item1parents, function (x) { - return Arr.exists(item2parents, function (y) { - return universe.eq(y, x); - }); - }); - - return Option.from(r); - }; - - return { - common: common - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.wrap.OrphanText', - - [ - 'ephox.compass.Arr' - ], - - function (Arr) { - // Textnodes cannot be children of these tags - var textBlacklist = [ 'table', 'tbody', 'thead', 'tfoot', 'tr', 'ul', 'ol' ]; - - return function (universe) { - var domUtils = universe.property(); - var validateParent = function (node, blacklist) { - return domUtils.parent(node).map(domUtils.name).map(function (name) { - return !Arr.contains(blacklist, name); - }).getOr(false); - }; - - var validateText = function (textNode) { - return domUtils.isText(textNode) && validateParent(textNode, textBlacklist); - }; - - return { - validateText: validateText - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.family.Range', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.phoenix.api.general.Extract', - 'ephox.phoenix.family.Parents', - 'ephox.phoenix.wrap.OrphanText' - ], - - function (Arr, Fun, Extract, Parents, OrphanText) { - var index = function (universe, items, item) { - return Arr.findIndex(items, Fun.curry(universe.eq, item)); - }; - - var order = function (items, a, delta1, b, delta2) { - return a < b ? items.slice(a + delta1, b + delta2) : items.slice(b + delta2, a + delta1); - }; - - /** - * Returns a flat array of text nodes between two defined nodes. - * - * Deltas are a broken concept. They control whether the item passed is included in the result. - */ - var range = function (universe, item1, delta1, item2, delta2) { - if (universe.eq(item1, item2)) return [item1]; - - return Parents.common(universe, item1, item2).fold(function () { - return []; // no common parent, therefore no intervening path. How does this clash with Path in robin? - }, function (parent) { - var items = [ parent ].concat(Extract.all(universe, parent, Fun.constant(false))); - var start = index(universe, items, item1); - var finish = index(universe, items, item2); - var result = start > -1 && finish > -1 ? order(items, start, delta1, finish, delta2) : []; - var orphanText = OrphanText(universe); - return Arr.filter(result, orphanText.validateText); - }); - }; - - return { - range: range - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.api.general.Family', - - [ - 'ephox.phoenix.family.Group', - 'ephox.phoenix.family.Range' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Group, Range) { - var range = function (universe, start, startDelta, finish, finishDelta) { - return Range.range(universe, start, startDelta, finish, finishDelta); - }; - - var group = function (universe, items, optimise) { - return Group.group(universe, items, optimise); - }; - - return { - range: range, - group: group - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.string.Sanitise', - - [ - - ], - - function () { - /** - * Sanitises a string for use in a CSS class name - */ - var css = function (str) { - // special case; the first character must a letter. More strict than CSS, but easier to implement. - var r = /^[a-zA-Z]/.test(str) ? '' : 'e'; - - // any non-word character becomes a hyphen - var sanitised = str.replace(/[^\w]/gi, '-'); - - return r + sanitised; - }; - - return { - css: css - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.string.Split', - - [ - 'ephox.compass.Arr' - ], - - function (Arr) { - /** - * Splits a string into multiple chunks - */ - var splits = function (value, indices) { - if (indices.length === 0) return [value]; - - var divisions = Arr.foldl(indices, function (acc, x) { - if (x === 0) return acc; - - var part = value.substring(acc.prev, x); - return { - prev: x, - values: acc.values.concat([part]) - }; - }, { prev: 0, values: [] }); - - var lastPoint = indices[indices.length - 1]; - return lastPoint < value.length ? divisions.values.concat(value.substring(lastPoint)) : divisions.values; - }; - - return { - splits: splits - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.api.Strings', - - [ - 'ephox.polaris.string.Sanitise', - 'ephox.polaris.string.Split' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Sanitise, Split) { - var splits = function (text, points) { - return Split.splits(text, points); - }; - - var cssSanitise = function (str) { - return Sanitise.css(str); - }; - - return { - cssSanitise: cssSanitise, - splits: splits - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.search.Splitter', - - [ - 'ephox.compass.Arr', - 'ephox.perhaps.Option', - 'ephox.phoenix.api.data.Spot', - 'ephox.polaris.api.PositionArray', - 'ephox.polaris.api.Strings' - ], - - function (Arr, Option, Spot, PositionArray, Strings) { - - /** - * Re-generates an item's text nodes, split as defined by the positions array. - * - * Returns a PositionArray of the result. - */ - var subdivide = function (universe, item, positions) { - var text = universe.property().getText(item); - var pieces = Arr.filter(Strings.splits(text, positions), function (section) { - return section.length > 0; - }); - - if (pieces.length <= 1) return [ Spot.range(item, 0, text.length) ]; - universe.property().setText(item, pieces[0]); - - var others = PositionArray.generate(pieces.slice(1), function (a, start) { - var nu = universe.create().text(a); - var result = Spot.range(nu, start, start + a.length); - return Option.some(result); - }, pieces[0].length); - - var otherElements = Arr.map(others, function (a) { return a.element(); }); - universe.insert().afterAll(item, otherElements); - - return [ Spot.range(item, 0, pieces[0].length) ].concat(others); - }; - - return { - subdivide: subdivide - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.search.MatchSplitter', - - [ - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.phoenix.search.Splitter', - 'ephox.polaris.api.PositionArray' - ], - - function (Arr, Fun, Splitter, PositionArray) { - /** - * Split each text node in the list using the match endpoints. - * - * Each match is then mapped to the word it matched and the elements that make up the word. - */ - var separate = function (universe, list, matches) { - var allPositions = Arr.bind(matches, function (match) { - return [ match.start(), match.finish() ]; - }); - - var subdivide = function (unit, positions) { - return Splitter.subdivide(universe, unit.element(), positions); - }; - - var structure = PositionArray.splits(list, allPositions, subdivide); - - var collate = function (match) { - var sub = PositionArray.sublist(structure, match.start(), match.finish()); - - var elements = Arr.map(sub, function (unit) { return unit.element(); }); - - var exact = Arr.map(elements, universe.property().getText).join(''); - return { - elements: Fun.constant(elements), - word: match.word, - exact: Fun.constant(exact) - }; - }; - - return Arr.map(matches, collate); - }; - - return { - separate: separate - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.bud.Unicode', - - [ - ], - - function () { - // \u200B needs to be removed manually as it is not considered whitespace when trimming - // \uFEFF does not need to be removed manually. It is considered whitespace when trimming - var zeroWidth = function () { - return '\u200B'; - }; - - // Note, we are separating these out so that we are accounting for the subtle differences - // between them. Eventually, we'll want to combine them again. - var trimNative = function (str) { - return str.replace(/\u200B/, '').trim(); - }; - - var trimWithRegex = function (str) { - return str.replace(/^\s+|\s+$/g, '').replace(/\u200B/, ''); - }; - - return { - zeroWidth: zeroWidth, - trimNative: trimNative, - trimWithRegex: trimWithRegex - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.pattern.Chars', - - [ - 'ephox.bud.Unicode', - 'ephox.peanut.Fun' - ], - - function (Unicode, Fun) { - // \w is a word character - // \' is an apostrophe - // '-' is a hyphen - // \u00C0 - \u00FF are various language characters - // \u2018 and \u2019 are the smart quote characters - var chars = '\\w' + '\'' + '\\-' + '\\u00C0-\\u00FF' + Unicode.zeroWidth() + '\\u2018\\u2019'; - var wordbreak = '[^' + chars + ']'; - var wordchar = '[' + chars + ']'; - - return { - chars: Fun.constant(chars), - wordbreak: Fun.constant(wordbreak), - wordchar: Fun.constant(wordchar) - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.pattern.Custom', - - [ - 'global!RegExp' - ], - - function (RegExp) { - return function (regex, prefix, suffix, flags) { - var term = function () { - return new RegExp(regex, flags.getOr('g')); - }; - - return { - term: term, - prefix: prefix, - suffix: suffix - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.pattern.Unsafe', - - [ - 'ephox.peanut.Fun', - 'ephox.perhaps.Option', - 'ephox.polaris.pattern.Chars', - 'ephox.polaris.pattern.Custom' - ], - - function (Fun, Option, Chars, Custom) { - - /** - * Tokens have no prefix or suffix - */ - var token = function (input) { - return Custom(input, Fun.constant(0), Fun.constant(0), Option.none()); - }; - - /** - * Words have complex rules as to what a "word break" actually is. - * - * These are consumed by the regex and then excluded by prefix/suffix lengths. - */ - var word = function (input) { - var regex = '((?:^\'?)|(?:' + Chars.wordbreak() + '+\'?))' + input + '((?:\'?$)|(?:\'?' + Chars.wordbreak() + '+))'; - - // ASSUMPTION: There are no groups in their input - var prefix = function (match) { - return match.length > 1 ? match[1].length : 0; - }; - - var suffix = function (match) { - return match.length > 2 ? match[2].length : 0; - }; - - return Custom(regex, prefix, suffix, Option.none()); - }; - - return { - token: token, - word: word - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.pattern.Safe', - - [ - 'ephox.polaris.pattern.Unsafe' - ], - - /** Sanitises all inputs to Unsafe */ - function (Unsafe) { - /** Escapes regex characters in a string */ - var sanitise = function (input) { - return input.replace(/[-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&'); - }; - - var word = function (input) { - var value = sanitise(input); - return Unsafe.word(value); - }; - - var token = function (input) { - var value = sanitise(input); - return Unsafe.token(value); - }; - - return { - sanitise: sanitise, - word: word, - token: token - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.api.Pattern', - - [ - 'ephox.polaris.pattern.Chars', - 'ephox.polaris.pattern.Custom', - 'ephox.polaris.pattern.Safe', - 'ephox.polaris.pattern.Unsafe' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Chars, Custom, Safe, Unsafe) { - var safeword = function (input) { - return Safe.word(input); - }; - - var safetoken = function (input) { - return Safe.token(input); - }; - - var custom = function (input, prefix, suffix, flags) { - return Custom(input, prefix, suffix, flags); - }; - - var unsafeword = function (input) { - return Unsafe.word(input); - }; - - var unsafetoken = function (input) { - return Unsafe.token(input); - }; - - var sanitise = function (input) { - return Safe.sanitise(input); - }; - - var chars = function () { - return Chars.chars(); - }; - - var wordbreak = function () { - return Chars.wordbreak(); - }; - - var wordchar = function () { - return Chars.wordchar(); - }; - - return { - safeword: safeword, - safetoken: safetoken, - custom: custom, - unsafeword: unsafeword, - unsafetoken: unsafetoken, - sanitise: sanitise, - chars: chars, - wordbreak: wordbreak, - wordchar: wordchar - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.search.Find', - - [ - 'ephox.peanut.Fun' - ], - - function (Fun) { - - /** - * Returns the offset pairs of all matches of pattern on the input string, adjusting for prefix and suffix offsets - */ - var all = function (input, pattern) { - var term = pattern.term(); - var r = []; - var match = term.exec(input); - while (match) { - var start = match.index + pattern.prefix(match); - var length = match[0].length - pattern.prefix(match) - pattern.suffix(match); - r.push({ - start: Fun.constant(start), - finish: Fun.constant(start + length) - }); - term.lastIndex = start + length; - match = term.exec(input); - } - return r; - }; - - return { - all: all - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.search.Sleuth', - - [ - 'ephox.compass.Arr', - 'ephox.highway.Merger', - 'ephox.polaris.search.Find', - 'global!Array' - ], - - function (Arr, Merger, Find, Array) { - var sort = function (array) { - var r = Array.prototype.slice.call(array, 0); - r.sort(function (a, b) { - if (a.start() < b.start()) return -1; - else if (b.start() < a.start()) return 1; - else return 0; - }); - return r; - }; - - /** - * For each target (pattern, ....), find the matching text (if there is any) and record the start and end offsets. - * - * Then sort the result by start point. - */ - var search = function (text, targets) { - var unsorted = Arr.bind(targets, function (t) { - var results = Find.all(text, t.pattern()); - return Arr.map(results, function (r) { - return Merger.merge(t, { - start: r.start, - finish: r.finish - }); - }); - }); - - return sort(unsorted); - }; - - return { - search: search - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.polaris.api.Search', - - [ - 'ephox.polaris.search.Find', - 'ephox.polaris.search.Sleuth' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Find, Sleuth) { - var findall = function (input, pattern) { - return Find.all(input, pattern); - }; - - var findmany = function (input, targets) { - return Sleuth.search(input, targets); - }; - - return { - findall: findall, - findmany: findmany - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.search.Searcher', - - [ - 'ephox.compass.Arr', - 'ephox.perhaps.Option', - 'ephox.phoenix.api.data.NamedPattern', - 'ephox.phoenix.api.data.Spot', - 'ephox.phoenix.api.general.Family', - 'ephox.phoenix.extract.TypedList', - 'ephox.phoenix.search.MatchSplitter', - 'ephox.polaris.api.Pattern', - 'ephox.polaris.api.PositionArray', - 'ephox.polaris.api.Search' - ], - - function (Arr, Option, NamedPattern, Spot, Family, TypedList, MatchSplitter, Pattern, PositionArray, Search) { - var gen = function (universe, input) { - return PositionArray.generate(input, function (unit, offset) { - var finish = offset + universe.property().getText(unit).length; - return Option.from(Spot.range(unit, offset, finish)); - }); - }; - - /** - * Extracts groups of elements separated by boundaries. - * - * For each group, search the text for pattern matches. - * - * Returns a list of matches. - */ - var run = function (universe, elements, patterns, optimise) { - var sections = Family.group(universe, elements, optimise); - var result = Arr.bind(sections, function (x) { - var input = TypedList.justText(x); - var text = Arr.map(input, universe.property().getText).join(''); - - var matches = Search.findmany(text, patterns); - var plist = gen(universe, input); - - return MatchSplitter.separate(universe, plist, matches); - }); - - return result; - }; - - - /** - * Runs a search for one or more words - */ - var safeWords = function (universe, elements, words, optimise) { - var patterns = Arr.map(words, function (word) { - var pattern = Pattern.safeword(word); - return NamedPattern(word, pattern); - }); - return run(universe, elements, patterns, optimise); - }; - - - /** - * Runs a search for a single token - */ - var safeToken = function (universe, elements, token, optimise) { - var pattern = NamedPattern(token, Pattern.safetoken(token)); - return run(universe, elements, [pattern], optimise); - }; - - return { - safeWords: safeWords, - safeToken: safeToken, - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.api.general.Search', - - [ - 'ephox.phoenix.search.Searcher' - ], - - /** - * Documentation is in the actual implementations. - */ - function (Searcher) { - var run = function (universe, items, patterns, optimise) { - return Searcher.run(universe, items, patterns, optimise); - }; - - var safeWords = function (universe, items, words, optimise) { - return Searcher.safeWords(universe, items, words, optimise); - }; - - var safeToken = function (universe, items, token, optimise) { - return Searcher.safeToken(universe, items, token, optimise); - }; - - return { - safeWords: safeWords, - safeToken: safeToken, - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.phoenix.api.dom.DomSearch', - - [ - 'ephox.boss.api.DomUniverse', - 'ephox.phoenix.api.general.Search' - ], - - /** - * Documentation is in the actual implementations. - */ - function (DomUniverse, Search) { - var universe = DomUniverse(); - - var run = function (elements, patterns, optimise) { - return Search.run(universe, elements, patterns, optimise); - }; - - var safeWords = function (elements, words, optimise) { - return Search.safeWords(universe, elements, words, optimise); - }; - - var safeToken = function (elements, token, optimise) { - return Search.safeToken(universe, elements, token, optimise); - }; - - return { - safeWords: safeWords, - safeToken: safeToken, - run: run - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sugar.api.SelectorExists', - - [ - 'ephox.sugar.api.SelectorFind' - ], - - function (SelectorFind) { - var any = function (selector) { - return SelectorFind.first(selector).isSome(); - }; - - var ancestor = function (scope, selector, isRoot) { - return SelectorFind.ancestor(scope, selector, isRoot).isSome(); - }; - - var sibling = function (scope, selector) { - return SelectorFind.sibling(scope, selector).isSome(); - }; - - var child = function (scope, selector) { - return SelectorFind.child(scope, selector).isSome(); - }; - - var descendant = function (scope, selector) { - return SelectorFind.descendant(scope, selector).isSome(); - }; - - var closest = function (scope, selector, isRoot) { - return SelectorFind.closest(scope, selector, isRoot).isSome(); - }; - - return { - any: any, - ancestor: ancestor, - sibling: sibling, - child: child, - descendant: descendant, - closest: closest - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.limbo.process.Preprocessor', - - [ - 'ephox.compass.Arr', - 'ephox.perhaps.Option', - 'ephox.phoenix.api.dom.DomSearch', - 'ephox.polaris.api.Pattern', - 'ephox.scullion.Struct', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.InsertAll', - 'ephox.sugar.api.Node', - 'ephox.sugar.api.SelectorExists' - ], - - function (Arr, Option, DomSearch, Pattern, Struct, Attr, Css, Element, Html, Insert, InsertAll, Node, SelectorExists) { - //the big fat holy grail of URL pattern matching.. - var regex = '((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[\\-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9\\.\\-]+|(?:www\\.|[\\-;:&=\\+\\$,\\w]+@)[A-Za-z0-9\\.\\-]+)(:[0-9]+)?((?:\\/[\\+~%\\/\\.\\w\\-_]*)?\\??(?:[\\-\\+=&;%@\\.\\w_]*)#?(?:[\\.\\!\\/\\\\\\w]*))?)'; - - var findLinks = function (elements) { - var data = Struct.immutable('word', 'pattern'); - var term = Pattern.unsafetoken(regex); - var pattern = data('__INTERNAL__', term); - return DomSearch.run(elements, [pattern]); - }; - - var notInLink = function (element) { - // return true; - return !SelectorExists.closest(element, 'a'); - }; - - var wrap = function (elements) { - return Option.from(elements[0]).filter(notInLink).map(function (first) { - var tag = Element.fromTag('a'); - Insert.before(first, tag); - InsertAll.append(tag, elements); - Attr.set(tag, 'href', Html.get(tag)); - return tag; - }); - }; - - var links = function (elements) { - var matches = findLinks(elements); - Arr.each(matches, function (match) { - // TBIO-2444 Do not wrap anything with @ symbol, it could be an email - if(match.exact().indexOf('@') < 0) wrap(match.elements()); - }); - }; - - var position = function (elements) { - Arr.each(elements, function (elem) { - if (Node.isElement(elem)) Css.remove(elem, 'position'); - }); - }; - - return { - links: links, - position: position - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.limbo.api.RunPaste', - - [ - 'ephox.compass.Arr', - 'ephox.limbo.process.PasteFilters', - 'ephox.limbo.process.Preprocessor', - 'ephox.pastiche.api.HybridAction', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Traverse' - ], - - function (Arr, PasteFilters, Preprocessor, HybridAction, Html, Traverse) { - var preprocess = function (platform, container) { - var children = Traverse.children(container); - Arr.each([ Preprocessor.links, Preprocessor.position ], function (f) { - f(children); - }); - }; - - var go = function (doc, platform, container, merging, isWord) { - preprocess(platform, container); - var html = Html.get(container); - var filters = PasteFilters.derive(isWord, merging, platform); - return HybridAction.go(doc, html, filters); - }; - - return { - go: go - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.limbo.api.Sources', - - [ - 'ephox.pastiche.api.HybridAction', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.PredicateExists' - ], - - function (HybridAction, Attr, Html, PredicateExists) { - var ie11 = function (container) { - // This looks expensive. Using grep on corpus, - // string searching for " -1 : false; - }); - }; - - var other = function (container) { - var html = Html.get(container); - return HybridAction.isWordContent(html); - }; - - var isWord = function (platform, container) { - var browser = platform.browser; - var detector = browser.isIE() && browser.version.major >= 11 ? ie11 : other; - return detector(container); - }; - - return { - isWord: isWord - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.data.Range', - - [ - 'ephox.peanut.Fun', - 'ephox.sugar.api.Compare' - ], - - function (Fun, Compare) { - return function (startContainer, startOffset, endContainer, endOffset) { - var collapsed = Compare.eq(startContainer, endContainer) && startOffset === endOffset; - - return { - startContainer: Fun.constant(startContainer), - startOffset: Fun.constant(startOffset), - endContainer: Fun.constant(endContainer), - endOffset: Fun.constant(endOffset), - collapsed: Fun.constant(collapsed) - }; - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.api.BodySwitch', - - [ - 'ephox.sloth.data.Range', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.Traverse' - ], - - function (Range, Element, Insert, Remove, Traverse) { - return function (selection) { - - var placeholder = Element.fromTag('br'); - - var toOn = function (element, offscreen) { - element.dom().focus(); - }; - - var getWin = function (offscreen) { - var doc = Traverse.owner(offscreen); - return doc.dom().defaultView; - }; - - var toOff = function (element, offscreen) { - var win = getWin(offscreen); - win.focus(); - Insert.append(offscreen, placeholder); - selection.set(win, Range(placeholder, 0, placeholder, 0)); - }; - - var cleanup = function () { - Remove.remove(placeholder); - }; - - return { - cleanup: cleanup, - toOn: toOn, - toOff: toOff - }; - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.api.DivSwitch', - - [ - 'ephox.peanut.Fun' - ], - - function (Fun) { - return function () { - var toOn = function (element, offscreen) { - element.dom().focus(); - }; - - var toOff = function (element, offscreen) { - offscreen.dom().focus(); - }; - - var cleanup = Fun.identity; - - return { - toOn: toOn, - toOff: toOff, - cleanup: cleanup - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.plumber.tap.control.BlockControl', - - [ - ], - - function () { - var create = function () { - var blocked = false; - var isBlocked = function () { return blocked; }; - var block = function () { blocked = true; }; - var unblock = function () { blocked = false; }; - - return { - isBlocked: isBlocked, - block: block, - unblock: unblock - } - }; - - return { - create: create - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.plumber.tap.wrap.Tapped', - - [ - ], - - function () { - var create = function (control, instance) { - return { - control: control, - instance: instance - } - }; - - return { - create: create - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.plumber.tap.function.BlockTap', - - [ - 'ephox.plumber.tap.control.BlockControl', - 'ephox.plumber.tap.wrap.Tapped' - ], - - function (BlockControl, Tapped) { - var tap = function (fn) { - var control = BlockControl.create(); - - var instance = function () { - if (!control.isBlocked()) - fn.apply(null, arguments); - }; - - return Tapped.create(control, instance); - }; - - return { - tap: tap - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.api.Paste', - - [ - 'ephox.fred.PlatformDetection', - 'ephox.peanut.Fun', - 'global!setTimeout' - ], - - function (PlatformDetection, Fun, setTimeout) { - var detection = PlatformDetection.detect(); - - var ie10 = function (doc, tap, postpaste) { - // Block the tap, and fire a paste. - tap.control.block(); - doc.dom().execCommand('paste'); - postpaste(); - tap.control.unblock(); - }; - - var others = function (doc, tap, postpaste) { - setTimeout(postpaste, 1); - }; - - // Most browsers can just let the paste event continue. - // on IE10, the paste event must be cancelled and done manually - var willBlock = detection.browser.isIE() && detection.browser.version.major <= 10; - - var runner = willBlock ? ie10 : others; - - var run = function (doc, tap, postpaste) { - return runner(doc, tap, postpaste); - }; - - return { - willBlock: Fun.constant(willBlock), - run: run - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.engine.Consolidator', - - [ - 'ephox.compass.Arr', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.InsertAll', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.Traverse' - ], - - function (Arr, Element, Insert, InsertAll, Remove, Traverse) { - // TBIO-2440. In some situations on Windows 7 Chrome, pasting into the offscreen div - // actually splits the div in two. The purpose of this function is to incorporate - // any of the split divs into the main one. - var consolidate = function (offscreen, isOffscreen) { - Traverse.nextSibling(offscreen).filter(isOffscreen).each(function (other) { - var children = Traverse.children(other); - InsertAll.append(offscreen, children); - Remove.remove(other); - }); - oneChild(offscreen, isOffscreen); - }; - // TBIO-3010: In Chrome (reproducible in both Windows and Mac) when pasting from notepad the offscreen div - // generates multiple sloth divs, causing the content to be not pasted correctly. This function - // runs across the children of the offscreen div and if it is a sloth element then it extract - // the content and wraps it in a normal div. - var cleanChild = function (child, offscreen) { - var children = Traverse.children(child); - var wrapper = Element.fromTag('div', Traverse.owner(child).dom()); - InsertAll.append(wrapper, children); - Insert.before(child, wrapper); - Remove.remove(child); - }; - - var oneChild = function (offscreen, isOffscreen) { - var children = Traverse.children(offscreen); - Arr.each(children, function (child) { - if (isOffscreen(child)) cleanChild(child, offscreen); - }); - }; - - return { - consolidate: consolidate - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.engine.Offscreen', - - [ - 'ephox.epithet.Id', - 'ephox.scullion.Struct', - 'ephox.sloth.engine.Consolidator', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Class', - 'ephox.sugar.api.Css', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Html', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.SelectorFind', - 'ephox.sugar.api.Traverse' - ], - - function (Id, Struct, Consolidator, Attr, Class, Css, Element, Html, Insert, Remove, SelectorFind, Traverse) { - var hash = Id.generate('ephox-sloth-bin'); - - return function (switcher) { - var offscreen = Element.fromTag('div'); - Attr.set(offscreen, 'contenteditable', 'true'); - Class.add(offscreen, hash); - Css.setAll(offscreen, { - position: 'absolute', - left: '0px', - top: '0px', - width: '0px', - height: '0px', - overflow: 'hidden' - }); - - var attach = function (target) { - Remove.empty(offscreen); - Insert.append(target, offscreen); - }; - - var focus = function () { - var body = SelectorFind.ancestor(offscreen, 'body'); - body.each(function (b) { - switcher.toOff(b, offscreen); - }); - }; - - var isOffscreen = function (other) { - return Class.has(other, hash); - }; - - var contents = function () { - Consolidator.consolidate(offscreen, isOffscreen); - var data = Struct.immutable('elements', 'html', 'container'); - var elements = Traverse.children(offscreen); - var html = Html.get(offscreen); - return data(elements, html, offscreen); - }; - - var detach = function () { - Remove.remove(offscreen); - }; - - var container = function () { - return offscreen; - }; - - return { - attach: attach, - focus: focus, - contents: contents, - container: container, - detach: detach - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.sloth.api.ProxyPaste', - - [ - 'ephox.peanut.Fun', - 'ephox.plumber.tap.function.BlockTap', - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.sloth.api.Paste', - 'ephox.sloth.engine.Offscreen', - 'ephox.sugar.api.Traverse' - ], - - function (Fun, BlockTap, Event, Events, Paste, Offscreen, Traverse) { - return function (switcher, element) { - var offscreen = Offscreen(switcher); - - var postpaste = function () { - switcher.cleanup(); - var contents = offscreen.contents(); - offscreen.detach(); - events.trigger.after(contents.elements(), contents.html(), offscreen.container()); - }; - - var tap = BlockTap.tap(function () { - events.trigger.before(); - offscreen.attach(element); - offscreen.focus(); - Paste.run(Traverse.owner(element), tap, postpaste); - }); - - var handler = function () { - tap.instance(); - }; - - var events = Events.create({ - before: Event([]), - after: Event(['elements', 'html', 'container']) - }); - - var destroy = Fun.noop; - - return { - instance: Fun.constant(handler), - destroy: destroy, - events: events.registry - }; - }; - - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.pastiche.Pastiche', - - [ - 'ephox.cement.api.CementConstants', - 'ephox.cement.pastiche.IeBlob', - 'ephox.compass.Arr', - 'ephox.fred.PlatformDetection', - 'ephox.fussy.api.WindowSelection', - 'ephox.limbo.api.RunPaste', - 'ephox.limbo.api.Sources', - 'ephox.peanut.Fun', - 'ephox.perhaps.Option', - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.sloth.api.BodySwitch', - 'ephox.sloth.api.DivSwitch', - 'ephox.sloth.api.ProxyPaste', - 'ephox.sugar.api.Class', - 'ephox.sugar.api.Elements', - 'ephox.sugar.api.Node', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.Traverse', - 'global!console', - 'global!setTimeout' - ], - - function (CementConstants, IeBlob, Arr, PlatformDetection, WindowSelection, RunPaste, Sources, Fun, Option, Event, Events, BodySwitch, DivSwitch, ProxyPaste, Class, Elements, Node, Remove, Traverse, console, setTimeout) { - var platform = PlatformDetection.detect(); - - return function (prePasteFilter, body, mergeSettings, intraFlag) { - // Temporary hack until we restructure in TBIO-1515 - var findClipboardTags = function (container, isWord) { - return (intraFlag !== undefined && !isWord) ? intraFlag.findClipboardTags(Traverse.children(container)) : Option.none(); - }; - - - var events = Events.create({ - paste: Event(['elements', 'assets']), - error: Event(['message']) - }); - - var fakeSelecton = { - // dupe from hare.selection.Selection - set: function (win, range) { - WindowSelection.setExact(win, range.startContainer(), range.startOffset(), range.endContainer(), range.endOffset()); - } - }; - - // TBIO-2019: scrollbar lock on paste. - // When using DivSwitch for inline editing, FF & webkit browsers will lock the scrollbar after paste - // This is because the the offscreen div was not used and hence no filtration was run and the scrollbar unlock code never got called - // To verify this paste formatted html and see the formatting unchanged test - // DivSwitch calls focus on the offscreen div, FF & Webkit do not set selection on focus, - // so inserting into offscreen div fails, bypassing the rest of the past process. - // It works in IE because amazingly IE sets selection on focus. - // Calling BodySwitch with IE inline mode paste fails altogether, the cause of the failure is unknown - var switchF = platform.browser.isIE() && Node.name(body) !== 'body' ? DivSwitch: BodySwitch; - var switcher = switchF(fakeSelecton); - var documentElement = Traverse.owner(body); - var proxyPaste = ProxyPaste(switcher, body); - var backgroundAssets = Option.none(); - - proxyPaste.events.after.bind(function (event) { - var container = event.container(); - switcher.toOn(body, container); - - // Run a paste filter over the off-screen div. - prePasteFilter(container); - - Class.add(container, CementConstants.binStyle()); - var isWord = Sources.isWord(platform, container); - - var pasteImpl = function (pasteSettings) { - var merging = (isWord && pasteSettings.mergeOfficeStyles) === true || (!isWord && pasteSettings.mergeHtmlStyles === true); - - try { - var dump = RunPaste.go(documentElement, platform, container, merging, isWord); - if (dump !== undefined && dump !== null && dump.length > 0) { - var elements = Elements.fromHtml(dump); - - backgroundAssets.fold(function () { - events.trigger.paste(elements, []); - }, function (future) { - future.get(function (assets) { - events.trigger.paste(elements, assets); - }); - }); - backgroundAssets = Option.none(); - } else { - // This is required to stop the scroll blocking. (TBIO-2440) - events.trigger.paste([], []); - } - } catch (e) { - console.error(e); - events.trigger.error('errors.paste.process.failure'); - } - }; - - // This potentially prompts the user, so it needs to be a callback - var normalPaste = Fun.curry(mergeSettings.get, isWord, pasteImpl); - - // Temporary hack until we restructure in TBIO-1515 - findClipboardTags(container, isWord).fold(normalPaste, function (tags) { - Arr.each(tags, Remove.remove); - // making sure it's asynchronous in both scenarios - setTimeout(function () { - // No need to call mergeSettings.get, we're just hard coding true - pasteImpl({ mergeHtmlStyles: true }); - }, 0); - }); - }); - - var destroy = function () { - proxyPaste.destroy(); - }; - - var handler = function (raw) { - try { - backgroundAssets = IeBlob.convert(raw); - var instance = proxyPaste.instance(); - instance(); - } catch (e) { - console.error(e); - events.trigger.error('errors.paste.process.failure'); - } - }; - - return { - handler: handler, - isSupported: Fun.constant(true), - events: events.registry, - destroy: destroy - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.smartpaste.PasteHandlers', - - [ - 'ephox.cement.html.HtmlPaste', - 'ephox.cement.images.ImagePaste', - 'ephox.cement.pastiche.Pastiche', - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.scullion.Struct', - 'ephox.violin.Strings' - ], - - function (HtmlPaste, ImagePaste, Pastiche, Event, Events, Struct, Strings) { - var result = Struct.immutable('captured'); - - var dataContainsMicrosoftOfficeUrn = function (data) { - // copied from ELJ, this logic doesn't exist in Tord and Pastiche's version isn't good enough - return Strings.contains(data, ' SourceEvent - */ - return function (fields, source) { - var mine = Event(fields); - var numHandlers = 0; - - var triggerer = function(evt) { - // yay! Let's unbox this event, convert it to a varargs, so it can be re-boxed! - var args = Arr.map(fields, function (field) { - return evt[field](); - }); - mine.trigger.apply(null, args); - }; - - var bind = function (handler) { - mine.bind(handler); - numHandlers++; - if (numHandlers === 1) { - source.bind(triggerer); - } - }; - - var unbind = function (handler) { - mine.unbind(handler); - numHandlers--; - if (numHandlers === 0) { - source.unbind(triggerer); - } - }; - - return { - bind: bind, - unbind: unbind, - trigger: Fun.die("Cannot trigger a source event.") - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.cement.api.Cement', - - [ - 'ephox.cement.flash.Flash', - 'ephox.cement.smartpaste.MergeSettings', - 'ephox.cement.smartpaste.PasteBroker', - 'ephox.limbo.api.RtfImage', - 'ephox.plumber.tap.function.BlockTap', - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.porkbun.SourceEvent', - 'ephox.sloth.api.Paste', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.InsertAll' - ], - - function (Flash, MergeSettings, PasteBroker, RtfImage, BlockTap, Event, Events, SourceEvent, Paste, Element, InsertAll) { - return function (body, createDialog, prePasteFilter, cementConfig) { - var flash = Flash(createDialog, cementConfig); - var mergeSettings = MergeSettings(createDialog, cementConfig); - var pasteSettings = { baseUrl: cementConfig.baseUrl, allowLocalImages: cementConfig.allowLocalImages, intraFlag: cementConfig.intraFlag }; - var pasteBroker = PasteBroker(prePasteFilter, body, mergeSettings, pasteSettings); - - var events = Events.create({ - cancel: SourceEvent([], mergeSettings.events.cancel), // only merge settings can cancel paste, not flash - error: Event(['message']), - insert: Event(['elements', 'assets']) - }); - - var insert = function (event) { - pasteTap.control.unblock(); - events.trigger.insert(event.elements(), event.assets()); - }; - - flash.events.insert.bind(insert); - - var pasteTap = BlockTap.tap(function (nativeEvent) { - if (Paste.willBlock()) { - /* - On IE10, a second paste is required. That happens synchronously, before we can - return anything that says "block the tap". - In order to make this code reentrant, we need to eagerly block. - */ - pasteTap.control.block(); - - /* - We then need to cancel the native event, because due to reentrancy the "is blocked" - check below actually returns false. If we don't prevent default here, we allow the - default paste to complete on the initial paste event. - */ - nativeEvent.preventDefault(); - } - - pasteBroker.handlePaste(nativeEvent); - - // If dialogs are opened, we set the block and need to prevent default - if (pasteTap.control.isBlocked()) nativeEvent.preventDefault(); - }); - - // block the broker from receiving paste events while the merge window is open. - mergeSettings.events.open.bind(pasteTap.control.block); - mergeSettings.events.close.bind(pasteTap.control.unblock); - - pasteBroker.events.paste.bind(function (event) { - var elements = event.elements(); - var content = Element.fromTag('div'); - InsertAll.append(content, elements); - - if (RtfImage.exists(content)) { - // block the broker from receiving paste events while the flash window is open. - pasteTap.control.block(); - flash.gordon(content, event.assets()); - } else { - insert(event); - } - }); - - var destroy = function () { - pasteBroker.destroy(); - }; - - var passThroughError = function (event) { - pasteTap.control.unblock(); - events.trigger.error(event.message()); - }; - flash.events.error.bind(passThroughError); - pasteBroker.events.error.bind(passThroughError); - - return { - paste: pasteTap.instance, - isBlocked: pasteTap.control.isBlocked, - destroy: destroy, - events: events.registry - }; - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.powerpaste.settings.Defaults', - - [ - - ], - - function() { - return { - officeStyles: 'prompt', - htmlStyles: 'clean' - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.powerpaste.styles.Styles', - - [ - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.SelectorExists', - 'ephox.sugar.api.SelectorFind', - 'global!document' - ], - - function(Attr, Element, Insert, Remove, SelectorExists, SelectorFind, document) { - var styleid = 'powerpaste-styles'; - var styleidselector = '#' + styleid; - - var injectStyles = function(url) { - if (!SelectorExists.any(styleidselector)){ - var htmlString = - ''; - - var style = Element.fromHtml(htmlString); - Attr.set(style, 'type', 'text/css'); - Attr.set(style, 'id', styleid); - - var head = SelectorFind.first('head').getOrDie('Head element could not be found.'); - - Insert.append(head, style); - - } - }; - - var removeStyles = function() { - if (SelectorExists.any(styleidselector)) { - - var head = SelectorFind.first('head').getOrDie('Head element could not be found.'); - var style = SelectorFind.descendant(head, styleidselector).getOrDie('The style element could not be removed'); - - Remove.remove(style); - - } - }; - - return { - injectStyles: injectStyles, - removeStyles: removeStyles - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.powerpaste.tinymce.ModernTinyDialog', - - [ - 'ephox.porkbun.Event', - 'ephox.porkbun.Events', - 'ephox.powerpaste.util.NodeUtil', - 'ephox.sugar.api.Attr', - 'ephox.sugar.api.Element', - 'ephox.sugar.api.Insert', - 'ephox.sugar.api.Remove', - 'ephox.sugar.api.SelectorFind' - ], - - function(Event, Events, NodeUtil, Attr, Element, Insert, Remove, SelectorFind) { - return function(editor) { - var createDialog = function() { - var win, title = "", content = "", controls = [], dialogContent = null; - - var events = Events.create({ - close: Event([]) - }); - - var setTitle = function(label) { - title = label; - }; - - var setContent = function(c) { - if (tinymce.Env.safari) { - - } - var contentString = NodeUtil.nodeToString(c.dom()); - content = [{ - type: 'container', - html: contentString - }]; - dialogContent = c; - }; - - var setButtons = function(buttons) { - var tinyButtons = []; - - buttons.forEach(function(element, index, array){ - //Convert cement buttons into tiny buttons - tinyButtons.push({ - text: element.text, - onclick: element.click - }); - }); - - controls = tinyButtons; - - }; - - var winCloseEvent = function(e) { - events.trigger.close(); - }; - - var programmaticWinClose = function() { - //Unbind the close event, as the dialog close event has already triggered and doesn't need to be triggered again - win.off('close', winCloseEvent); - win.close('close'); - }; - - var show = function() { - //If we don't have any buttons, we need to add one (even if it just closes the dialog) - if (controls.length === 0) { - //This gives us back the capability to hit esc to close the dialog & the dialog doesn't take focus away from the editor - controls = [{ - text: 'Close', - onclick: function() { - win.close(); - } - }]; - } - - var winSettings = { - title: title, - spacing: 10, - padding: 10, - items: content, - buttons: controls - }; - - win = editor.windowManager.open(winSettings); - - var tinyWindow = Element.fromDom(win.getEl()); - var proxy = SelectorFind.descendant(tinyWindow, '.' + Attr.get(dialogContent, 'class')).getOrDie('We must find this element or we cannot continue'); - Insert.before(proxy, dialogContent); - Remove.remove(proxy); - - win.on('close', winCloseEvent); - - }; - - var hide = function() { - programmaticWinClose(); - }; - - var destroy = function() { - programmaticWinClose(); - }; - - var reflow = function() { - //(this doesn't work, reflow doesn't calc based on what's actually there, it works it out based on what's in the container on tiny's side) - //So we could update the items, but for now the dialog sizes match so... - }; - - return { - events: events.registry, - setTitle: setTitle, - setContent: setContent, - setButtons: setButtons, - show: show, - hide: hide, - destroy: destroy, - reflow: reflow - }; - }; - - return { - createDialog: createDialog - }; - }; - - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.powerpaste.tinymce.ModernPowerPaste', - [ - 'ephox.cement.api.Cement', - 'ephox.compass.Arr', - 'ephox.peanut.Fun', - 'ephox.powerpaste.i18n.I18n', - 'ephox.powerpaste.settings.Defaults', - 'ephox.powerpaste.styles.Styles', - 'ephox.powerpaste.tinymce.ErrorDialog', - 'ephox.powerpaste.tinymce.ModernTinyDialog', - 'ephox.powerpaste.util.NodeUtil', - 'ephox.sugar.api.DomEvent', - 'ephox.sugar.api.Element', - 'global!setTimeout', - 'global!tinymce' - ], - function (Cement, Arr, Fun, I18n, Defaults, Styles, ErrorDialog, ModernTinyDialog, NodeUtil, DomEvent, Element, setTimeout, tinymce) { - return function (editor, url, settings, uploader) { - - var bm, swfUrl, imgUrl, cssUrl, jsUrl; - - jsUrl = (settings ? settings.swfUrl : url) + '/js'; - swfUrl = (settings ? settings.swfUrl : url) + '/flash/textboxpaste.swf'; - imgUrl = (settings ? settings.imgUrl : url) + '/img/spinner_96.gif'; - cssUrl = (settings ? settings.cssUrl : url) + '/css/editorcss.css'; - - editor.on('init', function(e) { - //Inject the styles for our dialog into the page - Styles.injectStyles(imgUrl); - - //Inject css into editor - editor.dom.loadCSS(cssUrl); - - var cementSettings = { - baseUrl: jsUrl, - swf: swfUrl, - officeStyles: editor.settings.powerpaste_word_import || Defaults.officeStyles, - htmlStyles: editor.settings.powerpaste_html_import || Defaults.htmlStyles, - translations: I18n.translate, - allowLocalImages: editor.settings.powerpaste_allow_local_images - }; - - var tinyDialog = ModernTinyDialog(editor); - var ed = Element.fromDom(editor.getBody()); - var cement = Cement(ed, tinyDialog.createDialog, Fun.noop, cementSettings); - - cement.events.cancel.bind(function() { - bm = null; - }); - - cement.events.error.bind(function(event) { - - bm = null; - - ErrorDialog.showDialog(editor, - I18n.translate( - event.message() - ) - ); - }); - - cement.events.insert.bind(function(event) { - - var stringHTML = Arr.map(event.elements(), function (element) { - return NodeUtil.nodeToString(element.dom()); - }).join(''); - - //This code was taken from tiny4 - if (editor.hasEventListeners('PastePostProcess')) { - // We need to attach the element to the DOM so Sizzle selectors work on the contents - var tempBody = editor.dom.add(editor.getBody(), 'div', {style: 'display:none'}, stringHTML); - stringHTML = editor.fire('PastePostProcess', {node: tempBody}).node.innerHTML; - editor.dom.remove(tempBody); - } - - //Ensure the editor has focus - editor.focus(); - - //Wait for focus to come back (ie10) - setTimeout(function(){ - - //Once we've got the html we want to insert and have performed post processing, return the - editor.selection.moveToBookmark(bm); //the selection to where it was - - //Delete the bookmark reference so we can do it all again - bm = null; - - editor.undoManager.transact(function(){ - //Content insertion - editor.insertContent(stringHTML, {merge: editor.settings.paste_merge_formats !== false}); - - uploader.prepareImages(event.assets()); - }); - - uploader.uploadImages(event.assets()); - - }, 1); - - - }); - - DomEvent.bind(ed, 'paste', function (e) { - //We need to bookmark the selection before we paste the content - //So that it knows where to place it back in to the editor when we insert from cement. - - if (!bm) { - //Since ie pastes twice, we need to get the bookmark once and ignore the second - bm = editor.selection.getBookmark(); - } - - cement.paste(e.raw()); - - //IE appears to require that we blur the iframe - setTimeout(function() { - if (editor.windowManager.windows[0]) { - editor.windowManager.windows[0].getEl().focus(); - } - }, 1); - }); - - }); - - editor.on('remove', function(e) { - //When we're removing the last editor, we need to remove our injected styles - if (tinymce.editors.length === 1) { - Styles.removeStyles(); - } - }); - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.powerpaste.tinymce.TinyPowerPaste', - [ - 'ephox.powerpaste.imageupload.UploaderFactory', - 'ephox.powerpaste.tinymce.LegacyPowerPaste', - 'ephox.powerpaste.tinymce.ModernPowerDrop', - 'ephox.powerpaste.tinymce.ModernPowerPaste', - 'global!tinymce' - ], - - function (UploaderFactory, LegacyPowerPaste, ModernPowerDrop, ModernPowerPaste, tinymce) { - /*jshint jquery:true */ - return function (settings) { - - return function (editor, url) { - - var setupModern = function () { - var uploader = UploaderFactory(editor); - - ModernPowerPaste(editor, url, settings, uploader); - - if (!editor.settings.powerpaste_block_drop) { - ModernPowerDrop(editor, url, settings, uploader); - } - }; - - var setupLegacy = function () { - LegacyPowerPaste(editor, settings); - }; - - if (tinymce.Env.ie && tinymce.Env.ie < 10) { - setupLegacy(); - } else { - setupModern(); - } - - var blockDragEvents = function (element) { - editor.dom.bind(element, 'drop dragstart dragend dragover dragenter dragleave dragdrop draggesture', function(e) { - return tinymce.dom.Event.cancel(e); - }); - }; - - if (editor.settings.powerpaste_block_drop) { - editor.on('init', function(e) { - blockDragEvents(editor.getBody()); - blockDragEvents(editor.getDoc()); - }); - } - - if (editor.settings.paste_postprocess) { - editor.on('PastePostProcess', function(e) { - editor.settings.paste_postprocess.call(this, this, e); - }); - } - }; - }; - } -); - -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -(function (define, require, demand) { -define( - 'ephox.powerpaste.PowerPastePlugin', - [ - 'ephox.powerpaste.tinymce.TinyPowerPaste', - 'global!tinymce' - ], - function(TinyPowerPaste, tinymce) { - return function(settings) { - tinymce.PluginManager.requireLangPack('powerpaste', 'ar,ca,cs,da,de,el,es,fa,fi,fr_FR,he_IL,hr,hu_HU,it,ja,kk,ko_KR,nb_NO,nl,pl,pt_BR,pt_PT,ro,ru,sk,sl_SI,sv_SE,th_TH,tr,uk,zh_CN,zh_TW'); - tinymce.PluginManager.add('powerpaste', TinyPowerPaste(settings)); - - }; - } -); -})(ephox.bolt.module.api.define, ephox.bolt.module.api.require, ephox.bolt.module.api.demand); - -dem('ephox.powerpaste.PowerPastePlugin')(); - if (this.ephox && this.ephox.bolt) - this.ephox.bolt = old; -})(); diff --git a/static/tinymce1.3/plugins/powerpaste/plugin.min.js b/static/tinymce1.3/plugins/powerpaste/plugin.min.js deleted file mode 100644 index a6f2107a..00000000 --- a/static/tinymce1.3/plugins/powerpaste/plugin.min.js +++ /dev/null @@ -1,23 +0,0 @@ -; -/* Ephox Fluffy plugin - * - * Copyright 2010-2016 Ephox Corporation. All rights reserved. - * - * Version: 1.0.0-3 - */ - -!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;ih&&(b(i),f())},g)};return{waitFor:d}}),h("4",window),h("c",document),g("8",["b","4","c"],function(a,b,c){var d=function(a,c){var d=a.currentStyle?a.currentStyle[c]:b.getComputedStyle(a,null)[c];return d?d:""},e=function(a){return function(){var b=d(a,"position").toLowerCase();return"absolute"===b||"fixed"===b}},f=function(){var a=c.createElement("div");return a.style.display="none",a.className="mce-floatpanel",a},g=function(a){a.parentNode.removeChild(a)},h=function(b,d){var h=f();c.body.appendChild(h),a.waitFor(e(h),function(){g(h),b()},function(){g(h),d()},10,5e3)};return{waitForSkinLoaded:h}}),h("9",alert),g("6",["8","9"],function(a,b){var c=function(a,b){a.notificationManager?a.notificationManager.open({text:b,type:"warning",timeout:0,icon:""}):a.windowManager.alert(b)},d=function(d){d.EditorManager.on("AddEditor",function(d){var e=d.editor,f=e.settings.service_message;f&&a.waitForSkinLoaded(function(){c(e,e.settings.service_message)},function(){b(f)})})};return{error:c,register:d}}),g("2",["5","1","6","4"],function(a,b,c,d){var e=function(b){var c,e,f=a.resolve(d,"tinymce.util.URI");c=b.base_url,c&&(this.baseURL=new f(this.documentBaseURL).toAbsolute(c.replace(/\/+$/,"")),this.baseURI=new f(this.baseURL)),e=b.suffix,b.suffix&&(this.suffix=e),this.defaultSettings=b},f=function(b){var c=a.resolve(d,"tinymce.util.Tools");return[c.extend({},this.defaultSettings,b)]},g=function(a){return"function"!=typeof a.overrideDefaults},h=function(a){c.register(a),a.overrideDefaults=e,a.EditorManager.init=b.before(a.EditorManager.init,f)};return{patch:b.nu(g,h)}}),g("a",[],function(){var a=0,b=1,c=-1,d=function(a){return parseInt(a,10)},e=function(a){return function(){return a}},f=function(a,b,c){return{major:e(a),minor:e(b),patch:e(c)}},g=function(a){var b=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(a);return b?f(d(b[1]),d(b[2]),d(b[3])):f(0,0,0)},h=function(d,e){var f=d-e;return 0===f?a:f>0?b:c},i=function(b,c){var d=h(b.major(),c.major());if(d!==a)return d;var e=h(b.minor(),c.minor());if(e!==a)return e;var f=h(b.patch(),c.patch());return f!==a?f:a};return{nu:f,parse:g,compare:i}}),g("7",["a"],function(a){var b=function(a){var b=[a.majorVersion,a.minorVersion].join(".");return b.split(".").slice(0,3).join(".")},c=function(c){return c?a.parse(b(c)):null},d=function(b,d){return a.compare(c(b),a.parse(d))<0};return{getVersion:c,isLessThan:d}}),g("3",["7","1"],function(a,b){var c=function(a){return function(b){var c=b.plugin_base_urls;for(var d in c)a.PluginManager.urls[d]=c[d]}},d=function(b){return a.isLessThan(b,"4.5.0")},e=function(a){a.overrideDefaults=b.before(a.overrideDefaults,c(a))};return{patch:b.nu(d,e)}}),g("0",["1","2","3","4"],function(a,b,c,d){var e=function(d){a.applyPatches(d,[b.patch,c.patch])};return e(d.tinymce),function(){return{applyPatches:e}}}),d("0")()}();; - -/* Ephox PowerPaste plugin - * - * Copyright 2010-2016 Ephox Corporation. All rights reserved. - * - * Version: 2.1.10-115 - */ - -!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i-1},f=function(a,b){return r(a,b)>-1},g=function(a,b){for(var c=[],d=0;dMore information on paste for Safari':b()},d=function(){return'Safari does not support direct paste of images. More information on image pasting for Safari'},e={"cement.dialog.paste.title":"Paste Formatting Options","cement.dialog.paste.instructions":"Choose to keep or remove formatting in the pasted content.","cement.dialog.paste.merge":"Keep Formatting","cement.dialog.paste.clean":"Remove Formatting","cement.dialog.flash.title":"Additional step needed to paste images","cement.dialog.flash.trigger-paste":"Your browser requires you to take one more action to paste the images in your content. Please press the below keys to complete the image paste:","cement.dialog.flash.missing":'Adobe Flash is required to import images from Microsoft Office. Install the Adobe Flash Player.',"cement.dialog.flash.press-escape":'Press "Close" to paste your content without images.',"loading.wait":"Please wait...","flash.clipboard.no.rtf":c(),"safari.imagepaste":d(),"webview.imagepaste":d(),"error.code.images.not.found":"The images service was not found: (","error.imageupload":"Image failed to upload: (","error.full.stop":").","errors.local.images.disallowed":"Local image paste has been disabled. Local images have been removed from pasted content.","flash.crashed":"Images have not been imported as Adobe Flash appears to have crashed. This may be caused by pasting large documents.","errors.imageimport.failed":"Some images failed to import.","errors.imageimport.unsupported":"Unsupported image type.","errors.imageimport.invalid":"Image is invalid."},f=function(a){return e[a]},g=function(b){return a.translate(f(b))};return{translate:g}}),g("s",[],function(){return{showDialog:function(a,b){var c=function(){win.close()},d=[{text:"Ok",onclick:c}],e={title:"Error",spacing:10,padding:10,items:[{type:"container",html:b}],buttons:d};win=a.windowManager.open(e)}}}),g("15",["y","d","s"],function(a,b,c){return function(d,e){var f=function(){return b.translate("error.code.images.not.found")+e+b.translate("error.full.stop")},g=function(){return b.translate("error.imageupload")+e+b.translate("error.full.stop")},h=function(a){var b=a.status(),e=0===b||b>=400||b<500,h=e?f:g;c.showDialog(d,h())},i=function(){return a(h)};return{instance:i}}}),g("3g",["g"],function(a){var b=function(b){var e=c(b),f=function(b){var c=b.split(" "),f=a.map(c,function(a){return d(e,a)});return f.join(" ")};return{resolve:f}},c=function(a){return a.replace(/\./g,"-")},d=function(a,b){return a+"-"+b};return{create:b,cssNamespace:c,cssClass:d}}),g("2d",["3g"],function(a){var b=a.create("ephox-salmon");return{resolve:b.resolve}}),g("26",["p","2d"],function(a,b){var c=b.resolve("upload-image-in-progress"),d="data-"+b.resolve("image-blob");return{uploadInProgress:a.constant(c),blobId:a.constant(d)}}),g("3h",[],function(){return function(a,b,c){var d=c||!1,e=function(){b(),d=!0},f=function(){a(),d=!1},g=function(){var a=d?f:e;a()},h=function(){return d};return{on:e,off:f,toggle:g,isOn:h}}}),g("1b",["12","13"],function(a,b){var c=function(c){if(null===c)return"null";var d=typeof c;return"object"===d&&a.prototype.isPrototypeOf(c)?"array":"object"===d&&b.prototype.isPrototypeOf(c)?"string":d},d=function(a){return function(b){return c(b)===a}};return{isString:d("string"),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean"),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")}}),g("1c",["14"],function(a){var b=function(){var b=a.keys,c=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b};return void 0===b?c:b}(),c=function(a,c){for(var d=b(a),e=0,f=d.length;e0?b.set(d,e,g.join(" ")):b.remove(d,e)};return{read:c,add:d,remove:e}}),g("3i",["g","5z"],function(a,b){var c=function(a){return void 0!==a.dom().classList},d=function(a){return b.read(a,"class")},e=function(a,c){return b.add(a,"class",c)},f=function(a,c){return b.remove(a,"class",c)},g=function(b,c){a.contains(d(b),c)?f(b,c):e(b,c)};return{get:d,add:e,remove:f,toggle:g,supports:c}}),g("27",["3h","j","3i"],function(a,b,c){var d=function(a,b){c.supports(a)?a.dom().classList.add(b):c.add(a,b)},e=function(a){var d=c.supports(a)?a.dom().classList:c.get(a);0===d.length&&b.remove(a,"class")},f=function(a,b){if(c.supports(a)){var d=a.dom().classList;d.remove(b)}else c.remove(a,b);e(a)},g=function(a,b){return c.supports(a)?a.dom().classList.toggle(b):c.toggle(a,b)},h=function(b,d){var e=c.supports(b),f=b.dom().classList,g=function(){e?f.remove(d):c.remove(b,d)},h=function(){e?f.add(d):c.add(b,d)};return a(g,h,i(b,d))},i=function(a,b){return c.supports(a)&&a.dom().classList.contains(b)};return{add:d,remove:f,toggle:g,toggler:h,has:i}}),h("1g",document),g("k",["p","1e","1f","1g"],function(a,b,c,d){var e=function(a,b){var e=b||d,f=e.createElement("div");if(f.innerHTML=a,!f.hasChildNodes()||f.childNodes.length>1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("3k",["g","1c","p","12"],function(a,b,c,d){var e=function(e,f){var g=function(){for(var b=new d(arguments.length),f=0;f0&&e.unsuppMessage(m);var n={};return a.each(g,function(a){n[a]=c.constant(j[a])}),a.each(h,function(a){n[a]=c.constant(f.prototype.hasOwnProperty.call(j,a)?d.some(j[a]):d.none())}),n}}}),g("2c",["3j","3k","3l"],function(a,b,c){return{immutable:a,immutable2:b,immutableBag:c}}),g("3m",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("4j",["p"],function(a){return function(b,c,d){var e=b.isiOS()&&/ipad/i.test(d)===!0,f=b.isiOS()&&!e,g=b.isAndroid()&&3===b.version.major,h=b.isAndroid()&&4===b.version.major,i=e||g||h&&/mobile/i.test(d)===!0,j=b.isiOS()||b.isAndroid(),k=j&&!i,l=c.isSafari()&&b.isiOS()&&/safari/i.test(d)===!1;return{isiPad:a.constant(e),isiPhone:a.constant(f),isTablet:a.constant(i),isPhone:a.constant(k),isTouch:a.constant(j),isAndroid:b.isAndroid,isiOS:b.isiOS,isWebView:a.constant(l)}}}),g("4k",[],function(){var a=function(a,b,c){return{browser:{current:a,version:b},os:{current:c}}};return{create:a}}),g("61",[],function(){var a=function(a){return function(){return a}},b=function(b,c,d){for(var e=0;e=e?c:b(c,F(d,e-f))}},H=G(function(a,b){return b+a}),I=G(function(a,b){return a+b});return{supplant:c,startsWith:e,startsWithIgnoringCase:f,endsWith:g,endsWithIgnoringCase:h,first:i,last:j,removeLeading:l,removeTrailing:m,ensureLeading:q,ensureTrailing:r,trim:s,lTrim:t,rTrim:u,contains:v,containsIgnoringCase:w,htmlEncodeDoubleQuotes:x,equals:y,equalsIgnoringCase:z,head:A,repead:F,padLeft:H,padRight:I,toe:B,tail:C,torso:D,capitalize:E}}),g("4m",["37"],function(a){var b=a.contains,c=function(a){return function(c){return b(c,a)}},d=function(){try{var a=new ActiveXObject("ChromeTab.ChromeFrame");return!!a}catch(b){return!1}},e=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,f=function(a){var d=[{name:"Spartan",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(a){var c=b(a,"edge/")&&b(a,"chrome")&&b(a,"safari")&&b(a,"applewebkit");return c}},{name:"ChromeFrame",versionRegexes:[/.*?chromeframe\/([0-9]+)\.([0-9]+).*/,e],search:function(c){return!!b(c,"chromeframe")&&a()}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,e],search:function(a){return b(a,"chrome")&&!b(a,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(c){var d=b(c,"msie")||b(c,"trident"),e=b(c,"chromeframe");return e?d&&!a():d}},{name:"Opera",versionRegexes:[e,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:c("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:c("firefox")},{name:"Safari",versionRegexes:[e,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(a){return(b(a,"safari")||b(a,"mobile/"))&&b(a,"applewebkit")}},{name:"Envjs",versionRegexes:[/.*?envjs\/\ ?([0-9]+)\.([0-9]+).*/],search:c("envjs")}],f=[{name:"Windows",search:c("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(a){return b(a,"iphone")||b(a,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:c("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:c("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:c("linux")},{name:"Solaris",search:c("sunos")},{name:"FreeBSD",search:c("freebsd")}];return{browsers:d,oses:f}};return{create:f,chromeFrameChecker:d}}),g("4n",[],function(){var a=function(a,b){var c=typeof a;if("boolean"===c)return!!a;if("object"===c){var d=a.minimum;return b.major>d.major||b.major===d.major&&b.minor>=d.minor}throw"invalid spec"};return{meetsSpec:a}}),g("66",[],function(){var a=function(a,b,c){for(var d=0;d-1?d.some(f):d.none()})},n=function(b,d){for(var e=a.isFunction(d)?d:c.constant(!1),f=b.dom(),g=[];null!==f.parentNode&&void 0!==f.parentNode;){var i=f.parentNode,j=h.fromDom(i);if(g.push(j),e(j)===!0)break;f=i}return g},o=function(a){var c=function(c){return b.filter(c,function(b){return!g.eq(a,b)})};return l(a).map(u).map(c).getOr([])},p=function(a){var b=a.dom();return d.from(b.offsetParent).map(h.fromDom)},q=function(a){var b=a.dom();return d.from(b.previousSibling).map(h.fromDom)},r=function(a){var b=a.dom();return d.from(b.nextSibling).map(h.fromDom)},s=function(a){return b.reverse(f.toArray(a,q))},t=function(a){return f.toArray(a,r)},u=function(a){var c=a.dom();return b.map(c.childNodes,h.fromDom)},v=function(a,b){var c=a.dom().childNodes;return d.from(c[b]).map(h.fromDom)},w=function(a){return v(a,0)},x=function(a){return v(a,a.dom().childNodes.length-1)},y=e.immutable("element","offset"),z=function(a,b){var c=u(a);return c.length>0&&b0},q=function(c){return a.contains(b,c)};return{findById:i,findAll:j,register:k, -report:n,inProgress:p,isActive:q,events:g.registry}}}),g("1l",["1b","12"],function(a,b){var c=function(a,b){return b},d=function(b,c){var d=a.isObject(b)&&a.isObject(c);return d?f(b,c):c},e=function(a){return function(){for(var c=new b(arguments.length),d=0;d=c.length&&b(d)}};0===c.length?b([]):a.each(c,function(a,b){a.get(f(b))})})},e=function(b,c){return d(a.map(b,c))},f=function(a,c,d){return b(function(b){var e=!1,f=!1,g=void 0,h=void 0,i=function(){if(e&&f){var a=d(g,h);b(a)}};a.get(function(a){g=a,e=!0,i()}),c.get(function(a){h=a,f=!0,i()})})},g=function(a,b){return function(c){return b(c).bind(a)}};return{nu:b,pure:c,par:d,mapM:e,lift2:f,compose:g}}}),g("o",["1u","1v","1w"],function(a,b,c){var d=function(c){var e=function(b){c(a.bounce(b))};return b(d,e)};return c(d)}),g("2u",["3p"],function(a){return function(){var b=a.getOrDie("FileReader");return new b}}),g("73",["o","2u"],function(a,b){return function(c){return a.nu(function(a){var d=b();d.onload=function(b){var c=b.target;a(c.result)},d.readAsText(c)})}}),g("74",["3p"],function(a){return function(){var b=a.getOrDie("XMLHttpRequest");return new b}}),g("69",["1b","1c","1l","73","o","74","n","2f","37","1f"],function(a,b,c,d,e,f,g,h,i,j){var k={"*":"*/*",text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},l=function(l,m,n,o){var p={url:l,contentType:"application/json",processData:!1,type:"GET"},q=c.merge(p,o),r=f();r.open(q.type.toUpperCase(),q.url,!0),"blob"===q.responseType&&(r.responseType=q.responseType),a.isString(q.contentType)&&r.setRequestHeader("Content-Type",q.contentType);var s=q.dataType,t=a.isString(s)&&"*"!==s?k[s]+", "+k["*"]+"; q=0.01":k["*"];r.setRequestHeader("Accept",t),void 0!==q.xhrFields&&q.xhrFields.withCredentials===!0&&(r.withCredentials=!0),a.isObject(q.headers)&&b.each(q.headers,function(b,c){a.isString(c)||a.isString(b)?r.setRequestHeader(c,b):j.error("Request header data was not a string: ",c," -> ",b)});var u=function(a,b,c){m(a)},v=function(){return"blob"===q.responseType?g.from(r.response).map(d).getOr(e.pure("no response content")):e.pure(r.responseText)},w=function(){v().get(function(a){0===r.status?n("Unknown HTTP error (possible cross-domain request)",r.status,a):n('Could not load url "'+l+'": '+r.statusText,r.status,a)})},x=function(){try{return h.value(JSON.parse(r.response))}catch(a){return h.error({status:r.status,statusText:"Response was not JSON",responseText:r.responseText})}},y=function(){var a="json"===s?x(r):h.value(r.response);a.fold(w,function(a){u(a,r.statusText,r)})},z=function(){0===r.status?i.startsWith(q.url,"file:")?y():w():r.status<100||r.status>=400?w():y()};r.onerror=w,r.onload=z,void 0===q.data?r.send():r.send(q.data)};return{ajax:l}}),g("3u",["3p"],function(a){var b=function(){return a.getOrDie("JSON")},c=function(a){return b().parse(a)},d=function(a,c,d){return b().stringify(a,c,d)};return{parse:c,stringify:d}}),g("3t",["1l","69","3u"],function(a,b,c){var d=function(c,d,e,f){b.ajax(c,d,e,a.merge({dataType:"text",type:"GET"},f))},e=function(d,e,f,g,h){b.ajax(d,f,g,a.merge({dataType:"text",data:c.stringify(e),type:"POST"},h))};return{get:d,post:e}}),g("6a",[],function(){var a=function(a){var b="";return""!==a.protocol&&(b+=a.protocol,b+=":"),""!==a.authority&&(b+="//",b+=a.authority),b+=a.path,""!==a.query&&(b+="?",b+=a.query),""!==a.anchor&&(b+="#",b+=a.anchor),b};return{recompose:a}}),g("75",["1l"],function(a){var b={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},c=function(a,b){for(var c=b,d=c.parser[c.strictMode?"strict":"loose"].exec(a),e={},f=14;f--;)e[c.key[f]]=d[f]||"";return e[c.q.name]={},e[c.key[12]].replace(c.q.parser,function(a,b,d){b&&(e[c.q.name][b]=d)}),e},d=function(d,e){var f=a.merge(b,e);return c(d,f)};return{parse:d}}),g("76",["37"],function(a){var b=function(b){return a.removeTrailing(b,d(b))},c=function(a){return a.match(/(^\/?.*?)(\/|$)/)[1]},d=function(a){return a.substring(a.lastIndexOf("/"))},e=function(d){for(var e=d,f="";""!==e;)if(a.startsWith(e,"../"))e=a.removeLeading(e,"../");else if(a.startsWith(e,"./"))e=a.removeLeading(e,"./");else if(a.startsWith(e,"/./"))e="/"+a.removeLeading(e,"/./");else if("/."===e)e="/";else if(a.startsWith(e,"/../"))e="/"+a.removeLeading(e,"/../"),f=b(f);else if("/.."===e)e="/",f=b(f);else if("."===e||".."===e)e="";else{var g=c(e);e=a.removeLeading(e,g),f+=g}return f};return{remove:e}}),g("77",["37"],function(a){var b=function(b,c,d){if(""!==d&&""===b)return"/"+c;var e=b.substring(b.lastIndexOf("/")+1);return a.removeTrailing(b,e)+c};return{merge:b}}),g("6b",["37","75","76","77"],function(a,b,c,d){var e=function(e,f){var g={strictMode:!0},h=b.parse(e,g),i=b.parse(f,g),j={};return""!==i.protocol?(j.protocol=i.protocol,j.authority=i.authority,j.path=c.remove(i.path),j.query=i.query):(""!==i.authority?(j.authority=i.authority,j.path=c.remove(i.path),j.query=i.query):(""===i.path?(j.path=h.path,""!==i.query?j.query=i.query:j.query=h.query):(a.startsWith(i.path,"/")?j.path=c.remove(i.path):(j.path=d.merge(h.path,i.path,e.authority),j.path=c.remove(j.path)),j.query=i.query),j.authority=h.authority),j.protocol=h.protocol),j.anchor=i.anchor,j};return{transform:e}}),g("3v",["6a","6b"],function(a,b){var c=function(c,d){var e=b.transform(c,d);return a.recompose(e)};return{resolve:c}}),g("2k",["1b","1l","3t","3u","2f","2j","37","3v"],function(a,b,c,d,e,f,g,h){return function(i){var j=function(){var a=i.url,b=a.lastIndexOf("/"),c=b>0?a.substr(0,b):a,d=void 0===i.basePath?c:i.basePath;return g.endsWith(d,"/")?d:d+"/"},k=j(),l=function(a,b){var c=a.split(/\s+/),d=1===c.length&&""!==c[0]?c[0]:b;return h.resolve(k,d)},m=function(g,h,j){var k=g.blob(),m=function(a,b,c){j(e.error(f.failureObject(a,b,c)))},n=f.getFilename(k,h),o=i.credentials!==!0?{}:{xhrFields:{withCredentials:!0}},p=b.merge(o,f.buildExtra("image",k,n)),q=function(b){var c;try{var f=d.parse(b);if(!a.isString(f.location))return void m("JSON response did not contain a string location",500,b);c=f.location}catch(g){c=b}var h=l(c,n);j(e.value({location:h}))};c.post(i.url,{},q,m,p)};return{upload:m}}}),h("x",setTimeout),g("2l",["1b","2f","2j","2c","1f","x"],function(a,b,c,d,e,f){var g=d.immutable("id","filename","blob","base64");return function(d){var h=function(h,i,j){var k=function(a){j(b.error(a))},l=function(c){a.isString(c)?j(b.value({location:c})):(e.error("Image upload result was not a string"),k(""))},m=c.getFilename(h.blob(),i),n=g(i,m,h.blob(),h.data().result);f(function(){d(n,l,k)},0)};return{upload:h}}}),g("1a",["2j","2k","2l"],function(a,b,c){var d=function(a){return b(a)},e=function(a){return c(a)},f=function(b,c,d){return a.failureObject(b,c,d)},g=function(b,c){return a.getFilename(b,c)},h=function(b,c,d){return a.buildExtra(b,c,d)};return{direct:d,custom:e,failureObject:f,getFilename:g,buildExtra:h}}),g("b",["g","p","n","c","15","16","17","18","19","1a","j","k"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=function(d,m){var n=g(),o=h(),p=(e(),e(d,m.url)),q=j.direct(m),r=function(){return l.fromDom(d.getBody())},s=function(b,c,e){a.each(c,function(a){k.set(a,"data-mce-src",b.location)}),f.resrcHistory(d,e,b)};o.events.complete.bind(function(a){f.unwrapHistory(d)});var t=function(a,b,c){i.handleUpload(q,o,n,r(),a,b,function(a){a.fold(function(a){c(a)},s)})},u=function(a,b){i.prepareForUpload(o,a.blobInfo().id(),a.image()).each(function(c){t(c,a.blobInfo(),b)})},v=function(b){var c=p.instance(),d=i.registerAssets(n,r(),b);a.each(d,function(a){a.fold(function(a){console.error(a)},function(a){u(a,c)})})},w=function(){var b=p.instance(),d=i.findBlobs(o,n,r());a.each(d,function(a){a.fold(function(a){o.report(a,c.none(),!1)},function(a){u(a,b)})})},x=function(a){w(),v(a)},y=function(a,b,c,d){return c};return{uploadImages:x,prepareImages:b.noop,getLocalURL:y}},n=function(a){var c=d(a);return{uploadImages:b.noop,prepareImages:c.prepareImages,getLocalURL:c.getLocalURL}};return function(a,b){return b?m(a,b):n(a)}}),g("3",["b","c"],function(a,b){return function(c){var d=!c.uploadImages&&c.settings.images_upload_url?{url:c.settings.images_upload_url,basePath:c.settings.images_upload_base_path,credentials:c.settings.images_upload_credentials}:null;return c.uploadImages?b(c):a(c,d)}}),g("1h",[],function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=function(a){return a.ownerDocument.defaultView?a.ownerDocument.defaultView.getComputedStyle(a,null):a.currentStyle||{}},c=function(a){"undefined"!=typeof console&&console.log&&console.log(a)},d=function(a){var b=Array.prototype.slice.call(a).reverse();return function(a){for(var c=a,d=0;d/i),p=null===o?n:o[0];return c(p)}if(!l.get("_mcePaste")){if(f=l.add(m,"div",{id:"_mcePaste","class":"mcePaste"},'\ufeff
'),i=m!=b.getDoc().body?l.getPos(b.selection.getStart(),m).y:m.scrollTop,l.setStyles(f,{position:"absolute",left:-1e4,top:i,width:1,height:1,overflow:"hidden"}),tinymce.isIE)return h=l.doc.body.createTextRange(),h.moveToElementText(f),h.execCommand("Paste"),l.remove(f),"\ufeff"===f.innerHTML?(b.execCommand("mcePasteWord"),void e.preventDefault()):(c(j?f.innerText:f.innerHTML),tinymce.dom.Event.cancel(e));var q=function(a){a.preventDefault()};l.bind(b.getDoc(),"mousedown",q),l.bind(b.getDoc(),"keydown",q),tinymce.isGecko&&(h=b.selection.getRng(!0),h.startContainer==h.endContainer&&3==h.startContainer.nodeType&&(nodes=l.select("p,h1,h2,h3,h4,h5,h6,pre",f),1==nodes.length&&l.remove(nodes.reverse(),!0))),g=b.selection.getRng(),f=f.firstChild,h=b.getDoc().createRange(),h.setStart(f,0),h.setEnd(f,1),k.setRng(h),window.setTimeout(function(){var d="",e=l.select("div.mcePaste");a.each(e,function(b){var c=b.firstChild;c&&"DIV"==c.nodeName&&c.style.marginTop&&c.style.backgroundColor&&l.remove(c,1),a.each(l.select("div.mcePaste",b),function(a){l.remove(a,1)}),a.each(l.select("span.Apple-style-span",b),function(a){l.remove(a,1)}),a.each(l.select("br[_mce_bogus]",b),function(a){l.remove(a)}),d+=b.innerHTML}),a.each(e,function(a){l.remove(a)}),g&&k.setRng(g),c(d),l.unbind(b.getDoc(),"mousedown",q),l.unbind(b.getDoc(),"keydown",q)},0)}}),c=function(a,c,d){return function(e){b(a,c,d,e)}},d=function(a,c,d){return function(e){(tinymce.isOpera||navigator.userAgent.indexOf("Firefox/2")>0)&&((tinymce.isMac?e.metaKey:e.ctrlKey)&&86==e.keyCode||e.shiftKey&&45==e.keyCode)&&b(a,c,d,e)}};return{getOnPasteFunction:c,getOnKeyDownFunction:d}}),g("1i",[],function(){var a=function(a,b){var c,d=b.getDoc(),e="ephoxInsertMarker",f=b.selection,g=b.dom;f.setContent(' '),c=g.get(e);for(var h=d.createDocumentFragment();a.firstChild&&!g.isBlock(a.firstChild);)h.appendChild(a.firstChild);for(var i=d.createDocumentFragment();a.lastChild&&!g.isBlock(a.lastChild);)i.appendChild(a.lastChild);if(c.parentNode.insertBefore(h,c),g.insertAfter(i,c),a.firstChild){if(g.isBlock(a.firstChild)){for(;!g.isBlock(c.parentNode)&&c.parentNode!==g.getRoot();)c=g.split(c.parentNode,c);g.is(c.parentNode,"td,th")||c.parentNode===g.getRoot()||(c=g.split(c.parentNode,c))}g.replace(a,c)}else g.remove(c)};return{insert:a}}),g("1j",["1h"],function(a){var b={strip_class_attributes:"all",retain_style_properties:"none"},c={strip_class_attributes:"none",retain_style_properties:"valid"},d=function(a,d){if(a&&"string"!=typeof a)return a;switch(a){case"clean":return b;case"merge":return c;default:return d}},e=function(b,c,e){var f=d(b,c);return f=a.extend(f,{base_64_images:e})},f=function(a,d,f){var g=e(a,b,f),h=e(d,c,f),i=h,j=function(a){i=a?g:h},k=function(a){return i[a]};return{setWordContent:j,get:k}};return{create:f}}),g("6c",["1h"],function(a){var b=function(a){return a.specified!==!1||"name"===a.nodeName&&""!==a.value},c=function(a,b){return a&&b?function(c,d){return b(c,a(c,d))}:a||b},d=function(d){var e,f,g=0,h=function(){return e},i=function(){return f()};f=function(){return e={},g=0,a.each(d.attributes,function(a){var c=a.nodeName,d=a.value;b(a)&&null!==d&&void 0!==d&&(e[c]=d,g++)}),void 0===e.style&&d.style.cssText&&(e.style=d.style.cssText,g++),f=h,e};var j,k,l=function(){return f(),g},m=function(a){j||(k=f),j=c(j,a),f=function(){return f=k,o(function(a,b){var c=j(a,b);null===c?(d.removeAttribute(a),delete e[a],g--):c!==b&&("class"===a?d.className=c:d.setAttribute(a,c),e[a]=c)}),f=h,e}},n=function(a){return f()[a]},o=function(b){a.each(f(),function(a,c){b(c,a)})};return{get:n,each:o,filter:m,getAttributes:i,getAttributeCount:l}};return{manager:d}}),g("3w",["6c","1h"],function(a,b,c){var d="startElement",e="endElement",f="text",g="comment",h=a.manager,i=function(a){return a.replace(/-(.)/g,function(a,b){return b.toUpperCase()})},j=function(a){return a.replace(/([A-Z])/g,function(a,b){return"-"+b.toLowerCase()})},k=!1,l=function(a,c,d){var e,f,g;a.style.length;g=c||a.getAttribute("style"),void 0!==g&&null!==g&&g.split||(g=a.style.cssText),b.each(g.split(";"),function(a){var c=a.indexOf(":");c>0&&(e=b.trim(a.substring(0,c)),e.toUpperCase()===e&&(e=e.toLowerCase()),e=j(e),f=b.trim(a.substring(c+1)),k||(k=0===e.indexOf("mso-")),d(e,f))}),k||(f=a.style["mso-list"],f&&d("mso-list",f))},m=function(a,c,j){var k,m,n,o,p;switch(a.nodeType){case 1:c?k=e:(k=d,o=h(a),p={},l(a,j,function(a,b){p[a]=b})),m="HTML"!==a.scopeName&&a.scopeName&&a.tagName&&a.tagName.indexOf(":")<=0?(a.scopeName+":"+a.tagName).toUpperCase():a.tagName;break;case 3:k=f,n=a.nodeValue;break;case 8:k=g,n=a.nodeValue;break;default:b.log("WARNING: Unsupported node type encountered: "+a.nodeType)}var q=function(){return o&&o.getAttributes(),a},r=function(){return m},s=function(){return k},t=function(){return n},u=function(){return"Type: "+k+", Tag: "+m+" Text: "+n},v=function(a){return o.get(a.toLowerCase())},w=function(a){k===d&&o.filter(a)},x=function(c){if(s()===d){var e="";b.each(p,function(b,d){var f=c(d,b);null===f?(a.style.removeProperty?a.style.removeProperty(i(d)):a.style.removeAttribute(i(d)),delete p[d]):(e+=d+": "+f+"; ",p[d]=f)}),e=e?e:null,w(function(a,b){return"style"===a?e:b}),a.style.cssText=e}},y=function(){return o.getAttributeCount()},z=function(a){o.each(a)},A=function(a){return p[a]},B=function(a){b.each(p,function(b,c){a(c,b)})},C=function(){return b.ephoxGetComputedStyle(a)},D=function(){return k===f&&/^[\s\u00A0]*$/.test(n)};return{getNode:q,tag:r,type:s,text:t,toString:u,getAttribute:v,filterAttributes:w,filterStyles:x,getAttributeCount:y,attributes:z,getStyle:A,styles:B,getComputedStyle:C,isWhitespace:D}},n=function(a,c,d,e){var f=e.createElement(a),g="";return b.each(c,function(a,b){f.setAttribute(b,a)}),b.each(d,function(a,b){g+=b+":"+a+";",f.style[i(b)]=a}),m(f,!1,""!==g?g:null)},o=function(a,b){return m(b.createElement(a),!0)},p=function(a,b){return m(b.createComment(a),!1)},q=function(a,b){return m(b.createTextNode(a))},r=o("HTML",window.document);return{START_ELEMENT_TYPE:d,END_ELEMENT_TYPE:e,TEXT_TYPE:f,COMMENT_TYPE:g,FINISHED:r,token:m,createStartElement:n,createEndElement:o,createComment:p,createText:q}}),g("2m",["3w"],function(a){var b=function(b){var c=b.createDocumentFragment(),d=c,e=function(a){g(a),c=a},f=function(){c=c.parentNode},g=function(a){c.appendChild(a)},h=function(c){var d=function(a){var b=a.getNode().cloneNode(!1);e(b)},h=function(a,c){var d=b.createTextNode(a.text());g(d)};switch(c.type()){case a.START_ELEMENT_TYPE:d(c);break;case a.TEXT_TYPE:h(c);break;case a.END_ELEMENT_TYPE:f();break;case a.COMMENT_TYPE:break;default:throw{message:"Unsupported token type: "+c.type()}}};return{dom:d,receive:h}};return{create:b}}),g("2n",["3w"],function(a){var b=function(b,c){var d;c=c||window.document,d=c.createElement("div"),c.body.appendChild(d),d.style.position="absolute",d.style.left="-10000px",d.innerHTML=b,nextNode=d.firstChild||a.FINISHED;var e=[];endNode=!1;var f=function(b,c){return b===a.FINISHED?b:b?a.token(b,c):void 0},g=function(){var b=nextNode,g=endNode;return!endNode&&nextNode.firstChild?(e.push(nextNode),nextNode=nextNode.firstChild):endNode||1!==nextNode.nodeType?nextNode.nextSibling?(nextNode=nextNode.nextSibling,endNode=!1):(nextNode=e.pop(),endNode=!0):endNode=!0,b===a.FINISHED||nextNode||(c.body.removeChild(d),nextNode=a.FINISHED),f(b,g)},h=function(){return void 0!==nextNode};return{hasNext:h,next:g}};return{tokenize:b}}),g("3x",["3w","1h"],function(a,b){var c=function(c,d){var e=function(e,f,g){var h,i,j,k=!1,l=function(){d&&d(w),k=!1,i=[],j=[]},m=function(a){b.each(a,function(a){e.receive(a)})},n=function(a){k?j.push(a):e.receive(a)},o=function(b){d&&i.push(b),c(w,b),b===a.FINISHED&&r()},p=function(){k=!0},q=function(){m(i),l()},r=function(){u(),m(j),l()},s=function(a){h=h||[],h.push(a)},t=function(){return h&&h.length>0},u=function(){b.each(h,function(a){n(a)}),v()},v=function(){h=[]},w={document:g||window.document,settings:f||{},emit:n,receive:o,startTransaction:p,rollback:q,commit:r,defer:s,hasDeferred:t,emitDeferred:u,dropDeferred:v};return l(),w};return e},d=function(a){return c(function(c,d){d.filterAttributes(b.bind(a,c)),c.emit(d)})};return{createFilter:c,createAttributeFilter:d}}),g("2o",["3x","3w"],function(a,b){var c=/^(P|H[1-6]|T[DH]|LI|DIV|BLOCKQUOTE|PRE|ADDRESS|FIELDSET|DD|DT|CENTER)$/,d=function(a){return c.test(a.tag())},e=function(){return null},f=!1;return a.createFilter(function(a,c){var g=function(){f||(a.emit(b.createStartElement("P",{},{},a.document)),f=!0)};switch(c.type()){case b.TEXT_TYPE:g(),a.emit(c);break;case b.END_ELEMENT_TYPE:f&&(d(c)||c===b.FINISHED)?(a.emit(b.createEndElement("P",a.document)),f=!1):"BR"===c.tag()&&a.emit(c);break;case b.START_ELEMENT_TYPE:"BR"===c.tag()?(c.filterAttributes(e),c.filterStyles(e),a.emit(c)):"IMG"===c.tag()&&c.getAttribute("alt")&&(g(),a.emit(b.createText(c.getAttribute("alt"),a.document)))}c===b.FINISHED&&a.emit(c)})}),g("3y",["3w"],function(a){var b=function(){if(navigator.userAgent.indexOf("Gecko")>0&&navigator.userAgent.indexOf("WebKit")<0)return!1;var b=document.createElement("div");try{b.innerHTML='

 

'}catch(c){return!1}return"Ignore"===a.token(b.firstChild).getStyle("mso-list")},c=b(),d=function(a){return"A"===a.tag()||"SPAN"===a.tag()},e=function(a){var b=a.getStyle("mso-list");return b&&"skip"!==b},f=function(b,c){return b.type()===a.START_ELEMENT_TYPE?0===b.getAttributeCount()||c&&1===b.getAttributeCount()&&null!==b.getAttribute("style")&&void 0!==b.getAttribute("style"):b.type()===a.END_ELEMENT_TYPE};return{hasNoAttributes:f,supportsCustomStyles:c,spanOrA:d,hasMsoListStyle:e}}),g("42",["3w","1h"],function(a,b){var c=[{regex:/^\(?[dc][\.\)]$/,type:{tag:"OL",type:"lower-alpha"}},{regex:/^\(?[DC][\.\)]$/,type:{tag:"OL",type:"upper-alpha"}},{regex:/^\(?M*(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})[\.\)]$/,type:{tag:"OL",type:"upper-roman"}},{regex:/^\(?m*(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})[\.\)]$/,type:{tag:"OL",type:"lower-roman"}},{regex:/^\(?[0-9]+[\.\)]$/,type:{tag:"OL"}},{regex:/^([0-9]+\.)*[0-9]+\.?$/,type:{tag:"OL",variant:"outline"}},{regex:/^\(?[a-z]+[\.\)]$/,type:{tag:"OL",type:"lower-alpha"}},{regex:/^\(?[A-Z]+[\.\)]$/,type:{tag:"OL",type:"upper-alpha"}}],d={"\u2022":{tag:"UL",type:"disc"},"\xb7":{tag:"UL",type:"disc"},"\xa7":{tag:"UL",type:"square"}},e={o:{tag:"UL",type:"circle"},"-":{tag:"UL",type:"disc"},"\u25cf":{tag:"UL",type:"disc"}},f=function(a,b){var c={tag:a.tag,type:a.type,variant:b};return a.start&&(c.start=a.start),a.type||delete c.type,c},g=function(a,g,i){var j,k,l,m=null;return a&&(j=a.text,k=a.symbolFont),j=b.trim(j),m=e[j],m?m=f(m,j):k?(m=d[j],m=m?f(m,j):{tag:"UL",variant:j}):(b.each(c,function(a){if(a.regex.test(j)){if(g&&h(a.type,g,!0))return m=a.type,m.start=parseInt(j),!1;m||(m=a.type),m.start=parseInt(j)}}),m&&!m.variant&&(l="("===j.charAt(0)?"()":")"===j.charAt(j.length-1)?")":".",m=f(m,l))),m&&"OL"===m.tag&&i&&("P"!==i.tag()||/^MsoHeading/.test(i.getAttribute("class")))&&(m=null),m},h=function(a,b,c){return a===b||a&&b&&a.tag===b.tag&&a.type===b.type&&(c||a.variant===b.variant)},i=function(b,c){return b.type()==a.START_ELEMENT_TYPE&&(font=b.getStyle("font-family"),font?c="Wingdings"===font||"Symbol"===font:/^(P|H[1-6]|DIV)$/.test(b.tag())&&(c=!1)),c};return{guessListType:g,eqListType:h,checkFont:i}}),g("3z",["3w","42","1h"],function(a,b,c){var d=function(d,e){var f,g,h,i=!1,j=function(a){var b=a.style.fontFamily;b&&(i="Wingdings"===b||"Symbol"===b)};if(d.type()===a.START_ELEMENT_TYPE&&e.openedTag&&"SPAN"===d.tag()){for(f=e.openedTag.getNode(),j(f),f.childNodes.length>1&&"A"===f.firstChild.tagName&&""===f.firstChild.textContent&&(f=f.childNodes[1]);f.firstChild&&("SPAN"===f.firstChild.tagName||"A"===f.firstChild.tagName);)f=f.firstChild,j(f);if(f=f.firstChild,!f||3!==f.nodeType)return f&&"IMG"===f.tagName;if(g=f.value,c.trim(g)||(f=f.parentNode.nextSibling,g=f?f.value:""),!f||c.trim(f.parentNode.textContent)!=g)return!1;if(h=b.guessListType({text:g,symbolFont:i},null,e.originalToken))return f.nextSibling&&"SPAN"===f.nextSibling.tagName&&/^[\u00A0\s]/.test(f.nextSibling.firstChild.value)&&("P"===e.openedTag.tag()||"UL"===h.tag)}return!1},e=function(a,b){var c,d=0;for(c=a.parentNode;null!==c&&void 0!==c&&c!==b.parentNode;)d+=c.offsetLeft,c=c.offsetParent;return d},f=function(a){var b={};return function(c,d){var e,f=c+","+d;return b.hasOwnProperty(f)?b[f]:(e=a.call(null,c,d),b[f]=e,e)}},g=function(a){var b=a.indexOf(".");if(b>=0&&c.trim(a.substring(b+1))===className)return match=results[2],!1},h=f(function(a,b){var d,e,f,h,i=/([^{]+){([^}]+)}/g;for(i.lastIndex=0;null!==(d=i.exec(a))&&!e;)c.each(d[1].split(","),g(selector));return!!e&&(f=document.createElement("p"),f.setAttribute("style",e),h=c.ephoxGetComputedStyle(f),!!h&&""+h.marginLeft)}),i=function(){var a,b,c=function(c,d,f,g){var i,j,k=1;return g&&/^([0-9]+\.)+[0-9]+\.?$/.test(g.text)?g.text.replace(/([0-9]+|\.$)/g,"").length+1:(i=b||parseInt(h(f,d.getAttribute("class"))),j=e(c.getNode(),d.getNode()),i?a?j+=a:0===j&&(a=i,j+=i):i=48,b=i=Math.min(j,i),k=Math.max(1,Math.floor(j/i))||1)};return{guessIndentLevel:c}},j=function(){var b=!1,c="",d=function(d){return b&&d.type()===a.TEXT_TYPE?(c+=d.text(),!0):d.type()===a.START_ELEMENT_TYPE&&"STYLE"===d.tag()?(b=!0,!0):d.type()===a.END_ELEMENT_TYPE&&"STYLE"===d.tag()&&(b=!1,!0)};return{check:d}};return{isListWithoutCommentsOrStyles:d,indentGuesser:i,styles:j}}),g("40",["3w","42"],function(a,b){var c=["disc","circle","square"],d=function(a,b){return"UL"===a.tag&&c[b-1]===a.type&&(a={tag:"UL"}),a};return function(c,e){var f,g=[],h=[],i=0,j=function(b,d){var h={},j={};i++,d&&b.type&&(h={"list-style-type":b.type}),b.start&&b.start>1&&(j={start:b.start}),g.push(b),c.emit(a.createStartElement(b.tag,j,h,e)),f=b},k=function(){c.emit(a.createEndElement(g.pop().tag,e)),i--,f=g[g.length-1]},l=function(){for(;i>0;)m(),k();c.commit()},m=function(){var b=h?h.pop():"P";"P"!=b&&c.emit(a.createEndElement(b,e)),c.emit(a.createEndElement("LI",e))},n=function(d,g,i){var l={};if(d){var m=d.getStyle("margin-left");void 0!==m&&(l["margin-left"]=m)}else l["list-style-type"]="none";f&&!b.eqListType(f,g)&&(k(),i&&(c.emit(a.createStartElement("P",{},{},e)),c.emit(a.createText("\xa0",e)),c.emit(a.createEndElement("P",e))),j(g,!0)),c.emit(a.createStartElement("LI",{},l,e)),d&&"P"!=d.tag()?(h.push(d.tag()),d.filterStyles(function(){return null}),c.emit(d)):h.push("P")},o=function(b,f,g,l){if(g){for(i||(i=0);i>b;)m(),k();if(g=d(g,b),i==b)m(),n(f,g,l);else for(b>1&&h.length>0&&"P"!==h[h.length-1]&&(c.emit(a.createEndElement(h[h.length-1],e)),h[h.length-1]="P");i0;)c.emit(h.spanCount.shift());a&&c.emit(i)}else e.log("Unknown list type: "+h.bulletInfo.text+" Symbol font? "+h.bulletInfo.symbolFont),c.rollback()};i.type()===b.TEXT_TYPE||i.type()===b.START_ELEMENT_TYPE?j(!0):i.type()===b.COMMENT_TYPE?j("[endif]"!==i.text()):i.type()===b.END_ELEMENT_TYPE?a.spanOrA(i)&&h.spanCount.pop():f(c,i)},q=function(a,c,d){d.type()===b.END_ELEMENT_TYPE&&d.tag()===c.originalToken.tag()?(c.nextFilter=h,c.skippedPara=!1):a.emit(d)},r=j;return{initial:r}}),g("2p",["3x","3y","3w","3z","40","41","42","1h"],function(a,b,c,d,e,f,g,h){var i={},j=function(a){i.nextFilter=f.initial,i.itemLevel=0,i.originalToken=null,i.commentMode=!1,i.openedTag=null,i.symbolFont=!1,i.listType=null,i.indentGuesser=d.indentGuesser(),i.emitter=e(a,a.document),i.styles=d.styles(),i.spanCount=[],i.skippedPara=!1,i.styleLevelAdjust=0,i.bulletInfo=void 0};j({});var k=function(a){j(a)},l=function(a,b){i.styles.check(b)||(i.symbolFont=g.checkFont(b,i.symbolFont),i.nextFilter(a,i,b))};return a.createFilter(l,k)}),g("2q",["1h"],function(a){var b=function(a){var b=a,c=65279===b.charCodeAt(b.length-1);return c?b.substring(0,b.length-1):a},c=function(a){return/<(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)/.test(a)?a.replace(/(?:
 [\s\r\n]+|
)*(<\/?(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)[^>]*>)(?:
 [\s\r\n]+|
)*/g,"$1"):a},d=function(a){return a.replace(/

/g,"

")},e=function(a){return a.replace(/
/g," ")},f=function(a){return a.replace(/

/g,"
")},g=[b],h=tinymce.isIE&&document.documentMode>=9?[f,e,d,c].concat(g):g,i=a.compose(h);return{all:i,textOnly:b}}),g("43",["3x"],function(a){var b=/^(mso-.*|tab-stops|tab-interval|language|text-underline|text-effect|text-line-through|font-color|horiz-align|list-image-[0-9]+|separator-image|table-border-color-(dark|light)|vert-align|vnd\..*)$/,c=function(a){return function(c,d){var e=!1;switch(a){case"all":case"*":e=!0;break;case"valid":e=!b.test(c);break;case void 0:case"none":e="list-style-type"===c;break;default:e=(","+a+",").indexOf(","+c+",")>=0}return e?d:null}};return a.createFilter(function(a,b){var d=a.settings.get("retain_style_properties");b.filterStyles(c(d)),a.emit(b)})}),g("44",["3x","3w"],function(a,b){return a.createFilter(function(a,c){a.seenList?a.emit(c):a.inferring?("LI"===c.tag()&&(c.type()===b.START_ELEMENT_TYPE?a.inferring++:(a.inferring--,a.inferring||(a.needsClosing=!0))),a.emit(c)):("OL"===c.tag()||"UL"===c.tag()?a.seenList=!0:"LI"===c.tag()&&(a.inferring=1,a.needsClosing||a.emit(b.createStartElement("UL",{},{},a.document))),!a.needsClosing||a.inferring||c.isWhitespace()||(a.needsClosing=!1,a.emit(b.createEndElement("UL",a.document))),a.emit(c))})}),g("45",["3x"],function(a){return a.createAttributeFilter(function(a,b){return"name"===a||"id"===a?null:b})}),g("46",["3x"],function(a){return a.createAttributeFilter(function(a,b){var c;if("class"===a)switch(c=this.settings.get("strip_class_attributes")){case"mso":return 0===b.indexOf("Mso")?null:b;case"none":return b;default:return null}return b})}),g("47",["3x","3y","3w"],function(a,b,c){var d=[],e=[],f=!1,g=function(a,b){var e,f,g=1;for(e=b+1;e=0&&b.hasNoAttributes(a,!0))};0===d.length?e.type()===c.START_ELEMENT_TYPE?h(e)?a.emit(e):i(a,e):a.emit(e):(f||(f=h(e)),i(a,e))})}),g("48",["3x"],function(a){return a.createAttributeFilter(function(a,b){return"style"===a&&""===b?null:b})}),g("49",["3x"],function(a){return a.createAttributeFilter(function(a,b){return"lang"===a?null:b})}),g("4a",["3x","3w"],function(a,b){return a.createFilter(function(a,c){if("IMG"===c.tag()){if(c.type()===b.END_ELEMENT_TYPE&&a.skipEnd)return void(a.skipEnd=!1);if(c.type()===b.START_ELEMENT_TYPE){if(/^file:/.test(c.getAttribute("src")))return void(a.skipEnd=!0);if(a.settings.get("base_64_images")&&/^data:image\/.*;base64/.test(c.getAttribute("src")))return void(a.skipEnd=!0)}}a.emit(c)})}),g("4b",["3x"],function(a){return a.createFilter(function(a,b){"META"!==b.tag()&&"LINK"!==b.tag()&&a.emit(b)})}),g("4c",["3x","3y","3w"],function(a,b,c){var d=function(a){return!b.hasNoAttributes(a)&&!/^OLE_LINK/.test(a.getAttribute("name"))},e=[];return a.createFilter(function(a,b){var f;b.type()===c.START_ELEMENT_TYPE&&"A"===b.tag()?(e.push(b),d(b)&&a.defer(b)):b.type()===c.END_ELEMENT_TYPE&&"A"===b.tag()?(f=e.pop(),d(f)&&a.defer(b),0===e.length&&a.emitDeferred()):a.hasDeferred()?a.defer(b):a.emit(b)})}),g("4d",["3x","3w"],function(a,b){var c=!1;return a.createFilter(function(a,d){"SCRIPT"===d.tag()?c=d.type()===b.START_ELEMENT_TYPE:c||(d.filterAttributes(function(a,b){return/^on/.test(a)||"language"===a?null:b}),a.emit(d))})}),g("2r",["43","44","45","46","47","48","49","4a","4b","4c","4d"],function(a,b,c,d,e,f,g,h,i,j,k){return[k,c,h,a,g,f,d,j,e,i,b]}),g("4e",["3x"],function(a){return a.createFilter(function(a,b){b.filterAttributes(function(a,c){return"align"===a?null:"UL"!==b.tag()&&"OL"!==b.tag()||"type"!==a?c:null}),a.emit(b)})}),g("4f",["3x"],function(a){return a.createAttributeFilter(function(a,b){return/^xmlns(:|$)/.test(a)?null:b})}),g("4g",["3x"],function(a){return a.createFilter(function(a,b){b.tag&&/^([OVWXP]|U[0-9]+|ST[0-9]+):/.test(b.tag())||a.emit(b)})}),g("4h",["3x"],function(a){return a.createAttributeFilter(function(a,b){return"href"===a&&(b.indexOf("#_Toc")>=0||b.indexOf("#_mso")>=0)?null:b})}),g("4i",["3x"],function(a){return a.createAttributeFilter(function(a,b){return/^v:/.test(a)?null:b})}),g("2s",["4e","4f","4g","4h","4i","2p"],function(a,b,c,d,e,f){return[c,f,d,e,b,a]}),g("1k",["2m","2n","2o","2p","2q","2r","2s"],function(a,b,c,d,e,f,g){var h=function(a,b,c,d){var e,f=b;for(e=a.length-1;e>=0;e--)f=a[e](f,c,d);return f},i=function(c,d,e,f){var g=a.create(e),i=b.tokenize(c,e);for(pipeline=h(f,g,d,e);i.hasNext();)pipeline.receive(i.next());return g.dom},j=function(a,b,c){var d=e.all(a),h=l(d);b.setWordContent(h);var j=f;return h&&(j=g.concat(f)),i(d,b,c,j)},k=function(a,b,d){var f=e.textOnly(a);return i(f,b,d,[c])},l=function(a){return a.indexOf("")>=0||a.indexOf("p.MsoNormal, li.MsoNormal, div.MsoNormal")>=0||a.indexOf("MsoListParagraphCxSpFirst")>=0||a.indexOf("")>=0};return{filter:j,filterPlainText:k,isWordContent:l}}),g("f",["1i","1j","1k","x"],function(a,b,c,d){return function(e,f){var g=function(g){var h=function(d){var f={content:g};e.fire("PastePreProcess",f);var h=b.create(d||e.settings.powerpaste_word_import,d||e.settings.powerpaste_html_import,!0),i=c.filter(f.content,h,e.getDoc());e.fire("PastePostProcess",i),e.undoManager.transact(function(){a.insert(i,e)})},i=function(a){return"clean"===a||"merge"===a},j=function(){var a,b=function(){a.close(),h("clean")},c=function(){a.close(),h("merge")},g=[{text:f("cement.dialog.paste.clean"),onclick:b},{text:f("cement.dialog.paste.merge"),onclick:c}],i={title:f("cement.dialog.paste.title"),spacing:10,padding:10,items:[{type:"container",html:f("cement.dialog.paste.instructions")}],buttons:g};a=e.windowManager.open(i),d(function(){a&&a.getEl().focus()},1)};c.isWordContent(g)&&!i(e.settings.powerpaste_word_import)?j():i(e.settings.powerpaste_html_import)?h():j()};return{showDialog:g}}}),g("4",["d","e","f"],function(a,b,c){return function(d,e,f){var g,h,i=this,j=c(d,a.translate),k=function(a){return function(b){a(b)}};g=b.getOnPasteFunction(d,j.showDialog,e),d.on("paste",k(g)),h=b.getOnKeyDownFunction(d,j.showDialog,e),d.on("keydown",k(h)),d.addCommand("mceInsertClipboardContent",function(a,b){j.showDialog(b.content||b)}),d.settings.paste_preprocess&&d.on("PastePreProcess",function(a){d.settings.paste_preprocess.call(i,i,a)})}}),g("1s",[],function(){var a=0,b=function(b){var c=new Date,d=c.getTime(),e=Math.floor(1e9*Math.random());return a++,b+"_"+e+a+String(d)};return{generate:b}}),g("1n",["g","1s","2t","h","o","2u","2b","j"],function(a,b,c,d,e,f,g,h){var i=c.detect(),j=function(a){var b=g.createObjectURL(a);return k(a,b)},k=function(a,c){return e.nu(function(e){var g=f();g.onload=function(f){var g=b.generate("image"),h=f.target,i=d.blob(g,a,c,h);e(i)},g.readAsDataURL(a)})},l=function(a){return 0===a.length?e.pure([]):e.mapM(a,j)},m=function(a){return a.raw().target.files||a.raw().dataTransfer.files},n=function(b){return 1===b.length&&a.contains(b,"Files")},o=function(b){return!a.contains(b,"text/_moz_htmlcontext")},p=function(b){return a.contains(b,"Files")},q=function(a){return!0},r=function(){return i.browser.isChrome()||i.browser.isSafari()||i.browser.isOpera()?p:i.browser.isFirefox()?o:i.browser.isIE()?n:q},s=r(),t=function(c){var f=a.map(c,function(a){var c=b.generate("image");return d.url(c,h.get(a,"src"),a)});return e.pure(f)};return{multiple:l,toFiles:m,isFiles:s,fromImages:t,single:j,singleWithUrl:k}}),g("i",["1n"],function(a){var b=function(b){return a.multiple(b)},c=function(b){return a.single(b)},d=function(b,c){return a.singleWithUrl(b,c)};return{multiple:b,single:c,singleWithUrl:d}}),g("5",["g","h","i","j","k","d","f","2"],function(a,b,c,d,e,f,g,h){return function(i,j,k,l){var m,n=/^image\/(jpe?g|png|gif|bmp)$/i;i.on("dragstart dragend",function(a){m="dragstart"===a.type}),i.on("dragover dragend dragleave",function(a){a.preventDefault()});var o=function(a){var b={};if(a){if(a.getData){var c=a.getData("Text");c&&c.length>0&&(b["text/plain"]=c)}if(a.types)for(var d=0;d0},q=function(a){return!r(a)&&(p(a,"text/html")||p(a,"text/plain"))},r=function(a){var b=a["text/plain"];return!!b&&0===b.indexOf("file://")},s=function(b){var c=b.target.files||b.dataTransfer.files;return a.filter(c,function(a){return n.test(a.type)})},t=function(c){return a.map(c,function(a){var c=e.fromTag("img"),f=b.cata(a,l.getLocalURL,function(a,b,c){return b});return d.set(c,"src",f),c.dom().outerHTML}).join("")},u=function(a){c.multiple(a).get(function(a){var b=t(a);i.insertContent(b,{merge:i.settings.paste_merge_formats!==!1}),l.uploadImages(a)})};i.on("drop",function(a){if(!m){if(h.dom.RangeUtils&&h.dom.RangeUtils.getCaretRangeFromPoint){var b=h.dom.RangeUtils.getCaretRangeFromPoint(a.clientX,a.clientY,i.getDoc());b&&i.selection.setRng(b)}var c=s(a);if(c.length>0)return u(c),void a.preventDefault();var d=o(a.dataTransfer);if(q(d)){var e=g(i,f.translate);e.showDialog(d["text/html"]||d["text/plain"]),a.preventDefault()}}})}}),g("4r",["g","2c","1f"],function(a,b,c){var d=["officeStyles","htmlStyles","isWord","proxyBin","isInternal","backgroundAssets"],e=function(b,c){var e={};return a.each(d,function(a){var d=c[a]().or(b[a]());d.each(function(b){e[a]=b})}),f(e)},f=b.immutableBag([],d);return{nu:f,merge:e}}),g("2w",["n","1m"],function(a,b){var c=b.generate([{error:["message"]},{paste:["elements","assets","correlated"]},{cancel:[]},{incomplete:["elements","assets","correlated","message"]}]),d=function(a,b,c,d,e){return a.fold(b,c,d,e)},e=function(b,e){return d(b,a.none,a.none,a.none,function(b,f,g,h){return d(e,a.none,function(b,d,e){return a.some(c.incomplete(b,d,e,h))},a.none,a.none)}).getOr(e)};return{error:c.error,paste:c.paste,cancel:c.cancel,incomplete:c.incomplete,cata:d,carry:e}}),g("4q",["4r","2w","1v","2c"],function(a,b,c,d){var e=d.immutableBag(["response","bundle"],[]),f=function(a){return l(function(b){var c=e(a);b(c)})},g=function(a,b){a(e(b))},h=function(a){return f({response:a.response(),bundle:a.bundle()})},i=function(c){return f({response:b.error(c),bundle:a.nu({})})},j=function(){return f({response:b.cancel(),bundle:a.nu({})})},k=function(){return f({response:b.paste([],[],[]),bundle:a.nu({})})},l=function(a){var b=function(b){a(b)};return c(l,b)};return{call:g,sync:l,pure:f,pass:h,done:e,error:i,initial:k,cancel:j}}),g("23",["n"],function(a){var b=function(a){for(var b=[],c=function(a){b.push(a)},d=0;d0){var j=c.mapM(h,function(a){var c=d.createObjectURL(a);return i.apply(g,[a,"specified",c]),b.singleWithUrl(a,c)});return e.some(j)}return e.none()};return{convert:g}}),g("30",["4u","o","p","n"],function(a,b,c,d){var e=function(){var c=d.none(),e=function(b){c=a.convert(b)},f=function(a){return c.fold(function(){return b.nu(function(a){a([])})},function(a){return a}).get(a)},g=function(){c=d.none()};return{convert:e,listen:f,clear:g}},f=function(){return{convert:d.none,listen:function(a){a([])},clear:c.noop}};return{background:e,ignore:f}}),h("4v",RegExp),g("31",["n","23","4v"],function(a,b,c){var d=function(a){return void 0!==a&&void 0!==a.types&&null!==a.types},e=function(a,c){return b.findMap(a,function(a){return f(c,a)})},f=function(d,e){var f=new c(e,"i");return b.findMap(d,function(b){return null!==b.match(f)?a.some({type:b,flavor:e}):a.none()})};return{isValidData:d,getPreferredFlavor:e,getFlavor:f}}),g("4x",["1l","1m"],function(a,b){var c=b.generate([{none:[]},{error:["message "]},{blob:["blob"]}]),d=function(a,b,c,d){return a.fold(b,c,d)};return a.merge(c,{cata:d})}),g("78",["3p"],function(a){return function(b,c){var d=a.getOrDie("Blob");return new d(b,c)}}),g("79",["3p"],function(a){return function(b){var c=a.getOrDie("Uint8Array");return new c(b)}}),g("7a",["3p"],function(a){var b=function(b){var c=a.getOrDie("requestAnimationFrame");c(b)},c=function(b){var c=a.getOrDie("atob");return c(b)};return{atob:c,requestAnimationFrame:b}}),g("6d",["4x","78","79","7a","n","2f","37","12","62"],function(a,b,c,d,e,f,g,h,i){var j=function(a,e){for(var f=1024,g=d.atob(a),j=g.length,k=i.ceil(j/f),l=new h(k),m=0;m"data:image/".length},l=function(b){if(!k(b))return a.none();var c=b.indexOf(";"),d=b.substr("data:".length,c-"data:".length),e=b.substr(c+";base64,".length);try{var f=a.blob(j(e,d));return f}catch(g){return a.error(g)}};return{convert:l}}),g("4w",["6d"],function(a){var b=function(b){return a.convert(b)};return{toBlob:b}}),g("4y",["2w","g","h","p","2c","j","k","1d","2a","1f"],function(a,b,c,d,e,f,g,h,i,j){var k=e.immutable("asset","image"),l=function(a,e){var g=[];return b.each(a,function(a,b){c.cata(a,function(c,d,h,i){var j=e[b];f.set(j,"src",h),g.push(k(a,j))},d.noop)}),g},m=function(a,e){var g=[],j=b.bind(a,function(a){return"img"===h.name(a)?[a]:i.descendants(a,"img")});return b.each(e,function(a){c.cata(a,function(c,d,e,h){b.each(j,function(b){f.get(b,"src")===e&&g.push(k(a,b))})},d.noop)}),g},n=function(d){var e=[],h=[],i=[];return b.each(d,function(a){return c.cata(a,function(b,c,d,j){var l=g.fromTag("img");f.set(l,"src",d),e.push(l),h.push(a),i.push(k(a,l))},function(a,b,c){j.error("Internal error: Paste operation produced an image URL instead of a Data URI: ",b)})}),a.paste(e,h,i)};return{createImages:n,findImages:m,updateSources:l}}),g("1y",["g","29","3f"],function(a,b,c){var d=function(b){b.dom().textContent="",a.each(c.children(b),function(a){e(a)})},e=function(a){var b=a.dom();null!==b.parentNode&&b.parentNode.removeChild(b)},f=function(a){var d=c.children(a);d.length>0&&b.before(a,d),e(a)};return{empty:d,remove:e,unwrap:f}}),g("32",["4w","4x","4q","4y","2w","g","i","n","2c","j","k","1d","1y","29","2a"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=i.immutable("blob","image"),q=function(c,d){var e=a.toBlob(d);return b.cata(e,h.none,h.none,function(a){return h.some(p(a,c))})},r=function(a){var b=k.fromTag("div");return n.append(b,a),o.descendants(b,"img[src]")},s=function(a){return 0===a.indexOf("data:")&&a.indexOf("base64")>-1},t=function(a){return 0===a.indexOf("blob:")},u=function(a){return s(a)||t(a)},v=function(a){var b=j.get(a,"src");return u(b)},w=function(a){return f.bind(r(a),function(a){var b=j.get(a,"src");return u(b)?q(a,b).toArray():[]})},x=function(a){var b=f.filter(a,function(a){return"img"!==l.name(a)||!v(a)});return e.incomplete(b,[],[],"errors.local.images.disallowed")};return function(a){return function(b,h){return c.sync(function(b){var i=function(){c.call(b,{response:h.response(),bundle:h.bundle()})},j=function(a){var i=w(a),j=f.map(i,function(a){return a.blob()});g.multiple(j).get(function(g){var j=f.map(i,function(a){return a.image()}),k=d.updateSources(g,j);c.call(b,{response:e.paste(a,g,k),bundle:h.bundle()})})},k=function(a){var d=f.filter(r(a),v);f.each(d,m.remove),c.call(b,{response:d.length>0?x(a):h.response(),bundle:h.bundle()})},l=function(b,c,d,e){a.allowLocalImages===!1?k(b):0===c.length?j(b):i()};e.cata(h.response(),i,l,i,l)})}}}),g("4z",["4q","2w","o","1f"],function(a,b,c,d){var e=function(c){var e=function(e,f){return c.proxyBin().fold(function(){return d.error(e),a.pure({response:b.cancel(),bundle:{}})},f)};return{handle:e}},f=function(a){return c.nu(function(b){a.backgroundAssets().fold(function(){b([])},function(a){a.listen(b)})})},g=function(a){var b=j(a);return b&&h(a)||!b&&i(a)},h=function(a){return a.officeStyles().getOr(!0)},i=function(a){return a.htmlStyles().getOr(!1)},j=function(a){return a.isWord().getOr(!1)},k=function(a){return a.isInternal().getOr(!1)};return{proxyBin:e,backgroundAssets:f,merging:g,mergeOffice:h,mergeNormal:i,isWord:j,isInternal:k}}),g("5c",["3g"],function(a){var b=a.create("ephox-cement");return{resolve:b.resolve}}),g("50",["5c","1l","p","n","27","k","28","1x","29"],function(a,b,c,d,e,f,g,h,i){return function(j,k){var l=k.translations,m=function(a,c,e){e(d.some(b.merge(c,{officeStyles:a,htmlStyles:a})))},n=function(b,c){var k=function(){t(),m(!1,b,c)},n=function(){t(),m(!0,b,c)},o=f.fromTag("div");e.add(o,a.resolve("styles-dialog-content"));var p=f.fromTag("p"),q=g.fromHtml(l("cement.dialog.paste.instructions"));i.append(p,q),h.append(o,p);var r={text:l("cement.dialog.paste.clean"),tabindex:0,className:a.resolve("clean-styles"),click:k},s={text:l("cement.dialog.paste.merge"),tabindex:1,className:a.resolve("merge-styles"),click:n},t=function(){v.destroy()},u=function(){c(d.none()),t()},v=j(!0);v.setTitle(l("cement.dialog.paste.title")),v.setContent(o),v.setButtons([r,s]),v.show(),v.events.close.bind(u)},o=function(a,b){var c=a?"officeStyles":"htmlStyles",d=k[c];"clean"===d?m(!1,k,b):"merge"===d?m(!0,k,b):n(k,b)};return{get:o,destroy:c.noop}}}),g("33",["4q","4r","4z","50","2w"],function(a,b,c,d,e){var f=function(f,g){var h=d(f,g);return function(d,f){var g=f.bundle(),i=f.response();return a.sync(function(d){h.get(c.isWord(g),function(c){var g=c.fold(function(){return{response:e.cancel(),bundle:f.bundle()}},function(a){return{response:i,bundle:b.nu({officeStyles:a.officeStyles,htmlStyles:a.htmlStyles})}});a.call(d,g)})})}},g=function(d,e){return function(g,h){return c.isInternal(h.bundle())?a.pure({response:h.response(),bundle:b.nu({officeStyles:!0,htmlStyles:!0})}):f(d,e)(g,h)}},h=function(c,d){return function(e,f){return a.pure({response:f.response(),bundle:b.nu({officeStyles:c,htmlStyles:d})})}};return{fixed:h,fromConfig:f,fromConfigIfExternal:g}}),g("7r",["2t","p","k","1g"],function(a,b,c,d){var e=function(a){for(var b=[];null!==a.nextNode();)b.push(c.fromDom(a.currentNode));return b},f=function(a){try{return e(a)}catch(b){return[]}},g=a.detect().browser,h=g.isIE()||g.isSpartan()?f:e,i=b.constant(b.constant(!0)),j=function(a,b){var c=b.fold(i,function(a){return function(b){return a(b.nodeValue)}});c.acceptNode=c;var e=d.createTreeWalker(a.dom(),NodeFilter.SHOW_COMMENT,c,!1);return h(e)};return{find:j}}),g("7b",["n","7r","37","1g"],function(a,b,c,d){var e=function(d){return b.find(d,a.some(function(a){return c.startsWith(a,"[if gte vml 1]")}))};return{find:e}}),g("6q",[],function(){var a=function(a){return void 0!==a.style};return{isSupported:a}}),h("11",window),g("5d",["1b","g","1c","n","j","5i","k","1d","6q","37","1e","1f","11"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(b,c,d){if(!a.isString(d))throw l.error("Invalid call to CSS.set. Property ",c,":: Value ",d,":: Element ",b),new k("CSS value must be a string: "+d);i.isSupported(b)&&b.style.setProperty(c,d)},o=function(a,b){i.isSupported(a)&&a.style.removeProperty(b)},p=function(a,b,c){var d=a.dom();n(d,b,c)},q=function(a,b){var d=a.dom();c.each(b,function(a,b){n(d,b,a)})},r=function(a,b){var d=a.dom();c.each(b,function(a,b){a.fold(function(){o(d,b)},function(a){n(d,b,a)})})},s=function(a,b){var c=a.dom(),d=m.getComputedStyle(c),e=d.getPropertyValue(b),g=""!==e||f.inBody(a)?e:t(c,b);return null===g?void 0:g},t=function(a,b){return i.isSupported(a)?a.style.getPropertyValue(b):""},u=function(a,b){var c=a.dom(),e=t(c,b);return d.from(e).filter(function(a){return a.length>0})},v=function(a,b,c){var d=g.fromTag(a);p(d,b,c);var e=u(d,b);return e.isSome()},w=function(a,b){var c=a.dom();o(c,b),e.has(a,"style")&&""===j.trim(e.get(a,"style"))&&e.remove(a,"style")},x=function(a,b){var c=e.get(a,"style"),d=b(a),f=void 0===c?e.remove:e.set;return f(a,"style",c),d},y=function(a,b){var c=a.dom(),d=b.dom();i.isSupported(c)&&i.isSupported(d)&&(d.style.cssText=c.style.cssText)},z=function(a){return a.dom().offsetWidth},A=function(a,b,c){u(a,c).each(function(a){u(b,c).isNone()&&p(b,c,a)})},B=function(a,c,d){h.isElement(a)&&h.isElement(c)&&b.each(d,function(b){A(a,c,b)})};return{copy:y,set:p,preserve:x,setAll:q,setOptions:r,remove:w,get:s,getRaw:u,isValidValue:v,reflow:z,transfer:B}}),g("6r",["1b","g","p","n","5i","3n","k","2i"],function(a,b,c,d,e,f,g,h){var i=function(a){return n(e.body(),a)},j=function(b,e,f){for(var h=b.dom(),i=a.isFunction(f)?f:c.constant(!1);h.parentNode;){h=h.parentNode;var j=g.fromDom(h);if(e(j))return d.some(j);if(i(j))break}return d.none()},k=function(a,b,c){var d=function(a){return b(a)};return h(d,j,a,b,c)},l=function(a,b){var c=a.dom();return c.parentNode?m(g.fromDom(c.parentNode),function(c){return!f.eq(a,c)&&b(c)}):d.none()},m=function(a,e){var f=b.find(a.dom().childNodes,c.compose(e,g.fromDom));return d.from(f).map(g.fromDom)},n=function(a,b){var c=function(a){for(var e=0;e");return d.dom().innerHTML=c.substr(h+"]>".length),g.descendant(d,function(a){return f.name(a)===b})},l=function(b){return f.isComment(b)?k(b,"v:shape"):a.none()},m=function(a){return l(a).map(function(a){var f=b.get(a,"o:spid"),g=void 0===f?b.get(a,"id"):f,h=e.fromTag("img");return c.add(h,"rtf-data-image"),b.set(h,"data-image-id",g.substr("_x0000_".length)),b.set(h,"data-image-type","code"),d.setAll(h,{width:d.get(a,"width"),height:d.get(a,"height")}),h})},n=function(d){if("img"===f.name(d)){var e=b.get(d,"src");if(void 0!==e&&null!==e&&j.startsWith(e,"file://")){var g=h.shallow(d),i=e.split(/[\/\\]/),k=i[i.length-1];return b.set(g,"data-image-id",k),b.remove(g,"src"),b.set(g,"data-image-type","local"),c.add(g,"rtf-data-image"),a.some(g)}return a.none()}return a.none()},o=function(a){return p(a).length>0},p=function(a){return i.descendants(a,".rtf-data-image")};return{local:n,vshape:m,find:p,exists:o,scour:l}}),g("6e",["7b","g","5a","n","23","2c","j","28","2a","1f"],function(a,b,c,d,e,f,g,h,i,j){var k=f.immutable("img","vshape"),l=function(a){var b=n(a);return b._rawElement=a.dom(),b},m=function(a){var b=n(a);return b._rawElement=a.dom(),b},n=function(a){return g.clone(a)},o=function(d){var f=h.fromHtml(d),g=b.bind(f,function(a){return i.descendants(a,"img")}),j=b.bind(f,a.find),k=e.cat(b.map(j,c.scour)),l=b.map(g,function(a){return p(a,k)});return e.cat(l)},p=function(a,c){var e=g.get(a,"v:shapes"),f=d.from(b.find(c,function(a){return g.get(a,"id")===e}));return f.isNone()&&j.log("WARNING: unable to find data for image",a.dom()),f.map(function(b){return q(a,b)})},q=function(a,b){return k(l(a),m(b))};return{extract:o}}),g("7c",["1b","g","p","n","j","27"],function(a,b,c,d,e,f){var g=function(b,c){var d=c.style;if(e.has(b,"width")&&e.has(b,"height")&&a.isString(d)){var f=d.match(/rotation:([^;]*)/);null===f||"90"!==f[1]&&"-90"!==f[1]||e.setAll(b,{width:e.get(b,"height"),height:e.get(b,"width")})}},h=function(a,b){var c=b["o:spid"],d=void 0===c?b.id:c;g(a,b),f.add(a,"rtf-data-image"),e.set(a,"data-image-id",d.substr("_x0000_".length)),e.set(a,"data-image-type","code")},i=function(a,b,c){return c.img()[a]===b},j=function(a,f,g){var h=e.get(f,g),j=c.curry(i,g,h),k=b.find(a,j);return d.from(k).map(function(a){return e.remove(f,g),a})},k=function(a,c,d){b.each(c,function(b){j(a,b,d).each(function(a){h(b,a.vshape())})})};return{rotateImage:g,insertRtfCorrelation:k}}),g("7s",["2t","n","1e"],function(a,b,c){return function(d,e){var f=function(a){if(!d(a))throw new c("Can only get "+e+" value of a "+e+" node");return j(a).getOr("")},g=function(a){try{return h(a)}catch(c){return b.none()}},h=function(a){ -return d(a)?b.from(a.dom().nodeValue):b.none()},i=a.detect().browser,j=i.isIE()&&10===i.version.major?g:h,k=function(a,b){if(!d(a))throw new c("Can only set raw "+e+" value of a "+e+" node");a.dom().nodeValue=b};return{get:f,getOption:j,set:k}}}),g("7d",["1d","7s"],function(a,b){var c=b(a.isComment,"comment"),d=function(a){return c.get(a)},e=function(a){return c.getOption(a)},f=function(a,b){c.set(a,b)};return{get:d,getOption:e,set:f}}),g("7t",["1x"],function(a){var b=function(b,c,d){b.dom().styleSheet?b.dom().styleSheet.cssText=c:a.append(b,d)};return{setCss:b}}),g("8f",[],function(){var a=function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")};return{escape:a}}),g("7u",["1c","8f","4v"],function(a,b,c){var d=function(a,d,e){var f=new c("url\\(\\s*['\"]?"+b.escape(d)+"(.*?)['\"]?\\s*\\)","g");return a.replace(f,'url("'+e+'$1")')},e=function(b,c){var e=b;return a.each(c,function(a,b){e=d(e,b,a)}),e};return{replace:d,replaceMany:e}}),g("7e",["j","k","1x","20","7t","7u","12"],function(a,b,c,d,e,f,g){var h=function(c){var d=b.fromTag("style",c.dom());return a.set(d,"type","text/css"),d},i=function(a,c,d){e.setCss(a,c,b.fromText(c,d.dom()))},j=function(a,b,e){var g=h(e),j=void 0===b?a:f.replaceMany(a,b);i(g,j,e);var k=d.descendant(e,"head").getOrDie();c.append(k,g)},k=function(a){var b=a.dom().styleSheets;return g.prototype.slice.call(b)};return{stylesheets:k,inject:j}}),g("7v",["g","2c"],function(a,b){var c=b.immutable("selector","style","raw"),d=function(b){var d=b.cssRules;return a.map(d,function(a){var b=a.selectorText,d=a.style.cssText;if(void 0===d)throw"WARNING: Browser does not support cssText property";return c(b,d,a.style)})},e=function(b){return a.bind(b,d)};return{extract:d,extractAll:e}}),g("7f",["7v"],function(a){var b=function(b){return a.extract(b)},c=function(b){return a.extractAll(b)};return{extract:b,extractAll:c}}),function(a,b,c){a("7g",[],function(){var a=function(){var a,b,c;return a=function(a){var c,d,e,f,g=[];for(c=a.split(","),e=0,f=c.length;e0&&g.push(b(d));return g},b=function(a){var b,c=a,d={a:0,b:0,c:0},e=[],f=/(\[[^\]]+\])/g,g=/(#[^\s\+>~\.\[:]+)/g,h=/(\.[^\s\+>~\.\[:]+)/g,i=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,j=/(:[\w-]+\([^\)]*\))/gi,k=/(:[^\s\+>~\.\[:]+)/g,l=/([^\s\+>~\.\[:]+)/g;return b=function(b,f){var g,h,i,j,k,l;if(b.test(c))for(g=c.match(b),h=0,i=g.length;h~]/g," "),c=c.replace(/[#\.]/g," "),b(l,"c"),e.sort(function(a,b){return a.index-b.index}),{selector:a,specificity:"0,"+d.a.toString()+","+d.b.toString()+","+d.c.toString(),specificityArray:[0,d.a,d.b,d.c],parts:e}},c=function(a,c){var d,e,f;if("string"==typeof a){if(a.indexOf(",")!==-1)throw"Invalid CSS selector";d=b(a).specificityArray}else{if(!Array.isArray(a))throw"Invalid CSS selector or specificity array";if(4!==a.filter(function(a){return"number"==typeof a}).length)throw"Invalid specificity array";d=a}if("string"==typeof c){if(c.indexOf(",")!==-1)throw"Invalid CSS selector";e=b(c).specificityArray}else{if(!Array.isArray(c))throw"Invalid CSS selector or specificity array";if(4!==c.filter(function(a){return"number"==typeof a}).length)throw"Invalid specificity array";e=c}for(f=0;f<4;f+=1){if(d[f]e[f])return 1}return 0},{calculate:a,compare:c}}();return"undefined"!=typeof exports&&(exports.calculate=a.calculate,exports.compare=a.compare),a})}(f.bolt.module.api.define,f.bolt.module.api.require,f.bolt.module.api.demand),g("6f",["7c","g","p","2c","j","7d","5d","1y","2a","3f","7e","7f","7g"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=d.immutable("selector","raw"),o=function(b,c,d,e,f){var g=i.descendants(c,"img");t(c),a.insertRtfCorrelation(d,g,e);var h=f.mergeInline()?s:p;h(b,c)},p=c.noop,q=function(a,c){var d={};return b.each(a,function(e){if(void 0!==a[e]){var f=c.dom().style;b.contains(f,e)||(d[e]=a[e])}}),d},r=function(a,c){var d=b.bind(c,function(c){var d=i.descendants(a,c.selector());return b.each(d,function(a){var b=q(c.raw(),a);g.setAll(a,b)}),d});b.each(d,function(a){e.remove(a,"class")})},s=function(a,c){var d=k.stylesheets(a),e=l.extractAll(d),f=function(a){return a.selector().indexOf(",")!==-1},g=function(a){return!f(a)},h=function(a){var c=a.selector().split(",");return b.map(c,function(b){var c=b.trim();return n(c,a.raw())})},i=b.flatten(b.map(b.filter(e,f),h)),j=b.filter(e,g),o=j.concat(i);o.sort(function(a,b){return m.compare(a.selector(),b.selector())}).reverse(),r(c,o)},t=function(a){var c=j.children(a);b.each(c,function(a){f.getOption(a).each(function(b){"StartFragment"!==b&&"EndFragment"!==b||h.remove(a)})})};return{doMergeInlineStyles:r,process:o}}),g("71",["n","k"],function(a,b){var c=function(c){var d=c.dom();try{var e=d.contentWindow?d.contentWindow.document:d.contentDocument;return void 0!==e&&null!==e?a.some(b.fromDom(e)):a.none()}catch(f){return console.log("Error reading iframe: ",d),console.log("Error was: "+f),a.none()}},d=function(a){var b=c(a);return b.fold(function(){return a},function(a){return a})};return{doc:d}}),g("5x",["71","5i"],function(a,b){var c=function(c,d){if(!b.inBody(c))throw"Internal error: attempted to write to an iframe that is not in the DOM";var e=a.doc(c),f=e.dom();f.open(),f.writeln(d),f.close()};return{write:c}}),g("25",["p","k"],function(a,b){var c=function(b,c,d,e,f,g,h){return{target:a.constant(b),x:a.constant(c),y:a.constant(d),stop:e,prevent:f,kill:g,raw:a.constant(h)}},d=function(d,e){return function(f){if(d(f)){var g=b.fromDom(f.target),h=function(){f.stopPropagation()},i=function(){f.preventDefault()},j=a.compose(i,h),k=c(g,f.clientX,f.clientY,h,i,j,f);e(k)}}},e=function(b,c,e,f,g){var i=d(e,f);return b.dom().addEventListener(c,i,g),{unbind:a.curry(h,b,c,i,g)}},f=function(a,b,c,d){return e(a,b,c,d,!1)},g=function(a,b,c,d){return e(a,b,c,d,!0)},h=function(a,b,c,d){a.dom().removeEventListener(b,c,d)};return{bind:f,capture:g}}),g("w",["p","25"],function(a,b){var c=a.constant(!0),d=function(a,d,e){return b.bind(a,d,c,e)},e=function(a,d,e){return b.capture(a,d,c,e)};return{bind:d,capture:e}}),g("6g",["p","5x","5d","w","k","1x","1y","x"],function(a,b,c,d,e,f,g,h){return function(i){var j=function(j,k,l){var m=e.fromTag("div"),n=e.fromTag("iframe");c.setAll(m,{display:"none"});var o=d.bind(n,"load",function(){o.unbind(),b.write(n,j);var c=n.dom().contentWindow.document;if(void 0===c)throw"sandbox iframe load event did not fire correctly";var d=e.fromDom(c),f=c.body;if(void 0===f)throw"sandbox iframe does not have a body";var i=e.fromDom(f),p=k(d,i);g.remove(m),h(a.curry(l,p),0)});f.append(m,n),f.append(i,m)};return{play:j}}}),g("6h",["k","28","1x","29","1y","3f"],function(a,b,c,d,e,f){var g=function(a){return a.dom().innerHTML},h=function(g,h){var i=f.owner(g),j=i.dom(),k=a.fromDom(j.createDocumentFragment()),l=b.fromHtml(h,j);d.append(k,l),e.empty(g),c.append(g,k)},i=function(b){var d=a.fromTag("div"),e=a.fromDom(b.dom().cloneNode(!0));return c.append(d,e),g(d)};return{get:g,set:h,getOuter:i}}),g("51",["4q","4r","6e","6f","2w","p","6g","k","28","6h","1g"],function(a,b,c,d,e,f,g,h,i,j,k){var l="data-textbox-image",m=function(a){return void 0===a||null===a||0===a.length},n=function(a){var b=1;return a.replace(/(]*)src=".*?"/g,function(a,c,d){return c+l+'="'+b++ +'"'})},o=function(a,b){var c=g(h.fromDom(k.body));return function(e,g){c.play(e,function(c,e){return d.process(c,e,a,l,{mergeInline:f.constant(b)}),j.get(e)},g)}},p=function(d,f,g){return a.sync(function(h){var j=c.extract(d),k=o(j,f);k(g,function(c){var d=i.fromHtml(c);a.call(h,{response:e.paste(d,[],[]),bundle:b.nu({})})})})},q=function(){return a.pure({response:e.paste([],[],[]),bundle:b.nu({})})},r=function(a){var b=a.indexOf("");return b>-1?a.substr(0,b+"".length):a},s=function(b,c,d){var f=r(b.data()),g=n(f);return d.cleanDocument(g,c).fold(function(){return a.pure({response:e.error("errors.paste.word.notready"),bundle:{}})},function(a){return m(a)?q():p(g,c,a)})};return{handle:s}}),g("52",["4q","4r","4y","g","i"],function(a,b,c,d,e){var f=function(f){var g=d.filter(f,function(a){return"file"===a.kind&&/image/.test(a.type)}),h=d.map(g,function(a){return a.getAsFile()});return a.sync(function(d){e.multiple(h).get(function(e){var f=c.createImages(e);a.call(d,{response:f,bundle:b.nu({})})})})};return{handle:f}}),g("7w",[],function(){return{validStyles:function(){return/^(mso-.*|tab-stops|tab-interval|language|text-underline|text-effect|text-line-through|font-color|horiz-align|list-image-[0-9]+|separator-image|table-border-color-(dark|light)|vert-align|vnd\..*)$/},specialInline:function(){return/^(font|em|strong|samp|acronym|cite|code|dfn|kbd|tt|b|i|u|s|sub|sup|ins|del|var|span)$/}}}),g("83",[],function(){var a=function(a){return g(function(b,c,d,e,f,g){return b(a)})},b=function(a){return g(function(b,c,d,e,f,g){return c(a)})},c=function(a){return g(function(b,c,d,e,f,g){return d(a)})},d=function(a){return g(function(b,c,d,e,f,g){return e(a)})},e=function(){return g(function(a,b,c,d,e,f){return e()})},f=function(a){return g(function(b,c,d,e,f,g){return g(a)})},g=function(a){var b=function(b){return a(function(a){return 0===b.toLowerCase().indexOf(a.toLowerCase())},function(a){return a.test(b.toLowerCase())},function(a){return b.toLowerCase().indexOf(a.toLowerCase())>=0},function(a){return b.toLowerCase()===a.toLowerCase()},function(){return!0},function(a){return!a.matches(b)})};return{fold:a,matches:b}},h=function(a,b,c,d,e,f,g){return a.fold(b,c,d,e,f,g)};return{starts:a,pattern:b,contains:c,exact:d,all:e,not:f,cata:h}}),g("7x",["p","1d","83"],function(a,b,c){var d=function(b,d,e,f){var g=f.name,h=void 0!==f.condition?f.condition:a.constant(!0),i=void 0!==f.value?f.value:c.all();return g.matches(e)&&i.matches(d)&&h(b)},e=function(c,d){var e=b.name(c),f=d.name,g=void 0!==d.condition?d.condition:a.constant(!0);return f.matches(e)&&g(c)};return{keyval:d,name:e}}),g("8g",["g","1c","p","j"],function(a,b,c,d){var e=function(b,c){var d={};return a.each(b.dom().attributes,function(a){c(a.value,a.name)||(d[a.name]=a.value)}),d},f=function(c,e,f){a.each(e,function(a){d.remove(c,a)}),b.each(f,function(a,b){d.set(c,b,a)})},g=function(c,d,e){var g=a.map(c.dom().attributes,function(a){return a.name});b.size(d)!==g.length&&f(c,g,d)};return{filter:e,clobber:g,scan:c.constant({})}}),g("8h",["g","1c","j","5d","37"],function(a,b,c,d,e){var f=function(b){var c={},d=void 0!==b&&null!==b?b.split(";"):[];return a.each(d,function(a){var b=a.split(":");2===b.length&&(c[e.trim(b[0])]=e.trim(b[1]))}),c},g=function(a,b){return a.dom().style.getPropertyValue(b)},h=function(b,c){var d=b.dom().style,e=void 0===d?[]:d,f={};return a.each(e,function(a){var d=g(b,a);c(d,a)||(f[a]=d)}),f},i=function(a,b,c){d.set(a,b,c)},j=function(b,c,d){var e=b.dom().getAttribute("style"),g=f(e),h={};return a.each(c,function(a){var b=g[a];void 0===b||d(b,a)||(h[a]=b)}),h},k=function(c){var d=b.keys(c);return a.map(d,function(a){return a+": "+c[a]}).join("; ")},l=function(a,d,e){c.set(a,"style","");var f=b.size(d),g=b.size(e);if(0===f&&0===g)c.remove(a,"style");else if(0===f)c.set(a,"style",k(e));else{b.each(d,function(b,c){i(a,c,b)});var h=c.get(a,"style"),j=g>0?k(e)+"; ":"";c.set(a,"style",j+h)}};return{filter:h,clobber:l,scan:j}}),g("7y",["8g","8h","p","k"],function(a,b,c,d){var e=["mso-list"],f=function(a,c){var d=b.scan(a,e,c),f=b.filter(a,c);b.clobber(a,f,d)},g=function(b,c){var d=a.filter(b,c);a.clobber(b,d,{})},h=function(a){var d=b.filter(a,c.constant(!1));b.clobber(a,d,{})},i=function(a,b){f(d.fromDom(a),b)},j=function(a,b){g(d.fromDom(a),b)};return{style:f,attribute:g,styleDom:i,attributeDom:j,validateStyles:h}}),g("7i",["g","1l","7x","7y","p","j","27","3q","1y","2a"],function(a,b,c,d,e,f,g,h,i,j){var k=function(b,d,e){b(e,function(b,f){return a.exists(d,function(a){return c.keyval(e,b,f,a)})})},l=function(l,m){var n=b.merge({styles:[],attributes:[],classes:[],tags:[]},m),o=j.descendants(l,"*");a.each(o,function(b){k(d.style,n.styles,b),k(d.attribute,n.attributes,b),a.each(n.classes,function(c){var d=f.has(b,"class")?h.get(b):[];a.each(d,function(a){c.name.matches(a)&&g.remove(b,a)})})});var p=j.descendants(l,"*");a.each(p,function(b){var d=a.exists(n.tags,e.curry(c.name,b));d&&i.remove(b)})},m=function(d,f){var g=b.merge({tags:[]},f),h=j.descendants(d,"*");a.each(h,function(b){var d=a.exists(g.tags,e.curry(c.name,b));d&&i.unwrap(b)})},n=function(d,f){var g=b.merge({tags:[]},f),h=j.descendants(d,"*");a.each(h,function(b){var d=a.find(g.tags,e.curry(c.name,b));void 0!==d&&null!==d&&d.mutate(b)})},o=function(b){var c=j.descendants(b,"*");a.each(c,function(a){d.validateStyles(a)})};return{remover:l,unwrapper:m,transformer:n,validator:o}}),g("86",["1c","5d","k"],function(a,b,c){var d="startElement",e="endElement",f="text",g="comment",h=function(a,h,i){var j,k,l,m=c.fromDom(a);switch(a.nodeType){case 1:h?j=e:(j=d,b.setAll(m,i||{})),k="HTML"!==a.scopeName&&a.scopeName&&a.tagName&&a.tagName.indexOf(":")<=0?(a.scopeName+":"+a.tagName).toUpperCase():a.tagName;break;case 3:j=f,l=a.nodeValue;break;case 8:j=g,l=a.nodeValue;break;default:console.log("WARNING: Unsupported node type encountered: "+a.nodeType)}var n=function(){return a},o=function(){return k},p=function(){return j},q=function(){return l};return{getNode:n,tag:o,type:p,text:q}},i=function(b,c,d,e){var f=e.createElement(b);return a.each(c,function(a,b){f.setAttribute(b,a)}),h(f,!1,d)},j=function(a,b){return h(b.createElement(a),!0)},k=function(a,b){return h(b.createComment(a),!1)},l=function(a,b){return h(b.createTextNode(a))},m=j("HTML",window.document);return{START_ELEMENT_TYPE:d,END_ELEMENT_TYPE:e,TEXT_TYPE:f,COMMENT_TYPE:g,FINISHED:m,token:h,createStartElement:i,createEndElement:j,createComment:k,createText:l}}),g("7z",["86"],function(a){var b=function(b){var c=b.createDocumentFragment(),d=c,e=function(a){g(a),c=a},f=function(){c=c.parentNode,null===c&&(c=d)},g=function(a){c.appendChild(a)},h=function(c){var d=function(a){var b=a.getNode().cloneNode(!1);e(b)},h=function(a,c){var d=b.createTextNode(a.text());g(d)};switch(c.type()){case a.START_ELEMENT_TYPE:d(c);break;case a.TEXT_TYPE:h(c);break;case a.END_ELEMENT_TYPE:f();break;case a.COMMENT_TYPE:break;default:throw{message:"Unsupported token type: "+c.type()}}};return{dom:d,receive:h,label:"SERIALISER"}};return{create:b}}),g("80",["86"],function(a){var b=function(b,c){var d;c=c||window.document,d=c.createElement("div"),c.body.appendChild(d),d.style.position="absolute",d.style.left="-10000px",d.innerHTML=b,nextNode=d.firstChild||a.FINISHED;var e=[];endNode=!1;var f=function(b,c){return b===a.FINISHED?b:b?a.token(b,c):void 0},g=function(){var b=nextNode,g=endNode;return!endNode&&nextNode.firstChild?(e.push(nextNode),nextNode=nextNode.firstChild):endNode||1!==nextNode.nodeType?nextNode.nextSibling?(nextNode=nextNode.nextSibling,endNode=!1):(nextNode=e.pop(),endNode=!0):endNode=!0,b===a.FINISHED||nextNode||(c.body.removeChild(d),nextNode=a.FINISHED),f(b,g)},h=function(){return void 0!==nextNode};return{hasNext:h,next:g}};return{tokenise:b}}),g("7j",["7z","80"],function(a,b){var c=function(a,b,c){var d,e=c;for(d=b.length-1;d>=0;d--)e=b[d](e,{},a);return e},d=function(d,e,f){for(var g=a.create(d),h=b.tokenise(e,d),i=c(d,f,g);h.hasNext();){var j=h.next();i.receive(j)}return g.dom};return{build:c,run:d}}),g("6m",["g","7i","7j","k","6h","1y","3f"],function(a,b,c,d,e,f,g){var h=function(a){return function(c){b.remover(c,a)}},i=function(a){return function(c){b.unwrapper(c,a)}},j=function(a){return function(c){b.transformer(c,a)}},k=function(){return function(a){b.validator(a)}},l=function(a){return function(b){var d=e.get(b),h=g.owner(b),i=c.run(h.dom(),d,a);f.empty(b),b.dom().appendChild(i)}},m=function(b,c,f){var g=d.fromTag("div",b.dom());return g.dom().innerHTML=c,a.each(f,function(a){a(g)}),e.get(g)},n=function(a,b){return a.indexOf("")>=0||b.browser.isSpartan()&&a.indexOf('v:shapes="')>=0||b.browser.isSpartan()&&a.indexOf("mso-")>=0||a.indexOf("mso-list")>=0||a.indexOf("p.MsoNormal, li.MsoNormal, div.MsoNormal")>=0||a.indexOf("MsoListParagraphCxSpFirst")>=0||a.indexOf("")>=0};return{removal:h,unwrapper:i,transformer:j,validate:k,pipeline:l,isWordContent:n,go:m}}),g("7l",["g","86"],function(a,b){return function(c,d,e){return function(e,f,g){var h=function(b){a.each(b,i)},i=function(a){e.receive(a)},j=function(a){c(l,a,k)},k=function(a,c){return b.token(c,a.type()===b.END_ELEMENT_TYPE,{})},l={emit:i,emitTokens:h,receive:j,document:window.document};return d(l),l}}}),g("8u",["8h","86","p","j","5d","k"],function(a,b,c,d,e,f){var g=function(a,b){var c=f.fromDom(a.getNode());return d.get(c,b)},h=function(a,b){var c=f.fromDom(a.getNode());return e.get(c,b)},i=function(a){return a.type()===b.TEXT_TYPE&&/^[\s\u00A0]*$/.test(a.text())},j=function(b){var d=f.fromDom(b.getNode()),e=a.scan(d,["mso-list"],c.constant(!1));return e["mso-list"]};return{getAttribute:g,getStyle:h,isWhitespace:i,getMsoList:j}}),g("96",["g","n"],function(a,b){var c=function(c,e){var f=a.find(c,function(a){return"UL"===a.tag||e&&d(a,e,!0)});return void 0!==f?b.some(f):c.length>0?b.some(c[0]):b.none()},d=function(a,b,c){return a===b||a&&b&&a.tag===b.tag&&a.type===b.type&&(c||a.variant===b.variant)};return{guessFrom:c,eqListType:d}}),g("8l",[],function(){var a=function(a,b){if(void 0===a||void 0===b)throw console.trace(),"brick";a.nextFilter.set(b)},b=function(b){return function(c,d,e){a(d,b)}},c=function(a,b,c){var d=b.nextFilter.get();d(a,b,c)},d=function(b){return function(d,e,f){a(e,b),c(d,e,f)}},e=function(a,b){return a.nextFilter.get()===b};return{next:a,go:c,jump:d,isNext:e,setNext:b}}),g("8t",["g","8u","96","8l","p","2c","j","k"],function(a,b,c,d,e,f,g,h){var i=function(a,b){return g.has(h.fromDom(b.getNode()),"data-list-level")},j=function(a){var b=parseInt(g.get(a,"data-list-level"),10),c=g.get(a,"data-list-emblems"),d=JSON.parse(c);return g.remove(a,"data-list-level"),g.remove(a,"data-list-emblems"),{level:e.constant(b),emblems:e.constant(d)}},k=f.immutable("level","token","type"),l=function(c){return!a.contains(["P"],c.tag())||/^MsoHeading/.test(b.getAttribute(c,"class"))},m=function(a,b,d,e){var f=d.getCurrentListType(),g=d.getCurrentLevel(),h=g==e.level()?f:null;return c.guessFrom(e.emblems(),h).filter(function(a){return!("OL"===a.tag&&l(b))})},n=function(a,b,c){var d=m(c.listType.get(),a,c.emitter,b);return d.each(c.listType.set),k(b.level(),c.originalToken.get(),c.listType.get())},o=function(a){return function(b,c,e){var f=j(h.fromDom(e.getNode()));f.level();c.originalToken.set(e);var g=n(e,f,c);c.emitter.openItem(g.level(),g.token(),g.type()),d.next(c,a.inside())}};return{predicate:i,action:o}}),g("8v",["p"],function(a){return function(b,c,d){return{pred:b,action:c,label:a.constant(d)}}}),g("8w",["g","p","n"],function(a,b,c){var d=function(a,b){return function(a,c,d){return b(a,c,d)}};return function(e,f,g){var h=d(e+" :: FALLBACK --- ",g),i=function(g,i,j){var k=c.from(a.find(f,function(a){return a.pred(i,j)})),l=k.fold(b.constant(h),function(a){var b=a.label();return void 0===b?a.action:d(e+" :: "+b,a.action)});l(g,i,j)};return i.toString=function(){return"Handlers for "+e},i}}),g("8i",["8t","86","8u","8v","8w","8l"],function(a,b,c,d,e,f){var g=function(a){var c=function(b,c,d){f.next(c,a.outside())},g=function(a,c){return c.type()===b.END_ELEMENT_TYPE&&a.originalToken.get()&&c.tag()===a.originalToken.get().tag()};return e("Inside.List.Item",[d(g,c,"Closing open tag")],function(a,b,c){a.emit(c)})},h=function(g){var h=function(a,b,c){b.emitter.closeAllLists(),a.emit(c),f.next(b,g.outside())},i=function(a,d){return d.type()===b.TEXT_TYPE&&c.isWhitespace(d)};return e("Outside.List.Item",[d(a.predicate,a.action(g),"Data List ****"),d(i,function(a,b,c){a.emit(c)},"Whitespace")],h)};return{inside:g,outside:h}}),g("97",["2c"],function(a){var b=a.immutable("state","result"),c=a.immutable("state","value"),d=a.immutable("level","type","types","items");return{state:d,value:c,result:b}}),g("9j",["97","n"],function(a,b){var c=function(c){var d=c.items().slice(0);if(d.length>0&&"P"!==d[d.length-1]){var e=d[d.length-1];d[d.length-1]="P";var f=a.state(c.level(),c.type(),c.types(),d);return a.value(f,b.some(e))}return a.value(c,b.none())},d=function(c,d){var e=c.items().slice(0),f=void 0!==d&&"P"!==d?b.some(d):b.none();f.fold(function(){e.push("P")},function(a){e.push(a)});var g=a.state(c.level(),c.type(),c.types(),e);return a.value(g,f)};return{start:d,finish:c}}),g("9k",["97"],function(a){var b=function(b,c,d){for(var e=[],f=b;c(f);){var g=d(f);f=g.state(),e=e.concat(g.result())}return a.result(f,e)},c=function(a,c,d){var e=function(a){return a.level()c};return b(a,e,d)};return{moveRight:c,moveLeft:d,moveUntil:b}}),g("9v",["8u"],function(a){var b=function(b){var c=a.getStyle(b,"margin-left");return void 0!==c&&"0px"!==c?{"margin-left":c}:{}},c=function(a){var c={"list-style-type":"none"};return a?b(a):c};return{from:c}}),g("9l",["7y","86","96","97","9j","9v","p"],function(a,b,c,d,e,f,g){var h=function(a,c,e){var f=c.start&&c.start>1?{start:c.start}:{},h=a.level()+1,i=c,j=a.types().concat([c]),k=[g.curry(b.createStartElement,c.tag,f,e)],l=d.state(h,i,j,a.items());return d.result(l,k)},i=function(a){var c=a.types().slice(0),e=[g.curry(b.createEndElement,c.pop().tag)],f=a.level()-1,h=c[c.length-1],i=d.state(f,h,c,a.items());return d.result(i,e)},j=function(a,b){var c=i(a),e=h(c.state(),b,b.type?{"list-style-type":b.type}:{});return d.result(e.state(),c.result().concat(e.result()))},k=function(h,i,k){var l={},m=f.from(i),n=h.type()&&!c.eqListType(h.type(),k)?j(h,k):d.result(h,[]),o=[g.curry(b.createStartElement,"LI",l,m)],p=e.start(n.state(),i&&i.tag()),q=p.value().map(function(b){return a.styleDom(i.getNode(),g.constant(!0)),[g.constant(i)]}).getOr([]);return d.result(p.state(),n.result().concat(o).concat(q))},l=function(a){var c=g.curry(b.createEndElement,"LI"),f=e.finish(a),h=f.value().fold(function(){return[c]},function(a){return[g.curry(b.createEndElement,a),c]});return d.result(f.state(),h)};return{open:h,openItem:k,close:i,closeItem:l}}),g("98",["g","86","97","9j","9k","9l","p","n"],function(a,b,c,d,e,f,g,h){var i=function(b){if(0===b.length)throw"Compose must have at least one element in the list";var d=b[b.length-1],e=a.bind(b,function(a){return a.result()});return c.result(d.state(),e)},j=function(a){var b=f.closeItem(a),c=f.close(b.state());return i([b,c])},k=function(a,b,c,d){var e=a.level()===c-1&&b.type?{"list-style-type":b.type}:{},g=f.open(a,b,e),h=f.openItem(g.state(),g.state().level()==c?d:void 0,b);return i([g,h])},l=function(a,b,d){var e=a.level()>0?f.closeItem(a):c.result(a,[]),g=f.openItem(e.state(),d,b);return i([e,g])},m=function(a,b,c,d){return e.moveRight(a,c,function(a){return k(a,b,c,d)})},n=function(a,b){return e.moveLeft(a,b,j)},o=function(a,e,f,i){var j=f>1?d.finish(a):c.value(a,h.none()),k=j.value().map(function(a){return[g.curry(b.createEndElement,a)]}).getOr([]),l=(f-j.state().level(),m(j.state(),e,f,i));return c.result(l.state(),k.concat(l.result()))},p=function(a,b,d,e){var f=a.level()>b?n(a,b):c.result(a,[]),g=f.state().level()===b?l(f.state(),e,d):o(f.state(),e,b,d);return i([f,g])},q=n;return{openItem:p,closeAllLists:q}}),g("8x",["g","97","98"],function(a,b,c){var d=["disc","circle","square"],e=function(a,b){return"UL"===a.tag&&d[b-1]===a.type&&(a={tag:"UL"}),a};return function(d,f){var g=b.state(0,void 0,[],[]),h=function(b){a.each(b.result(),function(a){var b=a(f);d.emit(b)})},i=function(){var a=c.closeAllLists(g,0);g=a.state(),h(a)},j=function(a,b,d){if(d){var f=e(d,a),i=c.openItem(g,a,b,f);g=i.state(),h(i)}},k=function(){return g.level()},l=function(){return g.type()};return{closeAllLists:i,openItem:j,getCurrentListType:l,getCurrentLevel:k}}}),g("z",[],function(){var a=function(b){var c=b,d=function(){return c},e=function(a){c=a},f=function(){return a(d())};return{get:d,set:e,clone:f}};return a}),g("8j",["8x","p","z"],function(a,b,c){var d={getCurrentListType:function(){return e().getCurrentListType()},getCurrentLevel:function(){return e().getCurrentLevel()},closeAllLists:function(){return e().closeAllLists.apply(void 0,arguments)},openItem:function(){return e().openItem.apply(void 0,arguments)}},e=function(){return{getCurrentListType:b.constant({}),getCurrentLevel:b.constant(1),closeAllLists:b.identity,openItem:b.identity}};return function(f){var g=c(f),h=c(null),i=c(null),j=function(c){g.set(f),h.set(null),i.set(null),_emitter=a(c,c.document),e=b.constant(_emitter)};return{reset:j,nextFilter:g,originalToken:h,listType:i,emitter:d}}}),g("8k",["86"],function(a){return function(){var b=!1,c="",d=function(d){return b&&d.type()===a.TEXT_TYPE?(c+=d.text(),!0):d.type()===a.START_ELEMENT_TYPE&&"STYLE"===d.tag()?(b=!0,!0):d.type()===a.END_ELEMENT_TYPE&&"STYLE"===d.tag()&&(b=!1,!0)};return{check:d}}}),g("81",["7l","8i","8j","8k","8l","1g"],function(a,b,c,d,e,f){var g={inside:function(){return i},outside:function(){return j}},h=d(),i=b.inside(g),j=b.outside(g),k=c(j);return a(function(a,b,c){h.check(b)||e.go(a,k,b)},k.reset,"list.filters")}),h("8o",parseInt),g("8y",["g","1l","64","8o"],function(a,b,c,d){var e=[{regex:/^\(?[dc][\.\)]$/,type:{tag:"OL",type:"lower-alpha"}},{regex:/^\(?[DC][\.\)]$/,type:{tag:"OL",type:"upper-alpha"}},{regex:/^\(?M*(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})[\.\)]$/,type:{tag:"OL",type:"upper-roman"}},{regex:/^\(?m*(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})[\.\)]$/,type:{tag:"OL",type:"lower-roman"}},{regex:/^\(?[0-9]+[\.\)]$/,type:{tag:"OL"}},{regex:/^([0-9]+\.)*[0-9]+\.?$/,type:{tag:"OL",variant:"outline"}},{regex:/^\(?[a-z]+[\.\)]$/,type:{tag:"OL",type:"lower-alpha"}},{regex:/^\(?[A-Z]+[\.\)]$/,type:{tag:"OL",type:"upper-alpha"}}],f={"\u2022":{tag:"UL",type:"disc"},"\xb7":{tag:"UL",type:"disc"},"\xa7":{tag:"UL",type:"square"}},g={o:{tag:"UL",type:"circle"},"-":{tag:"UL",type:"disc"},"\u25cf":{tag:"UL",type:"disc"},"\ufffd":{tag:"UL",type:"circle"}},h=function(a,b){return void 0!==a.variant?a.variant:"("===b.charAt(0)?"()":")"===b.charAt(b.length-1)?")":"."},i=function(a){var b=a.split("."),e=function(){if(0===b.length)return a;var c=b[b.length-1];return 0===c.length&&b.length>1?b[b.length-2]:c}(),f=d(e,10);return c(f)?{}:{start:f}},j=function(c,d){var j=g[c]?[g[c]]:[],k=d&&f[c]?[f[c]]:d?[{tag:"UL",variant:c}]:[],l=a.bind(e,function(a){return a.regex.test(c)?[b.merge(a.type,i(c),{variant:h(a.type,c)})]:[]}),m=j.concat(k).concat(l);return a.map(m,function(a){return void 0!==a.variant?a:b.merge(a,{variant:c})})};return{extract:j}}),g("7o",[],function(){var a=function(a){return a.dom().textContent},b=function(a,b){a.dom().textContent=b};return{get:a,set:b}}),g("8m",["g","8y","8h","p","n","5d","6h","1d","6r","7o","3f","62","64","8o"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=18,p=function(a){var b=c.scan(a,["mso-list"],d.constant(!1));return b["mso-list"]},q=function(a){var b=p(a),c=/ level([0-9]+)/.exec(b);return c&&c[1]?e.some(n(c[1],10)):e.none()},r=function(a,c){var d=j.get(a).trim(),f=b.extract(d,c);return f.length>0?e.some(f):e.none()},s=function(a){return i.child(a,v)},t=function(a){return i.child(a,h.isComment).bind(k.nextSibling).filter(function(a){return"span"===h.name(a)})},u=function(a){return i.descendant(a,function(a){var b=h.isElement(a)?c.scan(a,["mso-list"],d.constant(!1)):[];return!!b["mso-list"]})},v=function(b){return h.isElement(b)&&f.getRaw(b,"font-family").exists(function(b){return a.contains(["wingdings","symbol"],b.toLowerCase())})},w=function(a){return f.getRaw(a,"margin-left").bind(function(a){var b=n(a,10);return m(b)?e.none():e.some(l.max(1,l.ceil(b/o)))})};return{getMsoList:p,extractLevel:q,extractEmblem:r,extractSymSpan:s,extractMsoIgnore:u,extractCommentSpan:t,isSymbol:v,deduceLevel:w}}),h("8n",JSON),g("82",["g","8m","n","j","7r","1d","1y","3f","8n","8o"],function(a,b,c,d,e,f,g,h,i,j){var k=function(a,b,c){d.set(a,"data-list-level",b);var e=i.stringify(c);d.set(a,"data-list-emblems",e)},l=function(b){var d=e.find(b,c.none());a.each(d,g.remove)},m=function(b,c,e,f){k(b,c,e),l(b),a.each(f,g.remove),d.remove(b,"style"),d.remove(b,"class")},n=function(a){return b.extractLevel(a).bind(function(c){return b.extractSymSpan(a).bind(function(d){return b.extractEmblem(d,!0).map(function(b){var e=function(){m(a,c,b,[d])};return{mutate:e}})})})},o=function(a){return b.extractLevel(a).bind(function(c){return b.extractCommentSpan(a).bind(function(d){return b.extractEmblem(d,b.isSymbol(d)).map(function(b){var e=function(){m(a,c,b,[d])};return{mutate:e}})})})},p=function(a){return b.extractLevel(a).bind(function(c){return b.extractCommentSpan(a).bind(function(d){return b.extractEmblem(d,b.isSymbol(d)).map(function(b){var e=function(){m(a,c,b,[d])};return{mutate:e}})})})},q=function(a){return"p"!==f.name(a)?c.none():b.extractLevel(a).bind(function(c){return b.extractMsoIgnore(a).bind(function(d){return b.extractEmblem(d,!1).map(function(b){var e=function(){m(a,c,b,[h.parent(d).getOr(d)])};return{mutate:e}})})})},r=function(a){return"p"!==f.name(a)?c.none():b.extractMsoIgnore(a).bind(function(c){var d=h.parent(c).getOr(c),e=b.isSymbol(d);return b.extractEmblem(c,e).bind(function(c){return b.deduceLevel(a).map(function(b){var e=function(){m(a,b,c,[d])};return{mutate:e}})})})},s=function(a){return n(a).orThunk(function(){return o(a)}).orThunk(function(){return p(a)}).orThunk(function(){return q(a)}).orThunk(function(){return r(a)})};return{find:s}}),g("7k",["6m","81","82","83"],function(a,b,c,d){var e=a.transformer({tags:[{name:d.pattern(/^(p|h\d+)$/),mutate:function(a){c.find(a).each(function(a){a.mutate()})}}]});return{filter:b,preprocess:e}}),g("6n",["6r"],function(a){var b=function(b){return a.first(b).isSome()},c=function(b,c,d){return a.ancestor(b,c,d).isSome()},d=function(b,c,d){return a.closest(b,c,d).isSome()},e=function(b,c){return a.sibling(b,c).isSome()},f=function(b,c){return a.child(b,c).isSome()},g=function(b,c){return a.descendant(b,c).isSome()};return{any:b,ancestor:c,closest:d,sibling:e,child:f,descendant:g}}),g("84",["g","j","6h","1d","6n"],function(a,b,c,d,e){var f=function(a){return"img"!==d.name(a)},g=function(a){var b=a.dom().attributes,c=void 0!==b&&null!==b&&b.length>0;return"span"!==d.name(a)||c},h=function(b){return!k(b)||g(b)&&e.descendant(b,function(b){var c=!k(b),e=!a.contains(["font","em","strong","samp","acronym","cite","code","dfn","kbd","tt","b","i","u","s","sub","sup","ins","del","var","span"],d.name(b));return d.isText(b)||c||e})},i=function(a){return"ol"===d.name(a)||"ul"===d.name(a)},j=function(a){var c=b.get(a,"src");return/^file:/.test(c)},k=function(a){return void 0===a.dom().attributes||null===a.dom().attributes||(0===a.dom().attributes.length||1===a.dom().attributes.length&&"style"===a.dom().attributes[0].name)},l=function(a){return 0===c.get(a).length};return{isNotImage:f,hasContent:h,isList:i,isLocal:j,hasNoAttributes:k,isEmpty:l}}),g("8p",["1d","7s"],function(a,b){var c=b(a.isText,"text"),d=function(a){return c.get(a)},e=function(a){return c.getOption(a)},f=function(a,b){c.set(a,b)};return{get:d,getOption:e,set:f}}),g("85",["g","1c","n","j","5d","k","6h","1x","29","1d","1y","8p","3f"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(b,c){var d=f.fromTag(b);h.before(c,d);var e=c.dom().attributes;a.each(e,function(a){d.dom().setAttribute(a.name,a.value)});var g=m.children(c); -return i.append(d,g),k.remove(c),d},o=function(a){0===g.get(a).length&&h.append(a,f.fromTag("br"))},p=function(a){return m.prevSibling(a).bind(function(a){return j.isText(a)&&0===l.get(a).trim().length?p(a):"li"===j.name(a)?c.some(a):c.none()})},q=function(b){m.parent(b).each(function(c){var d=j.name(c);a.contains(["ol","ul"],d)&&p(b).fold(function(){var a=f.fromTag("li");e.set(a,"list-style-type","none"),h.wrap(b,a)},function(a){h.append(a,b)})})},r=function(a){var c=n("span",a),f={face:"font-family",size:"font-size",color:"color"},g={"font-size":{1:"8pt",2:"10pt",3:"12pt",4:"14pt",5:"18pt",6:"24pt",7:"36pt"}};b.each(f,function(a,b){if(d.has(c,b)){var f=d.get(c,b),h=void 0!==g[a]&&void 0!==g[a][f]?g[a][f]:f;e.set(c,a,h),d.remove(c,b)}})};return{changeTag:n,addBrTag:o,properlyNest:q,fontToSpan:r}}),g("7h",["7w","6m","7k","84","85","p","27","5d","3f","1d","83"],function(a,b,c,d,e,f,g,h,i,j,k){var l=b.unwrapper({tags:[{name:k.pattern(/^([OVWXP]|U[0-9]+|ST[0-9]+):/i)}]}),m=[b.pipeline([c.filter])],n=b.removal({attributes:[{name:k.pattern(/^v:/)},{name:k.exact("href"),value:k.contains("#_toc")},{name:k.exact("href"),value:k.contains("#_mso")},{name:k.pattern(/^xmlns(:|$)/)},{name:k.exact("type"),condition:d.isList}]}),o=b.removal({attributes:[{name:k.exact("id")},{name:k.exact("name")}]}),p=b.removal({tags:[{name:k.exact("script")},{name:k.exact("meta")},{name:k.exact("link")},{name:k.exact("style"),condition:d.isEmpty}],attributes:[{name:k.starts("on")},{name:k.exact('"')},{name:k.exact("lang")},{name:k.exact("language")}],styles:[{name:k.all(),value:k.pattern(/OLE_LINK/i)}]}),q=function(a){return!g.has(a,"ephox-limbo-transform")},r=function(a){return function(b){return i.parent(b).exists(function(b){return j.name(b)===a&&1===i.children(b).length})}},s=b.removal({styles:[{name:k.not(k.pattern(/width|height|list-style-type/)),condition:q},{name:k.pattern(/width|height/),condition:d.isNotImage}]}),t=b.removal({classes:[{name:k.not(k.exact("rtf-data-image"))}]}),u=b.removal({styles:[{name:k.pattern(a.validStyles())}]}),v=b.removal({classes:[{name:k.pattern(/mso/i)}]}),w=b.unwrapper({tags:[{name:k.exact("img"),condition:d.isLocal},{name:k.exact("a"),condition:d.hasNoAttributes}]}),x=b.unwrapper({tags:[{name:k.exact("a"),condition:d.hasNoAttributes}]}),y=b.removal({attributes:[{name:k.exact("style"),value:k.exact(""),debug:!0}]}),z=b.removal({attributes:[{name:k.exact("class"),value:k.exact(""),debug:!0}]}),A=b.unwrapper({tags:[{name:k.pattern(a.specialInline()),condition:f.not(d.hasContent)}]}),B=b.unwrapper({tags:[{name:k.exact("p"),condition:r("li")}]}),C=b.transformer({tags:[{name:k.exact("p"),mutate:e.addBrTag}]}),D=function(a){var b=e.changeTag("span",a);g.add(b,"ephox-limbo-transform"),h.set(b,"text-decoration","underline")},E=b.transformer({tags:[{name:k.pattern(/ol|ul/),mutate:e.properlyNest}]}),F=b.transformer({tags:[{name:k.exact("b"),mutate:f.curry(e.changeTag,"strong")},{name:k.exact("i"),mutate:f.curry(e.changeTag,"em")},{name:k.exact("u"),mutate:D},{name:k.exact("s"),mutate:f.curry(e.changeTag,"strike")},{name:k.exact("font"),mutate:e.fontToSpan,debug:!0}]}),G=b.removal({classes:[{name:k.exact("ephox-limbo-transform")}]}),H=b.removal({attributes:[{name:k.exact("href"),value:k.starts("file:///"),debug:!0}]});return{unwrapWordTags:l,removeWordAttributes:n,parseLists:m,removeExcess:p,cleanStyles:s,cleanClasses:t,mergeStyles:u,mergeClasses:v,removeLocalImages:w,removeVacantLinks:x,removeEmptyStyle:y,removeEmptyClass:z,pruneInlineTags:A,unwrapSingleParagraphsInlists:B,addPlaceholders:C,nestedListFixes:E,inlineTagFixes:F,cleanupFlags:G,removeLocalLinks:H,removeAnchors:o,none:f.noop}}),g("6k",["g","5a","7h","6m","7k","7l","p","k"],function(a,b,c,d,e,f,g,h){var i=function(a){return a.browser.isIE()&&a.browser.version.major>=11},j=function(a){return f(function(b,c,d){var e=a(h.fromDom(c.getNode())).fold(function(){return c},function(a){return d(c,a.dom())});b.emit(e)},g.noop,"image filters")},k=function(a,e,f){var g=f.browser.isFirefox()||f.browser.isSpartan()?b.local:b.vshape,h=i(f)?c.none:d.pipeline([j(g)]),k=g===b.local?c.none:c.removeLocalImages,l=a?h:c.none;return{annotate:[l],local:[k]}},l=function(a,b){var d=i(b)&&a;return d?[c.unwrapSingleParagraphsInlists]:[]},m=function(a,b,d){var e=[c.mergeStyles,c.mergeClasses],f=[c.cleanStyles,c.cleanClasses];return b?e:f},n=function(a,b,c){return i(c)||!a?[]:[e.preprocess]},o=function(a,b,d){if(!a)return[c.none];var e=[c.unwrapWordTags],f=i(d)?[]:c.parseLists;return e.concat(f).concat([c.removeWordAttributes])},p=function(a,b,d){return a?[c.removeAnchors]:[c.none]},q=function(b,d,e){var f=k(b,d,e);return a.flatten([n(b,d,e),f.annotate,[c.inlineTagFixes],o(b,d,e),[c.nestedListFixes],[c.removeExcess],p(b,d,e),f.local,m(b,d,e),[c.removeLocalLinks,c.removeVacantLinks],[c.removeEmptyStyle],[c.removeEmptyClass],[c.pruneInlineTags],[c.addPlaceholders],l(b,e),[c.cleanupFlags]])};return{derive:q}}),g("8q",[],function(){return["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"]}),g("87",["8q","g","p","j","3n","5d","k","1x","29","1d","3o","6r","1y","2a","20","8p","3f"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){return function(){var r=function(a){return g.fromDom(a.dom().cloneNode(!1))},s=function(c){return!!j.isElement(c)&&("body"===j.name(c)||b.contains(a,j.name(c)))},t=function(a){return!!j.isElement(a)&&b.contains(["br","img","hr"],j.name(a))},u=function(a,b){return a.dom().compareDocumentPosition(b.dom())},v=function(a,b){var c=d.clone(a);d.setAll(b,c)};return{up:c.constant({selector:o.ancestor,closest:o.closest,predicate:l.ancestor,all:q.parents}),down:c.constant({selector:n.descendants,predicate:k.descendants}),styles:c.constant({get:f.get,getRaw:f.getRaw,set:f.set,remove:f.remove}),attrs:c.constant({get:d.get,set:d.set,remove:d.remove,copyTo:v}),insert:c.constant({before:h.before,after:h.after,afterAll:i.after,append:h.append,appendAll:i.append,prepend:h.prepend,wrap:h.wrap}),remove:c.constant({unwrap:m.unwrap,remove:m.remove}),create:c.constant({nu:g.fromTag,clone:r,text:g.fromText}),query:c.constant({comparePosition:u,prevSibling:q.prevSibling,nextSibling:q.nextSibling}),property:c.constant({children:q.children,name:j.name,parent:q.parent,isText:j.isText,isElement:j.isElement,getText:p.get,setText:p.set,isBoundary:s,isEmptyTag:t}),eq:e.eq,is:e.is}}}),g("8z",["2c"],function(a){return a.immutable("word","pattern")}),g("90",["2c"],function(a){var b=a.immutable("element","offset"),c=a.immutable("element","deltaOffset"),d=a.immutable("element","start","finish"),e=a.immutable("begin","end"),f=a.immutable("element","text");return{point:b,delta:c,range:d,points:e,text:f}}),g("9n",["p","n"],function(a,b){var c=a.constant(!1),d=a.constant(!0),e=function(a,b){return h(function(c,d,e){return c(a,b)})},f=function(a,b){return h(function(c,d,e){return d(a,b)})},g=function(a,b){return h(function(c,d,e){return e(a,b)})},h=function(e){var f=function(){return e(d,c,c)},g=function(){return e(b.none,b.none,function(a,c){return b.some(a)})},h=function(a){return e(c,c,function(b,c){return c.eq(b,a)})},i=function(){return e(a.constant(0),a.constant(1),function(a,b){return b.property().getText(a).length})};return{isBoundary:f,fold:e,toText:g,is:h,len:i}},i=function(a,b,c,d){return a.fold(b,c,d)};return{text:g,boundary:e,empty:f,cata:i}}),g("9o",["g","p"],function(a,b){var c=function(c,d,e,f){var g=a.findIndex(c,b.curry(f,d)),h=g>-1?g:0,i=a.findIndex(c,b.curry(f,e)),j=i>-1?i+1:c.length;return c.slice(h,j)};return{boundAt:c}}),g("9p",["g"],function(a){var b=function(b,c){var d=a.findIndex(b,c);return b.slice(0,d)};return{sliceby:b}}),g("9r",["1m"],function(a){var b=a.generate([{include:["item"]},{excludeWith:["item"]},{excludeWithout:["item"]}]),c=function(a,b,c,d){return a.fold(b,c,d)};return{include:b.include,excludeWith:b.excludeWith,excludeWithout:b.excludeWithout,cata:c}}),g("9q",["g","9r"],function(a,b){var c=function(a,c){return d(a,function(a){return c(a)?b.excludeWithout(a):b.include(a)})},d=function(c,d){var e=[],f=[];return a.each(c,function(a){var c=d(a);b.cata(c,function(){f.push(a)},function(){f.length>0&&e.push(f),e.push([a]),f=[]},function(){f.length>0&&e.push(f),f=[]})}),f.length>0&&e.push(f),e};return{splitby:c,splitbyAdv:d}}),g("9b",["9o","9p","9q"],function(a,b,c){var d=function(b,c,d,e){return a.boundAt(b,c,d,e)},e=function(a,b){return c.splitby(a,b)},f=function(a,b){return c.splitbyAdv(a,b)},g=function(a,c){return b.sliceby(a,c)};return{splitby:e,splitbyAdv:f,sliceby:g,boundAt:d}}),g("92",["g","p","n","90","9b"],function(a,b,c,d,e){var f=function(b){return a.foldr(b,function(a,b){return b.len()+a},0)},g=function(a,b){return e.sliceby(a,function(a){return a.is(b)})},h=function(a,b){return a.fold(c.none,function(a){return c.some(d.range(a,b,b+1))},function(e){return c.some(d.range(e,b,b+a.len()))})},i=function(c){return a.bind(c,function(a){return a.fold(b.constant([]),b.constant([]),function(a){return[a]})})};return{count:f,dropUntil:g,gen:h,justText:i}}),g("9w",["g","90","9n","92"],function(a,b,c,d){var e=function(b,d,f){if(b.property().isText(d))return[c.text(d,b)];if(b.property().isEmptyTag(d))return[c.empty(d,b)];if(b.property().isElement(d)){var g=b.property().children(d),h=b.property().isBoundary(d)?[c.boundary(d,b)]:[],i=void 0!==f&&f(d)?[]:a.bind(g,function(a){return e(b,a,f)});return h.concat(i).concat(h)}return[]},f=function(b,c,d){var f=e(b,c,d),g=function(a,b){return a};return a.map(f,function(a){return a.fold(g,g,g)})},g=function(a,c,f,g,h){var i=e(a,g,h),j=d.dropUntil(i,c),k=d.count(j);return b.point(g,k+f)},h=function(a,c,d,e){return a.property().parent(c).fold(function(){return b.point(c,d)},function(b){return g(a,c,d,b,e)})},i=function(a,c,d,e,f){return a.up().predicate(c,e).fold(function(){return b.point(c,d)},function(b){return g(a,c,d,b,f)})};return{typed:e,items:f,extractTo:i,extract:h}}),g("9x",["g","p","9w"],function(a,b,c){var d="\n",e=" ",f=function(a,b){return"img"===b.property().name(a)?e:d},g=function(e,g,h){var i=c.typed(e,g,h);return a.map(i,function(a){return a.fold(b.constant(d),f,e.property().getText)}).join("")};return{from:g}}),g("9d",["g","p"],function(a,b){var c=function(c,d,e){var f={len:void 0!==e?e:0,list:[]},g=a.foldl(c,function(a,c){var e=d(c,a.len);return e.fold(b.constant(a),function(b){return{len:b.finish(),list:a.list.concat([b])}})},f);return g.list};return{make:c}}),g("9e",["g","n"],function(a,b){var c=function(a,b){return b>=a.start()&&b<=a.finish()},d=function(d,e){var f=a.find(d,function(a){return c(a,e)});return b.from(f)},e=function(b,c){return a.findIndex(b,function(a){return a.start()===c})},f=function(a,b){var c=a[a.length-1]&&a[a.length-1].finish()===b;return c?a.length+1:-1},g=function(a,b,c){var d=e(a,b),g=e(a,c),h=g>-1?g:f(a,c);return d>-1&&h>-1?a.slice(d,h):[]},h=function(c,d){return b.from(a.find(c,d))};return{get:d,find:h,inUnit:c,sublist:g}}),g("9g",["g","1l","p"],function(a,b,c){var d=function(d,e){return a.map(d,function(a){return b.merge(a,{start:c.constant(a.start()+e),finish:c.constant(a.finish()+e)})})};return{translate:d}}),g("9f",["g","9e","9g"],function(a,b,c){var d=function(a,b,d){var e=d(a,b);return c.translate(e,a.start())},e=function(c,e,f){return 0===e.length?c:a.bind(c,function(c){var g=a.bind(e,function(a){return b.inUnit(c,a)?[a-c.start()]:[]});return g.length>0?d(c,g,f):[c]})};return{splits:e}}),g("94",["9d","9e","9f","9g"],function(a,b,c,d){var e=function(b,c,d){return a.make(b,c,d)},f=function(a,c){return b.get(a,c)},g=function(a,c){return b.find(a,c)},h=function(a,b,d){return c.splits(a,b,d)},i=function(a,b){return d.translate(a,b)},j=function(a,c,d){return b.sublist(a,c,d)};return{generate:e,get:f,find:g,splits:h,translate:i,sublist:j}}),g("9y",["90","9w","92","94"],function(a,b,c,d){var e=function(e,f,g,h){var i=b.typed(e,f,h),j=d.generate(i,c.gen),k=d.get(j,g);return k.map(function(b){return a.point(b.element(),g-b.start())})};return{find:e}}),g("9m",["9w","9x","9y"],function(a,b,c){var d=function(b,c,d){return a.typed(b,c,d)},e=function(b,c,d){return a.items(b,c,d)},f=function(b,c,d,e){return a.extract(b,c,d,e)},g=function(b,c,d,e,f){return a.extractTo(b,c,d,e,f)},h=function(a,b,d,e){return c.find(a,b,d,e)},i=function(a,c,d){return b.from(a,c,d)};return{extract:f,extractTo:g,all:e,from:d,find:h,toText:i}}),g("99",["g","9m","9n","9b","9r"],function(a,b,c,d,e){var f=function(f,g,h){var i=a.bind(g,function(a){return b.from(f,a,h)}),j=d.splitbyAdv(i,function(a){return c.cata(a,function(){return e.excludeWithout(a)},function(){return e.excludeWith(a)},function(){return e.include(a)})});return a.filter(j,function(a){return a.length>0})};return{group:f}}),g("9s",["g","n"],function(a,b){var c=function(c,d,e){var f=[d].concat(c.up().all(d)),g=[e].concat(c.up().all(e)),h=a.find(f,function(b){return a.exists(g,function(a){return c.eq(a,b)})});return b.from(h)};return{common:c}}),g("9t",["g"],function(a){var b=["table","tbody","thead","tfoot","tr","ul","ol"];return function(c){var d=c.property(),e=function(b,c){return d.parent(b).map(d.name).map(function(b){return!a.contains(c,b)}).getOr(!1)},f=function(a){return d.isText(a)&&e(a,b)};return{validateText:f}}}),g("9a",["g","p","9m","9s","9t"],function(a,b,c,d,e){var f=function(c,d,e){return a.findIndex(d,b.curry(c.eq,e))},g=function(a,b,c,d,e){return b-1&&o>-1?g(m,n,j,o,l):[],q=e(h);return a.filter(p,q.validateText)})};return{range:h}}),g("91",["99","9a"],function(a,b){var c=function(a,c,d,e,f){return b.range(a,c,d,e,f)},d=function(b,c,d){return a.group(b,c,d)};return{range:c,group:d}}),g("9z",[],function(){var a=function(a){var b=/^[a-zA-Z]/.test(a)?"":"e",c=a.replace(/[^\w]/gi,"-");return b+c};return{css:a}}),g("a0",["g"],function(a){var b=function(b,c){if(0===c.length)return[b];var d=a.foldl(c,function(a,c){if(0===c)return a;var d=b.substring(a.prev,c);return{prev:c,values:a.values.concat([d])}},{prev:0,values:[]}),e=c[c.length-1];return e0});if(j.length<=1)return[c.range(g,0,i.length)];f.property().setText(g,j[0]);var k=d.generate(j.slice(1),function(a,d){var e=f.create().text(a),g=c.range(e,d,d+a.length);return b.some(g)},j[0].length),l=a.map(k,function(a){return a.element()});return f.insert().afterAll(g,l),[c.range(g,0,j[0].length)].concat(k)};return{subdivide:f}}),g("93",["g","p","9c","94"],function(a,b,c,d){var e=function(e,f,g){var h=a.bind(g,function(a){return[a.start(),a.finish()]}),i=function(a,b){return c.subdivide(e,a.element(),b)},j=d.splits(f,h,i),k=function(c){var f=d.sublist(j,c.start(),c.finish()),g=a.map(f,function(a){return a.element()}),h=a.map(g,e.property().getText).join("");return{elements:b.constant(g),word:c.word,exact:b.constant(h)}};return a.map(g,k)};return{separate:e}}),g("8s",[],function(){var a=function(){return"\ufeff"};return{zeroWidth:a}}),g("89",["8s","p"],function(a,b){var c="\\w'\\-\\u0100-\\u017F\\u00C0-\\u00FF"+a.zeroWidth()+"\\u2018\\u2019",d="[^"+c+"]",e="["+c+"]";return{chars:b.constant(c),wordbreak:b.constant(d),wordchar:b.constant(e)}}),g("8a",["4v"],function(a){return function(b,c,d,e){var f=function(){return new a(b,e.getOr("g"))};return{term:f,prefix:c,suffix:d}}}),g("8c",["p","n","89","8a"],function(a,b,c,d){var e=function(c){return d(c,a.constant(0),a.constant(0),b.none())},f=function(a){var e="((?:^'?)|(?:"+c.wordbreak()+"+'?))"+a+"((?:'?$)|(?:'?"+c.wordbreak()+"+))",f=function(a){return a.length>1?a[1].length:0},g=function(a){return a.length>2?a[2].length:0};return d(e,f,g,b.none())};return{token:e,word:f}}),g("8b",["8c"],function(a){var b=function(a){return a.replace(/[-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},c=function(c){var d=b(c);return a.word(d)},d=function(c){var d=b(c);return a.token(d)};return{sanitise:b,word:c,token:d}}),g("7n",["89","8a","8b","8c"],function(a,b,c,d){var e=function(a){return c.word(a)},f=function(a){return c.token(a)},g=function(a,c,d,e){return b(a,c,d,e)},h=function(a){return d.word(a)},i=function(a){return d.token(a)},j=function(a){return c.sanitise(a)},k=function(){return a.chars()},l=function(){return a.wordbreak()},m=function(){return a.wordchar()};return{safeword:e,safetoken:f,custom:g,unsafeword:h,unsafetoken:i,sanitise:j,chars:k,wordbreak:l,wordchar:m}}),g("9h",["p"],function(a){var b=function(b,c){for(var d=c.term(),e=[],f=d.exec(b);f;){var g=f.index+c.prefix(f),h=f[0].length-c.prefix(f)-c.suffix(f);e.push({start:a.constant(g),finish:a.constant(g+h)}),d.lastIndex=g+h,f=d.exec(b)}return e};return{all:b}}),g("9i",["g","1l","9h","12"],function(a,b,c,d){var e=function(a){var b=d.prototype.slice.call(a,0);return b.sort(function(a,b){return a.start()=q&&b<=r},x=function(b){a.each(b,function(a){k.isElement(a)&&g.getRaw(a,"position").isSome()&&g.remove(a,"position")})},y=function(b){var c=a.filter(b,function(a){return"li"===k.name(a)});if(c.length>0){var d=n.prevSiblings(c[0]),e=h.fromTag("ul");if(i.before(b[0],e),d.length>0){var f=h.fromTag("li");i.append(e,f),j.append(f,d)}j.append(e,c)}};return{links:v,position:x,list:y}}),g("55",["g","6k","6l","6m","6h","3f"],function(a,b,c,d,e,f){var g=function(b){var d=f.children(b);a.each([c.links,c.position,c.list],function(a){a(d)})},h=function(a,c,f,h,i){g(f);var j=e.get(f),k=b.derive(i,h,c);return d.go(a,j,k)};return{go:h,preprocess:g}}),g("6i",["4q","4r","4y","2w","2t","55","2f","28","1f"],function(a,b,c,d,e,f,g,h,i){var j=e.detect(),k=function(a,b,c,d){try{var e=f.go(a,j,b,c,d),k=void 0!==e&&null!==e&&e.length>0,l=k?h.fromHtml(e):[];return g.value(l)}catch(m){return i.error(m),g.error("errors.paste.process.failure")}},l=function(e,f,g,h,i){var j=k(e,f,h,g);return j.fold(function(b){return a.error(b)},function(e){return a.sync(function(f){i.get(function(g){var h=c.findImages(e,g);a.call(f,{response:d.paste(e,g,h),bundle:b.nu({})})})})})};return{transfer:l}}),g("53",["6i","g","o","n","1y","3f"],function(a,b,c,d,e,f){var g=function(b,c,d,e,f){return a.transfer(b,c,e,d,f)},h=function(g,h,i){var j=!1,k=!0,l=function(a,b){return void 0===h||b?d.none():h.findClipboardTags(f.children(a))},m=l(i,j).getOr([]);b.each(m,e.remove);var n=c.nu(function(a){a([])});return a.transfer(g,i,j,k,n)};return{internal:h,external:g}}),g("6j",["g","k","6h","7o"],function(a,b,c,d){var e=function(a){var e=b.fromTag("div");return d.set(e,a),c.get(e)},f=function(b){var c=b.trim().split(/\n{2,}|(?:\r\n){2,}/),d=a.map(c,function(a){return a.split(/\n|\r\n/).join("
")});return 1===d.length?d[0]:a.map(d,function(a){return"

"+a+"

"}).join("")};return{encode:e,convert:f}}),g("54",["4q","6j","4r","31","2w","n","23","28","11"],function(a,b,c,d,e,f,g,h,i){var j=function(a){return a.length>0},k=function(a){return d.isValidData(a)?g.findMap(a.types,function(b){return"text/plain"===b?f.some(a.getData(b)):f.none()}):f.none()},l=function(){var a=i.clipboardData;return void 0!==a?f.some(a.getData("text")):f.none()},m=function(a){var c=b.encode(a),d=b.convert(c),f=h.fromHtml(d);return e.paste(f,[],[])},n=function(b){return a.sync(function(f){var g=d.isValidData(b)?k:l,h=g(b).filter(j).fold(e.cancel,m);a.call(f,{response:h,bundle:c.nu({})})})};return{handle:n}}),g("34",["4q","4r","4z","51","52","53","54","2w","2t","55","p","k","29","3f","1f"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=i.detect(),q=function(a,b,c){return g.handle(a)},r=function(b,c){var d=function(b,d,e){var f=l.fromTag("div");m.append(f,b),j.preprocess(f);var g=n.children(f);return a.pure({response:h.paste(g,d,e),bundle:c.bundle()})},e=k.curry(a.pass,c);return h.cata(c.response(),e,d,e,d)},s=function(a,b){return function(d,e){var g=e.bundle();return c.proxyBin(g).handle("There was no proxy bin setup. Ensure you have run proxyStep first.",function(c){var d=n.owner(a);return f.internal(d,b,c)})}},t=function(a,b){return function(d,e){var g=e.bundle();return c.proxyBin(g).handle("There was no proxy bin setup. Ensure you have run proxyStep first.",function(d){var e=c.merging(g),h=c.isWord(g),i=c.isInternal(g),j=c.backgroundAssets(g),k=n.owner(a);return i?f.internal(k,b,d):f.external(k,d,e,h,j)})}},u=function(){return function(b,c){return a.error("errors.local.images.disallowed")}},v=function(){return function(b,c){if(p.browser.isSafari()){var d=p.deviceType.isWebView()?"webview.imagepaste":"safari.imagepaste";return a.error(d)}return e.handle(b)}},w=function(a){return function(b,e){var f=c.mergeOffice(e.bundle());return d.handle(b,f,a)}},x=function(b,c){return a.cancel()},y=function(c){return function(d,e){var f=b.merge(e.bundle(),b.nu(c));return a.pure({response:e.response(),bundle:f})}};return{plain:q,autolink:r,noImages:u,images:v,internal:s,external:t,gwt:w,setBundle:y,none:x}}),g("56",["5c","p"],function(a,b){var c=a.resolve("smartpaste-eph-bin");return{binStyle:b.constant(c)}}),g("57",["6m","j","6h","6n"],function(a,b,c,d){var e=function(a,c){return d.descendant(a,function(a){return!!b.has(a,"style")&&b.get(a,"style").indexOf("mso-")>-1})},f=function(b,d){var e=c.get(b);return a.isWordContent(e,d)},g=function(a,b){var c=a.browser,d=c.isIE()&&c.version.major>=11?e:f;return d(b,a)};return{isWord:g}}),g("35",["4q","4r","56","2t","57","27","3f"],function(a,b,c,d,e,f,g){var h=d.detect();return function(d,i,j,k,l){return function(m,n){var o=l(),p=n.response();return a.sync(function(l){var n=d(j);n.events.after.bind(function(d){var j=d.container();i(j),f.add(j,c.binStyle());var m=e.isWord(h,j),n=g.children(j),q=k.findClipboardTags(n,m).isSome();a.call(l,{response:p,bundle:b.nu({isWord:m,isInternal:q,proxyBin:j,backgroundAssets:o})})}),o.convert(m.data()),n.run()})}}}),g("8d",["78","79","12","62","13","8o"],function(a,b,c,d,e,f){var g=function(a){for(var b=new c(a.length/2),e=0;ec&&c!==-1?(b=c+1,++e):(c>d||c<0)&&d!==-1&&(b=d+1,--e),b>f||d===-1)return-1;while(e>0);return b},k=function(a,b,c,e){var f=i(a,c,e),g=/[^a-fA-F0-9]([a-fA-F0-9]+)\}$/;return h(c,e,f,g,d)},l=function(a,b,c,d){var e=i(a,c,d),g=/([a-fA-F0-9]{64,})(?:\}.*)/;return h(c,d,e,g,f)},m=function(d,f){var h=g(c,d,f),i=j(d,h),m=g(e,d,f),n=j(d,m),o=a.curry(l,d,f,m,n),p=a.curry(k,d,f,h,i);return h===-1&&m===-1?b.none():h===-1?o():m===-1?p():mi?p():hn?o():h=0?e.value("image/png"):a.indexOf("\\jpegblip")>=0?e.value("image/jpeg"):e.error("errors.imageimport.unsupported")},h=function(a){return a.replace(/\r/g,"").replace(/\n/g,"")},i=function(a,b){var c=a.match(b);return c&&c[1]&&c[1].length%2===0?e.value(c[1]):e.error("errors.imageimport.invalid")},j=function(a){var b=a.match(/\\shplid(\d+)/);return null!==b?d.some(b[1]):d.none()},k=function(c){var d=c.bower(),e=c.regex();return j(d).map(function(f){var h=c.idRef()+f;return g(d).fold(function(a){return b.unsupported(h,a)},function(c){return i(d,e).fold(function(a){return b.unsupported(h,a)},function(d){return b.supported(h,c,a.convert(d,c))})})})},l=function(a){for(var b=[],c=function(){return a.length},d=function(a){var c=k(a);return b=b.concat(c.toArray()),a.end()},e=0;e0?(f.each(b,m.remove),t(e.incomplete(d,c,o,"errors.local.images.disallowed"))):t(e.paste(d,c,o))}})};e.cata(c.response(),j,o,j,o)})}}}),g("1p",["2z","30","31","32","33","34","35","36","2t","p","n","2c","37","11"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=l.immutable("data","rtf"),p=i.detect(),q="^image/",r="file",s=[q,r],t="html",u="rtf",v=function(a){return m.contains(a,"0?k.some(c):k.none()}):k.none()},D=function(a,b,c,d){return{label:j.constant(a),getAvailable:b,steps:j.constant(c),capture:j.constant(d)}},E=function(c,d,h,i){var k=j.curry(z,i);return D("Within Textbox.io (tables) pasting",k,[a.normal(g(d,c,h,i,b.ignore)),a.normal(e.fixed(!0,!0)),a.normal(f.internal(h,i))],!1)},F=function(c,i,j,k,l,m,n){return D("Outside of Textbox.io pasting (could be internal but another browser)",x,[a.normal(g(k,j,l,n,b.background)),a.normal(e.fromConfigIfExternal(c,i)),a.normal(f.external(l,n)),a.blocking(h(m,i)),a.normal(d(i))],!1)},G=function(b,c,d,g){return D("GWT pasting",w,[a.normal(f.setBundle({isWord:!0})),a.normal(e.fromConfig(c,d)),a.normal(f.gwt(b)),a.blocking(h(g,d))],!0)},H=function(b){return D("Image pasting",y,[a.normal(b.allowLocalImages===!1?f.noImages(j.noop):f.images())],!0)},I=function(){return D("Only plain text is available to paste",B,[a.normal(f.plain),a.normal(f.autolink)],!0)},J=function(){return D("Plain text pasting",A,[a.normal(f.plain),a.normal(f.autolink)],!0)},K=function(){return D("There is no valid way to paste",k.some,[a.normal(f.none)],!1)};return{internal:E,pastiche:F,gwt:G,image:H,text:J,onlyText:I,none:K}}),g("5b",["5c","2t","j","27","k","6h","29"],function(a,b,c,d,e,f,g){var h=function(){var a=b.detect(),c=a.os.isOSX();return c?["\u2318"]:["Ctrl"]},i=function(a){return e.fromHtml("

"+a("cement.dialog.flash.press-escape")+"

")},j=function(b){var c=e.fromTag("div");d.add(c,a.resolve("flashbin-helpcopy"));var f=h(),j=e.fromHtml("

"+b("cement.dialog.flash.trigger-paste")+"

"),k=e.fromHtml('
'+f+' + V
');return d.add(k,a.resolve("flashbin-helpcopy-kbd")),g.append(c,[j,k,i(b)]),c},k=function(b){var c=e.fromTag("div");d.add(c,a.resolve("flashbin-helpcopy"));var f=e.fromHtml("

"+b("cement.dialog.flash.missing")+"

");return g.append(c,[f,i(b)]),c},l=function(b){var h=e.fromTag("div");d.add(h,a.resolve("flashbin-loading"));var i=e.fromTag("div");d.add(i,a.resolve("flashbin-loading-spinner"));var j=e.fromTag("p"),k=b("loading.wait");return f.set(j,k),c.set(j,"aria-label",k),g.append(h,[i,j]),h};return{paste:j,noflash:k,indicator:l}}),h("5e",navigator),g("38",["5b","5c","2t","p","27","5d","k","1x","29","5e"],function(a,b,c,d,e,f,g,h,i,j){var k=c.detect(),l=function(){return new ActiveXObject("ShockwaveFlash.ShockwaveFlash")},m=function(){try{var a=k.browser.isIE()?l():j.plugins["Shockwave Flash"];return void 0!==a}catch(b){return!1}},n=function(b,c,e,f){var g=a.noflash(f);return h.append(b,g),{reset:d.noop}},o=function(b,c,d,e){var g=a.paste(e),h=a.indicator(e);i.append(b,[h,g,c.element()]);var j=function(){f.setAll(h,{height:"0",padding:"0"})},k=function(){f.set(g,"display","block"),f.set(h,"display","none"),d()},l=function(){f.set(g,"display","none"),f.set(h,"display","block"),f.remove(h,"height"),f.remove(h,"padding"),d()};return c.events.spin.bind(l),c.events.reset.bind(k),c.events.hide.bind(j),{reset:k}};return function(a,c,f){var h=g.fromTag("div"),i="flashbin-wrapper-"+(k.os.isOSX()?"cmd":"ctrl");e.add(h,b.resolve(i));var j=m()?o:n,l=j(h,a,c,f.translations);return{element:d.constant(h),reset:l.reset}}}),h("5k",clearInterval),h("5m",setInterval),g("5f",["n","21","22","z","5k","5m"],function(a,b,c,d,e,f){var g=function(){var g=d(a.none()),h=c.create({crashed:b([]),timeout:b([])}),i=function(b,c,d,i){var j=c,k=f(function(){d()?e(k):j<=0?(h.trigger.timeout(),e(k)):i()&&(e(k),h.trigger.crashed()),j--},b);g.set(a.some(k))},j=function(){g.get().each(function(a){e(a)})};return{start:i,stop:j,events:h.registry}};return{responsive:g}}),g("5g",["1b","g","5k","5m"],function(a,b,c,d){return function(e,f,g){var h=function(c){return b.forall(f,function(b){return a.isFunction(c[b])})},i=function(){var b=e.dom();a.isFunction(b.PercentLoaded)&&100===b.PercentLoaded()&&h(b)&&(l(),g())},j=!0,k=d(i,500),l=function(){j&&(c(k),j=!1)};return{stop:l}}}),g("6t",["72"],function(a){var b=function(a,b){return void 0!==a[b]&&null!==a[b]||(a[b]={}),a[b]},c=function(c,d){for(var e=d||a,f=c.split("."),g=0;g ';if(A.browser.isIE()&&10===A.browser.version.major){var d=f.generate("flash-bin");return p.fromHtml(''+c+"")}return p.fromHtml(''+c+"")},L=K(),M=function(){o.setAll(L,{width:"2px",height:"2px"})};M();var N=b(L,e.keys(J),D);r.append(s,L);var O=function(){return s},P=function(){A.browser.isFirefox()&&y.getSelection().removeAllRanges(),q.focus(L)},Q=null,R=function(){n.add(s,c.resolve("flash-activate")),o.remove(L,"height"),o.remove(L,"width"),h.trigger.hide()},S=function(){t(Q),n.remove(s,c.resolve("flash-activate")),M()},T=function(){Q=w(R,3e3),h.trigger.spin(),o.set(s,"display","block"),P()},U=function(){o.set(s,"display","none"),B.each(function(a){d.each(a,function(a){a.unbind()})})},V=function(){U(),d.each(e.values(J),function(a){z.unregister(a)}),z.unregister(E),N.stop()};return{focus:P,element:O,activate:T,deactivate:U,destroy:V,events:h.registry}}}),g("1q",["38","39","21","22","w","k","11"],function(a,b,c,d,e,f,g){return function(h,i){var j=i.translations,k=d.create({response:c(["rtf","hide"]),cancel:c([]),error:c(["message"]),failed:c(["message"])}),l=function(){var c=b(i.swf);c.deactivate();var d=f.fromDom(g),l=e.bind(d,"mouseup",c.focus),m=function(){q()},n=function(){m(),k.trigger.cancel()};c.events.cancel.bind(n),c.events.response.bind(function(a){k.trigger.response(a.rtf(),m)}),c.events.error.bind(function(a){m(),k.trigger.error(a.message())}),c.events.failed.bind(function(a){m(),k.trigger.failed(a.message())});var o=h();o.setTitle(j("cement.dialog.flash.title"));var p=a(c,o.reflow,i);p.reset(),o.setContent(p.element()),o.events.close.bind(n),o.show(),c.activate();var q=function(){l.unbind(),c.destroy(),o.destroy()}};return{open:l,events:k.registry}}}),g("5p",[],function(){var a=function(a,b){return d(function(c,d,e){return d(a,b)})},b=function(a){return d(function(b,c,d){return b(a)})},c=function(a){return d(function(b,c,d){return d(a)})},d=function(a){return{fold:a}};return{on:a,before:b,after:c}}),g("5o",["5p","2c","k"],function(a,b,c){var d=b.immutable("start","soffset","finish","foffset"),e=b.immutable("start","soffset","finish","foffset"),f=b.immutable("start","finish"),g=function(b){var d=c.fromDom(b.startContainer),e=c.fromDom(b.endContainer);return f(a.on(d,b.startOffset),a.on(e,b.endOffset))};return{read:d,general:e,write:f,writeFromNative:g}}),g("5q",[],function(){var a=function(a,b){if(a.getSelection)return b(a,a.getSelection());throw"No selection model supported."};return{run:a}}),g("6v",["3n","3f"],function(a,b){var c=function(c,d,e,f){var g=b.owner(c),h=g.dom().createRange();h.setStart(c.dom(),d),h.setEnd(e.dom(),f);var i=a.eq(c,e)&&d===f;return h.collapsed&&!i};return{after:c}}),g("6u",["5o","6v","k","3f"],function(a,b,c,d){var e=function(a){return b.after(c.fromDom(a.anchorNode),a.anchorOffset,c.fromDom(a.focusNode),a.focusOffset)},f=function(b,d){var f=c.fromDom(d.startContainer),g=c.fromDom(d.endContainer);return e(b)?a.read(g,d.endOffset,f,d.startOffset):a.read(f,d.startOffset,g,d.endOffset)},g=function(a){return e(a)},h=function(a,b,c,e){return function(f){if(f.extend)f.collapse(a.dom(),b),f.extend(c.dom(),e);else{var g=d.owner(a).dom().createRange();g.setStart(c.dom(),e),g.setEnd(a.dom(),b),f.removeAllRanges(),f.addRange(g)}}},i=function(a,c,d,e){return b.after(a,c,d,e)},j=function(){return{flip:f,isRtl:g}},k=function(){return{flip:h,isRtl:i}};return{read:j,write:k}}),g("5s",["5o","6u","n","6v","k"],function(a,b,c,d,e){var f=function(b,d){var f=h(b,d.start(),d.finish());if(f.collapsed===!0){var g=h(b,d.finish(),d.start());return g.collapsed===!0?c.none():c.some(a.general(e.fromDom(g.endContainer),g.endOffset,e.fromDom(g.startContainer),g.startOffset))}return c.none()},g=function(a,b){var c=h(a,b.start(),b.finish());return c.collapsed===!0?h(a,b.finish(),b.start()):c},h=function(a,b,c){var d=m(a);return b.fold(function(a){d.setStartBefore(a.dom())},function(a,b){d.setStart(a.dom(),b)},function(a){d.setStartAfter(a.dom())}),c.fold(function(a){d.setEndBefore(a.dom())},function(a,b){d.setEnd(a.dom(),b)},function(a){d.setEndAfter(a.dom())}),d},i=function(a,b){return h(a,b.start(),b.finish())},j=function(a,b,c,e,f){var g=d.after(b,c,e,f),h=a.document.createRange();return g?(h.setStart(e.dom(),f),h.setEnd(b.dom(),c)):(h.setStart(b.dom(),c),h.setEnd(e.dom(),f)),h},k=function(a,b){var c=i(a,b);return function(a){a.addRange(c)}},l=function(a,c){var d=f(a,c);return d.fold(function(){return k(a,c)},function(a){return b.write().flip(a.start(),a.soffset(),a.finish(),a.foffset())})},m=function(a){return a.document.createRange()};return{create:m,build:l,toNative:i,forceRange:g,toExactNative:j}}),g("5r",["g","5s","k","1d","2a","2h"],function(a,b,c,d,e,f){var g=function(a,b,c){return a.selectNodeContents(c.dom()),a.compareBoundaryPoints(b.END_TO_START,b)<1&&a.compareBoundaryPoints(b.START_TO_END,b)>-1},h=function(b,c,d,h){var i=b.document.createRange(),j=f.is(c,h)?[c]:[],k=j.concat(e.descendants(c,h));return a.filter(k,function(a){return g(i,d,a)})},i=function(a,e,f){var g=b.forceRange(a,e),i=c.fromDom(g.commonAncestorContainer);return d.isElement(i)?h(a,i,g,f):[]};return{find:i}}),g("6w",["g","5o","5p","1d"],function(a,b,c,d){var e=function(b,e){var f=d.name(b);return"input"===f?c.after(b):a.contains(["br","img"],f)?0===e?c.before(b):c.after(b):c.on(b,e)},f=function(a){var d=a.start().fold(c.before,e,c.after),f=a.finish().fold(c.before,e,c.after);return b.write(d,f)};return{beforeSpecial:e,preprocess:f}}),g("6x",["g","k","1g"],function(a,b,c){var d=function(d,e){var f=e||c,g=f.createDocumentFragment();return a.each(d,function(a){g.appendChild(a.dom())}),b.fromDom(g)};return{fromElements:d}}),g("5t",["5o","6u","5s","6w","n","k","6x"],function(a,b,c,d,e,f,g){var h=function(a){return function(b,e){var f=d.preprocess(a),g=c.build(b,f);void 0!==e&&null!==e&&(e.removeAllRanges(),g(e))}},i=function(a){return function(b,d){var e=c.create(b);e.selectNodeContents(a.dom()),d.removeAllRanges(),d.addRange(e)}},j=function(a,b){var c=b.getRangeAt(0),d=b.getRangeAt(b.rangeCount-1),e=a.document.createRange();return e.setStart(c.startContainer,c.startOffset),e.setEnd(d.endContainer,d.endOffset),e},k=function(c,d){var e=f.fromDom(d.startContainer),g=f.fromDom(d.endContainer);return b.read().isRtl(c)?b.read().flip(c,d):a.read(e,d.startOffset,g,d.endOffset)},l=function(a,b){return void 0!==b&&null!==b&&b.rangeCount>0?e.from(j(a,b)):e.none()},m=function(a,b){var c=l(a,b);return c.map(function(a){return k(b,a)})},n=function(a){return function(b,c){var d=l(b,c);d.each(function(c){o(b,c,a)})}},o=function(a,b,c){var d=g.fromElements(c,a.document);b.deleteContents(),b.insertNode(d.dom())},p=function(a,b){return function(e,f){var g=d.preprocess(a),h=c.toNative(e,g);o(e,h,b)}},q=function(a,b,d,e){return function(f,g){var h=c.toExactNative(f,a,b,d,e);h.deleteContents()}},r=function(a,b,d,e){return function(g,h){var i=c.toExactNative(g,a,b,d,e),j=i.cloneContents();return f.fromDom(j)}},s=function(a,b,d,f){return function(g,h){var i=c.toExactNative(g,a,b,d,f),j=i.getClientRects(),k=j.length>0?j[0]:i.getBoundingClientRect();return k.width>0||k.height>0?e.some(k):e.none()}},t=function(a){return function(b,d){var f=c.create(b);f.selectNode(a.dom());var g=f.getBoundingClientRect();return g.width>0||g.height>0?e.some(g):e.none()}},u=function(a,b){a.getSelection().removeAllRanges()},v=function(a,b,d,e){return function(f,g){var h=c.toExactNative(f,a,b,d,e);return h.toString()}};return{get:m,set:h,selectElementContents:i,replace:n,replaceRange:p,deleteRange:q,cloneFragment:r,rectangleAt:s,bounds:t,clearSelection:u,stringAt:v}}),g("3a",["5o","5p","5q","5r","5s","5t","3n","k"],function(a,b,c,d,e,f,g,h){var i=function(a){return c.run(a,f.get)},j=function(a,b){c.run(a,f.set(b))},k=function(c,d,e,f,g){var h=a.write(b.on(d,e),b.on(f,g));j(c,h)},l=function(a,b){c.run(a,f.selectElementContents(b))},m=function(a,b){c.run(a,f.replace(b))},n=function(a,b,d){c.run(a,f.replaceRange(b,d))},o=function(a,b,d,e,g){c.run(a,f.deleteRange(b,d,e,g))},p=function(a,b,d,e,g){return c.run(a,f.cloneFragment(b,d,e,g))},q=function(a,b,c,d){return g.eq(a,c)&&b===d},r=function(a,b,d,e,g){return c.run(a,f.rectangleAt(b,d,e,g))},s=function(a,b){return c.run(a,f.bounds(b))},t=function(a,b,c){return d.find(a,b,c)},u=function(c,d,e,f,g,h){var i=a.write(b.on(d,e),b.on(f,g));return t(c,i,h)},v=function(b,c){var d=e.forceRange(b,c);return a.general(h.fromDom(d.startContainer),d.startOffset,h.fromDom(d.endContainer),d.endOffset)},w=function(a){c.run(a,f.clearSelection)},x=function(a,b,d,e,g){return c.run(a,f.stringAt(b,d,e,g))};return{get:i,set:j,setExact:k,selectElementContents:l,replace:m,replaceRange:n,deleteRange:o,isCollapsed:q,cloneFragment:p,rectangleAt:r,bounds:s,findWithin:t,findWithinExact:u,deriveExact:v,clearAll:w,stringAt:x}}),g("5u",["p","3n"],function(a,b){return function(c,d,e,f){var g=b.eq(c,e)&&d===f;return{startContainer:a.constant(c),startOffset:a.constant(d),endContainer:a.constant(e),endOffset:a.constant(f),collapsed:a.constant(g)}}}),g("3b",["5u","k","1x","1y","3f"],function(a,b,c,d,e){return function(f){var g=b.fromTag("br"),h=function(a,b){a.dom().focus()},i=function(a){var b=e.owner(a);return b.dom().defaultView},j=function(b,d){var e=i(d);e.focus(),c.append(d,g),f.set(e,a(g,0,g,0))},k=function(){d.remove(g)};return{cleanup:k,toOn:h,toOff:j}}}),g("3c",["p"],function(a){return function(){var b=function(a,b){a.dom().focus()},c=function(a,b){b.dom().focus()},d=a.identity;return{toOn:b,toOff:c,cleanup:d}}}),g("6y",["g","k","1x","29","1y","3f"],function(a,b,c,d,e,f){var g=function(a,b){f.nextSibling(a).filter(b).each(function(b){var c=f.children(b);d.append(a,c),e.remove(b)}),i(a,b)},h=function(a,g){var h=f.children(a),i=b.fromTag("div",f.owner(a).dom());d.append(i,h),c.before(a,i),e.remove(a)},i=function(b,c){var d=f.children(b);a.each(d,function(a){c(a)&&h(a,b)})};return{consolidate:g}}),g("6z",["3g"],function(a){var b=a.create("ephox-sloth");return{resolve:b.resolve}}),g("70",["5d"],function(a){var b=function(a,b){return function(d){return"rtl"===c(d)?b:a}},c=function(b){return"rtl"===a.get(b,"direction")?"rtl":"ltr"};return{onDirection:b,getDirection:c}}),g("5v",["1s","2c","6y","6z","j","27","3q","5d","70","k","6h","1x","1y","20","3f"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=d.resolve("bin"),q=p+a.generate(""),r=i.onDirection("-100000px","100000px");return function(a){var d=j.fromTag("div");e.setAll(d,{contenteditable:"true","aria-hidden":"true"}),h.setAll(d,{position:"fixed",top:"0px",width:"100px",height:"100px",overflow:"hidden",opacity:"0"}),g.add(d,[p,q]);var i=function(a){m.empty(d),h.set(d,"left",r(a)),l.append(a,d)},s=function(){var b=n.ancestor(d,"body");b.each(function(b){a.toOff(b,d)})},t=function(a){return f.has(a,q)},u=function(){c.consolidate(d,t);var a=b.immutable("elements","html","container"),e=o.children(d),f=k.get(d);return a(e,f,d)},v=function(){m.remove(d)},w=function(){return d};return{attach:i,focus:s,contents:u,container:w,detach:v}}}),g("3d",["p","2x","21","22","2y","5v","3f"],function(a,b,c,d,e,f,g){return function(h,i){var j=f(h),k=function(){h.cleanup();var a=j.contents();j.detach(),n.trigger.after(a.elements(),a.html(),j.container())},l=b.tap(function(){n.trigger.before(),j.attach(i),j.focus(),e.run(g.owner(i),l,k)}),m=function(){l.instance()},n=d.create({before:c([]),after:c(["elements","html","container"])}),o=a.noop;return{instance:a.constant(m),destroy:o,events:n.registry}}}),g("1r",["2t","3a","21","22","3b","3c","3d","1d"],function(a,b,c,d,e,f,g,h){var i=a.detect(),j={set:function(a,c){b.setExact(a,c.startContainer(),c.startOffset(),c.endContainer(),c.endOffset())}},k=function(a){var b=i.browser.isIE()&&"body"!==h.name(a)?f:e;return b(j)};return function(a){var b=d.create({after:c(["container"])}),e=k(a),f=g(e,a);f.events.after.bind(function(c){e.toOn(a,c.container()),b.trigger.after(c.container())});var h=function(){f.instance()()};return{run:h,events:b.registry}}}),g("5y",["w","k","1g"],function(a,b,c){var d=function(d){if("complete"===c.readyState||"interactive"===c.readyState)d();else var e=a.bind(b.fromDom(c),"DOMContentLoaded",function(){d(),e.unbind()})};return{execute:d}}),g("3e",["2t","5h","p","5w","n","5x","5i","5d","w","k","1x","5y","1y"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=b.install("ephox.keurig.init"),o=e.none(),p=a.detect(),q=p.browser,r=q.isIE()||q.isSpartan()||p.deviceType.isiOS()||p.deviceType.isAndroid(),s=r?c.noop:d.cached(function(a){var b=j.fromTag("div");if(void 0===a)throw"baseUrl was undefined";var c=j.fromTag("iframe");h.setAll(b,{display:"none"});var d=i.bind(c,"load",function(){var g=function(a){o=e.some(a),q.isSafari()||m.remove(b)},h=n.ephemeral(g),i=a+"/wordimport.js";f.write(c,'"),d.unbind()});l.execute(function(){k.append(g.body(),b),k.append(b,c)})}),t=function(a,b){return o.map(function(c){return c(a,b)})},u=function(){return o.isSome()};return{load:s,cleanDocument:t,ready:u}}),g("1t",["3e"],function(a){return function(b){return a.ready()||a.load(b),{cleanDocument:a.cleanDocument}}}),g("l",["1o","1p","1q","1r","g","1s","1t","p","n"],function(a,b,c,d,e,f,g,h,i){return function(j,k,l,m){var n=g(m.baseUrl),o=h.curry(c,k),p=d,q=function(){return{clipboardType:f.generate("clipboard-type"),findClipboardTags:i.none}},r=void 0!==m.intraFlag?m.intraFlag:q(),s=e.flatten([void 0!==m.intraFlag?[b.internal(l,p,j,r)]:[],[b.onlyText()],[b.gwt(n,k,m,o)],[b.image(m)]]),t=b.pastiche(k,m,l,p,j,o,r);return a(s,t)}}),g("m",["1o","1p"],function(a,b){return function(){return a([b.text()],b.none())}}),g("q",[],function(){return{officeStyles:"prompt",htmlStyles:"clean"}}),g("r",["j","k","1x","1y","1z","20","1g"],function(a,b,c,d,e,f,g){var h="powerpaste-styles",i="#"+h,j=function(d){if(!e.any(i)){var g="",j=b.fromHtml(g);a.set(j,"type","text/css"),a.set(j,"id",h);var k=f.first("head").getOrDie("Head element could not be found.");c.append(k,j)}},k=function(){if(e.any(i)){var a=f.first("head").getOrDie("Head element could not be found."),b=f.descendant(a,i).getOrDie("The style element could not be removed");d.remove(b)}};return{injectStyles:j,removeStyles:k}}),g("v",["g","k","j","1g"],function(a,b,c,d){var e=function(a){var b=d.createElement("div");b.appendChild(a.cloneNode(!0));var c=b.innerHTML;return b=a=null,c},f=function(d){a.each(a.map(d.getElementsByTagName("*"),b.fromDom),function(a){c.has(a,"data-mce-style")&&!c.has(a,"style")&&c.set(a,"style",c.get(a,"data-mce-style"))})};return{nodeToString:e,restoreStyleAttrs:f}}),g("t",["21","22","v","j","k","1x","1y","20"],function(a,b,c,d,e,f,g,h){return function(i){var j=function(){var j,k="",l="",m=[],n=null,o=b.create({close:a([])}),p=function(a){k=a},q=function(a){var b=c.nodeToString(a.dom());l=[{type:"container",html:b}],n=a},r=function(a){var b=[];a.forEach(function(a,c,d){b.push({text:a.text,onclick:a.click})}),m=b},s=function(a){o.trigger.close()},t=function(){j.off("close",s),j.close("close")},u=function(){0===m.length&&(m=[{text:"Close",onclick:function(){j.close()}}]);var a={title:k,spacing:10,padding:10,minWidth:300,minHeight:100,layout:"flex",items:l,buttons:m};j=i.windowManager.open(a);var b=e.fromDom(j.getEl()),c=h.descendant(b,"."+d.get(n,"class")).getOrDie("We must find this element or we cannot continue");f.before(c,n),g.remove(c),j.on("close",s)},v=function(){t()},w=function(){t()},x=function(){};return{events:o.registry,setTitle:p,setContent:q,setButtons:r,show:u,hide:v,destroy:w,reflow:x}};return{createDialog:j}}}),g("24",["2c","n"],function(a,b){var c=a.immutable("url","html"),d=function(a){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(a)},e=function(a){return d(a)&&/.(gif|jpe?g|png)$/.test(a)},f=function(a){var d=/^([^<]+)<\/a>$/.exec(a);return b.from(d).bind(function(d){var e=c(d[1],a);return d[1]===d[2]?b.some(e):b.none()})};return{isAbsoluteUrl:d,isImageUrl:e,parseUrlFromLinkHtml:f}}),g("u",["g","n","23","24"],function(a,b,c,d){var e=function(a){return"extra"in a.undoManager},f=function(a,c,d){return e(a)?(a.undoManager.extra(function(){k(a,c)},d),b.some(!0)):b.none()},g=function(a,b){return f(a,b.html(),function(){a.insertContent('')})},h=function(a,b){return f(a,b.html(),function(){a.execCommand("mceInsertLink",!1,b.url())})},i=function(a,c){return d.parseUrlFromLinkHtml(c).bind(function(c){var e=a.selection.isCollapsed()===!1&&d.isAbsoluteUrl(c.url());return e?h(a,c):b.none()})},j=function(a,c){return d.parseUrlFromLinkHtml(c).bind(function(c){return d.isImageUrl(c.url())?g(a,c):b.none()})},k=function(a,c){return a.insertContent(c,{merge:a.settings.paste_merge_formats!==!1,paste:!0}),b.some(!0)},l=function(a,b,d){var e=function(c){return c(a,b)};return c.findMap(d,e)};return{until:l,linkSelection:i,insertImage:j,insertContent:k}}),g("8",[],function(){var a=function(a,b){return a.hasEventListeners(b)},b=function(a,b){return a.fire("PastePreProcess",{content:b}).content},c=function(a,b){var c=a.dom.add(a.getBody(),"div",{style:"display:none"},b),d=a.fire("PastePostProcess",{node:c}).node.innerHTML;return a.dom.remove(c),d},d=function(c,d){return a(c,"PastePreProcess")?b(c,d):d},e=function(b,d){return a(b,"PastePostProcess")?c(b,d):d},f=function(a,b){return e(a,d(a,b))},g=function(a){var b=a.settings,c=a.plugins.powerpaste;b.paste_preprocess&&a.on("PastePreProcess",function(d){b.paste_preprocess.call(a,c,d)}),b.paste_postprocess&&a.on("PastePostProcess",function(d){b.paste_postprocess.call(a,c,d)})};return{process:f,registerEvents:g}}),g("6",["l","m","g","n","o","p","d","q","r","s","t","u","8","v","w","k","x","2"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){return function(s,t,u,v,w){var x,y,z,A,B;B=(v?v.jsUrl:u)+"/js",y=(v?v.swfUrl:u)+"/flash/textboxpaste.swf",z=(v?v.imgUrl:u)+"/img/spinner_96.gif",A=(v?v.cssUrl:u)+"/css/editorcss.css";var C=function(a){return a.settings.smart_paste!==!1},D=function(a){return function(b,c){return b.undoManager.transact(function(){l.insertContent(b,c),n.restoreStyleAttrs(b.getBody()),w.prepareImages(a)}),d.some(!0)}},E=function(a,b,c){var d=C(a)?[l.linkSelection,l.insertImage]:[];l.until(a,b,d.concat([D(c)]))},F=function(){x&&s.selection.moveToBookmark(x),x=null};s.on("init",function(d){i.injectStyles(z),s.dom.loadCSS(A);var l={baseUrl:B,swf:y,officeStyles:s.settings.powerpaste_word_import||h.officeStyles,htmlStyles:s.settings.powerpaste_html_import||h.htmlStyles,translations:g.translate,allowLocalImages:s.settings.powerpaste_allow_local_images!==!1,enableFlashImport:s.settings.powerpaste_enable_flash_import!==!1,preprocessor:function(a){return e.pure(a)}},r=k(s),u=p.fromDom(s.getBody()),v=function(a){a.events.cancel.bind(function(){F()}),a.events.error.bind(function(a){F(),s.notificationManager?s.notificationManager.open({text:g.translate(a.message()),type:"error"}):j.showDialog(s,g.translate(a.message()))}),a.events.insert.bind(function(a){var b=c.map(a.elements(),function(a){return n.nodeToString(a.dom())}).join("");s.focus(),q(function(){F(),E(s,m.process(s,b),a.assets()),w.uploadImages(a.assets())},1)})},C=a(u,r.createDialog,f.noop,l),D=b();c.each([C,D],v),o.bind(u,"paste",function(a){x||(x=s.selection.getBookmark());var b=t.isText()?D:C;b.paste(a.raw()),t.reset(),q(function(){s.windowManager.windows[0]&&s.windowManager.windows[0].getEl()&&s.windowManager.windows[0].getEl().focus()},1)})}),s.on("remove",function(a){1===r.editors.length&&i.removeStyles()})}}),g("7",["y","z"],function(a,b){var c=function(a){return tinymce.util.VK.metaKeyPressed(a)&&86==a.keyCode&&a.shiftKey};return function(d){var e=b(d.settings.paste_as_text),f=b(!1);d.on("keydown",function(a){c(a)&&(f.set(!0),tinymce.Env.ie&&tinymce.Env.ie<10&&(a.preventDefault(),d.fire("paste",{})))});var g=a(function(){var a=d.translate("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.");d.notificationManager.open({text:a,type:"info"})}),h=function(){var a=this,b=!e.get();a.active(b),e.set(b),d.fire("PastePlainTextToggle",{state:b}),b===!0&&0!=d.settings.paste_plaintext_inform&&g(),d.focus()},i=function(){f.set(!1)},j=function(){return f.get()||e.get()};return{toggle:h,reset:i,isText:j}}}),g("10",[],function(){var a=0,b=1,c=-1,d=function(a){return parseInt(a,10)},e=function(a){return function(){return a}},f=function(a,b,c){return{major:e(a),minor:e(b),patch:e(c)}},g=function(a){var b=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(a);return b?f(d(b[1]),d(b[2]),d(b[3])):f(0,0,0)},h=function(d,e){var f=d-e;return 0===f?a:f>0?b:c},i=function(b,c){var d=h(b.major(),c.major());if(d!==a)return d;var e=h(b.minor(),c.minor());if(e!==a)return e;var f=h(b.patch(),c.patch());return f!==a?f:a};return{nu:f,parse:g,compare:i}}),g("9",["10"],function(a){var b=function(a){var b=[a.majorVersion,a.minorVersion].join(".");return b.split(".").slice(0,3).join(".")},c=function(c){return c?a.parse(b(c)):null},d=function(b,d){return a.compare(c(b),a.parse(d))<0};return{getVersion:c,isLessThan:d}}),g("a",["11"],function(a){var b=function(a,b){return function(){var c=a.console;c&&b in c&&c[b].apply(c,arguments)}};return{log:b(a,"log"),error:b(a,"error"),warn:b(a,"warm")}}),g("1",["3","4","5","6","7","8","9","a","2"],function(a,b,c,d,e,f,g,h,i){return function(j){return g.isLessThan(i,"4.0.0")?(h.error('The "powerpaste" plugin requires at least 4.0.0 version of TinyMCE.'),function(){}):function(g,h){var k=e(g),l=function(){var b=a(g);d(g,k,h,j,b),g.settings.powerpaste_block_drop||c(g,h,j,b)},m=function(){b(g,k,j)},n=function(){var a=this;a.active(k.isText()),g.on("PastePlainTextToggle",function(b){a.active(b.state)})};i.Env.ie&&i.Env.ie<10?m():l();var o=function(a){g.dom.bind(a,"drop dragstart dragend dragover dragenter dragleave dragdrop draggesture",function(a){return i.dom.Event.cancel(a)})};g.settings.powerpaste_block_drop&&g.on("init",function(a){o(g.getBody()),o(g.getDoc())}),f.registerEvents(g),g.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:k.toggle,onPostRender:n}),g.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,onclick:k.toggle,onPostRender:n})}}}),g("0",["1","2"],function(a,b){return function(c){b.PluginManager.requireLangPack("powerpaste","ar,ca,cs,da,de,el,es,fa,fi,fr_FR,he_IL,hr,hu_HU,it,ja,kk,ko_KR,nb_NO,nl,pl,pt_BR,pt_PT,ro,ru,sk,sl_SI,sv_SE,th_TH,tr,uk,zh_CN,zh_TW"),b.PluginManager.add("powerpaste",a(c))}}),d("0")()}();