Page MenuHomePhorge

No OneTemporary

Size
12 KB
Referenced Files
None
Subscribers
None
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 675c4b5bf2..18dafa8e26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,130 +1,135 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
## [Unreleased patch]
+
### Changed
- Polls will be hidden with status content if "Collapse posts with subjects" is enabled and the post is collapsed.
+### Fixed
+- Autocomplete won't stop at the second @, so it'll still work with "@lain@l" and not start over.
+- Fixed weird autocomplete behavior when you write ":custom_emoji: ?"
+
## [2.1.0] - 2020-08-28
### Added
- Autocomplete domains from list of known instances
- 'Bot' settings option and badge
- Added profile meta data fields that can be set in profile settings
- Added option to reset avatar/banner in profile settings
- Descriptions can be set on uploaded files before posting
- Added status preview option to preview your statuses before posting
- When a post is a reply to an unavailable post, the 'Reply to'-text has a strike-through style
- Added ability to see all favoriting or repeating users when hovering the number on highlighted statuses
- Bookmarks
### Changed
- Change heart to thumbs up in reaction picker
- Close the media modal on navigation events
- Add colons to the emoji alt text, to make them copyable
- Add better visual indication for drag-and-drop for files
- When disabling attachments, the placeholder links now show an icon and the description instead of just IMAGE or VIDEO etc
- Remove unnecessary options for 'automatic loading when loading older' and 'reply previews'
- Greentext now has separate color slot for it
- Removed the use of with_move parameters when fetching notifications
- Push notifications now are the same as normal notfication, and are localized.
- Updated Notification Settings to match new BE API
### Fixed
- Custom Emoji will display in poll options now.
- Status ellipsis menu closes properly when selecting certain options
- Cropped images look correct in Chrome
- Newlines in the muted words settings work again
- Clicking on non-latin hashtags won't open a new window
- Uploading and drag-dropping multiple files works correctly now.
- Subject field now appears disabled when posting
- Fix status ellipsis menu being cut off in notifications column
- Fixed autocomplete sometimes not returning the right user when there's already some results
- Videos and audio and misc files show description as alt/title properly now
- Clicking on non-image/video files no longer opens an empty modal
- Audio files can now be played back in the frontend with hidden attachments
- Videos are not cropped awkwardly in the uploads section anymore
- Reply filtering options in Settings -> Filtering now work again using filtering on server
- Don't show just blank-screen when cookies are disabled
- Add status idempotency to prevent accidental double posting when posting returns an error
- Weird bug related to post being sent seemingly after pasting with keyboard (hopefully)
- Multiple issues with muted statuses/notifications
## [2.0.5] - 2020-05-12
### Added
- Added private notifications option for push notifications
- 'Copy link' button for statuses (in the ellipsis menu)
### Changed
- Registration page no longer requires email if the server is configured not to require it
### Fixed
- Status ellipsis menu closes properly when selecting certain options
## [2.0.3] - 2020-05-02
### Fixed
- Show more/less works correctly with auto-collapsed subjects and long posts
- RTL characters won't look messed up in notifications
### Changed
- Emoji autocomplete will match any part of the word and not just start, for example :drool will now helpfully suggest :blobcatdrool: and :blobcatdroolreach:
### Added
- Follow request notification support
## [2.0.2] - 2020-04-08
### Fixed
- Favorite/Repeat avatars not showing up on private instances/non-public posts
- Autocorrect getting triggered in the captcha field
- Overflow on long domains in follow/move notifications
### Changed
- Polish translation updated
## [2.0.0] - 2020-02-28
### Added
- Tons of color slots including ones for hover/pressed/toggled buttons
- Experimental `--variable[,mod]` syntax support for color slots in themes. the `mod` makes color brighter/darker depending on background color (makes darker color brighter/darker depending on background color)
- Paper theme by Shpuld
- Icons in nav panel
- Private mode support
- Support for 'Move' type notifications
- Pleroma AMOLED dark theme
- User level domain mutes, under User Settings -> Mutes
- Emoji reactions for statuses
- MRF keyword policy disclosure
### Changed
- Updated Pleroma default themes
- theme engine update to 3 (themes v2.1 introduction)
- massive internal changes in theme engine - slowly away from "generate things separately with spaghetti code" towards "feed all data into single 'generateTheme' function and declare slot inheritance and all in a separate file"
- Breezy theme updates to make it closer to actual Breeze in some aspects
- when using `--variable` in shadows it no longer uses the actual CSS3 variable, instead it generates color from other slots
- theme doesn't get saved to local storage when opening FE anonymously
- Captcha now resets on failed registrations
- Notifications column now cleans itself up to optimize performance when tab is left open for a long time
- 403 messaging
### Fixed
- Fixed loader-spinner not disappearing when a status preview fails to load
- anon viewers won't get theme data saved to local storage, so admin changing default theme will have an effect for users coming back to instance.
- Single notifications left unread when hitting read on another device/tab
- Registration fixed
- Deactivation of remote accounts from frontend
- Fixed NSFW unhiding not working with videos when using one-click unhiding/displaying
- Improved performance of anything that uses popovers (most notably statuses)
## [1.1.7 and earlier] - 2019-12-14
### Added
- Ability to hide/show repeats from user
- User profile button clutter organized into a menu
- Emoji picker
- Started changelog anew
- Ability to change user's email
- About page
- Added remote user redirect
- Bookmarks
### Changed
- changed the way fading effects for user profile/long statuses works, now uses css-mask instead of gradient background hacks which weren't exactly compatible with semi-transparent themes
### Fixed
- improved hotkey behavior on autocomplete popup
diff --git a/src/services/completion/completion.js b/src/services/completion/completion.js
index df83d03d14..8a6eba7e4d 100644
--- a/src/services/completion/completion.js
+++ b/src/services/completion/completion.js
@@ -1,70 +1,70 @@
import { reduce, find } from 'lodash'
export const replaceWord = (str, toReplace, replacement) => {
return str.slice(0, toReplace.start) + replacement + str.slice(toReplace.end)
}
export const wordAtPosition = (str, pos) => {
- const words = splitIntoWords(str)
+ const words = splitByWhitespaceBoundary(str)
const wordsWithPosition = addPositionToWords(words)
return find(wordsWithPosition, ({ start, end }) => start <= pos && end > pos)
}
export const addPositionToWords = (words) => {
return reduce(words, (result, word) => {
const data = {
word,
start: 0,
end: word.length
}
if (result.length > 0) {
const previous = result.pop()
data.start += previous.end
data.end += previous.end
result.push(previous)
}
result.push(data)
return result
}, [])
}
-export const splitIntoWords = (str) => {
- // Split at word boundaries
- const regex = /\b/
- const triggers = /[@#:]+$/
-
- let split = str.split(regex)
-
- // Add trailing @ and # to the following word.
- const words = reduce(split, (result, word) => {
- if (result.length > 0) {
- let previous = result.pop()
- const matches = previous.match(triggers)
- if (matches) {
- previous = previous.replace(triggers, '')
- word = matches[0] + word
- }
- result.push(previous)
+export const splitByWhitespaceBoundary = (str) => {
+ let result = []
+ let currentWord = ''
+ for (let i = 0; i < str.length; i++) {
+ const currentChar = str[i]
+ // Starting a new word
+ if (!currentWord) {
+ currentWord = currentChar
+ continue
}
- result.push(word)
-
- return result
- }, [])
-
- return words
+ // current character is whitespace while word isn't, or vice versa:
+ // add our current word to results, start over the current word.
+ if (!!currentChar.trim() !== !!currentWord.trim()) {
+ result.push(currentWord)
+ currentWord = currentChar
+ continue
+ }
+ currentWord += currentChar
+ }
+ // Add the last word we were working on
+ if (currentWord) {
+ result.push(currentWord)
+ }
+ return result
}
const completion = {
wordAtPosition,
addPositionToWords,
- splitIntoWords,
+ splitByWhitespaceBoundary,
replaceWord
}
export default completion
diff --git a/test/unit/specs/services/completion/completion.spec.js b/test/unit/specs/services/completion/completion.spec.js
index 8a41c6537a..81d3a26a26 100644
--- a/test/unit/specs/services/completion/completion.spec.js
+++ b/test/unit/specs/services/completion/completion.spec.js
@@ -1,70 +1,85 @@
-import { replaceWord, addPositionToWords, wordAtPosition, splitIntoWords } from '../../../../../src/services/completion/completion.js'
+import { replaceWord, addPositionToWords, wordAtPosition, splitByWhitespaceBoundary } from '../../../../../src/services/completion/completion.js'
describe('addPositiontoWords', () => {
it('adds the position to a word list', () => {
- const words = ['hey', 'this', 'is', 'fun']
+ const words = ['hey', ' ', 'this', ' ', 'is', ' ', 'fun']
const expected = [
{
word: 'hey',
start: 0,
end: 3
},
{
- word: 'this',
+ word: ' ',
start: 3,
- end: 7
+ end: 4
},
{
- word: 'is',
- start: 7,
+ word: 'this',
+ start: 4,
+ end: 8
+ },
+ {
+ word: ' ',
+ start: 8,
end: 9
},
{
- word: 'fun',
+ word: 'is',
start: 9,
+ end: 11
+ },
+ {
+ word: ' ',
+ start: 11,
end: 12
+ },
+ {
+ word: 'fun',
+ start: 12,
+ end: 15
}
]
const res = addPositionToWords(words)
expect(res).to.eql(expected)
})
})
-describe('splitIntoWords', () => {
+describe('splitByWhitespaceBoundary', () => {
it('splits at whitespace boundaries', () => {
- const str = 'This is a #nice @test for you, @idiot.'
- const expected = ['This', ' ', 'is', ' ', 'a', ' ', '#nice', ' ', '@test', ' ', 'for', ' ', 'you', ', ', '@idiot', '.']
- const res = splitIntoWords(str)
+ const str = 'This is a #nice @test for you, @idiot@idiot.com'
+ const expected = ['This', ' ', 'is', ' ', 'a', ' ', '#nice', ' ', '@test', ' ', 'for', ' ', 'you,', ' ', '@idiot@idiot.com']
+ const res = splitByWhitespaceBoundary(str)
expect(res).to.eql(expected)
})
})
describe('wordAtPosition', () => {
it('returns the word for a given string and postion, plus the start and end position of that word', () => {
const str = 'Hey this is fun'
const { word, start, end } = wordAtPosition(str, 4)
expect(word).to.eql('this')
expect(start).to.eql(4)
expect(end).to.eql(8)
})
})
describe('replaceWord', () => {
it('replaces a word (with start and end) with another word in a given string', () => {
- const str = 'hey @take, how are you'
- const wordsWithPosition = addPositionToWords(splitIntoWords(str))
+ const str = 'hey @take , how are you'
+ const wordsWithPosition = addPositionToWords(splitByWhitespaceBoundary(str))
const toReplace = wordsWithPosition[2]
expect(toReplace.word).to.eql('@take')
- const expected = 'hey @takeshitakenji, how are you'
+ const expected = 'hey @takeshitakenji , how are you'
const res = replaceWord(str, toReplace, '@takeshitakenji')
expect(res).to.eql(expected)
})
})

File Metadata

Mime Type
text/x-diff
Expires
Sun, Aug 30, 2:07 PM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1738024
Default Alt Text
(12 KB)

Event Timeline