{"id":12673,"date":"2021-06-13T06:33:43","date_gmt":"2021-06-13T11:33:43","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/docs\/tinymce\/ui-components\/autocompleter%e5%85%a7%e5%ae%b9%e6%a0%a1%e6%ad%a3\/"},"modified":"2021-06-13T06:42:22","modified_gmt":"2021-06-13T11:42:22","slug":"autocompleter%e5%85%a7%e5%ae%b9%e6%a0%a1%e6%ad%a3","status":"publish","type":"docs","link":"https:\/\/www.powenko.com\/wordpress\/?docs=tinymce\/ui-components\/autocompleter%e5%85%a7%e5%ae%b9%e6%a0%a1%e6%ad%a3","title":{"rendered":"Autocompleter\u5167\u5bb9\u6821\u6b63"},"content":{"rendered":"<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;!--\r\n    &lt;script src=&quot;httpsss:\/\/cdn.tiny.cloud\/1\/mott8ilewgbu1tryzfu9q7sdcmn5qfqt19jixbvaqgaz6kjc\/tinymce\/5\/tinymce.min.js&quot; referrerpolicy=&quot;origin&quot;&gt;&lt;\/script&gt;\r\n    --&gt;\r\n    &lt;script src=&quot;httpsss:\/\/code.jquery.com\/jquery-1.11.3.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script src=&quot;..\/..\/..\/system\/libs\/tinymce\/js\/tinymce\/tinymce.min.js&quot; referrerpolicy=&quot;origin&quot;&gt;&lt;\/script&gt;\r\n\r\n    &lt;script&gt;\r\n\r\n\r\n\r\n        var specialChars = &#x5B;\r\n            { text: 'exclamation mark', value: '!' },\r\n            { text: 'at', value: '@' },\r\n            { text: 'hash', value: '#' },\r\n            { text: 'dollars', value: '$' },\r\n            { text: 'percent sign', value: '%' },\r\n            { text: 'caret', value: '^' },\r\n            { text: 'ampersand', value: '&amp;' },\r\n            { text: 'asterisk', value: '*' }\r\n        ];\r\n        tinymce.init({\r\n            selector: 'textarea#richTextArea_ww_powenko_com',\r\n            height: 250,\r\n            setup: function (editor) {\r\n                var onAction = function (autocompleteApi, rng, value) {\r\n                    editor.selection.setRng(rng);\r\n                    editor.insertContent(value);\r\n                    autocompleteApi.hide();\r\n                };\r\n\r\n                var getMatchedChars = function (pattern) {\r\n                    return specialChars.filter(function (char) {\r\n                        return char.text.indexOf(pattern) !== -1;\r\n                    });\r\n                };\r\n\r\n                \/* An autocompleter that allows you to insert special characters *\/\r\n                editor.ui.registry.addAutocompleter('specialchars', {\r\n                    ch: ':',\r\n                    minChars: 1,\r\n                    columns: 'auto',\r\n                    onAction: onAction,\r\n                    fetch: function (pattern) {\r\n                        return new tinymce.util.Promise(function (resolve) {\r\n                            var results = getMatchedChars(pattern).map(function (char) {\r\n                                return {\r\n                                    type: 'autocompleteitem',\r\n                                    value: char.value,\r\n                                    text: char.text,\r\n                                    icon: char.value\r\n                                }\r\n                            });\r\n                            resolve(results);\r\n                        });\r\n                    }\r\n                });\r\n\r\n                \/**\r\n                 * An autocompleter that allows you to insert special characters.\r\n                 * Items are built using the CardMenuItem.\r\n                 *\/\r\n                editor.ui.registry.addAutocompleter('specialchars_cardmenuitems', {\r\n                    ch: '-',\r\n                    minChars: 1,\r\n                    columns: 1,\r\n                    highlightOn: &#x5B;'char_name'],\r\n                    onAction: onAction,\r\n                    fetch: function (pattern) {\r\n                        return new tinymce.util.Promise(function (resolve) {\r\n                            var results = getMatchedChars(pattern).map(function (char) {\r\n                                return {\r\n                                    type: 'cardmenuitem',\r\n                                    value: char.value,\r\n                                    label: char.text,\r\n                                    items: &#x5B;\r\n                                        {\r\n                                            type: 'cardcontainer',\r\n                                            direction: 'vertical',\r\n                                            items: &#x5B;\r\n                                                {\r\n                                                    type: 'cardtext',\r\n                                                    text: char.text,\r\n                                                    name: 'char_name'\r\n                                                },\r\n                                                {\r\n                                                    type: 'cardtext',\r\n                                                    text: char.value\r\n                                                }\r\n                                            ]\r\n                                        }\r\n                                    ]\r\n                                }\r\n                            });\r\n                            resolve(results);\r\n                        });\r\n                    }\r\n                });\r\n            },\r\n            content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'\r\n        });\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n    &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;textarea id=&quot;richTextArea_ww_powenko_com&quot;&gt;\r\n\u8acb\u8f38\u5165:amp\r\n &lt;p&gt;Type &lt;b&gt;:&lt;\/b&gt; below and then keep typing to reduce further matches. For example, typing &lt;b&gt;:amp&lt;\/b&gt; should show the ampersand item in the menu. Pressing esc should close the autocomplete menu.&lt;\/p&gt;\r\n  &lt;p&gt;&lt;\/p&gt;\r\n&lt;\/textarea&gt;\r\nwww.popwenko.comw\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><a href=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-13-at-7.36.17-PM.png\"><img loading=\"lazy\" decoding=\"async\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-13-at-7.36.17-PM-570x194.png\" alt=\"\" width=\"570\" height=\"194\" class=\"alignnone size-medium wp-image-12675\" srcset=\"https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-13-at-7.36.17-PM-570x194.png 570w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-13-at-7.36.17-PM-768x262.png 768w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-13-at-7.36.17-PM-300x102.png 300w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-13-at-7.36.17-PM.png 1554w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><\/p>\n<p><iframe loading=\"lazy\" width=\"100%\" height=\"300\" src=\"\/\/jsfiddle.net\/powenko\/qe7nL8bg\/4\/embedded\/\" allowfullscreen=\"allowfullscreen\" allowpaymentrequest frameborder=\"0\"><\/iframe><\/p>\n","protected":false},"featured_media":0,"parent":12672,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-12673","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/docs\/12673"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12673"}],"version-history":[{"count":2,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/docs\/12673\/revisions"}],"predecessor-version":[{"id":12676,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/docs\/12673\/revisions\/12676"}],"up":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/docs\/12672"}],"next":[{"title":"UICompleter\u5716\u7247\u6309\u53f3","link":"https:\/\/www.powenko.com\/wordpress\/?docs=tinymce\/ui-components\/uicompleter%e5%9c%96%e7%89%87%e6%8c%89%e5%8f%b3","href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/docs\/12678"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12673"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=12673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}