• Stars
    star
    524
  • Rank 84,541 (Top 2 %)
  • Language Vue
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

At.js for Vue.

vue-at

        Join the chat at https://gitter.im/fritx/vue-at

  

  • Chrome / Firefox / Edge / IE9~IE11
  • Plain-text based, no jQuery, no extra nodes
  • Content-Editable / Textarea
  • Avatars, custom templates
  • Vue3 / Vue2 / Vue1
  • Vuetify / Element UI / Element Plus
  • Vue-CLI migration
  • Vite migration

Playground: https://we-demo.github.io/vue-at-vite-app/
Vue3 Docs: https://github.com/fritx/vue-at/tree/vue3#readme
Vue2 Docs: https://fritx.github.io/vue-at/ or see below
See also: react-at

Motivation

At.js is awesome, but:

  • It is based on jQuery and jQuery-Caret.
  • It introduces extra node wrappers.
  • It could be unstable on content edit/copy/paste.

Finally I ended up creating this.

If you're using Vue3, read branch vue3 instead.

npm i vue-at@next  # for Vue3 (branch vue3)
npm i [email protected]  # for Vue2 (branch vue2)
npm i [email protected]  # for Vue1 (branch vue1-legacy)
npm i vue1-at  # for Vue1 (branch vue1-new)
<template>
  <at :members="members">
    <div contenteditable></div>
  </at>
</template>

<script>
import At from 'vue-at'

export default {
  components: { At },
  data () {
    return {
      members: ['Roxie Miles', 'grace.carroll', '小浩']
    }
  }
}
</script>

<style>
#app .atwho-view { /* more */ }
#app .atwho-ul { /* more */ }
</style>

Using V-Model (Recommended)

With Content-Editable, v-model should be bound in <at> container.
With Textarea, v-model should be bound in <textarea> itself.

<at v-model="html">
  <div contenteditable></div>
</at>

<at-ta>
  <textarea v-model="text"></textarea>
</at-ta>

Textarea

<template>
  <at-ta>
    <textarea></textarea>
  </at-ta>
</template>

<script>
// import At from 'vue-at' // for content-editable
import AtTa from 'vue-at/dist/vue-at-textarea' // for textarea

export default {
  components: { AtTa }
}
</script>
npm i -S textarea-caret  # also, for textarea

Custom Templates

Custom List

<template>
  <at :members="members" name-key="name">
    <template slot="item" slot-scope="s">
      <img :src="s.item.avatar">
      <span v-text="s.item.name"></span>
    </template>
    <div contenteditable></div>
  </at>
</template>

<script>
// ...
members: [{
  avatar: 'https://randomuser.me/api/portraits/men/2.jpg',
  name: 'myrtie.green'
}, {
  avatar: 'https://randomuser.me/api/portraits/men/8.jpg',
  name: '椿木'
}]
</script>

<style>
#app .atwho-li { /* more */ }
#app .atwho-li img { /* more */ }
#app .atwho-li span { /* more */ }
</style>

Custom List with Vue 1.x

There is no "scoped slot" feature in Vue 1.
Use a "normal slot" with data- attribute instead.

<!-- vue1-at for [email protected] -->
<template slot="item">
  <img data-src="item.avatar">
  <span data-text="item.name"></span>
</template>

Custom Tags

This gives you the option of changing the style of inserted tagged items. It is only supported for ContentEditable version, not Textarea.

<span slot="embeddedItem" slot-scope="s">
  <span class="tag"><img :src="s.current.avatar">{{ s.current.name }}</span>
</span>

<!-- with Vue 2.6+ 'v-slot' directive -->
<!-- note at least two '<span>' wrapper are required to work -->
<template v-slot:embeddedItem="s">
  <span><span class="tag"><img class="avatar" :src="s.current.avatar">{{ s.current.name }}</span></span>
</template>

Used with 3rd-party libraries

Vuetify v-textarea

<at-ta :members="members">
  <!-- slots -->
  <v-textarea v-model="text"></v-textarea>
</at-ta>

Element-UI el-input

<at-ta :members="members">
  <!-- slots -->
  <el-input v-model="text" type="textarea"></el-input>
</at-ta>

More Repositories

1

wxbot

[已过时] 普通个人号 微信机器人/外挂
JavaScript
804
star
2

vue-threejs

Vue bindings for Three.js
JavaScript
786
star
3

react-threejs

WIP: Simplest bindings between React & Three.js
JavaScript
82
star
4

wxchangba

微信唱吧: 基于node.js和微信jssdk的校园轻应用
CSS
56
star
5

react-editor

Pure Rich-text Editor with TS & React-hooks
TypeScript
55
star
6

react-native-auto-scroll

ScrollView that scrolls down responsively.
JavaScript
46
star
7

markppt

一篇markdown,一份ppt。
JavaScript
33
star
8

wqq

[已停用] 基于webqq协议的nodejs qq api模块
JavaScript
30
star
9

silent

Be a silent, static blog
HTML
28
star
10

SorryPress

Sorry动图 VuePress版
JavaScript
25
star
11

share.wx

微信jssdk 分享生成器
Vue
18
star
12

react-drag-sizing

"Drag to resize" (sizing) as React Component.
TypeScript
17
star
13

react-at

At.js for React.
JavaScript
17
star
14

cross-unzip

Cross-platform 'native' unzip in Node.js
JavaScript
17
star
15

qqlog

基于node.js wqq(webqq)开发的一个qq命令行
JavaScript
13
star
16

nw-remote

Screen-Sharing & Remote-Controlling via NW.js App
JavaScript
12
star
17

jayin

Piping with js at terminal
JavaScript
11
star
18

evm

[Deprecated] Electron Version Manager
JavaScript
11
star
19

cross-sqlcipher

Cross-platform encrypted sqlite3
JavaScript
11
star
20

win-7zip

7zip Windows Package via Node.js
JavaScript
11
star
21

vue-server-demo

"Vue" is a language.
Vue
9
star
22

blog

Life is short, I use JS
JavaScript
9
star
23

threejs-galaxy

我是如何用three.js创造一个宇宙的?
JavaScript
9
star
24

win-sqlcipher

Encrypted sqlite3 for Windows
JavaScript
9
star
25

css-inline

Inline css into html dom
JavaScript
8
star
26

vue-parcel-electron

[WIP] Boilerplate for stack of Vue/Parcel/Electron
JavaScript
8
star
27

gulp-eol

Replace or append EOL of files
JavaScript
8
star
28

gulp-mail

Send mails with gulp
JavaScript
7
star
29

channel

轻应用:#在线云频道#
JavaScript
7
star
30

PUM

Shell Process Manager: PUM
JavaScript
6
star
31

qqface

经典QQ表情/文字替换
JavaScript
6
star
32

img2txt

Image to Ascii Text. Dead simple, something useless.
JavaScript
6
star
33

unix-sqlcipher

Encrypted sqlite3 for MacOS and Linux.
JavaScript
6
star
34

spacewar

3d的飞船射击游戏,和npc混战,键盘W/S/A/D/R/F前后左右升降,鼠标控制视角,点左键射击。
JavaScript
5
star
35

mshop

An online shop adapted to mobile.
JavaScript
5
star
36

fs-auth

Auth beyond filesystem
JavaScript
4
star
37

git-green-someone-else

[DEPRECATED] git green other people
Shell
4
star
38

qsbk-desktop

[糗事百科]桌面客户端
JavaScript
4
star
39

gulp-app

gulp as an app
JavaScript
4
star
40

xq

尝试做个象棋
HTML
4
star
41

emshop

Another online shop(mall) highly adapted to mobiles
JavaScript
4
star
42

koa-captcha-2

Captcha utils for koa 2
JavaScript
4
star
43

fritxbash

Manage your dotfiles in a git repo
Shell
3
star
44

mp.wx

微信公众号项目后端架构
HTML
3
star
45

os-web

JavaScript
3
star
46

51voa-cli

Downloading mp3 from 51voa
JavaScript
3
star
47

cracker

Fetch data from the web
JavaScript
3
star
48

prt

Package Manager for Windows
JavaScript
3
star
49

gulp-edit

Edit files with gulp
JavaScript
3
star
50

exc

Tool to Execute Commands
JavaScript
3
star
51

gh-wxpay

打造一个基于github登录与微信支付,但又不依赖于微信登录(由github登录替代)的创新型支付体系,简称gx。
JavaScript
3
star
52

nixe

Another high-level browser automation library.
JavaScript
3
star
53

fritx.github.io

Homepage (link to my blog)
3
star
54

css-obj

Parse css to js obj model
JavaScript
3
star
55

nw-chat

JavaScript
2
star
56

wet

Grabbing metadata from webpages
JavaScript
2
star
57

vue-library

Vue.js library boilerplate
JavaScript
2
star
58

insert-text-2

[WIP] Cross-browser insertText library
JavaScript
2
star
59

sc-app

(WIP) Screen-capture app built with Electron
JavaScript
2
star
60

buffer-encoding

😂 Convert buffers across different encodings, with encoding detection support.
JavaScript
1
star
61

koa-ts-demo

JavaScript
1
star
62

sqlcipher-electron-demo

Demo for cross-sqlcipher used with Electron
HTML
1
star
63

passwordless-mailer

Sends passwordless emails in your site
JavaScript
1
star
64

nw-shot

Screencapture app built on nw.js
JavaScript
1
star
65

paste

轻应用:#在线云粘贴#
JavaScript
1
star
66

AwesomeProject_1

Project Example keeping up with React-Native Exercises
JavaScript
1
star
67

onedoc

Doc within one page
JavaScript
1
star
68

freegolf

也是2013年6月份鼓捣的东西
JavaScript
1
star
69

n0gx

No Nginx, Node Only
JavaScript
1
star
70

lift

A fork of the vertical slides of lagou.com/subject
CSS
1
star
71

AwesomeProject

Chat App built with React-Native.
JavaScript
1
star
72

eslint-config-fritx

Fritx' ESLint config presets
JavaScript
1
star
73

jsonedit

A command-line (terminal) tool to edit / create JSON files
JavaScript
1
star
74

prj

Init your project with templates from npm
JavaScript
1
star
75

mda

使用web及nosql技术,对数据挖掘作业的一次创新作答,颠覆传统sql教学。
JavaScript
1
star
76

gui-cli

GUI for CLI
JavaScript
1
star
77

obj-html

Parse js obj model to html
JavaScript
1
star
78

gulp-semi

Add or remove SEMICOLON of JavaScript
JavaScript
1
star
79

rsa-im

JavaScript
1
star