init
This commit is contained in:
16
public/tinymce/src/plugins/advlist/demo/html/demo.html
Normal file
16
public/tinymce/src/plugins/advlist/demo/html/demo.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Plugin: advlist Demo Page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Plugin: advlist Demo Page</h2>
|
||||
<div id="ephox-ui">
|
||||
<textarea name="" id="" cols="30" rows="10" class="tinymce"></textarea>
|
||||
</div>
|
||||
|
||||
<script src="../../../../../js/tinymce/tinymce.js"></script>
|
||||
<script src="../../../../../scratch/demos/plugins/advlist/demo.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
22
public/tinymce/src/plugins/advlist/demo/ts/demo/Demo.ts
Normal file
22
public/tinymce/src/plugins/advlist/demo/ts/demo/Demo.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Demo.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2016 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
declare let tinymce: any;
|
||||
|
||||
tinymce.init({
|
||||
selector: 'textarea.tinymce',
|
||||
theme: 'modern',
|
||||
skin_url: '../../../../../js/tinymce/skins/lightgray',
|
||||
plugins: 'lists advlist code',
|
||||
toolbar: 'bullist numlist | outdent indent | code',
|
||||
height: 600
|
||||
});
|
||||
|
||||
export {};
|
||||
25
public/tinymce/src/plugins/advlist/main/ts/Plugin.ts
Normal file
25
public/tinymce/src/plugins/advlist/main/ts/Plugin.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
import PluginManager from 'tinymce/core/api/PluginManager';
|
||||
import Tools from 'tinymce/core/api/util/Tools';
|
||||
import Commands from './api/Commands';
|
||||
import Buttons from './ui/Buttons';
|
||||
|
||||
PluginManager.add('advlist', function (editor) {
|
||||
const hasPlugin = function (editor, plugin) {
|
||||
const plugins = editor.settings.plugins ? editor.settings.plugins : '';
|
||||
return Tools.inArray(plugins.split(/[ ,]/), plugin) !== -1;
|
||||
};
|
||||
|
||||
if (hasPlugin(editor, 'lists')) {
|
||||
Buttons.register(editor);
|
||||
Commands.register(editor);
|
||||
}
|
||||
});
|
||||
|
||||
export default function () { }
|
||||
22
public/tinymce/src/plugins/advlist/main/ts/api/Commands.ts
Normal file
22
public/tinymce/src/plugins/advlist/main/ts/api/Commands.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
import Actions from '../core/Actions';
|
||||
|
||||
const register = function (editor) {
|
||||
editor.addCommand('ApplyUnorderedListStyle', function (ui, value) {
|
||||
Actions.applyListFormat(editor, 'UL', value['list-style-type']);
|
||||
});
|
||||
|
||||
editor.addCommand('ApplyOrderedListStyle', function (ui, value) {
|
||||
Actions.applyListFormat(editor, 'OL', value['list-style-type']);
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
register
|
||||
};
|
||||
21
public/tinymce/src/plugins/advlist/main/ts/api/Settings.ts
Normal file
21
public/tinymce/src/plugins/advlist/main/ts/api/Settings.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
const getNumberStyles = function (editor) {
|
||||
const styles = editor.getParam('advlist_number_styles', 'default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman');
|
||||
return styles ? styles.split(/[ ,]/) : [];
|
||||
};
|
||||
|
||||
const getBulletStyles = function (editor) {
|
||||
const styles = editor.getParam('advlist_bullet_styles', 'default,circle,disc,square');
|
||||
return styles ? styles.split(/[ ,]/) : [];
|
||||
};
|
||||
|
||||
export default {
|
||||
getNumberStyles,
|
||||
getBulletStyles
|
||||
};
|
||||
15
public/tinymce/src/plugins/advlist/main/ts/core/Actions.ts
Normal file
15
public/tinymce/src/plugins/advlist/main/ts/core/Actions.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
const applyListFormat = function (editor, listName, styleValue) {
|
||||
const cmd = listName === 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList';
|
||||
editor.execCommand(cmd, false, styleValue === false ? null : { 'list-style-type': styleValue });
|
||||
};
|
||||
|
||||
export default {
|
||||
applyListFormat
|
||||
};
|
||||
31
public/tinymce/src/plugins/advlist/main/ts/core/ListUtils.ts
Normal file
31
public/tinymce/src/plugins/advlist/main/ts/core/ListUtils.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
const isChildOfBody = function (editor, elm) {
|
||||
return editor.$.contains(editor.getBody(), elm);
|
||||
};
|
||||
|
||||
const isTableCellNode = function (node) {
|
||||
return node && /^(TH|TD)$/.test(node.nodeName);
|
||||
};
|
||||
|
||||
const isListNode = function (editor) {
|
||||
return function (node) {
|
||||
return node && (/^(OL|UL|DL)$/).test(node.nodeName) && isChildOfBody(editor, node);
|
||||
};
|
||||
};
|
||||
|
||||
const getSelectedStyleType = function (editor) {
|
||||
const listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');
|
||||
return editor.dom.getStyle(listElm, 'listStyleType') || '';
|
||||
};
|
||||
|
||||
export default {
|
||||
isTableCellNode,
|
||||
isListNode,
|
||||
getSelectedStyleType
|
||||
};
|
||||
91
public/tinymce/src/plugins/advlist/main/ts/ui/Buttons.ts
Normal file
91
public/tinymce/src/plugins/advlist/main/ts/ui/Buttons.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
import Tools from 'tinymce/core/api/util/Tools';
|
||||
import Settings from '../api/Settings';
|
||||
import Actions from '../core/Actions';
|
||||
import ListUtils from '../core/ListUtils';
|
||||
import ListStyles from './ListStyles';
|
||||
|
||||
const findIndex = function (list, predicate) {
|
||||
for (let index = 0; index < list.length; index++) {
|
||||
const element = list[index];
|
||||
|
||||
if (predicate(element)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
const listState = function (editor, listName) {
|
||||
return function (e) {
|
||||
const ctrl = e.control;
|
||||
|
||||
editor.on('NodeChange', function (e) {
|
||||
const tableCellIndex = findIndex(e.parents, ListUtils.isTableCellNode);
|
||||
const parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
|
||||
const lists = Tools.grep(parents, ListUtils.isListNode(editor));
|
||||
ctrl.active(lists.length > 0 && lists[0].nodeName === listName);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const updateSelection = function (editor) {
|
||||
return function (e) {
|
||||
const listStyleType = ListUtils.getSelectedStyleType(editor);
|
||||
e.control.items().each(function (ctrl) {
|
||||
ctrl.active(ctrl.settings.data === listStyleType);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const addSplitButton = function (editor, id, tooltip, cmd, nodeName, styles) {
|
||||
editor.addButton(id, {
|
||||
active: false,
|
||||
type: 'splitbutton',
|
||||
tooltip,
|
||||
menu: ListStyles.toMenuItems(styles),
|
||||
onPostRender: listState(editor, nodeName),
|
||||
onshow: updateSelection(editor),
|
||||
onselect (e) {
|
||||
Actions.applyListFormat(editor, nodeName, e.control.settings.data);
|
||||
},
|
||||
onclick () {
|
||||
editor.execCommand(cmd);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const addButton = function (editor, id, tooltip, cmd, nodeName, styles) {
|
||||
editor.addButton(id, {
|
||||
active: false,
|
||||
type: 'button',
|
||||
tooltip,
|
||||
onPostRender: listState(editor, nodeName),
|
||||
onclick () {
|
||||
editor.execCommand(cmd);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const addControl = function (editor, id, tooltip, cmd, nodeName, styles) {
|
||||
if (styles.length > 0) {
|
||||
addSplitButton(editor, id, tooltip, cmd, nodeName, styles);
|
||||
} else {
|
||||
addButton(editor, id, tooltip, cmd, nodeName, styles);
|
||||
}
|
||||
};
|
||||
|
||||
const register = function (editor) {
|
||||
addControl(editor, 'numlist', 'Numbered list', 'InsertOrderedList', 'OL', Settings.getNumberStyles(editor));
|
||||
addControl(editor, 'bullist', 'Bullet list', 'InsertUnorderedList', 'UL', Settings.getBulletStyles(editor));
|
||||
};
|
||||
|
||||
export default {
|
||||
register
|
||||
};
|
||||
27
public/tinymce/src/plugins/advlist/main/ts/ui/ListStyles.ts
Normal file
27
public/tinymce/src/plugins/advlist/main/ts/ui/ListStyles.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
|
||||
import Tools from 'tinymce/core/api/util/Tools';
|
||||
|
||||
const styleValueToText = function (styleValue) {
|
||||
return styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function (chr) {
|
||||
return chr.toUpperCase();
|
||||
});
|
||||
};
|
||||
|
||||
const toMenuItems = function (styles) {
|
||||
return Tools.map(styles, function (styleValue) {
|
||||
const text = styleValueToText(styleValue);
|
||||
const data = styleValue === 'default' ? '' : styleValue;
|
||||
|
||||
return { text, data };
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
toMenuItems
|
||||
};
|
||||
@@ -0,0 +1,198 @@
|
||||
import AdvListPlugin from 'tinymce/plugins/advlist/Plugin';
|
||||
import ListsPlugin from 'tinymce/plugins/lists/Plugin';
|
||||
import ModernTheme from 'tinymce/themes/modern/Theme';
|
||||
import { LegacyUnit, TinyLoader } from '@ephox/mcagar';
|
||||
import { Pipeline } from '@ephox/agar';
|
||||
import { UnitTest } from '@ephox/bedrock';
|
||||
|
||||
UnitTest.asynctest('browser.tinymce.plugins.lists.AdvlistPluginTest', function () {
|
||||
const success = arguments[arguments.length - 2];
|
||||
const failure = arguments[arguments.length - 1];
|
||||
const suite = LegacyUnit.createSuite();
|
||||
|
||||
AdvListPlugin();
|
||||
ListsPlugin();
|
||||
ModernTheme();
|
||||
|
||||
const listStyleTest = function (title, definition) {
|
||||
suite.test(title, function (editor) {
|
||||
editor.getBody().innerHTML = definition.inputContent;
|
||||
LegacyUnit.setSelection(editor, definition.inputSelection[0], definition.inputSelection[1]);
|
||||
editor.execCommand(definition.command, false, { 'list-style-type': definition.listType });
|
||||
const rng = editor.selection.getRng(true);
|
||||
const expectedElm = editor.dom.select(definition.expectedSelection[0])[0];
|
||||
|
||||
LegacyUnit.equal(editor.getContent(), definition.expectedContent, 'Editor content should be equal');
|
||||
LegacyUnit.equalDom(rng.startContainer.parentNode, expectedElm, 'Selection elements should be equal');
|
||||
LegacyUnit.equal(rng.startOffset, definition.expectedSelection[1], 'Selection offset should be equal');
|
||||
});
|
||||
};
|
||||
|
||||
listStyleTest('Apply unordered list style to an unordered list', {
|
||||
inputContent: '<ul><li>a</li></ul>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: 'disc',
|
||||
expectedContent: '<ul style="list-style-type: disc;"><li>a</li></ul>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style to an ordered list', {
|
||||
inputContent: '<ol><li>a</li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: 'lower-roman',
|
||||
expectedContent: '<ol style="list-style-type: lower-roman;"><li>a</li></ol>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style to an unordered list', {
|
||||
inputContent: '<ol><li>a</li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: 'disc',
|
||||
expectedContent: '<ul style="list-style-type: disc;"><li>a</li></ul>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style to an unordered list with a child unordered list', {
|
||||
inputContent: '<ul><li>a<ul><li>b</li></ul></li></ul>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: 'disc',
|
||||
expectedContent: '<ul style="list-style-type: disc;"><li>a<ul><li>b</li></ul></li></ul>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style to an ordered list with a child ordered list', {
|
||||
inputContent: '<ol><li>a<ol><li>b</li></ol></li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: 'lower-roman',
|
||||
expectedContent: '<ol style="list-style-type: lower-roman;"><li>a<ol><li>b</li></ol></li></ol>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style to an unordered list with a child ordered list', {
|
||||
inputContent: '<ul><li>a<ol><li>b</li></ol></li></ul>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: 'disc',
|
||||
expectedContent: '<ul style="list-style-type: disc;"><li>a<ol><li>b</li></ol></li></ul>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style to an unordered list with a child unordered list', {
|
||||
inputContent: '<ol><li>a<ul><li>b</li></ul></li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: 'lower-roman',
|
||||
expectedContent: '<ol style="list-style-type: lower-roman;"><li>a<ul><li>b</li></ul></li></ol>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style to an unordered list with a child unordered list', {
|
||||
inputContent: '<ul><li>a<ul><li>b</li></ul></li></ul>',
|
||||
inputSelection: ['li:nth-child(1) > ul > li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: 'disc',
|
||||
expectedContent: '<ul><li>a<ul style="list-style-type: disc;"><li>b</li></ul></li></ul>',
|
||||
expectedSelection: ['li:nth-child(1) > ul > li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style to an ordered list with a child ordered list', {
|
||||
inputContent: '<ol><li>a<ol><li>b</li></ol></li></ol>',
|
||||
inputSelection: ['li:nth-child(1) > ol > li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: 'lower-roman',
|
||||
expectedContent: '<ol><li>a<ol style="list-style-type: lower-roman;"><li>b</li></ol></li></ol>',
|
||||
expectedSelection: ['li:nth-child(1) > ol > li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style to an unordered list with a child ordered list', {
|
||||
inputContent: '<ul><li>a<ol><li>b</li></ol></li></ul>',
|
||||
inputSelection: ['li:nth-child(1) > ol > li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: 'lower-roman',
|
||||
expectedContent: '<ul><li>a<ol style="list-style-type: lower-roman;"><li>b</li></ol></li></ul>',
|
||||
expectedSelection: ['li:nth-child(1) > ol > li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style to ordered list with a child unordered list', {
|
||||
inputContent: '<ol><li>a<ul><li>b</li></ul></li></ol>',
|
||||
inputSelection: ['li:nth-child(1) > ul > li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: 'disc',
|
||||
expectedContent: '<ol><li>a<ul style="list-style-type: disc;"><li>b</li></ul></li></ol>',
|
||||
expectedSelection: ['li:nth-child(1) > ul > li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style to an unordered list with a child ordered list', {
|
||||
inputContent: '<ul><li>a<ol><li>b</li></ol></li></ul>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: false,
|
||||
expectedContent: '<ol><li>a<ol><li>b</li></ol></li></ol>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style to an ordered list with a child unordered list', {
|
||||
inputContent: '<ol><li>a<ul><li>b</li></ul></li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: false,
|
||||
expectedContent: '<ul><li>a<ul><li>b</li></ul></li></ul>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style "false" to an ordered list with a child unordered list', {
|
||||
inputContent: '<ol><li>a<ul><li>b</li></ul></li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: false,
|
||||
expectedContent: '<p>a</p><ul><li style="list-style-type: none;"><ul><li>b</li></ul></li></ul>',
|
||||
expectedSelection: ['p:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style "false" to an unordered list with a child ordered list', {
|
||||
inputContent: '<ul><li>a<ol><li>b</li></ol></li></ul>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: false,
|
||||
expectedContent: '<p>a</p><ol><li style="list-style-type: none;"><ol><li>b</li></ol></li></ol>',
|
||||
expectedSelection: ['p:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply unordered list style "false" to an ordered list with a child ordered list', {
|
||||
inputContent: '<ol><li>a<ol><li>b</li></ol></li></ol>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyUnorderedListStyle',
|
||||
listType: false,
|
||||
expectedContent: '<ul><li>a<ol><li>b</li></ol></li></ul>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
listStyleTest('Apply ordered list style "false" to an unordered list with a child unordered list', {
|
||||
inputContent: '<ul><li>a<ul><li>b</li></ul></li></ul>',
|
||||
inputSelection: ['li:nth-child(1)', 0],
|
||||
command: 'ApplyOrderedListStyle',
|
||||
listType: false,
|
||||
expectedContent: '<ol><li>a<ul><li>b</li></ul></li></ol>',
|
||||
expectedSelection: ['li:nth-child(1)', 0]
|
||||
});
|
||||
|
||||
TinyLoader.setup(function (editor, onSuccess, onFailure) {
|
||||
Pipeline.async({}, suite.toSteps(editor), onSuccess, onFailure);
|
||||
}, {
|
||||
plugins: 'advlist lists',
|
||||
add_unload_trigger: false,
|
||||
indent: false,
|
||||
entities: 'raw',
|
||||
valid_elements: 'li[style],ol[style],ul[style],dl,dt,dd,em,strong,span,#p,div,br',
|
||||
valid_styles: {
|
||||
'*': 'list-style-type'
|
||||
},
|
||||
disable_nodechange: true,
|
||||
skin_url: '/project/js/tinymce/skins/lightgray'
|
||||
}, success, failure);
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
import { GeneralSteps, Logger, Pipeline } from '@ephox/agar';
|
||||
import { TinyApis, TinyLoader, TinyUi } from '@ephox/mcagar';
|
||||
import AdvlistPlugin from 'tinymce/plugins/advlist/Plugin';
|
||||
import ListsPlugin from 'tinymce/plugins/lists/Plugin';
|
||||
import ModernTheme from 'tinymce/themes/modern/Theme';
|
||||
import { UnitTest } from '@ephox/bedrock';
|
||||
|
||||
UnitTest.asynctest('browser.tinymce.plugins.lists.ChangeListStyleTest', function () {
|
||||
const success = arguments[arguments.length - 2];
|
||||
const failure = arguments[arguments.length - 1];
|
||||
|
||||
ModernTheme();
|
||||
ListsPlugin();
|
||||
AdvlistPlugin();
|
||||
|
||||
TinyLoader.setup(function (editor, onSuccess, onFailure) {
|
||||
const tinyApis = TinyApis(editor);
|
||||
const tinyUi = TinyUi(editor);
|
||||
|
||||
Pipeline.async({}, [
|
||||
Logger.t('ul to alpha, cursor only in parent', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
|
||||
tinyApis.sSetCursor([0, 0, 0], 0),
|
||||
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Numbered list"] button.mce-open'),
|
||||
tinyUi.sClickOnUi('click lower alpha item', 'div[role="menuitem"] span:contains("Lower Alpha")'),
|
||||
tinyApis.sAssertContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ul><li>b</li></ul></ol>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
|
||||
])),
|
||||
Logger.t('ul to alpha, selection from parent to sublist', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
|
||||
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
|
||||
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Numbered list"] button.mce-open'),
|
||||
tinyUi.sClickOnUi('click lower alpha item', 'div[role="menuitem"] span:contains("Lower Alpha")'),
|
||||
tinyApis.sAssertContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
|
||||
])),
|
||||
Logger.t('ol to ul, cursor only in parent', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ol><li>a</li><ol><li>b</li></ol></ol>'),
|
||||
tinyApis.sSetCursor([0, 0, 0], 0),
|
||||
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Bullet list"] > button'),
|
||||
tinyApis.sAssertContent('<ul><li>a</li><ol><li>b</li></ol></ul>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
|
||||
])),
|
||||
Logger.t('ol to ul, selection from parent to sublist', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ol><li>a</li><ol><li>b</li></ol></ol>'),
|
||||
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
|
||||
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Bullet list"] > button'),
|
||||
tinyApis.sAssertContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
|
||||
])),
|
||||
Logger.t('alpha to ol, cursor only in parent', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
|
||||
tinyApis.sSetCursor([0, 0, 0], 0),
|
||||
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Numbered list"] button.mce-open'),
|
||||
tinyUi.sClickOnUi('click lower alpha item', 'div[role="menuitem"] span:contains("Default")'),
|
||||
tinyApis.sAssertContent('<ol><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
|
||||
])),
|
||||
Logger.t('alpha to ol, selection from parent to sublist', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
|
||||
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
|
||||
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Numbered list"] button.mce-open'),
|
||||
tinyUi.sClickOnUi('click lower alpha item', 'div[role="menuitem"] span:contains("Default")'),
|
||||
tinyApis.sAssertContent('<ol><li>a</li><ol><li>b</li></ol></ol>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
|
||||
])),
|
||||
Logger.t('alpha to ul, cursor only in parent', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
|
||||
tinyApis.sSetCursor([0, 0, 0], 0),
|
||||
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Bullet list"] > button'),
|
||||
tinyApis.sAssertContent('<ul><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ul>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
|
||||
])),
|
||||
Logger.t('alpha to ul, selection from parent to sublist', GeneralSteps.sequence([
|
||||
tinyApis.sSetContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
|
||||
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
|
||||
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Bullet list"] > button'),
|
||||
tinyApis.sAssertContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
|
||||
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
|
||||
]))
|
||||
], onSuccess, onFailure);
|
||||
}, {
|
||||
indent: false,
|
||||
plugins: 'lists advlist',
|
||||
toolbar: 'numlist bullist',
|
||||
skin_url: '/project/js/tinymce/skins/lightgray'
|
||||
}, success, failure);
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import AdvListPlugin from 'tinymce/plugins/advlist/Plugin';
|
||||
import ListsPlugin from 'tinymce/plugins/lists/Plugin';
|
||||
import ModernTheme from 'tinymce/themes/modern/Theme';
|
||||
import { LegacyUnit, TinyLoader } from '@ephox/mcagar';
|
||||
import { Pipeline } from '@ephox/agar';
|
||||
import { UnitTest } from '@ephox/bedrock';
|
||||
|
||||
UnitTest.asynctest('browser.tinymce.plugins.lists.SplitButtonTest', function () {
|
||||
const success = arguments[arguments.length - 2];
|
||||
const failure = arguments[arguments.length - 1];
|
||||
const suite = LegacyUnit.createSuite();
|
||||
|
||||
AdvListPlugin();
|
||||
ListsPlugin();
|
||||
ModernTheme();
|
||||
|
||||
suite.test('Replace splitbutton control with button when advlist_number_styles/advlist_bullet_styles are empty', function (editor) {
|
||||
LegacyUnit.equal(editor.buttons.numlist.type, 'button');
|
||||
LegacyUnit.equal(editor.buttons.bullist.type, 'button');
|
||||
});
|
||||
|
||||
TinyLoader.setup(function (editor, onSuccess, onFailure) {
|
||||
Pipeline.async({}, suite.toSteps(editor), onSuccess, onFailure);
|
||||
}, {
|
||||
plugins: 'advlist lists',
|
||||
advlist_bullet_styles: '',
|
||||
advlist_number_styles: '',
|
||||
toolbar: 'numlist bullist',
|
||||
skin_url: '/project/js/tinymce/skins/lightgray'
|
||||
}, success, failure);
|
||||
});
|
||||
Reference in New Issue
Block a user