Skip to content

Commit

Permalink
EMMR-110 Complete transcription replace features
Browse files Browse the repository at this point in the history
  • Loading branch information
camilocodes committed Nov 24, 2023
1 parent 9357c0e commit ba30b42
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ emmr_transcribe_plugins:
- <span>
- <span class="trxn-caret">
- <span class="trxn-text">
- <span class="trxn-replace">
- <span class="trxn-retext">
- <span class="trxn-margin">
- <span class="trxn-number">
- <s class="trxn-replaced">
# *Additional configuration properties*
# conditions: for setting additional criteria that must be met for the
# plugin to be active.
Expand Down
2 changes: 1 addition & 1 deletion custom/modules/emmr_transcribe/js/build/transReplace.js

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

Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ export default class InsertTransReplaceCommand extends Command {
}

function createTransReplace(writer, selected) {
alert(selected);
// Create instances of the three elements registered with the editor in
// transreplaceediting.js.
const transReplace = writer.createElement('transReplace');
const transReplaceOld = writer.createElement('transReplaceOld');
writer.appendText('^', {}, transReplaceOld);
writer.appendText(selected, {}, transReplaceOld);
const transReplaceText = writer.createElement('transReplaceText');
let replaceText = prompt("Enter transcription replacement text");
writer.appendText(replaceText, {}, transReplaceText);

// Append the title and description elements to the transReplace, which matches
// the parent/child relationship as defined in their schemas.
writer.append(transReplaceOld, transReplace);
writer.append(transReplaceText, transReplace);
writer.append(transReplaceOld, transReplace);

// Return the element to be added to the editor.
return transReplace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import InsertTransReplaceCommand from './inserttransreplacecommand';
*
* CKEditor 5 internally interacts with transReplace as this model:
* <transReplace>
* <transReplaceOld></transReplaceOld>
* <transReplaceText></transReplaceText>
* <transReplaceOld></transReplaceOld>
* </transReplace>
*
* Which is converted for the browser/user as this markup
* <trxnrep>
* <span class="trxn-replace"></span>
* <span class="trxn-retext"></span>
* <s class="trxn-replaced"></s>
* </trxnrep>
*
* This file has the logic for defining the transReplace model, and for how it is
Expand All @@ -42,8 +42,8 @@ export default class TransReplaceEditing extends Plugin {
/*
* This registers the structure that will be seen by CKEditor 5 as
* <transReplace>
* <transReplaceOld></transReplaceOld>
* <transReplaceText></transReplaceText>
* <transReplaceOld></transReplaceOld>
* </transReplace>
*
* The logic in _defineConverters() will determine how this is converted to
Expand Down Expand Up @@ -110,15 +110,15 @@ export default class TransReplaceEditing extends Plugin {
},
});

// If <span class="trxn-caret"> is present in the existing markup
// If <s class="trxn-replaced"> is present in the existing markup
// processed by CKEditor, then CKEditor recognizes and loads it as a
// <transReplaceOld> model, provided it is a child element of <transReplace>,
// as required by the schema.
conversion.for('upcast').elementToElement({
model: 'transReplaceOld',
view: {
name: 'span',
classes: 'trxn-caret',
name: 's',
classes: 'trxn-replaced',
},
});

Expand Down Expand Up @@ -147,12 +147,12 @@ export default class TransReplaceEditing extends Plugin {
});

// Instances of <transReplaceOld> are saved as
// <span class="trxn-caret">{{inner content}}</span>.
// <s class="trxn-replaced">{{inner content}}</s>.
conversion.for('dataDowncast').elementToElement({
model: 'transReplaceOld',
view: {
name: 'span',
classes: 'trxn-caret',
name: 's',
classes: 'trxn-replaced',
},
});

Expand Down Expand Up @@ -181,13 +181,13 @@ export default class TransReplaceEditing extends Plugin {
},
});

// Convert the <transReplaceOld> model into an editable <span> widget.
// Convert the <transReplaceOld> model into an editable <s> widget.
conversion.for('editingDowncast').elementToElement({
model: 'transReplaceOld',
view: (modelElement, { writer: viewWriter }) => {
const span = viewWriter.createContainerElement('span',
const span = viewWriter.createContainerElement('s',
{
class: 'trxn-caret'
class: 'trxn-replaced'
});
return toWidget(span, viewWriter);
},
Expand Down
3 changes: 2 additions & 1 deletion custom/themes/emmr_lib_unb_ca/src/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ h1.page-header > a {
}

/* Transcription */
trxnin, trxnin + p, p:has(+ trxnin) {
trxnin, trxnin + p, p:has(+ trxnin),
trxnrep, trxnrep + p, p:has(+ trxnrep) {
display: inline;
}

Expand Down

0 comments on commit ba30b42

Please sign in to comment.