Skip to content

Commit

Permalink
Merge pull request #24 from Nebukam/Inspector-shell-update
Browse files Browse the repository at this point in the history
1.2.2 udpate
  • Loading branch information
Nebukam authored Aug 11, 2023
2 parents e0a3822 + d1999a1 commit 4970943
Show file tree
Hide file tree
Showing 644 changed files with 3,471 additions and 5,593 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ typings/
.fusebox/

# NKMjs
builds
builds
yarn.lock
53 changes: 27 additions & 26 deletions app/js-unicode/unicode-singleton-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ const UniBlock = require(`./catalogs/definition-uni-block`);
const UniCategory = require(`./catalogs/definition-uni-cat`);
const UniCategoryGroup = require(`./catalogs/definition-uni-cat-group`);

const _setActivateRangeCMD = new CmdSetActiveRange();

class UNICODE extends nkm.com.helpers.Singleton {
class UNICODE extends nkm.com.Observable {
constructor() { super(); }

static SetActiveRange = new CmdSetActiveRange();
get SetActiveRange() { return _setActivateRangeCMD; }

static get MAX_GLYPH_COUNT() { return 65534; }
get MAX_GLYPH_COUNT() { return 65534; }

_Init() {

Expand All @@ -32,7 +33,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
for (let i = 0; i < subs.length; i++) {
let lcgc = subs[i];
lcgc.parent = lgc;
lcgc.primaryCommand = this.constructor.SetActiveRange;
lcgc.primaryCommand = this.SetActiveRange;
lcgc.itemClass = UniCategory;
cgc.content.push(lcgc);
}
Expand All @@ -43,7 +44,7 @@ class UNICODE extends nkm.com.helpers.Singleton {

b.forEach((obj) => {
obj.itemClass = UniBlock;
obj.primaryCommand = this.constructor.SetActiveRange;
obj.primaryCommand = this.SetActiveRange;
});

this._blocks = b;
Expand All @@ -68,14 +69,14 @@ class UNICODE extends nkm.com.helpers.Singleton {
for (let cid in cMap) {
let char = cMap[cid];
this._charList[char.i] = char;
char.char = this.constructor.GetUnicodeCharacter(parseInt(cid, 16));
char.char = this.GetUnicodeCharacter(parseInt(cid, 16));
}

//let relMap = UNI_REL_MAPPING;

}

static GetInfos(p_unicode, p_createLigature = false) {
GetInfos(p_unicode, p_createLigature = false) {

let data = null;

Expand All @@ -84,26 +85,26 @@ class UNICODE extends nkm.com.helpers.Singleton {
this.GetSingle(p_unicode[0]) :
this.GetLigature(p_unicode, p_createLigature);
} else {
data = this.instance._charMap[p_unicode];
data = this._charMap[p_unicode];
}

return data || null;

}

static GetSingle(p_lookup) {
GetSingle(p_lookup) {

if (u.isNumber(p_lookup)) { p_lookup = p_lookup.toString(16).padStart(4, `0`); }

let result = this.instance._charMap[this.GetLookup(p_lookup)];
let result = this._charMap[this.GetLookup(p_lookup)];
if (!result) {
let isHex = u.isHex(p_lookup, 4);
if (isHex) {

let
uid = `${p_lookup}`,
index = parseInt(uid, 16),
list = this.instance._blocks,
list = this._blocks,
ownerBlock = null;

result = {
Expand All @@ -127,20 +128,20 @@ class UNICODE extends nkm.com.helpers.Singleton {
if (ownerBlock) { result.block = ownerBlock; }
else { console.error(`p_lookup = ${p_lookup} / index : ${index}`); }

this.instance._charMap[uid] = result;
this._charMap[uid] = result;

}
}
return result;
}

static GetLigature(p_lookups, p_create = true) {
GetLigature(p_lookups, p_create = true) {

let lps = [];
p_lookups.forEach((item) => { lps.push(this.GetLookup(item)); });
let
ligatureLookup = lps.join(`+`),
ligature = this.instance._charMap[ligatureLookup];
ligature = this._charMap[ligatureLookup];

if (!ligature) {
if (!p_create) { return null; }
Expand All @@ -149,19 +150,19 @@ class UNICODE extends nkm.com.helpers.Singleton {
lps.forEach((item) => { charPts.push(this.GetUnicodeCharacter(parseInt(item, 16))); });
charPts = charPts.join('');

ligature = { u: ligatureLookup, name: `LIGATURE ${charPts}`, cat: this.instance._categories.Liga, ligature: true, char: charPts };
this.instance._charMap[ligatureLookup] = ligature;
ligature = { u: ligatureLookup, name: `LIGATURE ${charPts}`, cat: this._categories.Liga, ligature: true, char: charPts };
this._charMap[ligatureLookup] = ligature;
}

return ligature;

}

static GetAddress(p_character) {
GetAddress(p_character) {
return p_character.codePointAt(0).toString(16).padStart(4, '0');
}

static GetUnicodeCharacter(p_codePoint) {
GetUnicodeCharacter(p_codePoint) {

if (p_codePoint >= 0 && p_codePoint <= 0xD7FF || p_codePoint >= 0xE000 && p_codePoint <= 0xFFFF) {
return String.fromCharCode(p_codePoint);
Expand All @@ -187,7 +188,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
* Attempts to find existing glyphs from UNICODE infos
* @param {*} p_infos
*/
static GetLookup(p_infos) {
GetLookup(p_infos) {

let lookup = null;

Expand All @@ -203,7 +204,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
return lookup;
}

static UUni(p_infos) {
UUni(p_infos) {
if (p_infos.ligature) {
let ulist = p_infos.u.split(`+`);
for (let i = 0; i < ulist.length; i++) { ulist[i] = `U+${ulist[i]}`; }
Expand All @@ -213,7 +214,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
}
}

static GetAddressesFromText(p_text, p_ignoreLigatures = true) {
GetAddressesFromText(p_text, p_ignoreLigatures = true) {
let result = [];
if (true) { //p_ignoreLigatures
for (let i = 0; i < p_text.length; i++) {
Expand All @@ -233,7 +234,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
* @param {string} p_string accepts : 'a', 'abc', 'aU+0000', 'abcU+0000', 'U+0000U+0000U+0000', 'U+0000-abU+0000U+0000'
* @returns
*/
static TryGetInfosFromString(p_string, p_createLigature = false, p_sep = `-`) {
TryGetInfosFromString(p_string, p_createLigature = false, p_sep = `-`) {

if (!p_string || p_string == ``) { return null; }

Expand All @@ -246,7 +247,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
for (let i = 0; i < resolved.length; i++) {
let uchar = resolved.substr(i, 1);
if (uchar == ``) { continue; }
unicodes.push(UNICODE.GetAddress(uchar));
unicodes.push(this.GetAddress(uchar));
}

glyphInfos = this.GetInfos(unicodes, p_createLigature);
Expand All @@ -262,7 +263,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
* @param {string} p_string accepts : 'a', 'abc', 'aU+0000', 'abcU+0000', 'U+0000U+0000U+0000', 'U+0000-abU+0000U+0000'
* @returns
*/
static ResolveString(p_string, p_sep = `-`) {
ResolveString(p_string, p_sep = `-`) {

if (!p_string || p_string == ``) { return ``; }

Expand All @@ -289,7 +290,7 @@ class UNICODE extends nkm.com.helpers.Singleton {
cPt = Number.parseInt(uHex, 16);

if (!Number.isNaN(cPt)) { result += String.fromCodePoint(cPt); }
else{ result += `U+${uHex}`; }
else { result += `U+${uHex}`; }

if (cSplit.length == 0) { continue; }
if (cSplit.length == 1 && cSplit[0] == ``) { continue; } // Trailing separator : U+0000-
Expand All @@ -307,4 +308,4 @@ class UNICODE extends nkm.com.helpers.Singleton {

}

module.exports = UNICODE;
module.exports = new UNICODE();
28 changes: 9 additions & 19 deletions app/js/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,31 @@ class Bindings extends nkm.com.helpers.BindingKit {
_Init() {
super._Init();

this.AddClasses(
mkfData.Family
);

let unicodeInfos = { name: 1, u: 1, char: 1 };

this.Add(
{
context: nkm.data.catalogs.Catalog,
ctx: nkm.data.catalogs.Catalog,
kvps: [
{ key: mkfData.Glyph, binding: mkfData.Slot },
]
},
{
context: mkfWidgets.lists.UniCategoryGroup,
ctx: mkfWidgets.lists.UniCategoryGroup,
kvps: [
{ key: mkfCatalogs.UniCategory, binding: mkfWidgets.lists.UniCategory },
{ key: mkfCatalogs.UniCategoryGroup, binding: mkfWidgets.lists.UniCategoryGroup },
]
},
{
context: nkm.uilib.lists.FolderListRoot,
ctx: nkm.uilib.lists.FolderListRoot,
kvps: [
{ key: mkfCatalogs.UniCategory, binding: mkfWidgets.lists.UniCategory },
{ key: mkfCatalogs.UniCategoryGroup, binding: mkfWidgets.lists.UniCategoryGroup },
]
},
{
context: nkm.datacontrols.CONTEXT.DEFAULT_EDITOR,
kvps: [
{ key: mkfData.Family, binding: mkfEditors.FontEditor },
]
},
{
context: nkm.datacontrols.CONTEXT.DEFAULT_INSPECTOR,
ctx: nkm.datacontrols.CTX.DEFAULT_INSPECTOR,
kvps: [
{
key: mkfData.Glyph, keys: unicodeInfos,
Expand All @@ -54,7 +44,7 @@ class Bindings extends nkm.com.helpers.BindingKit {
]
},
{
context: nkm.datacontrols.CONTEXT.DEFAULT_LIST_INSPECTOR,
ctx: nkm.datacontrols.CTX.DEFAULT_LIST_INSPECTOR,
kvps: [
{
key: mkfData.Glyph, keys: unicodeInfos,
Expand All @@ -63,14 +53,14 @@ class Bindings extends nkm.com.helpers.BindingKit {
]
},
{
context: nkm.data.serialization.CONTEXT.JSON,
ctx: nkm.data.s11n.CTX.JSON,
kvps: [
{ key: mkfData.Family, binding: mkfData.serialization.json.Family },
{ key: mkfData.Prefs, binding: mkfData.serialization.json.SimpleDataEx }
{ key: mkfData.Family, binding: mkfData.s11n.json.Family },
{ key: mkfData.Prefs, binding: mkfData.s11n.json.FontObjectData }
]
},
{
context: nkm.documents.CONTEXT.DOCUMENT,
ctx: nkm.documents.CTX.DOCUMENT,
kvps: [
{ key: mkfData.Family, binding: nkm.documents.bound.JSONDocument }
]
Expand Down
12 changes: 4 additions & 8 deletions app/js/content-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const IDS = require(`./data/ids`);

const SIGNAL = require(`./signal`);

class ContentManager extends nkm.com.helpers.SingletonEx {
class ContentManager extends nkm.com.Observable {
constructor() { super(); }


Expand All @@ -27,13 +27,9 @@ class ContentManager extends nkm.com.helpers.SingletonEx {

//#region Update

static Push(p_data, p_method) {
this.instance._Push(p_data, p_method);
}

static get ready() { return this.instance._ready; }
get ready() { return this._ready; }

_Push(p_data, p_method) {
Push(p_data, p_method) {

let array = this._dataMap.get(p_data);

Expand Down Expand Up @@ -86,4 +82,4 @@ class ContentManager extends nkm.com.helpers.SingletonEx {

}

module.exports = ContentManager;
module.exports = new ContentManager();
43 changes: 43 additions & 0 deletions app/js/data/app-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const nkm = require(`@nkmjs/core`);
const ENUMS = require("./enums");
const ui = nkm.ui;
const inputs = nkm.uilib.inputs;

const IDS = require(`./ids`);
const IDS_EXT = require(`./ids-ext`);
const IDS_PREFS = require(`./ids-prefs`);

const base = nkm.app.AppSettings;
class AppSettings extends base {
constructor() { super(); }

static __VALUES = {

...base.__VALUES,

[IDS_PREFS.SVG_EDITOR_PATH]: { value: ``, group: IDS_PREFS.GROUP_THIRD_PARTIES },
[IDS_PREFS.ILLU_PATH]: { value: ``, group: IDS_PREFS.GROUP_THIRD_PARTIES },

[IDS_PREFS.MANUAL_PREVIEW_REFRESH_THRESHOLD]: { value: 5000, group: IDS_PREFS.GROUP_DISPLAY },

[IDS_PREFS.MARK_COLOR]: { value: `#FF00FF`, group: IDS_PREFS.GROUP_RESOURCES },
[IDS_EXT.IMPORT_BIND_RESOURCE]: { value: true, group: IDS_PREFS.GROUP_RESOURCES },

[IDS.FAMILY]: { value: `New MKFont`, group: IDS_PREFS.GROUP_DEFAULTS },
[IDS.COPYRIGHT]: { value: `(c) mkfont 2023`, group: IDS_PREFS.GROUP_DEFAULTS },
[IDS.DESCRIPTION]: { value: `Made with mkfont`, group: IDS_PREFS.GROUP_DEFAULTS },
[IDS.URL]: { value: `https://github.com/Nebukam/mkfont`, group: IDS_PREFS.GROUP_DEFAULTS },
[IDS.COLOR_PREVIEW]: { value: `#f5f5f5`, group: IDS_PREFS.GROUP_DEFAULTS },
[IDS.PREVIEW_SIZE]: { value: 70, group: IDS_PREFS.GROUP_DEFAULTS },

};

_Init() {
super._Init();
}

}

module.exports = nkm.data.Register(AppSettings);
Loading

0 comments on commit 4970943

Please sign in to comment.