-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(developer): ldml-editor: repertoire viewer 🗼
- some refactoring still - disabled the raw XML view Fixes: #12789
- Loading branch information
Showing
6 changed files
with
238 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Keyman is copyright (C) SIL Global. MIT License. | ||
* | ||
* Visual editor app | ||
*/ | ||
|
||
import { Card } from 'antd'; | ||
import React from 'react'; | ||
|
||
/** workaround Card TS linkage (and also make the border always set) */ | ||
export function FixedCard({ title, bordered, children } : { title: string, bordered?: boolean, children?: any }) { | ||
return ( | ||
// TODO-EPIC-LDML: why the red squiggle on the next line? | ||
<Card title={title} bordered={bordered}> | ||
{children} | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Keyman is copyright (C) SIL Global. MIT License. | ||
* | ||
* the Raw Source view | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Button } from 'antd'; | ||
/** Ant's Card had an import problem, so we use this workaround */ | ||
import { FixedCard as Card } from './FixedCard.js'; | ||
|
||
|
||
/** The "show raw source" panel */ | ||
export function RawSource({ text }) { | ||
const [shown, setShown] = React.useState(false); | ||
function show() { | ||
setShown(true); | ||
} | ||
if (!text) return; | ||
if (!shown) return ( | ||
<Card title="Raw XML Source" > | ||
<Button type="primary" onClick={() => setShown(true)}>Show</Button> | ||
</Card> | ||
); | ||
return ( | ||
<Card title="Raw XML Source" bordered={true}> | ||
<Button type="primary" onClick={() => setShown(false)}>Hide</Button> | ||
<pre className="code">{text}</pre> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Keyman is copyright (C) SIL Global. MIT License. | ||
* | ||
* Placeholder for a dynamic repertoire object. | ||
*/ | ||
|
||
export type RepertoireEntry = string; | ||
|
||
export class FakeRepertoire implements Iterable<RepertoireEntry> { | ||
constructor(private items: RepertoireEntry[]) { | ||
|
||
} | ||
|
||
// allow `for (x of repertoire)` | ||
[Symbol.iterator](): Iterator<RepertoireEntry, any, any> { | ||
// use the string array's iterator | ||
return this.items[Symbol.iterator](); | ||
} | ||
|
||
// allow `repertoire.map` | ||
map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any { | ||
return this.items.map(callbackfn); | ||
} | ||
} | ||
|
||
export const SAMPLE_REPERTOIRE = new FakeRepertoire([ | ||
..."abcdefghijklmnopqrstuvwxyz".split(''), | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters