Browse Source
TINY-6587: Review Autocompleter, Split Button, and Menu Button page (#2000)
pull/2008/head
TINY-6587: Review Autocompleter, Split Button, and Menu Button page (#2000)
pull/2008/head

committed by
GitHub

No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 45 deletions
-
11_includes/components/choice-menu-items.md
-
0_includes/live-demos/autocompleter-autocompleteitem/index.html
-
48_includes/live-demos/autocompleter-autocompleteitem/index.js
-
4_includes/live-demos/autocompleter-cardmenuitem/index.html
-
26_includes/live-demos/autocompleter-cardmenuitem/index.js
-
20ui-components/autocompleter.md
-
4ui-components/typesoftoolbarbuttons.md
@ -0,0 +1,48 @@ |
|||
var specialChars = [ |
|||
{ text: 'exclamation mark', value: '!' }, |
|||
{ text: 'at', value: '@' }, |
|||
{ text: 'hash', value: '#' }, |
|||
{ text: 'dollars', value: '$' }, |
|||
{ text: 'percent sign', value: '%' }, |
|||
{ text: 'caret', value: '^' }, |
|||
{ text: 'ampersand', value: '&' }, |
|||
{ text: 'asterisk', value: '*' } |
|||
]; |
|||
tinymce.init({ |
|||
selector: 'textarea#autocompleter', |
|||
height: 250, |
|||
setup: function (editor) { |
|||
var onAction = function (autocompleteApi, rng, value) { |
|||
editor.selection.setRng(rng); |
|||
editor.insertContent(value); |
|||
autocompleteApi.hide(); |
|||
}; |
|||
|
|||
var getMatchedChars = function (pattern) { |
|||
return specialChars.filter(function (char) { |
|||
return char.text.indexOf(pattern) !== -1; |
|||
}); |
|||
}; |
|||
|
|||
/* An autocompleter that allows you to insert special characters */ |
|||
editor.ui.registry.addAutocompleter('specialchars', { |
|||
ch: ':', |
|||
minChars: 1, |
|||
columns: 'auto', |
|||
onAction: onAction, |
|||
fetch: function (pattern) { |
|||
return new tinymce.util.Promise(function (resolve) { |
|||
var results = getMatchedChars(pattern).map(function (char) { |
|||
return { |
|||
type: 'autocompleteitem', |
|||
value: char.value, |
|||
text: char.text, |
|||
icon: char.value |
|||
} |
|||
}); |
|||
resolve(results); |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
}); |
@ -0,0 +1,4 @@ |
|||
<textarea id="autocompleter-cardmenuitem"> |
|||
<p>Type <b>-</b> below and then keep typing to reduce further matches. For example, typing <b>-amp</b> should show the ampersand item in the menu. Pressing esc should close the autocomplete menu.</p> |
|||
<p></p> |
|||
</textarea> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue