26 Commits

Author SHA1 Message Date
Anatoly
54854d711e Merge branch 'pggalaviz:master' into master 2021-11-19 01:27:03 +03:00
f2269798e6 Made mentionWithDots available as a prop 2021-11-19 01:26:37 +03:00
Pedro G. Galaviz
3579013b2b Merge pull request #21 from pggalaviz/dependabot/npm_and_yarn/postcss-7.0.36
Bump postcss from 7.0.23 to 7.0.36
2021-09-06 22:55:39 -05:00
Anatoly
6a840c3171 Update index.js 2021-08-28 21:14:37 +03:00
Anatoly
55b4441a9f Update index.js 2021-08-26 02:08:07 +03:00
dependabot[bot]
e7779bdc49 Bump postcss from 7.0.23 to 7.0.36
Bumps [postcss](https://github.com/postcss/postcss) from 7.0.23 to 7.0.36.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/7.0.23...7.0.36)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-17 12:28:38 +00:00
Pedro G. Galaviz
8ebd12db49 Merge pull request #15 from pggalaviz/dependabot/npm_and_yarn/handlebars-4.7.7
Bump handlebars from 4.5.3 to 4.7.7
2021-05-20 14:51:35 -05:00
Pedro G. Galaviz
4edb700cd8 Merge pull request #18 from pggalaviz/dependabot/npm_and_yarn/lodash-4.17.21
Bump lodash from 4.17.20 to 4.17.21
2021-05-11 19:32:55 -05:00
dependabot[bot]
3588880c50 Bump lodash from 4.17.20 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 23:14:13 +00:00
Pedro G. Galaviz
32a4700f1d Merge pull request #16 from pggalaviz/dependabot/npm_and_yarn/url-parse-1.5.1
Bump url-parse from 1.4.7 to 1.5.1
2021-05-10 08:14:56 -05:00
dependabot[bot]
a71b28e934 Bump url-parse from 1.4.7 to 1.5.1
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.4.7 to 1.5.1.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.4.7...1.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 12:58:07 +00:00
dependabot[bot]
148d8a9355 Bump handlebars from 4.5.3 to 4.7.7
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.5.3 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.5.3...v4.7.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-09 10:27:52 +00:00
Pedro G. Galaviz
6f956e45f8 Merge pull request #12 from pggalaviz/dependabot/npm_and_yarn/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1
2021-04-01 13:08:46 -06:00
dependabot[bot]
658d7767cd Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 08:14:50 +00:00
Pedro G. Galaviz
be5852c6c5 Merge pull request #8 from pggalaviz/dependabot/npm_and_yarn/acorn-5.7.4
Bump acorn from 5.7.3 to 5.7.4
2021-02-16 23:09:58 -06:00
Pedro G. Galaviz
1697ba939b Merge pull request #9 from pggalaviz/dependabot/npm_and_yarn/http-proxy-1.18.1
Bump http-proxy from 1.18.0 to 1.18.1
2021-01-25 22:00:35 -06:00
Pedro G. Galaviz
5ad9328c80 Merge pull request #10 from pggalaviz/dependabot/npm_and_yarn/elliptic-6.5.3
Bump elliptic from 6.5.2 to 6.5.3
2020-12-14 09:52:38 -06:00
Pedro G. Galaviz
3395e84d59 Merge pull request #11 from pggalaviz/dependabot/npm_and_yarn/ini-1.3.8
Bump ini from 1.3.5 to 1.3.8
2020-12-14 09:52:18 -06:00
dependabot[bot]
b4471203e6 Bump ini from 1.3.5 to 1.3.8
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-13 07:11:48 +00:00
Pedro G. Galaviz
07daecd990 Merge pull request #4 from pggalaviz/dependabot/npm_and_yarn/dot-prop-4.2.1
Bump dot-prop from 4.2.0 to 4.2.1
2020-12-07 19:59:35 -06:00
Pedro G. Galaviz
d63f186200 Merge pull request #7 from pggalaviz/dependabot/npm_and_yarn/lodash-4.17.20
Bump lodash from 4.17.15 to 4.17.20
2020-12-06 21:54:05 -06:00
dependabot[bot]
ce307fdacb Bump http-proxy from 1.18.0 to 1.18.1
Bumps [http-proxy](https://github.com/http-party/node-http-proxy) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/http-party/node-http-proxy/releases)
- [Changelog](https://github.com/http-party/node-http-proxy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/http-party/node-http-proxy/compare/1.18.0...1.18.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-07 03:53:14 +00:00
dependabot[bot]
5bc015cd2c Bump elliptic from 6.5.2 to 6.5.3
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-07 03:53:14 +00:00
dependabot[bot]
0168d188b2 Bump acorn from 5.7.3 to 5.7.4
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-07 03:53:13 +00:00
dependabot[bot]
d75978f778 Bump lodash from 4.17.15 to 4.17.20
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.20.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.20)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-07 03:53:12 +00:00
dependabot[bot]
96daeb420a Bump dot-prop from 4.2.0 to 4.2.1
Bumps [dot-prop](https://github.com/sindresorhus/dot-prop) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/sindresorhus/dot-prop/releases)
- [Commits](https://github.com/sindresorhus/dot-prop/compare/v4.2.0...v4.2.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-07 03:53:11 +00:00
15 changed files with 17218 additions and 107 deletions

View File

@@ -58,6 +58,7 @@ As you can see, the component accepts some props:
| ---- | ---- | -------- | | ---- | ---- | -------- |
| value | String | The text to highlight (**v-model**). | | value | String | The text to highlight (**v-model**). |
| extractUrlsWithoutProtocol | Boolean | As the name says, when active, the compoponet will try to match URLs even when a protocol (http://, https://) is not found. **Defaults to true** | | extractUrlsWithoutProtocol | Boolean | As the name says, when active, the compoponet will try to match URLs even when a protocol (http://, https://) is not found. **Defaults to true** |
| mentionsWithDots | Boolean | Whether a mention can contain a dot. **Defaults to false** |
| caretColor | String | A valid HEX color (eg. #ccc, #ff4545). | | caretColor | String | A valid HEX color (eg. #ccc, #ff4545). |
| placeholder | String | A placeholder to show when no text is entered. | | placeholder | String | A placeholder to show when no text is entered. |
| usernameClass | String | The CSS class(es) that will be added to a @username match. | | usernameClass | String | The CSS class(es) that will be added to a @username match. |

View File

@@ -1083,7 +1083,7 @@ const endMentionMatch = _regexSupplant(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/
const validMention = _regexSupplant( const validMention = _regexSupplant(
'(#{validMentionPrecedingChars})' + // $1: Preceding character '(#{validMentionPrecedingChars})' + // $1: Preceding character
'(#{atSigns})' + // $2: At mark '(#{atSigns})' + // $2: At mark
'([a-zA-Z0-9_]{1,20})', // $3: Screen name '([a-zA-Z0-9_\.]{1,20})', // $3: Screen name
// '(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?', // $4: List (optional) // '(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?', // $4: List (optional)
{ validMentionPrecedingChars, atSigns }, { validMentionPrecedingChars, atSigns },
'g' 'g'
@@ -1675,6 +1675,10 @@ function src_autoLink (text, options) {
type: Boolean, type: Boolean,
default: true default: true
}, },
mentionsWithDots: {
type: Boolean,
default: false
},
caretColor: { caretColor: {
type: String, type: String,
default: '#ccc' default: '#ccc'
@@ -1697,7 +1701,8 @@ function src_autoLink (text, options) {
}, },
computedBody () { computedBody () {
return highlight(this.body, { return highlight(this.body, {
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol,
mentionsWithDots: this.mentionsWithDots
}) })
} }
}, },

File diff suppressed because one or more lines are too long

View File

@@ -1092,7 +1092,7 @@ const endMentionMatch = _regexSupplant(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/
const validMention = _regexSupplant( const validMention = _regexSupplant(
'(#{validMentionPrecedingChars})' + // $1: Preceding character '(#{validMentionPrecedingChars})' + // $1: Preceding character
'(#{atSigns})' + // $2: At mark '(#{atSigns})' + // $2: At mark
'([a-zA-Z0-9_]{1,20})', // $3: Screen name '([a-zA-Z0-9_\.]{1,20})', // $3: Screen name
// '(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?', // $4: List (optional) // '(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?', // $4: List (optional)
{ validMentionPrecedingChars, atSigns }, { validMentionPrecedingChars, atSigns },
'g' 'g'
@@ -1684,6 +1684,10 @@ function src_autoLink (text, options) {
type: Boolean, type: Boolean,
default: true default: true
}, },
mentionsWithDots: {
type: Boolean,
default: false
},
caretColor: { caretColor: {
type: String, type: String,
default: '#ccc' default: '#ccc'
@@ -1706,7 +1710,8 @@ function src_autoLink (text, options) {
}, },
computedBody () { computedBody () {
return highlight(this.body, { return highlight(this.body, {
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol,
mentionsWithDots: this.mentionsWithDots
}) })
} }
}, },

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -21,6 +21,7 @@
:placeholder="placeholder" :placeholder="placeholder"
:caretColor="caretColor" :caretColor="caretColor"
:extractUrlsWithoutProtocol="options.extractUrlsWithoutProtocol" :extractUrlsWithoutProtocol="options.extractUrlsWithoutProtocol"
:mentionsWithDots="options.mentionsWithDots"
/> />
</div> </div>
@@ -28,14 +29,18 @@
<div id="options" class="content-container"> <div id="options" class="content-container">
<h4>Options (props)</h4> <h4>Options (props)</h4>
<div class="flex center"> <div class="flex center">
<label for="ep" class="mr-lg cursor-pointer"> <label for="ep" class="cursor-pointer">
<input id="ep" type="checkbox" v-model="options.extractUrlsWithoutProtocol"> <input id="ep" type="checkbox" v-model="options.extractUrlsWithoutProtocol">
extractUrlsWithoutProtocol extractUrlsWithoutProtocol
</label> </label>
<label for="tb" class="cursor-pointer"> <label for="tb" class="mx-lg cursor-pointer">
<input id="tb" type="checkbox" v-model="options.targetBlank"> <input id="tb" type="checkbox" v-model="options.targetBlank">
targetBlank targetBlank
</label> </label>
<label for="md" class="cursor-pointer">
<input id="md" type="checkbox" v-model="options.mentionsWithDots">
mentionsWithDots
</label>
</div> </div>
<div class="flex center mt-sm text-left relative"> <div class="flex center mt-sm text-left relative">
@@ -130,6 +135,7 @@ export default {
options: { options: {
targetBlank: true, targetBlank: true,
extractUrlsWithoutProtocol: true, extractUrlsWithoutProtocol: true,
mentionsWithDots: false,
usernameClass: 'highlights username', usernameClass: 'highlights username',
usernameUrlBase: '#/', usernameUrlBase: '#/',
hashtagClass: 'highlights hashtag', hashtagClass: 'highlights hashtag',

17258
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,10 @@ export default {
type: Boolean, type: Boolean,
default: true default: true
}, },
mentionsWithDots: {
type: Boolean,
default: false
},
caretColor: { caretColor: {
type: String, type: String,
default: '#ccc' default: '#ccc'
@@ -37,7 +41,8 @@ export default {
}, },
computedBody () { computedBody () {
return highlight(this.body, { return highlight(this.body, {
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol,
mentionsWithDots: this.mentionsWithDots
}) })
} }
}, },

View File

@@ -8,7 +8,7 @@ import removeOverlappingEntities from './removeOverlappingEntities'
export default function (text, options) { export default function (text, options) {
const entities = extractUrls(text, options) const entities = extractUrls(text, options)
.concat(extractMentions(text)) .concat(extractMentions(text, options))
.concat(extractHashtags(text)) .concat(extractHashtags(text))
if (entities.length === 0) { if (entities.length === 0) {

View File

@@ -17,7 +17,8 @@ const OPTIONS_NOT_ATTRIBUTES = {
invisibleTagAttrs: true, invisibleTagAttrs: true,
linkAttributeBlock: true, linkAttributeBlock: true,
htmlEscapeNonEntities: true, htmlEscapeNonEntities: true,
extractUrlsWithoutProtocol: true extractUrlsWithoutProtocol: true,
mentionsWithDots: true
} }
export default function (options) { export default function (options) {

View File

@@ -1,15 +1,16 @@
// Extracts mentions from text. // Extracts mentions from text.
import { atSigns, endMentionMatch, validMention } from './regex' import { atSigns, endMentionMatch, validMention, validDotMention } from './regex'
export default function (text) { export default function (text, options) {
if (!text || !text.match(atSigns)) { if (!text || !text.match(atSigns)) {
return [] return []
} }
const mentions = [] const mentions = []
const mentionRegex = options.mentionsWithDots ? validDotMention : validMention
text.replace(validMention, function (match, before, atSign, mentionText, offset, chunk) { text.replace(mentionRegex, function (match, before, atSign, mentionText, offset, chunk) {
const after = chunk.slice(offset + match.length) const after = chunk.slice(offset + match.length)
if (!after.match(endMentionMatch)) { if (!after.match(endMentionMatch)) {
const startPosition = offset + before.length const startPosition = offset + before.length

View File

@@ -4,7 +4,8 @@ import autoHighlight from './autoHighlight'
const defaultOptions = { const defaultOptions = {
targetBlank: true, targetBlank: true,
extractUrlsWithoutProtocol: true extractUrlsWithoutProtocol: true,
mentionsWithDots: false
} }
export function link (text, options = defaultOptions) { export function link (text, options = defaultOptions) {

View File

@@ -194,3 +194,11 @@ export const validMention = regexSupplant(
{ validMentionPrecedingChars, atSigns }, { validMentionPrecedingChars, atSigns },
'g' 'g'
) )
export const validDotMention = regexSupplant(
'(#{validMentionPrecedingChars})' + // $1: Preceding character
'(#{atSigns})' + // $2: At mark
'([a-zA-Z0-9_\.]{1,20})', // $3: Screen name
// '(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?', // $4: List (optional)
{ validMentionPrecedingChars, atSigns },
'g'
)