如何从textAngular工具栏上的自定义按钮插入文本/符号

基本上我想在工具栏上添加一个按钮,允许用户将©插入文本框编辑器( http://textangular.com/ ),但是我无法理解如何在注册后添加function到我的按钮…由于textangular网站上的自定义function的所有示例都使用相同的语句“wrapSelection”,其中包含非常少的文档,下面显示了一个带有引号按钮的示例。

taRegisterTool('quote', { iconclass: 'fa fa-quote-right', tooltiptext: taTranslations.quote.tooltip, action: function(){ return this.$editor().wrapSelection("formatBlock", "
"); }, activeState: function(){ return this.$editor().queryFormatBlockState('blockquote'); } });

我很困惑“formatBlock”初始化的地方,并相信找到它的来源将帮助我解决这个问题。 如你所见,任何帮助将不胜感激

  taRegisterTool('insertCopyright', { buttontext: '©', tooltiptext: taTranslations.insertCopyright.tooltip, action: function () { //??? }, }); 

我想我会为任何希望插入自定义符号或类似内容的人发布我们的解决方法答案,显然我们可以将’insertTextAtCursor’和’moveCaret’移动到其他地方进行清理,但无论如何……

  taRegisterTool('insertCopyright', { buttontext: '©', tooltiptext: taTranslations.insertCopyright.tooltip, action: function() { function insertTextAtCursor(text) { var sel, range; if (window.getSelection) { sel = window.getSelection(); if (sel.getRangeAt && sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(text)); } } else if (document.selection && document.selection.createRange) { document.selection.createRange().text = text; } } function moveCaret(charCount) { var sel, range; if (window.getSelection) { sel = window.getSelection(); if (sel.rangeCount > 0) { var textNode = sel.focusNode; sel.collapse(textNode.nextSibling, charCount); } } else if ((sel = window.document.selection)) { if (sel.type != "Control") { range = sel.createRange(); range.move("character", charCount); range.select(); } } } insertTextAtCursor(String.fromCharCode(169)); return moveCaret(1); }, });