@podlite/editor-react 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -6944,6 +6944,9 @@ var require_AstTree = __commonJS({
6944
6944
  {
6945
6945
  $ref: "#/definitions/BlockInput"
6946
6946
  },
6947
+ {
6948
+ $ref: "#/definitions/BlockInclude"
6949
+ },
6947
6950
  {
6948
6951
  $ref: "#/definitions/BlockPara"
6949
6952
  },
@@ -7543,6 +7546,58 @@ var require_AstTree = __commonJS({
7543
7546
  "type"
7544
7547
  ]
7545
7548
  },
7549
+ BlockInclude: {
7550
+ type: "object",
7551
+ properties: {
7552
+ name: {
7553
+ type: "string",
7554
+ enum: [
7555
+ "include"
7556
+ ]
7557
+ },
7558
+ type: {
7559
+ type: "string",
7560
+ enum: [
7561
+ "block"
7562
+ ]
7563
+ },
7564
+ location: {
7565
+ $ref: "#/definitions/Location"
7566
+ },
7567
+ content: {
7568
+ type: "array",
7569
+ items: {
7570
+ $ref: "#/definitions/PodNode"
7571
+ }
7572
+ },
7573
+ margin: {
7574
+ type: "string"
7575
+ },
7576
+ config: {
7577
+ type: "array",
7578
+ items: {
7579
+ anyOf: [
7580
+ {
7581
+ $ref: "#/definitions/BrokenConfigItem"
7582
+ },
7583
+ {
7584
+ $ref: "#/definitions/ConfigItem"
7585
+ }
7586
+ ]
7587
+ }
7588
+ },
7589
+ id: {
7590
+ type: "string"
7591
+ }
7592
+ },
7593
+ required: [
7594
+ "content",
7595
+ "location",
7596
+ "margin",
7597
+ "name",
7598
+ "type"
7599
+ ]
7600
+ },
7546
7601
  BlockPara: {
7547
7602
  type: "object",
7548
7603
  properties: {
@@ -7810,6 +7865,9 @@ var require_AstTree = __commonJS({
7810
7865
  {
7811
7866
  $ref: "#/definitions/BlockInput"
7812
7867
  },
7868
+ {
7869
+ $ref: "#/definitions/BlockInclude"
7870
+ },
7813
7871
  {
7814
7872
  $ref: "#/definitions/BlockPara"
7815
7873
  },
@@ -9638,6 +9696,9 @@ var require_PodliteDocument = __commonJS({
9638
9696
  {
9639
9697
  $ref: "#/definitions/BlockInput"
9640
9698
  },
9699
+ {
9700
+ $ref: "#/definitions/BlockInclude"
9701
+ },
9641
9702
  {
9642
9703
  $ref: "#/definitions/BlockPara"
9643
9704
  },
@@ -10237,6 +10298,58 @@ var require_PodliteDocument = __commonJS({
10237
10298
  "type"
10238
10299
  ]
10239
10300
  },
10301
+ BlockInclude: {
10302
+ type: "object",
10303
+ properties: {
10304
+ name: {
10305
+ type: "string",
10306
+ enum: [
10307
+ "include"
10308
+ ]
10309
+ },
10310
+ type: {
10311
+ type: "string",
10312
+ enum: [
10313
+ "block"
10314
+ ]
10315
+ },
10316
+ location: {
10317
+ $ref: "#/definitions/Location"
10318
+ },
10319
+ content: {
10320
+ type: "array",
10321
+ items: {
10322
+ $ref: "#/definitions/PodNode"
10323
+ }
10324
+ },
10325
+ margin: {
10326
+ type: "string"
10327
+ },
10328
+ config: {
10329
+ type: "array",
10330
+ items: {
10331
+ anyOf: [
10332
+ {
10333
+ $ref: "#/definitions/BrokenConfigItem"
10334
+ },
10335
+ {
10336
+ $ref: "#/definitions/ConfigItem"
10337
+ }
10338
+ ]
10339
+ }
10340
+ },
10341
+ id: {
10342
+ type: "string"
10343
+ }
10344
+ },
10345
+ required: [
10346
+ "content",
10347
+ "location",
10348
+ "margin",
10349
+ "name",
10350
+ "type"
10351
+ ]
10352
+ },
10240
10353
  BlockPara: {
10241
10354
  type: "object",
10242
10355
  properties: {
@@ -10504,6 +10617,9 @@ var require_PodliteDocument = __commonJS({
10504
10617
  {
10505
10618
  $ref: "#/definitions/BlockInput"
10506
10619
  },
10620
+ {
10621
+ $ref: "#/definitions/BlockInclude"
10622
+ },
10507
10623
  {
10508
10624
  $ref: "#/definitions/BlockPara"
10509
10625
  },
@@ -18446,6 +18562,7 @@ var require_grammar = __commonJS({
18446
18562
  "defn",
18447
18563
  "formula",
18448
18564
  "head",
18565
+ "include",
18449
18566
  "input",
18450
18567
  "item",
18451
18568
  "markdown",
@@ -25124,7 +25241,7 @@ var require_package = __commonJS({
25124
25241
  "../podlite-schema/package.json"(exports, module) {
25125
25242
  module.exports = {
25126
25243
  name: "@podlite/schema",
25127
- version: "0.0.24",
25244
+ version: "0.0.25",
25128
25245
  description: "AST tools for Podlite markup language",
25129
25246
  main: "./src/index.ts",
25130
25247
  license: "MIT",
@@ -25184,7 +25301,7 @@ var require_package = __commonJS({
25184
25301
 
25185
25302
  // src/index.tsx
25186
25303
  import React from "react";
25187
- import {Controlled as CodeMirrorControlled, UnControlled as CodeMirror} from "react-codemirror2";
25304
+ import {Controlled as CodeMirrorControlled, UnControlled as CodeMirror3} from "react-codemirror2";
25188
25305
  import CMirror from "codemirror";
25189
25306
 
25190
25307
  // src/dict.ts
@@ -25453,6 +25570,693 @@ import "codemirror/addon/search/searchcursor";
25453
25570
  import "codemirror/addon/dialog/dialog";
25454
25571
  import "codemirror/addon/dialog/dialog.css";
25455
25572
 
25573
+ // src/podlite-mode.js
25574
+ import CodeMirror2 from "codemirror";
25575
+
25576
+ // src/simpleplus.js
25577
+ import CodeMirror from "codemirror";
25578
+ CodeMirror.defineSimpleModePlus = function(name, states) {
25579
+ CodeMirror.defineMode(name, function(config) {
25580
+ return CodeMirror.simpleModePlus(config, states);
25581
+ });
25582
+ };
25583
+ CodeMirror.simpleModePlus = function(config, states) {
25584
+ ensureState(states, "start");
25585
+ var states_ = {}, meta = states.meta || {}, hasIndentation = false;
25586
+ for (var state in states)
25587
+ if (state != meta && states.hasOwnProperty(state)) {
25588
+ var list = states_[state] = [], orig = states[state];
25589
+ for (var i = 0; i < orig.length; i++) {
25590
+ var data = orig[i];
25591
+ list.push(new Rule(data, states));
25592
+ if (data.indent || data.dedent)
25593
+ hasIndentation = true;
25594
+ }
25595
+ }
25596
+ var mode = {
25597
+ startState: function() {
25598
+ return {state: "start", pending: null, local: null, localState: null, indent: hasIndentation ? [] : null};
25599
+ },
25600
+ copyState: function(state2) {
25601
+ var s = {
25602
+ state: state2.state,
25603
+ pending: state2.pending,
25604
+ local: state2.local,
25605
+ localState: null,
25606
+ indent: state2.indent && state2.indent.slice(0),
25607
+ blankLine: state2.blankLine && state2.blankLine
25608
+ };
25609
+ if (state2.localState)
25610
+ s.localState = CodeMirror.copyState(state2.local.mode, state2.localState);
25611
+ if (state2.stack)
25612
+ s.stack = state2.stack.slice(0);
25613
+ for (var pers = state2.persistentStates; pers; pers = pers.next)
25614
+ s.persistentStates = {
25615
+ mode: pers.mode,
25616
+ spec: pers.spec,
25617
+ state: pers.state == state2.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state),
25618
+ next: s.persistentStates
25619
+ };
25620
+ return s;
25621
+ },
25622
+ token: tokenFunction(states_, config),
25623
+ innerMode: function(state2) {
25624
+ return state2.local && {mode: state2.local.mode, state: state2.localState};
25625
+ },
25626
+ indent: indentFunction(states_, meta),
25627
+ blankLine: function(state2) {
25628
+ state2.blankLine = 1;
25629
+ }
25630
+ };
25631
+ if (meta) {
25632
+ for (var prop in meta)
25633
+ if (meta.hasOwnProperty(prop))
25634
+ mode[prop] = meta[prop];
25635
+ }
25636
+ return mode;
25637
+ };
25638
+ function ensureState(states, name) {
25639
+ if (!states.hasOwnProperty(name))
25640
+ throw new Error("Undefined state " + name + " in simple mode");
25641
+ }
25642
+ function toRegex(val, caret) {
25643
+ if (!val)
25644
+ return /(?:)/;
25645
+ var flags = "";
25646
+ if (val instanceof RegExp) {
25647
+ if (val.ignoreCase)
25648
+ flags = "i";
25649
+ if (val.unicode)
25650
+ flags += "u";
25651
+ val = val.source;
25652
+ } else {
25653
+ val = String(val);
25654
+ }
25655
+ return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
25656
+ }
25657
+ function asToken(val) {
25658
+ if (!val)
25659
+ return null;
25660
+ if (val.apply)
25661
+ return val;
25662
+ if (typeof val == "string")
25663
+ return val.replace(/\./g, " ");
25664
+ var result = [];
25665
+ for (var i = 0; i < val.length; i++)
25666
+ result.push(val[i] && val[i].replace(/\./g, " "));
25667
+ return result;
25668
+ }
25669
+ function Rule(data, states) {
25670
+ if (data.push)
25671
+ ensureState(states, data.push);
25672
+ this.regex = toRegex(data.regex);
25673
+ this.token = asToken(data.token);
25674
+ this.data = data;
25675
+ }
25676
+ function tokenFunction(states, config) {
25677
+ return function(stream, state) {
25678
+ if (state.pending) {
25679
+ var pend = state.pending.shift();
25680
+ if (state.pending.length == 0)
25681
+ state.pending = null;
25682
+ stream.pos += pend.text.length;
25683
+ return pend.token;
25684
+ }
25685
+ if (state.local) {
25686
+ if (state.local.end && stream.match(state.local.end)) {
25687
+ var tok = state.local.endToken || null;
25688
+ state.local = state.localState = null;
25689
+ return tok;
25690
+ } else {
25691
+ var tok = state.local.mode.token(stream, state.localState), m;
25692
+ if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
25693
+ stream.pos = stream.start + m.index;
25694
+ return tok;
25695
+ }
25696
+ }
25697
+ const ruleBlankLine = states[state.state].find((i2) => i2.data.blankline);
25698
+ if (state.blankLine && ruleBlankLine) {
25699
+ if (ruleBlankLine.data.next) {
25700
+ state.state = ruleBlankLine.data.next;
25701
+ } else if (ruleBlankLine.data.push) {
25702
+ ;
25703
+ (state.stack || (state.stack = [])).push(state.state);
25704
+ state.state = ruleBlankLine.data.push;
25705
+ } else if (ruleBlankLine.data.pop && state.stack && state.stack.length) {
25706
+ state.state = state.stack.pop();
25707
+ }
25708
+ }
25709
+ state.blankLine = void 0;
25710
+ var curState = states[state.state];
25711
+ for (var i = 0; i < curState.length; i++) {
25712
+ var rule = curState[i];
25713
+ var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
25714
+ if (matches) {
25715
+ if (rule.data.next) {
25716
+ var next = rule.data.next;
25717
+ if (next.apply)
25718
+ next = next(matches);
25719
+ state.state = next;
25720
+ } else if (rule.data.push) {
25721
+ ;
25722
+ (state.stack || (state.stack = [])).push(state.state);
25723
+ state.state = rule.data.push;
25724
+ } else if (rule.data.pop && state.stack && state.stack.length) {
25725
+ state.state = state.stack.pop();
25726
+ }
25727
+ if (rule.data.mode)
25728
+ enterLocalMode(config, state, rule.data.mode, rule.token);
25729
+ if (rule.data.indent)
25730
+ state.indent.push(stream.indentation() + config.indentUnit);
25731
+ if (rule.data.dedent)
25732
+ state.indent.pop();
25733
+ var token = rule.token;
25734
+ if (token && token.apply)
25735
+ token = token(matches, state);
25736
+ if (matches.length > 2 && rule.token && typeof rule.token != "string") {
25737
+ for (var j = 2; j < matches.length; j++)
25738
+ if (matches[j])
25739
+ (state.pending || (state.pending = [])).push({text: matches[j], token: token[j - 1]});
25740
+ stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
25741
+ return token[0];
25742
+ } else if (token && token.join) {
25743
+ return token[0];
25744
+ } else {
25745
+ return token;
25746
+ }
25747
+ }
25748
+ }
25749
+ stream.next();
25750
+ return null;
25751
+ };
25752
+ }
25753
+ function cmp(a, b) {
25754
+ if (a === b)
25755
+ return true;
25756
+ if (!a || typeof a != "object" || !b || typeof b != "object")
25757
+ return false;
25758
+ var props = 0;
25759
+ for (var prop in a)
25760
+ if (a.hasOwnProperty(prop)) {
25761
+ if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop]))
25762
+ return false;
25763
+ props++;
25764
+ }
25765
+ for (var prop in b)
25766
+ if (b.hasOwnProperty(prop))
25767
+ props--;
25768
+ return props == 0;
25769
+ }
25770
+ function enterLocalMode(config, state, spec, token) {
25771
+ var pers;
25772
+ if (spec.persistent) {
25773
+ for (var p = state.persistentStates; p && !pers; p = p.next)
25774
+ if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode)
25775
+ pers = p;
25776
+ }
25777
+ var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
25778
+ var lState = pers ? pers.state : CodeMirror.startState(mode);
25779
+ if (spec.persistent && !pers)
25780
+ state.persistentStates = {mode, spec: spec.spec, state: lState, next: state.persistentStates};
25781
+ state.localState = lState;
25782
+ state.local = {
25783
+ mode,
25784
+ end: spec.end && toRegex(spec.end),
25785
+ endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
25786
+ endToken: token && token.join ? token[token.length - 1] : token
25787
+ };
25788
+ }
25789
+ function indexOf(val, arr) {
25790
+ for (var i = 0; i < arr.length; i++)
25791
+ if (arr[i] === val)
25792
+ return true;
25793
+ }
25794
+ function indentFunction(states, meta) {
25795
+ return function(state, textAfter, line) {
25796
+ if (state.local && state.local.mode.indent)
25797
+ return state.local.mode.indent(state.localState, textAfter, line);
25798
+ if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
25799
+ return CodeMirror.Pass;
25800
+ var pos = state.indent.length - 1, rules2 = states[state.state];
25801
+ scan:
25802
+ for (; ; ) {
25803
+ for (var i = 0; i < rules2.length; i++) {
25804
+ var rule = rules2[i];
25805
+ if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
25806
+ var m = rule.regex.exec(textAfter);
25807
+ if (m && m[0]) {
25808
+ pos--;
25809
+ if (rule.next || rule.push)
25810
+ rules2 = states[rule.next || rule.push];
25811
+ textAfter = textAfter.slice(m[0].length);
25812
+ continue scan;
25813
+ }
25814
+ }
25815
+ }
25816
+ break;
25817
+ }
25818
+ return pos < 0 ? 0 : state.indent[pos];
25819
+ };
25820
+ }
25821
+
25822
+ // src/podlite-mode.js
25823
+ function ifBeginAbbrBlock(ifOk) {
25824
+ const res = [
25825
+ {
25826
+ regex: /\s*(=)(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
25827
+ token: "keyword",
25828
+ sol: true,
25829
+ push: ifOk
25830
+ }
25831
+ ];
25832
+ return res;
25833
+ }
25834
+ function getBlockNames() {
25835
+ const names = [
25836
+ "code",
25837
+ "comment",
25838
+ "data",
25839
+ "defn",
25840
+ "formula",
25841
+ "input",
25842
+ "markdown",
25843
+ "nested",
25844
+ "output",
25845
+ "para",
25846
+ "picture",
25847
+ "pod",
25848
+ "table",
25849
+ "toc",
25850
+ "include"
25851
+ ];
25852
+ names.push(...[...Array(10)].map((_, i) => `head${i + 1}`));
25853
+ names.push(...[...Array(10)].map((_, i) => `item${i + 1}`).reverse());
25854
+ names.push("item", "head");
25855
+ return names;
25856
+ }
25857
+ function getContentState(token = "content") {
25858
+ return [
25859
+ {
25860
+ regex: /(?=\s*=\w+)/,
25861
+ token: "content",
25862
+ sol: true,
25863
+ pop: true
25864
+ },
25865
+ ...getDefaultContentState(token)
25866
+ ];
25867
+ }
25868
+ function getDefaultContentState(token = "content") {
25869
+ const getStateForMarkupCodes = ({token: token2}) => {
25870
+ const allcodes = ["A", "B", "F", "I", "L", "O", "Z"].join("|");
25871
+ const handler = (token3) => (matches) => {
25872
+ var _a;
25873
+ const code = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.code) || "NONEXISTS";
25874
+ const mapCodeToToken = {
25875
+ A: `variable-3 ${token3}`,
25876
+ B: `strong ${token3}`,
25877
+ F: `${token3}`,
25878
+ I: `em ${token3}`,
25879
+ L: `link ${token3}`,
25880
+ O: `strikethrough ${token3}`,
25881
+ Z: `comment ${token3}`
25882
+ };
25883
+ const resultToken = matches[1];
25884
+ return ["keyword", "keyword", mapCodeToToken[resultToken] || token3, "keyword"];
25885
+ };
25886
+ return [
25887
+ {
25888
+ regex: new RegExp(`(?<code>${allcodes})(<)([^>]*)(>)`),
25889
+ token: handler(token2)
25890
+ },
25891
+ {
25892
+ regex: new RegExp(`(?<code>${allcodes})(\xAB)([^\xBB]*)(\xBB)`),
25893
+ token: handler(token2)
25894
+ },
25895
+ {
25896
+ regex: /./,
25897
+ token: token2
25898
+ }
25899
+ ];
25900
+ };
25901
+ return [
25902
+ ...getStateForMarkupCodes({token}),
25903
+ {
25904
+ regex: /./,
25905
+ token
25906
+ }
25907
+ ];
25908
+ }
25909
+ function getVerbatimContentState(token = "content") {
25910
+ return [
25911
+ {
25912
+ regex: /./,
25913
+ token
25914
+ }
25915
+ ];
25916
+ }
25917
+ function isBlankLine(attr = {}) {
25918
+ return [
25919
+ {
25920
+ regex: /^\s*$/,
25921
+ token: null,
25922
+ sol: true,
25923
+ pop: true,
25924
+ ...attr
25925
+ },
25926
+ {
25927
+ regex: /blankline/,
25928
+ token: null,
25929
+ blankline: true,
25930
+ pop: true,
25931
+ ...attr
25932
+ }
25933
+ ];
25934
+ }
25935
+ function getStatesForBlock(blockName, contentToken) {
25936
+ if (blockName.match(/^(?:code|comment|data)$/)) {
25937
+ return {
25938
+ [`${blockName}_content_Abbr`]: [...getVerbatimContentState(contentToken)],
25939
+ [`${blockName}_attr_Para`]: [
25940
+ ...ifNextStartAnyBlock({pop: true}),
25941
+ ...attributesContent({next: `${blockName}_content_Para`})
25942
+ ],
25943
+ [`${blockName}_content_Para`]: [...isBlankLine({pop: true}), ...getVerbatimContentState(contentToken)],
25944
+ [`${blockName}_attr_Delim`]: [...attributesContent({next: `${blockName}_content_Delim`})],
25945
+ [`${blockName}_content_Delim`]: [
25946
+ {
25947
+ regex: new RegExp(`(?=\\s*=end\\s*(?:${blockName}))`),
25948
+ token: null,
25949
+ sol: true,
25950
+ next: "endDelimBlock"
25951
+ },
25952
+ ...getVerbatimContentState(contentToken),
25953
+ {
25954
+ regex: /.*/,
25955
+ token: `content`
25956
+ }
25957
+ ]
25958
+ };
25959
+ }
25960
+ return {
25961
+ [`${blockName}_content_Abbr`]: [...isBlankLine({pop: true}), ...getContentState(contentToken)],
25962
+ [`${blockName}_attr_Para`]: [
25963
+ ...ifNextStartAnyBlock({pop: true}),
25964
+ ...attributesContent({next: `${blockName}_content_Para`})
25965
+ ],
25966
+ [`${blockName}_content_Para`]: [...isBlankLine({pop: true}), ...getContentState(contentToken)],
25967
+ [`${blockName}_attr_Delim`]: [
25968
+ ...ifNextStartAnyBlock({pop: true}),
25969
+ ...attributesContent({next: `${blockName}_content_Delim`})
25970
+ ],
25971
+ [`${blockName}_content_Delim`]: [
25972
+ ...ifNextAliasDirective("beginAliasDirective"),
25973
+ ...ifNextConfigDirective("beginConfigDirective"),
25974
+ ...ifBeginParaBlock("beginParaBlock"),
25975
+ ...ifBeginAbbrBlock("beginAbbrBlock"),
25976
+ ...ifBeginDelimBlock("beginDelimBlock"),
25977
+ ...ifNextEndDelimBlock({next: "endDelimBlock"}),
25978
+ ...getDefaultContentState(contentToken),
25979
+ {
25980
+ regex: /.*/,
25981
+ token: `content`
25982
+ }
25983
+ ]
25984
+ };
25985
+ }
25986
+ function getContentStates() {
25987
+ const names = getBlockNames();
25988
+ const getStateForBlock = (blockName) => {
25989
+ var _a, _b;
25990
+ const matchRes = blockName.match(/(?<blockname>[^\d]+)(?<level>\d*)/);
25991
+ const level = ((_a = matchRes == null ? void 0 : matchRes.groups) == null ? void 0 : _a.level) || 1;
25992
+ const blName = ((_b = matchRes == null ? void 0 : matchRes.groups) == null ? void 0 : _b.blockname) || blockName;
25993
+ if (blName === "head") {
25994
+ return getStatesForBlock(blockName, `header header-${level}`);
25995
+ }
25996
+ if (blName === "comment") {
25997
+ return getStatesForBlock(blockName, `comment`);
25998
+ }
25999
+ return getStatesForBlock(blockName);
26000
+ };
26001
+ return names.reduce((acc, name) => {
26002
+ return {...acc, ...getStateForBlock(name)};
26003
+ }, {});
26004
+ }
26005
+ function ifBlockName(ifOk = "content", attr = {}) {
26006
+ const names = getBlockNames();
26007
+ if (ifOk === "Para") {
26008
+ const res = {
26009
+ regex: /(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26010
+ token: function(matches) {
26011
+ var _a;
26012
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26013
+ return [`variable-2 ${blockName}`];
26014
+ },
26015
+ next: function(matches) {
26016
+ var _a;
26017
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26018
+ return `${blockName}_attr_Para`;
26019
+ }
26020
+ };
26021
+ return [res];
26022
+ }
26023
+ if (ifOk === "Abbr") {
26024
+ const res = {
26025
+ regex: /(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26026
+ token: function(matches) {
26027
+ var _a;
26028
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26029
+ return [`variable-2 ${blockName}`];
26030
+ },
26031
+ next: function(matches) {
26032
+ var _a;
26033
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26034
+ return `${blockName}_content_Abbr`;
26035
+ }
26036
+ };
26037
+ return [res];
26038
+ }
26039
+ if (ifOk === "Delim") {
26040
+ const res = {
26041
+ regex: /(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26042
+ token: function(matches) {
26043
+ var _a;
26044
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26045
+ return [`variable-2 ${blockName}`];
26046
+ },
26047
+ next: function(matches) {
26048
+ var _a;
26049
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26050
+ return `${blockName}_attr_Delim`;
26051
+ }
26052
+ };
26053
+ return [res];
26054
+ }
26055
+ throw new Error("[ifBlockName] Undefined parametr vlue " + ifOk);
26056
+ }
26057
+ function ifNextBeginDelimBlock(attr = {}) {
26058
+ return [
26059
+ {
26060
+ regex: /(?=\s*=begin\s*(?:head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+))/,
26061
+ token: null,
26062
+ sol: true,
26063
+ ...attr
26064
+ }
26065
+ ];
26066
+ }
26067
+ function ifNextEndDelimBlock(attr = {}) {
26068
+ return [
26069
+ {
26070
+ regex: /(?=\s*=end\s*(?:head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+))/,
26071
+ token: null,
26072
+ sol: true,
26073
+ ...attr
26074
+ }
26075
+ ];
26076
+ }
26077
+ function ifNextBeginAbbrBlock(attr = {}) {
26078
+ return [
26079
+ {
26080
+ regex: /(?=\s*=(?:head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include))/,
26081
+ token: null,
26082
+ sol: true,
26083
+ ...attr
26084
+ }
26085
+ ];
26086
+ }
26087
+ function ifNextBeginParaBlock(attr = {}) {
26088
+ return [
26089
+ {
26090
+ regex: /(?=\s*=for\s*(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+))/,
26091
+ token: "keyword",
26092
+ sol: true,
26093
+ ...attr
26094
+ }
26095
+ ];
26096
+ }
26097
+ function ifNextStartAnyBlock(attr = {}) {
26098
+ return [...ifNextBeginDelimBlock(attr), ...ifNextBeginAbbrBlock(attr), ...ifNextBeginParaBlock(attr)];
26099
+ }
26100
+ function attributesContent(attr = {}) {
26101
+ return [
26102
+ ...ifEndOfAttributes(attr),
26103
+ {
26104
+ regex: /(\s*)(=)(\s*)/,
26105
+ token: [null, "keyword", null],
26106
+ sol: true
26107
+ },
26108
+ {
26109
+ regex: /:\w+/,
26110
+ token: "attribute"
26111
+ },
26112
+ {
26113
+ regex: /[<(].*?[>)]/,
26114
+ token: "string"
26115
+ }
26116
+ ];
26117
+ }
26118
+ function ifEndOfAttributes(attr = {}) {
26119
+ return [
26120
+ {
26121
+ regex: /(?!\s*=\s+)/,
26122
+ token: null,
26123
+ sol: true,
26124
+ ...attr
26125
+ }
26126
+ ];
26127
+ }
26128
+ function ifBeginDelimBlock(ifOk) {
26129
+ return [
26130
+ {
26131
+ regex: /\s*(=begin)\s*(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+)/,
26132
+ token: "keyword",
26133
+ sol: true,
26134
+ push: ifOk
26135
+ }
26136
+ ];
26137
+ }
26138
+ function ifBeginParaBlock(ifOk) {
26139
+ return [
26140
+ {
26141
+ regex: /\s*(=for)\s*(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+)/,
26142
+ token: "keyword",
26143
+ sol: true,
26144
+ push: ifOk
26145
+ }
26146
+ ];
26147
+ }
26148
+ function ifNextAliasDirective(ifOk) {
26149
+ return [
26150
+ {
26151
+ regex: /(?=\s*=alias)/,
26152
+ token: null,
26153
+ sol: true,
26154
+ push: ifOk
26155
+ }
26156
+ ];
26157
+ }
26158
+ function ifNextConfigDirective(ifOk) {
26159
+ return [
26160
+ {
26161
+ regex: /(?=\s*=config)/,
26162
+ token: null,
26163
+ sol: true,
26164
+ push: ifOk
26165
+ }
26166
+ ];
26167
+ }
26168
+ CodeMirror2.defineSimpleModePlus("podlite", {
26169
+ start: [
26170
+ ...ifNextAliasDirective("beginAliasDirective"),
26171
+ ...ifNextConfigDirective("beginConfigDirective"),
26172
+ ...ifBeginParaBlock("beginParaBlock"),
26173
+ ...ifBeginAbbrBlock("beginAbbrBlock"),
26174
+ ...ifBeginDelimBlock("beginDelimBlock"),
26175
+ ...getDefaultContentState()
26176
+ ],
26177
+ beginDelimBlock: [
26178
+ ...ifBlockName("Delim"),
26179
+ {
26180
+ regex: /(\w+)(\s*)/,
26181
+ token: [`variable-3`, null],
26182
+ next: "attributes_delim"
26183
+ }
26184
+ ],
26185
+ attributes_delim: [
26186
+ ...ifNextEndDelimBlock({next: "endDelimBlock"}),
26187
+ ...attributesContent({next: "contentDelimBlock"})
26188
+ ],
26189
+ contentDelimBlock: [
26190
+ ...ifBeginParaBlock("beginParaBlock"),
26191
+ ...ifBeginAbbrBlock("beginAbbrBlock"),
26192
+ ...ifBeginDelimBlock("beginDelimBlock"),
26193
+ ...ifNextEndDelimBlock({next: "endDelimBlock"}),
26194
+ ...getDefaultContentState(),
26195
+ {
26196
+ regex: /.*/,
26197
+ token: `content`
26198
+ }
26199
+ ],
26200
+ endDelimBlock: [
26201
+ {
26202
+ regex: /(\s*)(=end)(\s*)(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26203
+ token: function(matches) {
26204
+ var _a;
26205
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26206
+ return [null, "keyword", null, blockName === "comment" ? "comment" : "variable-2"];
26207
+ },
26208
+ sol: true,
26209
+ pop: true
26210
+ },
26211
+ {
26212
+ regex: /(\s*)(=end)(\s*)(\w+)/,
26213
+ token: [null, "keyword", null, "variable-3"],
26214
+ sol: true,
26215
+ pop: true
26216
+ }
26217
+ ],
26218
+ beginAliasDirective: [
26219
+ {
26220
+ regex: /(\s*)(=)(\s+)(.*)$/,
26221
+ token: [null, "keyword", null, "content"],
26222
+ sol: true
26223
+ },
26224
+ {
26225
+ regex: /^(\s*)(=\w+)(\s*)(\w*)(.*)$/,
26226
+ token: [null, "keyword", null, "variable-3", "content"],
26227
+ sol: true
26228
+ },
26229
+ {
26230
+ regex: /(?!\s*=\s+)/,
26231
+ token: null,
26232
+ sol: true,
26233
+ pop: true
26234
+ }
26235
+ ],
26236
+ beginConfigDirective: [
26237
+ {
26238
+ regex: /(\s*)(=\w+)(\s*)/,
26239
+ token: [null, "keyword", null],
26240
+ sol: true,
26241
+ next: "config_attr"
26242
+ }
26243
+ ],
26244
+ config_attr: [...ifNextStartAnyBlock({pop: true}), ...attributesContent({pop: true})],
26245
+ beginParaBlock: [
26246
+ ...ifBlockName("Para"),
26247
+ {
26248
+ regex: /(\w+)(\s*)/,
26249
+ token: ["variable-3", null],
26250
+ next: "attributes"
26251
+ }
26252
+ ],
26253
+ attributes: [...ifNextStartAnyBlock({pop: true}), ...attributesContent({next: "content"})],
26254
+ beginAbbrBlock: [...ifBlockName("Abbr")],
26255
+ content: [...getContentState()],
26256
+ ...getContentStates()
26257
+ });
26258
+ CodeMirror2.defineMIME("text/podlite", "podlite");
26259
+
25456
26260
  // ../podlite-schema/src/index.ts
25457
26261
  var import_ajv = __toModule(require_ajv());
25458
26262
  var pointer = __toModule(require_json_pointer());
@@ -26990,7 +27794,8 @@ var Editor = ({
26990
27794
  },
26991
27795
  sourceType = "pod6",
26992
27796
  isControlled = false,
26993
- isAutoComplete = true
27797
+ isAutoComplete = true,
27798
+ isHighlightSource = false
26994
27799
  }) => {
26995
27800
  const [text, updateText] = useState(content2);
26996
27801
  const [marks, updateMarks] = useState([]);
@@ -27030,12 +27835,14 @@ var Editor = ({
27030
27835
  autofocus: true,
27031
27836
  lineWrapping: true,
27032
27837
  viewportMargin: Infinity,
27033
- mode: sourceType !== "md" ? null : {
27034
- name: "gfm",
27035
- tokenTypeOverrides: {
27036
- emoji: "emoji"
27838
+ ...isHighlightSource ? {
27839
+ mode: sourceType !== "md" ? {name: "podlite"} : {
27840
+ name: "gfm",
27841
+ tokenTypeOverrides: {
27842
+ emoji: "emoji"
27843
+ }
27037
27844
  }
27038
- },
27845
+ } : {mode: null},
27039
27846
  theme: isDarkTheme ? "duotone-dark" : "default"
27040
27847
  };
27041
27848
  const previewEl = useRef(null);
@@ -27212,7 +28019,7 @@ var Editor = ({
27212
28019
  onScroll: scrollEditorHandler,
27213
28020
  options,
27214
28021
  className: "editorApp"
27215
- }) : /* @__PURE__ */ React.createElement(CodeMirror, {
28022
+ }) : /* @__PURE__ */ React.createElement(CodeMirror3, {
27216
28023
  value: content2,
27217
28024
  editorDidMount: (editor) => {
27218
28025
  instanceCM = editor;