Skip to content

Commit

Permalink
chore: Remove bowser module exposed on Editable.browser
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove bowser module exposed on `Editable.browser`
  • Loading branch information
marcbachmann committed Oct 20, 2023
1 parent f4c718c commit 6be0ace
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"version": "0.0.0-development",
"dependencies": {
"@babel/runtime": "^7.16.7",
"bowser": "2.11.0",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 0 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Cursor from './cursor'
import highlightSupport from './highlight-support'
import MonitoredHighlighting from './monitored-highlighting'
import createDefaultEvents from './create-default-events'
import browser from 'bowser'
import {textNodesUnder, getTextNodeAndRelativeOffset} from './util/element'
import {binaryCursorSearch} from './util/binary_search'
import {domArray, createRange, nodeContainsRange} from './util/dom'
Expand Down Expand Up @@ -513,7 +512,6 @@ export class Editable {
// Expose modules and editable
Editable.parser = parser
Editable.content = content
Editable.browser = browser

// Set up callback functions for several events.
;['focus', 'blur', 'flow', 'selection', 'cursor', 'newline',
Expand Down
12 changes: 7 additions & 5 deletions src/feature-detection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import browser from 'bowser'

/**
* Check for contenteditable support
*
Expand All @@ -10,9 +8,13 @@ import browser from 'bowser'
*/
export const contenteditable = typeof document.documentElement.contentEditable !== 'undefined'

const parser = browser.getParser(window.navigator.userAgent)
const browserEngine = parser.getEngineName()
const webKit = browserEngine === 'WebKit'
// Detect webkit browser engine
// That way we can detect the contenteditable span bug on safari, but exclude chrome
// Regex taken from: https://github.com/lancedikson/bowser/blob/f09411489ced05811c91cc6670a8e4ca9cbe39a7/src/parser-engines.js#L93-L106
// Attention, this might be error prone as any engine version change breaks this.
const isBlink = /(apple)?webkit\/537\.36/i.test(window.navigator.userAgent)
const isWebkit = /(apple)?webkit/i.test(window.navigator.userAgent)
const webKit = !isBlink && isWebkit

/**
* Check selectionchange event (supported in IE, Chrome, Firefox and Safari)
Expand Down

0 comments on commit 6be0ace

Please sign in to comment.