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

Support for subscript and superscript marks #531

Merged
merged 2 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions addon/components/plugins/subscript/button.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Rdfa::ToolbarIcon
@active={{this.isActive}}
@title={{t 'ember-rdfa-editor.subscript'}}
@icon='subscript'
{{on 'click' this.toggle}}
/>
20 changes: 20 additions & 0 deletions addon/components/plugins/subscript/button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { ProseController } from '@lblod/ember-rdfa-editor';

type Args = {
controller: ProseController;
};
export default class SubscriptButton extends Component<Args> {
get controller() {
return this.args.controller;
}
get isActive() {
return this.controller.isMarkActive(this.controller.schema.marks.subscript);
}

@action
toggle() {
this.controller.toggleMark('subscript');
}
}
6 changes: 6 additions & 0 deletions addon/components/plugins/superscript/button.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Rdfa::ToolbarIcon
@active={{this.isActive}}
@title={{t 'ember-rdfa-editor.superscript'}}
@icon='superscript'
{{on 'click' this.toggle}}
/>
22 changes: 22 additions & 0 deletions addon/components/plugins/superscript/button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';

type Args = {
controller: ProseController;
};
export default class SuperscriptButton extends Component<Args> {
get controller() {
return this.args.controller;
}
get isActive() {
return this.controller.isMarkActive(
this.controller.schema.marks.superscript
);
}

@action
toggle() {
this.controller.toggleMark('superscript');
}
}
15 changes: 15 additions & 0 deletions addon/plugins/subscript/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { WidgetSpec } from '@lblod/ember-rdfa-editor/core/prosemirror';
import { MarkSpec } from 'prosemirror-model';

export const subscript: MarkSpec = {
excludes: 'subscript superscript',
parseDOM: [{ tag: 'sub' }],
toDOM() {
return ['sub', 0];
},
};

export const subscriptWidget: WidgetSpec = {
componentName: 'plugins/subscript/button',
desiredLocation: 'toolbarMiddle',
};
15 changes: 15 additions & 0 deletions addon/plugins/superscript/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { WidgetSpec } from '@lblod/ember-rdfa-editor/core/prosemirror';
import { MarkSpec } from 'prosemirror-model';

export const superscript: MarkSpec = {
excludes: 'superscript subscript',
parseDOM: [{ tag: 'sup' }],
toDOM() {
return ['sup', 0];
},
};

export const superscriptWidget: WidgetSpec = {
componentName: 'plugins/superscript/button',
desiredLocation: 'toolbarMiddle',
};
1 change: 1 addition & 0 deletions app/components/plugins/subscript/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@lblod/ember-rdfa-editor/components/plugins/subscript/button';
1 change: 1 addition & 0 deletions app/components/plugins/superscript/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@lblod/ember-rdfa-editor/components/plugins/superscript/button';
11 changes: 11 additions & 0 deletions app/styles/ember-rdfa-editor/_c-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ $say-editor-highlight-hover-color: var(--au-gray-200) !default;
display: inline-block;
}

sub {
vertical-align: sub;
font-size: smaller;
}

sup {
vertical-align: super;
font-size: smaller;
}

// Table styling
table th {
white-space: initial;
Expand Down Expand Up @@ -439,3 +449,4 @@ $say-editor-highlight-hover-color: var(--au-gray-200) !default;
font-weight: var(--au-medium);
}
}

Loading