Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve citation bug in chrome #770

Merged
merged 9 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Addition of list inputrules
### Fixed
- Also observe responsive toolbar children for resize
- Solve bug with cursor in front a multiple line link


### Changed
Expand Down
38 changes: 38 additions & 0 deletions addon/plugins/chrome-hacks-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
Decoration,
DecorationSet,
EditorState,
ProsePlugin,
} from '@lblod/ember-rdfa-editor';
import { chrome } from '@lblod/ember-rdfa-editor/utils/_private/browser';

export function chromeHacksPlugin(): ProsePlugin {
const chromeHacksPlugin = new ProsePlugin({
props: {
decorations(state: EditorState): DecorationSet | undefined {
if (!chrome) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need to test edge

return;
}
const { $from, from, to } = state.selection;
if (from !== to) {
return;
}
const nextNode = $from.nodeAfter;
if (nextNode?.type.spec.needsChromeCursorFix) {
return DecorationSet.create(state.doc, [
Decoration.widget(
from,
() => {
const fakeCursor = document.createElement('span');
return fakeCursor;
},
{ side: 1 }
),
]);
}
return;
},
},
});
return chromeHacksPlugin;
}
1 change: 1 addition & 0 deletions addon/plugins/link/nodes/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const emberNodeConfig: (options: LinkOptions) => EmberNodeConfig = (
},
},
needsFFKludge: true,
needsChromeCursorFix: true,
parseDOM: [
{
tag: 'a',
Expand Down
1 change: 0 additions & 1 deletion app/styles/ember-rdfa-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}


@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 2 additions & 0 deletions tests/dummy/app/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
ordered_list_input_rule,
} from '@lblod/ember-rdfa-editor/plugins/list/input_rules';
import { inputRules } from '@lblod/ember-rdfa-editor';
import { chromeHacksPlugin } from '@lblod/ember-rdfa-editor/plugins/chrome-hacks-plugin';

export default class IndexController extends Controller {
@tracked rdfaEditor?: SayController;
Expand Down Expand Up @@ -117,6 +118,7 @@ export default class IndexController extends Controller {
@tracked plugins: Plugin[] = [
// disabled until https://binnenland.atlassian.net/browse/GN-4147 is fixed
firefoxCursorFix(),
chromeHacksPlugin(),
lastKeyPressedPlugin,
tablePlugin,
tableKeymap,
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/app/controllers/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import {
ordered_list_input_rule,
} from '@lblod/ember-rdfa-editor/plugins/list/input_rules';
import { inputRules } from '@lblod/ember-rdfa-editor';
import { chromeHacksPlugin } from '@lblod/ember-rdfa-editor/plugins/chrome-hacks-plugin';
import { firefoxCursorFix } from '@lblod/ember-rdfa-editor/plugins/firefox-cursor-fix';

export default class IndexController extends Controller {
@tracked rdfaEditor?: SayController;
Expand Down Expand Up @@ -132,6 +134,8 @@ export default class IndexController extends Controller {
};
};
@tracked plugins: Plugin[] = [
firefoxCursorFix(),
chromeHacksPlugin(),
highlightPlugin({ testKey: 'yeet' }),
tablePlugin,
tableKeymap,
Expand Down