Skip to content

Commit

Permalink
fix: Can not select the text in Android OS
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfuhai committed Nov 13, 2024
1 parent 22c152e commit 62e82a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
26 changes: 10 additions & 16 deletions src/extensions/SelectionMarkerExt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,23 @@ import {Decoration, DecorationSet} from '@tiptap/pm/view';

export const SelectionMarkerExt = Extension.create({
addProseMirrorPlugins() {
const e = this.editor;
return [
new Plugin({
key: new PluginKey("selection-marker"),
state: {
init: () => DecorationSet.empty,
apply: (tr, set, state) => {
const {selection} = tr;
if (selection) {
const decos = [Decoration.inline(selection.$from.pos, selection.$to.pos,
{class: 'selection-marker'},
{inclusiveLeft: true, inclusiveRight: true}
)];
return DecorationSet.create(state.doc, decos);
}
return set;
}
},
props: {
decorations(state) {
return this.getState(state);
if (state.selection.empty || e.isFocused) {
return null;
}
return DecorationSet.create(state.doc, [
Decoration.inline(state.selection.from, state.selection.to,
{class: 'selection-marker'}
)
])
}
}
}),
]
},
})
})
14 changes: 11 additions & 3 deletions src/styles/aieditor.less
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,20 @@

.aie-content {
::selection {
background: none;
background: #88c6ff66;
}

[contenteditable="true"]::selection {
background: #88c6ff66;
}

[contenteditable="true"]:focus-visible {
outline: none;
}

.selection-marker {
background: #85c3ff6d;
padding: 2px 0;
background: #88c6ff66;
padding: 0;
}
}

Expand Down

0 comments on commit 62e82a1

Please sign in to comment.