1 Star 45 Fork 15

张鑫旭 / 类似飞书OKR输入框的AT提及功能

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

类似飞书OKR输入框的AT提及功能

介绍

div模拟富文本编辑框,借助 tributejs 实现,里面有可交互的 @ 提及功能。

Demo地址:https://zhangxinxu.gitee.io/okr-at-mention/

使用说明

  1. 引入 src 目录中的 JS 和 CSS
  2. 按照语法进行参数设置和处理
<link rel="stylesheet" href="./src/atMention.css">

<div id="container"></div>

<script type="module">
    import atWakaka from './src/atWakaka.js';
    atWakaka('container', {
        url: './cgi/data.json'
    });
</script>

语法和参数

语法为:

atWakaka(container, options, optionsTribute);

其中:

container
可输入的编辑框容器元素,可以是 DOM 元素本身,也可以是元素的 id 字符串。
options
可选参数,下面有注释说明。
optionsTribute
可选参数。参见 https://github.com/zurb/tribute 中的参数设置。

关于options可选参数

{
    url: '',
    // 按下回车键后,如果希望阻止默认的回车换行
    // 并做一些事情,这个参数就可以用到
    pressEnter: null,
    // 鼠标经过的提示元素,默认本组件会自己创建
    // 也可以可以自己指定具体的元素
    popOver: 'auto',
    // 鼠标经过和移出 @ 元素的处理
    // event 是事件对象
    // data 是 @元素 对应的请求数据
    // popover 是浮层元素
    onMouseOver: function (event, data, popover) {},
    onMouseOut: function (event, data, popover) {}
}

关于 optionsTribute 可选参数

如果 @ 下拉列表样式不满意,或者请求的数据结构和自己这边的不符合,均是使用 optionsTribute 可选参数进行处理。

请求数据处理使用 values 参数(Function 类型),列表模板和选择后的样式使用参数 menuItemTemplate 和 selectTemplate,详见 https://github.com/zurb/tribute 中的参数设置。

或者参见 atWakaka.js 中的使用示意,对其进行一一替换即可。

其他

原生 JS 开发,兼容各大框架,但是不兼容 IE 浏览器。

MIT License Copyright (c) 2022 张鑫旭 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

div模拟富文本编辑框,借助tributejs实现,里面有可交互的 @ 提及功能。 展开 收起
JavaScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/zhangxinxu/okr-at-mention.git
git@gitee.com:zhangxinxu/okr-at-mention.git
zhangxinxu
okr-at-mention
类似飞书OKR输入框的AT提及功能
master

搜索帮助