{"id":10513,"date":"2022-08-31T22:53:11","date_gmt":"2022-08-31T14:53:11","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10513"},"modified":"2022-09-01T10:09:39","modified_gmt":"2022-09-01T02:09:39","slug":"gitee-feishu-okr-at-mention","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2022\/08\/gitee-feishu-okr-at-mention\/","title":{"rendered":"gitee\u4e0a\u64b8\u4e86\u4e2a\u7c7b\u4f3c\u98de\u4e66OKR\u8f93\u5165\u6846\u7684@\u63d0\u53ca\u9879\u76ee"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10513\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10513<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u53ef\u4ee5\u5168\u6587\u8f6c\u8f7d\uff0c\u65e0\u9700\u6388\u6743\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u6b22\u8fce\u70b9\u8d5e\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202208-orr-at.jpg';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202208\/feishu-cover.jpg\" width=\"480\" height=\"315\" alt=\"\u98de\u4e66\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u6548\u679c\u9884\u89c8<\/h3>\n<p>\u5148\u770bdemo\uff1a<a href=\"https:\/\/zhangxinxu.gitee.io\/okr-at-mention\/\" rel=\"noopener\" target=\"_blank\">https:\/\/zhangxinxu.gitee.io\/okr-at-mention\/<\/a><\/p>\n<p>\u6548\u679c\u5982\u4e0b\u89c6\u9891\u6240\u793a\uff08\u4e0d\u52a8\u70b9\u51fb\u64ad\u653e\uff09\uff0c\u8f93\u5165 @ \u5b57\u7b26\u4f1a\u51fa\u73b0\u5339\u914d\u7684\u4eba\u540d\u5217\u8868\uff0c\u7531\u4e8e\u662f\u9759\u6001\u9875\u9762\uff0c\u6240\u4ee5\u8bf7\u6c42\u7684\u6570\u636e\u662f\u6b7b\u7684\uff0c\u5b9e\u9645\u5f00\u53d1\u662f\u540e\u7aef\u6839\u636e\u641c\u7d22\u5173\u952e\u5b57\u52a8\u6001\u8fd4\u56de\u7684\u3002<\/p>\n<p>\u9f20\u6807hover\u60ac\u505c\u5728\u4eba\u540d\u4e0a\uff0c\u4f1a\u51fa\u73b0 popover \u63d0\u793a\u6d6e\u5c42\uff0c\u53ef\u4ee5\u67e5\u770b\u4eba\u7269\u76f8\u5173\u7684\u4fe1\u606f\u3002<\/p>\n<p><video src='\/\/image.zhangxinxu.com\/video\/blog\/202208\/atwakaka-use.mp4' type=\"video\/mp4\" width=\"574\" height=\"292\" preload=\"auto\" muted autoplay autobuffer loop x-webkit-airplay=\"allow\" x5-video-player-type=\"h5\" x5-video-player-fullscreen=\"true\" x5-video-orientation=\"portraint\" webkit-playsinline=\"true\" playsinline=\"true\" \u200b\u200b\u200b\u200bposter=\"\/\/image.zhangxinxu.com\/image\/blog\/201806\/poster.png\"><\/video><\/p>\n<p>\u53e6\u5916\uff0c\u672c JS \u9879\u76ee\u5bf9\u590d\u5236\u6216\u8005\u62d6\u62fd\u8fdb\u6765\u7684\u5bcc\u6587\u672c\u8fdb\u884c\u4e86\u8fc7\u6ee4\u5904\u7406\uff0c\u4fdd\u8bc1\u4e86\u4e86\u8f93\u5165\u6846\u91cc\u9762\u5185\u5bb9\u7684\u7eaf\u7cb9\u3002<\/p>\n<p>\u4ee5\u53ca\u5bf9\u56de\u8f66\u884c\u4e3a\u8fdb\u884c\u4e86\u52ab\u6301\uff0c\u4f8b\u5982\u4f60\u5e0c\u671b\u56de\u8f66\u4e0d\u6362\u884c\uff0c\u800c\u662f\u505a\u5176\u4ed6\u4e8b\u60c5\uff0c\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<h4>\u9879\u76ee\u5730\u5740<\/h4>\n<p>\u9879\u76ee\u5730\u5740\uff1a<a href=\"https:\/\/gitee.com\/zhangxinxu\/okr-at-mention\" rel=\"noopener\" class=\"a_link\" target=\"_blank\">https:\/\/gitee.com\/zhangxinxu\/okr-at-mention<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202208\/2022-08-31_223615.png\" width=\"667\" height=\"368\" alt=\"\u9879\u76ee\u5730\u5740\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6b22\u8fce Star\uff0c\u6b22\u8fce fork\uff0c\u4e5f\u6b22\u8fce\u5173\u6ce8\u6211\u7684 gitee \u8d26\u53f7\uff0c\u4f1a\u4e0d\u5b9a\u671f\u66f4\u65b0\u4e00\u4e9b\u5de5\u4f5c\u4e2d\u9047\u5230\u7684\u5c0f\u73a9\u610f\uff0c\u6216\u8005\u7a81\u7136\u840c\u53d1\u7684\u6709\u8da3\u7684\u60f3\u6cd5\u3002<\/p>\n<h3>\u4e8c\u3001\u4f7f\u7528\u8bf4\u660e<\/h3>\n<p>\u4f7f\u7528\u5f88\u7b80\u5355\uff0c\u5f15\u5165\u5bf9\u5e94\u7684CSS\u548cJS\uff0c\u7136\u540e\u6309\u7167\u66b4\u9732\u7684\u65b9\u6cd5\u8fdb\u884c\u8c03\u7528\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;link rel=\"stylesheet\" href=\".\/src\/atMention.css\"&gt;<\/pre>\n<p>\u5047\u8bbe\u6709\u5bb9\u5668\u5143\u7d20\uff08\u4e5f\u5c31\u662f\u8f93\u5165\u6846\u5143\u7d20\uff09\uff1a<\/p>\n<pre>&lt;div id=\"container\"&gt;&lt;\/div&gt;<\/pre>\n<p>\u5219\u5bf9\u5e94\u7684 JavaScript \u4ee3\u7801\u5219\u53ef\u4ee5\u8fd9\u4e48\u4f7f\u7528\uff1a<\/p>\n<pre>&lt;script type=\"module\"&gt;\r\n    import atWakaka from '.\/src\/atWakaka.js';\r\n    atWakaka('container', {\r\n        url: '.\/cgi\/data.json'\r\n    });\r\n&lt;\/script&gt;<\/pre>\n<p>\u5c31\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u5e94\u7684\u529f\u80fd\u4e86\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u672c JS \u4f9d\u8d56 tributejs \u8fd9\u4e2a\u77e5\u540d\u7684\u539f\u751fAT\u63d0\u53ca JS\uff0c\u6240\u4ee5\uff0c\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u9700\u8981\u4fdd\u8bc1 atWakaka.js \u540c\u76ee\u5f55\u4e0b\u6709 tributejs\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202208\/2022-08-31_220113.png\" width=\"667\" height=\"217\" alt=\"tributejs\u9879\u76ee\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u5f53\u7136\uff0c\u4e0d\u540c\u9879\u76ee\u5bf9\u4ea4\u4e92\u7ec6\u8282\u7684\u8981\u6c42\u4e5f\u4e0d\u4e00\u6837\uff0c\u56e0\u6b64\uff0c\u4e5f\u63d0\u4f9b\u4e86\u5bf9\u4e8e\u7684 API \u53c2\u6570\u63a5\u53e3\u3002<\/p>\n<h4>\u8bed\u6cd5\u548c\u53c2\u6570<\/h4>\n<p>\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<pre>atWakaka(container, options, optionsTribute);<\/pre>\n<p>\u4e4b\u6240\u4ee5\u53eb\u505a&#8221;wakaka&#8221;\uff0c\u6ca1\u6709\u4ec0\u4e48\u7279\u522b\u7684\u539f\u56e0\uff0c\u7eaf\u7cb9\u662f\u5f53\u65f6\u6211\u5c31\u6709\u8fd9\u80a1\u83ab\u540d\u7684\u51b2\u52a8\u3002<\/p>\n<p><strong>\u5176\u4e2d\uff1a<\/strong><\/p>\n<dl>\n<dt><strong>container<\/strong><\/dt>\n<dd>\u53ef\u8f93\u5165\u7684\u7f16\u8f91\u6846\u5bb9\u5668\u5143\u7d20\uff0c\u53ef\u4ee5\u662f DOM \u5143\u7d20\u672c\u8eab\uff0c\u4e5f\u53ef\u4ee5\u662f\u5143\u7d20\u7684 id \u5b57\u7b26\u4e32\u3002<\/dd>\n<dt><strong>options<\/strong><\/dt>\n<dd>\u53ef\u9009\u53c2\u6570\uff0c\u4e0b\u9762\u6709\u6ce8\u91ca\u8bf4\u660e\u3002<\/p>\n<pre>{\r\n    url: '',\r\n    \/\/ \u6309\u4e0b\u56de\u8f66\u952e\u540e\uff0c\u5982\u679c\u5e0c\u671b\u963b\u6b62\u9ed8\u8ba4\u7684\u56de\u8f66\u6362\u884c\r\n    \/\/ \u5e76\u505a\u4e00\u4e9b\u4e8b\u60c5\uff0c\u8fd9\u4e2a\u53c2\u6570\u5c31\u53ef\u4ee5\u7528\u5230\r\n    pressEnter: null,\r\n    \/\/ \u9f20\u6807\u7ecf\u8fc7\u7684\u63d0\u793a\u5143\u7d20\uff0c\u9ed8\u8ba4\u672c\u7ec4\u4ef6\u4f1a\u81ea\u5df1\u521b\u5efa\r\n    \/\/ \u4e5f\u53ef\u4ee5\u53ef\u4ee5\u81ea\u5df1\u6307\u5b9a\u5177\u4f53\u7684\u5143\u7d20\r\n    popOver: 'auto',\r\n    \/\/ \u9f20\u6807\u7ecf\u8fc7\u548c\u79fb\u51fa @ \u5143\u7d20\u7684\u5904\u7406\r\n    \/\/ event \u662f\u4e8b\u4ef6\u5bf9\u8c61\r\n    \/\/ data \u662f @\u5143\u7d20 \u5bf9\u5e94\u7684\u8bf7\u6c42\u6570\u636e\r\n    \/\/ popover \u662f\u6d6e\u5c42\u5143\u7d20\r\n    onMouseOver: function (event, data, popover) {},\r\n    onMouseOut: function (event, data, popover) {}\r\n}<\/pre>\n<\/dd>\n<dt><strong>optionsTribute<\/strong><\/dt>\n<dd>\u53ef\u9009\u53c2\u6570\u3002\u53c2\u89c1 <a href=\"https:\/\/github.com\/zurb\/tribute\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/zurb\/tribute<\/a> \u4e2d\u7684\u53c2\u6570\u8bbe\u7f6e\uff0c\u6216\u8005\u6e90\u7801\u4e2d\u5bf9\u5e94\u53c2\u6570\u7684\u4f7f\u7528\uff08\u5982\u4e0b\u6240\u793a\uff09\u3002<\/p>\n<pre>{\r\n    \/\/ \u4e0b\u62c9\u5bb9\u5668\u7c7b\u540d\r\n    containerClass: 'ui-at-drop-x',\r\n    \/\/ \u524d\u9762\u4e0d\u9700\u8981\u6709\u7a7a\u683c\r\n    requireLeadingSpace: false,\r\n    \/\/ \u662f\u5426\u9ad8\u4eae\u5339\u914d\uff0c\u8fd9\u91cc\u8d70\u7684\u662f\u81ea\u5df1\u5339\u914d\r\n    \/\/ \u8fd9\u91cc\u5176\u5b9e\u4ec5 skip \u6709\u6548\r\n    searchOpts: {\r\n        pre: '&lt;mark&gt;',\r\n        post: '&lt;\/mark&gt;',\r\n        \/\/ \u662f\u5426\u670d\u52a1\u7aef\u641c\u7d22\u6570\u636e\r\n        skip: true\r\n    },\r\n    \/\/ \u52a8\u6001\u83b7\u53d6\u5339\u914d\u7684\u503c\r\n    values: valuesTribute,\r\n    \/\/ \u6ca1\u6570\u636e\u65f6\u5019\u8fd4\u56de\u7684HTML\u5185\u5bb9\r\n    noMatchTemplate: function () {},\r\n    \/\/ \u9009\u4e2d\u8fd4\u56de\u5230\u8f93\u5165\u6846\u7684HTML\u5185\u5bb9\r\n    selectTemplate: function(item) {},\r\n    \/\/ \u4e0b\u62c9\u83dc\u5355\u6bcf\u4e00\u9879\u7684HTML\u5185\u5bb9\r\n    menuItemTemplate: function (item) {}\r\n};\r\n<\/pre>\n<p>\u5927\u5bb6\u5982\u679c\u5e0c\u671b\u6539\u53d8\u4e0b\u62c9\u5217\u8868\u7684\u5143\u7d20\u7ed3\u6784\uff0c\u5c31\u662f\u4f7f\u7528 <code>optionsTribute<\/code> \u4e2d\u7684\u53ef\u9009\u53c2\u6570\u8fdb\u884c\u8bbe\u7f6e\u3002\n<\/dd>\n<\/dl>\n<h3>\u4e09\u3001\u5b9e\u73b0\u6280\u5de7<\/h3>\n<p>\u8fd9\u91cc\u6709\u4e09\u4e2a\u5b9e\u73b0\u6280\u5de7\u6211\u89c9\u5f97\u503c\u5f97\u548c\u5927\u5bb6\u5206\u4eab\u4e0b\u3002<\/p>\n<h4>1. @\u63cf\u8ff0\u6574\u5220\u6574\u52a0<\/h4>\n<p>\u5728\u53ef\u7f16\u8f91\u7684 div \u5143\u7d20\u4e2d\uff0c\u8981\u60f3\u8ba9\u91cc\u9762\u67d0\u6bb5\u6587\u5b57\u4e0d\u80fd\u7f16\u8f91\uff0c\u6709\u4e2a\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u5c31\u662f\u8bbe\u7f6e <code>contenteditable=\"false\"<\/code>\uff0c\u4f8b\u5982\uff0c\u4e0b\u9762 HTML \u4ee3\u7801\u4e2d\u7684 <code>&lt;span&gt;<\/code> \u5143\u7d20\u5c31\u65e0\u6cd5\u7f16\u8f91\uff0c\u91cc\u9762\u7684\u6587\u5b57\u4e94\u6bd2\u4e0d\u4fb5\u3002<\/p>\n<pre>&lt;div contenteditable=\"true\"&gt;\r\n   \u6211\u662f\u6587\u5b57\uff0c\u53ef\u9010\u4e2a\u5220\u9664\uff0c&lt;span style=\"display:inline-block;\" contenteditable=\"false\"&gt;\u6211\u53ea\u80fd\u6574\u4f53\u5220\u9664&lt;\/span&gt;\uff01\r\n&lt;\/div&gt;<\/pre>\n<p>\u7136\u540e\uff0c\u4e0a\u9762\u7684\u5b9e\u73b0\u770b\u4f3c\u5b8c\u7f8e\uff0c\u5b9e\u9645\u4e0a\u6709\u4e2a\u5f88\u5934\u75bc\u7684\u95ee\u9898\uff0c\u8bbe\u7f6e\u4e86 <code>contenteditable=\"false\"<\/code> \u7684\u5143\u7d20\u540e\u9762\u662f\u4e0d\u80fd\u5149\u6807\u5b9a\u4f4d\u7684\uff0c\u8fd9\u5c31\u5bfc\u81f4\u6211\u60f3\u5b9a\u4f4d\u5728 @xxx \u7684\u540e\u9762\uff0c\u7136\u540e\u5220\u9664\uff0c\u505a\u4e0d\u5230\uff0c\u8981\u4e48 JS \u5b9e\u65f6\u89c2\u5bdf\u5e76\u6539\u53d8\u5149\u6807\u4f4d\u7f6e\uff0c\u8981\u4e48\u5728\u540e\u9762\u63d2\u5165\u4e00\u4e2a\u96f6\u5bbd\u7a7a\u683c\u3002<\/p>\n<p>\u4e0a\u9762\u65e0\u8bba\u54ea\u4e2a\u65b9\u6cd5\uff0c\u6210\u672c\u90fd\u6bd4\u8f83\u9ad8\u3002<\/p>\n<p>\u5728\u672c JS \u7684\u5b9e\u73b0\u4e2d\uff0c\u521b\u65b0\u7684\u91c7\u7528\u4e86\u5355\u6807\u7b7e\u5143\u7d20 <code>&lt;hr&gt;<\/code> \u6765\u6a21\u62df @xxx \u6548\u679c\uff0c\u7531\u4e8e\u5355\u6807\u7b7e\u5143\u7d20\u672c\u8eab\u5185\u5bb9 textContent \u662f\u7a7a\u7684\uff0c\u56e0\u6b64\uff0c\u65e0\u9700\u8bbe\u7f6e<code>contenteditable=\"false\"<\/code>\uff0c\u5c31\u80fd\u5b9e\u73b0\u5220\u9664\u53ea\u80fd\u5220\u6574\u4f53\u3002<\/p>\n<p>\u5728\u6240\u6709\u6d4f\u89c8\u5668\u4e2d\uff0c<code>&lt;hr&gt;<\/code>\u5143\u7d20\u90fd\u652f\u6301 <code>::before\/::after<\/code> \u4f2a\u5143\u7d20\uff0c\u56e0\u6b64\uff0c\u53ef\u4ee5\u521b\u5efa\u4e30\u5bcc\u7684\u5185\u5bb9\u548c\u56fe\u5f62\u751f\u6210\uff0c\u6709\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u770b\u770b\u6211\u4e4b\u524d\u7684\u8fd9\u7bc7\u6587\u7ae0\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/05\/css-html-hr\/\">666\uff0c\u770bhr\u6807\u7b7e\u5b9e\u73b0\u5206\u9694\u7ebf\u5982\u4f55\u73a9\u51fa\u82b1<\/a>\u201d\u3002<\/p>\n<h4>2. hover\u51fa\u73b0\u6d6e\u5c42\u4ea4\u4e92<\/h4>\n<p>Hover\u51fa\u73b0\u6d6e\u5c42\u7684\u4ea4\u4e92\u5e76\u4e0d\u96be\u5b9e\u73b0\uff0c\u53ef\u5982\u679c\u662f\u5728\u53ef\u7f16\u8f91\u7684 div \u5185\u90e8\u5462\uff1f\u4ee5\u53ca\uff0c\u8981\u662f\u662f\u5728 Vue \u6216\u8005 React \u7b49\u6846\u67b6\u4e2d\u7684\u3002<\/p>\n<p>\u5982\u679c\u8fd8\u662f\u6309\u7167\u4f20\u7edf\u7684\u5b9e\u73b0\uff0c\u627e\u5230\u5bf9\u5e94\u7684 trigger \u5143\u7d20\uff0c\u7136\u540e\u4f7f\u7528\u7ec4\u4ef6\u5305\u4e00\u4e0b\uff0c\u90a3\u53ef\u80fd\u5c31\u4f1a\u51fa\u73b0\u5f88\u591a\u7684\u95ee\u9898\uff0c\u6bd4\u65b9\u8bf4\u5305\u4e0d\u4e86\uff0c\u53c8\u6bd4\u65b9\u8bf4\u4e8b\u4ef6\u7ed1\u5b9a\u4e0d\u4e0a\u3002<\/p>\n<p>\u9762\u5bf9\u8fd9\u6837\u7684\u573a\u666f\uff0c\u89e3\u51b3\u65b9\u6cd5\u90fd\u662f\u7c7b\u4f3c\u7684\uff0c\u90a3\u5c31\u662f\u59d4\u6258\u3002<\/p>\n<p>\u5c06mouseover\/mouseout\u7684\u884c\u4e3a\u7ed1\u5b9a\u5728\u5bb9\u5668\u4e0a\uff0c\u7136\u540e\u8fdb\u884c\u5b9a\u4f4d\u5904\u7406\u3002<\/p>\n<p>\u56e0\u4e3a\u5bb9\u5668\u5143\u7d20\u662f\u56fa\u5b9a\u7684\uff0c\u800c\u91cc\u9762\u7684\u5143\u7d20\u662f\u591a\u53d8\u7684\uff0c\u7ed1\u5b9a\u5728\u5bb9\u5668\u4e0a\u5c31\u80fd\u4ee5\u4e0d\u53d8\u5e94\u4e07\u53d8\uff0c\u6027\u80fd\u4e5f\u66f4\u597d\u3002<\/p>\n<p>\u5177\u4f53\u5b9e\u73b0\u53c2\u89c1 <a href=\"https:\/\/gitee.com\/zhangxinxu\/okr-at-mention\/blob\/master\/src\/atWakaka.js\" rel=\"noopener\" target=\"_blank\">JS \u6e90\u7801<\/a>\u3002<\/p>\n<h4>3. \u590d\u5236\u7c98\u8d34\u6216\u8005\u62d6\u62fd\u8fdb\u53bb\u7684\u90fd\u662f\u7eaf\u6587\u672c<\/h4>\n<p>\u5bcc\u6587\u672c\u7f16\u8f91\u673a\u7eaf\u624b\u6253\u5e94\u8be5\u662f\u6253\u4e0d\u4e86\u5bcc\u6587\u672c\u7684\uff0c\u4f46\u662f\u7c98\u8d34\u548c\u62d6\u62fd\u5374\u80fd\u5c06\u5bcc\u6587\u672c\u5f04\u8fdb\u53bb\u3002<\/p>\n<p>\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u8fc7\u6ee4\u5bcc\u6587\u672c\uff0c\u8ba9\u7528\u6237\u7c98\u8d34\u6216\u62d6\u62fd\u7684\u5185\u5bb9\u9ed8\u8ba4\u5c31\u662f\u7eaf\u6587\u672c\u5462\uff1f<\/p>\n<p>\u6709\u7684\u54c8\uff01<\/p>\n<p>\u6d4f\u89c8\u5668\u5176\u5b9e\u63d0\u4f9b\u4e86\u539f\u751f\u7684\u80fd\u529b\u3002<\/p>\n<p>\u5305\u62ec\u83b7\u53d6\u526a\u5207\u677f\u91cc\u9762\u7684\u6587\u672c\u548c\u5bcc\u6587\u672c\u5185\u5bb9\uff0c\u83b7\u53d6\u62d6\u62fd\u5185\u5bb9\u4e2d\u7684\u6587\u672c\u548c\u5bcc\u6587\u672c\uff0c\u6b64\u65f6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a\uff0c\u5c06\u7eaf\u6587\u672c\u5185\u5bb9\u63d2\u5165\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u6765\u4e00\u62db\u795e\u4e0d\u77e5\u9b3c\u4e0d\u89c9\u7684\u79fb\u82b1\u63a5\u6728\u3002<\/p>\n<p>\u76f8\u5173\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff08\u62d6\u62fd\u548c\u7c98\u8d34\u4e8c\u5408\u4e00\u4e86\uff0c\u56e0\u4e3a API \u7c7b\u4f3c\uff09\uff1a<\/p>\n<pre>const doStripHtml = function (event) {\r\n    var dataInput = event.clipboardData || event.dataTransfer;\r\n    \/\/ \u5bcc\u6587\u672c\r\n    let htmlOrigin = dataInput.getData('text\/html');\r\n    \/\/ \u7eaf\u6587\u672c\r\n    let textOrigin = dataInput.getData('text');\r\n\r\n    \/\/ \u5982\u679c\u5305\u542b\u5bcc\u6587\u672c\r\n    if (htmlOrigin) {\r\n        \/\/ \u624b\u52a8\u63d2\u5165\r\n        \/\/ \u963b\u6b62\u9ed8\u8ba4\u7684\u884c\u4e3a\r\n        event.preventDefault();\r\n\r\n        \/\/ \u53ea\u63d2\u5165\u7eaf\u6587\u672c\r\n        let lastRange = window.getSelection().getRangeAt(0);\r\n        const newNode = document.createTextNode(textOrigin);\r\n        lastRange.deleteContents();\r\n        lastRange.insertNode(newNode);\r\n        lastRange.setStartAfter(newNode);\r\n        event.target.focus();\r\n    }\r\n};\r\n<\/pre>\n<p>\u5176\u4e2d\uff0c\u63d2\u5165\u5185\u5bb9\u8fd9\u6bb5\u4ee3\u7801\u5bf9\u4e8e\u4efb\u610f\u7684\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u90fd\u662f\u53d7\u7528\u7684\uff0c\u5173\u4e8e\u5149\u6807\u548c\u9009\u533a\u66f4\u591a\u77e5\u8bc6\u53ef\u4ee5\u53c2\u89c1\u8fd9\u7bc7\u516c\u4f17\u53f7\u6587\u7ae0\uff1a<a href=\"https:\/\/segmentfault.com\/a\/1190000041457245\" rel=\"noopener\" target=\"_blank\">Web \u4e2d\u7684\u201c\u9009\u533a\u201d\u548c\u201c\u5149\u6807\u201d<\/a>\u3002<\/p>\n<h3>\u56db\u3001\u7ed3\u8bed<\/h3>\n<p>\u4f7f\u7528<code>&lt;hr&gt;<\/code> \u6765\u6a21\u62df @xxx \u6548\u679c\u4e5f\u5e76\u975e\u5b8c\u7f8e\u65e0\u7455\uff0c\u4e5f\u662f\u6709\u6240\u727a\u7272\u7684\uff0c\u9996\u5148\u5c31\u662f @xxx \u8fd9\u6837\u7684\u6587\u5b57\u5185\u5bb9\u662f\u65e0\u6cd5\u6846\u9009\u590d\u5236\u7684\uff0c\u56e0\u4e3a\u4f2a\u5143\u7d20\u751f\u6210\u7684\u6587\u672c\u662f\u65e0\u6cd5\u9009\u62e9\u7684\u3002<\/p>\n<p>\u5176\u6b21\uff0c\u5c31\u662f\u6570\u636e\u63d0\u4ea4\u7684\u65f6\u5019\uff0c\u76f4\u63a5 div.textContent \u662f\u4e0d\u884c\u7684\uff0c\u56e0\u4e3a\u4f1a\u4e22\u5931 @xxx \u8fd9\u6837\u7684\u4fe1\u606f\uff0c\u9700\u8981\u5728\u989d\u5916\u5904\u7406\u4e0b\u3002<\/p>\n<p>\u4e0d\u8fc7\u76f8\u6bd4\u5f0a\uff0c\u5e26\u6765\u7684\u5229\u60f3\u8ba9\u662f\u66f4\u5927\u7684\u3002<\/p>\n<p>\u597d\uff0c\u5c31\u8bf4\u8fd9\u4e48\u591a\u7684\uff0c\u5e0c\u671b\u5bf9\u9047\u5230\u7c7b\u4f3c\u9700\u6c42\u7684\u5c0f\u4f19\u4f34\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u2026\u2026<\/p>\n<p>\u660e\u59299\u67081\u53f7\u5c0f\u670b\u53cb\u5f00\u5b66\u4e86\uff0c\u672c\u5e94\u5f00\u5fc3\u624d\u5bf9\uff0c\u53ef\u60dc\u6bcf\u5929\u8981\u5404\u79cd\u7801\uff0c\u5404\u79cd\u4e0a\u62a5\uff0c\u8fd8\u8981\u5929\u5929\u6838\u9178\uff0c\u53e3\u7f69\u957f\u5e26\uff0c\u60f3\u60f3\u5c31\u8111\u58f3\u75bc\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/1f62a.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202208\/feishu-cover.jpg\" width=\"160\" height=\"105\" alt=\"\u98de\u4e66\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u5728\u7ebf\u529e\u516c\u65f6\u5019 @\u67d0\u67d0\u67d0 \u7136\u540e\u4e0b\u62c9\u5217\u8868\u9009\u62e9\uff0c\u7136\u540e\u9ad8\u4eae\uff0chover\u6b64\u4eba\u8fd8\u6709\u4fe1\u606f\u662f\u5f88\u5e38\u89c1\u7684\u529f\u80fd\uff0c\u6211\u90fd\u9047\u5230\u4e86\u8fd9\u6837\u7684\u9700\u6c42\uff0c\u522b\u4eba\u4e5f\u53ef\u80fd\u4f1a\u9047\u5230\uff0c\u4e8e\u662f\u6574\u7406\u6574\u7406\uff0c\u628a\u81ea\u5df1\u7684\u5b9e\u73b0\u601d\u8def\u5c01\u88c5\u4e0b\uff0c\u5f00\u6e90\u7ed9\u9700\u8981\u7684\u5c0f\u4f19\u4f34\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[180],"tags":[544,1726,1852,1307,1484,1851,1033,409],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10513"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10513"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10513\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}