Skip to content

Commit

Permalink
Merge pull request evt-project#106 from evt-project/feature/deletions
Browse files Browse the repository at this point in the history
Feature/deletions
  • Loading branch information
szenzaro authored Nov 27, 2020
2 parents 4a99e75 + 1ca44c5 commit 237559b
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated to Angular 9

### Added
- Deletion vizualization
- Verses group visualization
- Multiple line words normalization in interpretative and critical edition
- Word visualization
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { CharComponent } from './components/char/char.component';
import { ChoiceComponent } from './components/choice/choice.component';
import { ContentViewerComponent } from './components/content-viewer/content-viewer.component';
import { DamageComponent } from './components/damage/damage.component';
import { DeletionComponent } from './components/deletion/deletion.component';
import { EditionLevelSelectorComponent } from './components/edition-level-selector/edition-level-selector.component';
import { EntitiesSelectComponent } from './components/entities-select/entities-select.component';
import { GComponent } from './components/g/g.component';
Expand Down Expand Up @@ -101,6 +102,7 @@ export function initializeApp(appConfig: AppConfig) {
CollationComponent,
ContentViewerComponent,
DamageComponent,
DeletionComponent,
EditionLevelSelectorComponent,
EditorialConventionLayoutDirective,
EntitiesSelectComponent,
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/deletion/deletion.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span class="del" [attr.data-edition]="editionLevel" [attr.data-rend]="data.rend" [evtHtmlAttributes]="data?.attributes"
[evtHighlight]="highlightData" [evtEditorialConventionLayout]="editorialConventionData">
<evt-content-viewer *ngFor="let element of data.content" [content]="element" [editionLevel]="editionLevel"
[itemsToHighlight]="itemsToHighlight"></evt-content-viewer>
</span>
Empty file.
25 changes: 25 additions & 0 deletions src/app/components/deletion/deletion.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DeletionComponent } from './deletion.component';

describe('DeletionComponent', () => {
let component: DeletionComponent;
let fixture: ComponentFixture<DeletionComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DeletionComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DeletionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
27 changes: 27 additions & 0 deletions src/app/components/deletion/deletion.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, Input } from '@angular/core';

import { EditorialConventionLayoutData } from '../../directives/editorial-convention-layout.directive';
import { Deletion } from '../../models/evt-models';
import { register } from '../../services/component-register.service';
import { EditionlevelSusceptible, Highlightable } from '../components-mixins';

export interface DeletionComponent extends EditionlevelSusceptible, Highlightable { }

@register(Deletion)
@Component({
selector: 'evt-deletion',
templateUrl: './deletion.component.html',
styleUrls: ['./deletion.component.scss'],
})
export class DeletionComponent {
@Input() data: Deletion;

get editorialConventionData(): EditorialConventionLayoutData {
return {
name: 'del',
attributes: this.data.attributes,
editionLevel: this.editionLevel,
defaultsKey: 'deletion',
};
}
}
4 changes: 4 additions & 0 deletions src/app/models/evt-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,7 @@ export class Sic extends GenericElement {
export class Word extends GenericElement {
lemma?: string;
}

export class Deletion extends GenericElement {
rend: string;
}
14 changes: 13 additions & 1 deletion src/app/services/editorial-conventions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EditorialConvention, EditorialConventionLayouts } from '../models/evt-m

// List of handled editorial convention
export type EditorialConventionDefaults = 'addition' | 'additionAbove' | 'additionBelow' | 'additionInline' | 'additionLeft' | 'additionRight' |
'damage' | 'sicCrux' | 'surplus';
'damage' | 'deletion' | 'sicCrux' | 'surplus';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -90,6 +90,18 @@ export class EditorialConventionsService {
},
},
},
deletion: {
diplomatic: {
style: {
'background-color': '#fdd3d1',
'text-decoration': 'line-through',
},
},
interpretative: {
pre: '[[',
post: ']]',
},
},
sicCrux: {
diplomatic: {
pre: '&dagger;',
Expand Down
17 changes: 16 additions & 1 deletion src/app/services/xml-parsers/basic-parsers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AttributesMap } from 'ng-dynamic-component';
import {
Addition, Attributes, Damage, Gap, GenericElement, Lb, Note, NoteLayout,
Addition, Attributes, Damage, Deletion, Gap, GenericElement, Lb, Note, NoteLayout,
Paragraph, PlacementType, Supplied, Text, Verse, VersesGroup, Word, XMLElement,
} from '../../models/evt-models';
import { isNestedInElem, xpath } from '../../utils/dom-utils';
Expand Down Expand Up @@ -256,3 +256,18 @@ export class WordParser extends EmptyParser implements Parser<XMLElement> {
};
}
}

export class DeletionParser extends EmptyParser implements Parser<XMLElement> {
elementParser = createParser(ElementParser, this.genericParse);
attributeParser = createParser(AttributeParser, this.genericParse);
parse(xml: XMLElement): Deletion {
return {
type: Deletion,
rend: xml.getAttribute('rend'),
path: xpath(xml),
content: parseChildren(xml, this.genericParse),
attributes: this.attributeParser.parse(xml),
class: xml.tagName.toLowerCase(),
};
}
}
5 changes: 3 additions & 2 deletions src/app/services/xml-parsers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Comment, GenericElement, HTML, XMLElement } from '../../models/evt-models';
import { AppParser, RdgParser } from './app-parser';
import {
AdditionParser, DamageParser, ElementParser, GapParser, LBParser, NoteParser, ParagraphParser,
AdditionParser, DamageParser, DeletionParser, ElementParser, GapParser, LBParser, NoteParser, ParagraphParser,
PtrParser, SuppliedParser, TextParser, VerseParser, VersesGroupParser, WordParser,
} from './basic-parsers';
import { CharParser, GlyphParser, GParser } from './character-declarations-parser';
Expand All @@ -14,7 +14,7 @@ import {
} from './named-entity-parsers';
import { createParser, Parser, ParseResult } from './parser-models';

type SupportedTagNames = 'add' | 'app' | 'char' | 'choice' | 'damage' | 'event' | 'g' | 'gap' | 'geogname' | 'glyph' | 'graphic' | 'l' | 'lb' |
type SupportedTagNames = 'add' | 'app' | 'char' | 'choice' | 'damage' | 'del' | 'event' | 'g' | 'gap' | 'geogname' | 'glyph' | 'graphic' | 'l' | 'lb' |
'lem' | 'lg' | 'note' | 'orgname' | 'p' | 'persname' | 'placename' | 'ptr' | 'person' | 'personGrp' | 'place' | 'org' | 'rdg' | 'sic' | 'surface' |
'supplied' | 'surplus' | 'w' | 'zone';

Expand All @@ -24,6 +24,7 @@ export const parseF: { [T in SupportedTagNames]: Parser<XMLElement> } = {
char: createParser(CharParser, parse),
choice: createParser(ChoiceParser, parse),
damage: createParser(DamageParser, parse),
del: createParser(DeletionParser, parse),
event: createParser(NamedEntityRefParser, parse),
g: createParser(GParser, parse),
gap: createParser(GapParser, parse),
Expand Down

0 comments on commit 237559b

Please sign in to comment.