@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.cjs CHANGED
@@ -6948,6 +6948,9 @@ var require_AstTree = __commonJS({
6948
6948
  {
6949
6949
  $ref: "#/definitions/BlockInput"
6950
6950
  },
6951
+ {
6952
+ $ref: "#/definitions/BlockInclude"
6953
+ },
6951
6954
  {
6952
6955
  $ref: "#/definitions/BlockPara"
6953
6956
  },
@@ -7547,6 +7550,58 @@ var require_AstTree = __commonJS({
7547
7550
  "type"
7548
7551
  ]
7549
7552
  },
7553
+ BlockInclude: {
7554
+ type: "object",
7555
+ properties: {
7556
+ name: {
7557
+ type: "string",
7558
+ enum: [
7559
+ "include"
7560
+ ]
7561
+ },
7562
+ type: {
7563
+ type: "string",
7564
+ enum: [
7565
+ "block"
7566
+ ]
7567
+ },
7568
+ location: {
7569
+ $ref: "#/definitions/Location"
7570
+ },
7571
+ content: {
7572
+ type: "array",
7573
+ items: {
7574
+ $ref: "#/definitions/PodNode"
7575
+ }
7576
+ },
7577
+ margin: {
7578
+ type: "string"
7579
+ },
7580
+ config: {
7581
+ type: "array",
7582
+ items: {
7583
+ anyOf: [
7584
+ {
7585
+ $ref: "#/definitions/BrokenConfigItem"
7586
+ },
7587
+ {
7588
+ $ref: "#/definitions/ConfigItem"
7589
+ }
7590
+ ]
7591
+ }
7592
+ },
7593
+ id: {
7594
+ type: "string"
7595
+ }
7596
+ },
7597
+ required: [
7598
+ "content",
7599
+ "location",
7600
+ "margin",
7601
+ "name",
7602
+ "type"
7603
+ ]
7604
+ },
7550
7605
  BlockPara: {
7551
7606
  type: "object",
7552
7607
  properties: {
@@ -7814,6 +7869,9 @@ var require_AstTree = __commonJS({
7814
7869
  {
7815
7870
  $ref: "#/definitions/BlockInput"
7816
7871
  },
7872
+ {
7873
+ $ref: "#/definitions/BlockInclude"
7874
+ },
7817
7875
  {
7818
7876
  $ref: "#/definitions/BlockPara"
7819
7877
  },
@@ -9642,6 +9700,9 @@ var require_PodliteDocument = __commonJS({
9642
9700
  {
9643
9701
  $ref: "#/definitions/BlockInput"
9644
9702
  },
9703
+ {
9704
+ $ref: "#/definitions/BlockInclude"
9705
+ },
9645
9706
  {
9646
9707
  $ref: "#/definitions/BlockPara"
9647
9708
  },
@@ -10241,6 +10302,58 @@ var require_PodliteDocument = __commonJS({
10241
10302
  "type"
10242
10303
  ]
10243
10304
  },
10305
+ BlockInclude: {
10306
+ type: "object",
10307
+ properties: {
10308
+ name: {
10309
+ type: "string",
10310
+ enum: [
10311
+ "include"
10312
+ ]
10313
+ },
10314
+ type: {
10315
+ type: "string",
10316
+ enum: [
10317
+ "block"
10318
+ ]
10319
+ },
10320
+ location: {
10321
+ $ref: "#/definitions/Location"
10322
+ },
10323
+ content: {
10324
+ type: "array",
10325
+ items: {
10326
+ $ref: "#/definitions/PodNode"
10327
+ }
10328
+ },
10329
+ margin: {
10330
+ type: "string"
10331
+ },
10332
+ config: {
10333
+ type: "array",
10334
+ items: {
10335
+ anyOf: [
10336
+ {
10337
+ $ref: "#/definitions/BrokenConfigItem"
10338
+ },
10339
+ {
10340
+ $ref: "#/definitions/ConfigItem"
10341
+ }
10342
+ ]
10343
+ }
10344
+ },
10345
+ id: {
10346
+ type: "string"
10347
+ }
10348
+ },
10349
+ required: [
10350
+ "content",
10351
+ "location",
10352
+ "margin",
10353
+ "name",
10354
+ "type"
10355
+ ]
10356
+ },
10244
10357
  BlockPara: {
10245
10358
  type: "object",
10246
10359
  properties: {
@@ -10508,6 +10621,9 @@ var require_PodliteDocument = __commonJS({
10508
10621
  {
10509
10622
  $ref: "#/definitions/BlockInput"
10510
10623
  },
10624
+ {
10625
+ $ref: "#/definitions/BlockInclude"
10626
+ },
10511
10627
  {
10512
10628
  $ref: "#/definitions/BlockPara"
10513
10629
  },
@@ -18450,6 +18566,7 @@ var require_grammar = __commonJS({
18450
18566
  "defn",
18451
18567
  "formula",
18452
18568
  "head",
18569
+ "include",
18453
18570
  "input",
18454
18571
  "item",
18455
18572
  "markdown",
@@ -25128,7 +25245,7 @@ var require_package = __commonJS({
25128
25245
  "../podlite-schema/package.json"(exports, module2) {
25129
25246
  module2.exports = {
25130
25247
  name: "@podlite/schema",
25131
- version: "0.0.24",
25248
+ version: "0.0.25",
25132
25249
  description: "AST tools for Podlite markup language",
25133
25250
  main: "./src/index.ts",
25134
25251
  license: "MIT",
@@ -25194,7 +25311,7 @@ __export(exports, {
25194
25311
  });
25195
25312
  var import_react = __toModule(require("react"));
25196
25313
  var import_react_codemirror2 = __toModule(require("react-codemirror2"));
25197
- var import_codemirror = __toModule(require("codemirror"));
25314
+ var import_codemirror3 = __toModule(require("codemirror"));
25198
25315
 
25199
25316
  // src/dict.ts
25200
25317
  var dict = [
@@ -25462,6 +25579,693 @@ var import_searchcursor = __toModule(require("codemirror/addon/search/searchcurs
25462
25579
  var import_dialog = __toModule(require("codemirror/addon/dialog/dialog"));
25463
25580
  var import_dialog2 = __toModule(require("codemirror/addon/dialog/dialog.css"));
25464
25581
 
25582
+ // src/podlite-mode.js
25583
+ var import_codemirror2 = __toModule(require("codemirror"));
25584
+
25585
+ // src/simpleplus.js
25586
+ var import_codemirror = __toModule(require("codemirror"));
25587
+ import_codemirror.default.defineSimpleModePlus = function(name, states) {
25588
+ import_codemirror.default.defineMode(name, function(config) {
25589
+ return import_codemirror.default.simpleModePlus(config, states);
25590
+ });
25591
+ };
25592
+ import_codemirror.default.simpleModePlus = function(config, states) {
25593
+ ensureState(states, "start");
25594
+ var states_ = {}, meta = states.meta || {}, hasIndentation = false;
25595
+ for (var state in states)
25596
+ if (state != meta && states.hasOwnProperty(state)) {
25597
+ var list = states_[state] = [], orig = states[state];
25598
+ for (var i = 0; i < orig.length; i++) {
25599
+ var data = orig[i];
25600
+ list.push(new Rule(data, states));
25601
+ if (data.indent || data.dedent)
25602
+ hasIndentation = true;
25603
+ }
25604
+ }
25605
+ var mode = {
25606
+ startState: function() {
25607
+ return {state: "start", pending: null, local: null, localState: null, indent: hasIndentation ? [] : null};
25608
+ },
25609
+ copyState: function(state2) {
25610
+ var s = {
25611
+ state: state2.state,
25612
+ pending: state2.pending,
25613
+ local: state2.local,
25614
+ localState: null,
25615
+ indent: state2.indent && state2.indent.slice(0),
25616
+ blankLine: state2.blankLine && state2.blankLine
25617
+ };
25618
+ if (state2.localState)
25619
+ s.localState = import_codemirror.default.copyState(state2.local.mode, state2.localState);
25620
+ if (state2.stack)
25621
+ s.stack = state2.stack.slice(0);
25622
+ for (var pers = state2.persistentStates; pers; pers = pers.next)
25623
+ s.persistentStates = {
25624
+ mode: pers.mode,
25625
+ spec: pers.spec,
25626
+ state: pers.state == state2.localState ? s.localState : import_codemirror.default.copyState(pers.mode, pers.state),
25627
+ next: s.persistentStates
25628
+ };
25629
+ return s;
25630
+ },
25631
+ token: tokenFunction(states_, config),
25632
+ innerMode: function(state2) {
25633
+ return state2.local && {mode: state2.local.mode, state: state2.localState};
25634
+ },
25635
+ indent: indentFunction(states_, meta),
25636
+ blankLine: function(state2) {
25637
+ state2.blankLine = 1;
25638
+ }
25639
+ };
25640
+ if (meta) {
25641
+ for (var prop in meta)
25642
+ if (meta.hasOwnProperty(prop))
25643
+ mode[prop] = meta[prop];
25644
+ }
25645
+ return mode;
25646
+ };
25647
+ function ensureState(states, name) {
25648
+ if (!states.hasOwnProperty(name))
25649
+ throw new Error("Undefined state " + name + " in simple mode");
25650
+ }
25651
+ function toRegex(val, caret) {
25652
+ if (!val)
25653
+ return /(?:)/;
25654
+ var flags = "";
25655
+ if (val instanceof RegExp) {
25656
+ if (val.ignoreCase)
25657
+ flags = "i";
25658
+ if (val.unicode)
25659
+ flags += "u";
25660
+ val = val.source;
25661
+ } else {
25662
+ val = String(val);
25663
+ }
25664
+ return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
25665
+ }
25666
+ function asToken(val) {
25667
+ if (!val)
25668
+ return null;
25669
+ if (val.apply)
25670
+ return val;
25671
+ if (typeof val == "string")
25672
+ return val.replace(/\./g, " ");
25673
+ var result = [];
25674
+ for (var i = 0; i < val.length; i++)
25675
+ result.push(val[i] && val[i].replace(/\./g, " "));
25676
+ return result;
25677
+ }
25678
+ function Rule(data, states) {
25679
+ if (data.push)
25680
+ ensureState(states, data.push);
25681
+ this.regex = toRegex(data.regex);
25682
+ this.token = asToken(data.token);
25683
+ this.data = data;
25684
+ }
25685
+ function tokenFunction(states, config) {
25686
+ return function(stream, state) {
25687
+ if (state.pending) {
25688
+ var pend = state.pending.shift();
25689
+ if (state.pending.length == 0)
25690
+ state.pending = null;
25691
+ stream.pos += pend.text.length;
25692
+ return pend.token;
25693
+ }
25694
+ if (state.local) {
25695
+ if (state.local.end && stream.match(state.local.end)) {
25696
+ var tok = state.local.endToken || null;
25697
+ state.local = state.localState = null;
25698
+ return tok;
25699
+ } else {
25700
+ var tok = state.local.mode.token(stream, state.localState), m;
25701
+ if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
25702
+ stream.pos = stream.start + m.index;
25703
+ return tok;
25704
+ }
25705
+ }
25706
+ const ruleBlankLine = states[state.state].find((i2) => i2.data.blankline);
25707
+ if (state.blankLine && ruleBlankLine) {
25708
+ if (ruleBlankLine.data.next) {
25709
+ state.state = ruleBlankLine.data.next;
25710
+ } else if (ruleBlankLine.data.push) {
25711
+ ;
25712
+ (state.stack || (state.stack = [])).push(state.state);
25713
+ state.state = ruleBlankLine.data.push;
25714
+ } else if (ruleBlankLine.data.pop && state.stack && state.stack.length) {
25715
+ state.state = state.stack.pop();
25716
+ }
25717
+ }
25718
+ state.blankLine = void 0;
25719
+ var curState = states[state.state];
25720
+ for (var i = 0; i < curState.length; i++) {
25721
+ var rule = curState[i];
25722
+ var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
25723
+ if (matches) {
25724
+ if (rule.data.next) {
25725
+ var next = rule.data.next;
25726
+ if (next.apply)
25727
+ next = next(matches);
25728
+ state.state = next;
25729
+ } else if (rule.data.push) {
25730
+ ;
25731
+ (state.stack || (state.stack = [])).push(state.state);
25732
+ state.state = rule.data.push;
25733
+ } else if (rule.data.pop && state.stack && state.stack.length) {
25734
+ state.state = state.stack.pop();
25735
+ }
25736
+ if (rule.data.mode)
25737
+ enterLocalMode(config, state, rule.data.mode, rule.token);
25738
+ if (rule.data.indent)
25739
+ state.indent.push(stream.indentation() + config.indentUnit);
25740
+ if (rule.data.dedent)
25741
+ state.indent.pop();
25742
+ var token = rule.token;
25743
+ if (token && token.apply)
25744
+ token = token(matches, state);
25745
+ if (matches.length > 2 && rule.token && typeof rule.token != "string") {
25746
+ for (var j = 2; j < matches.length; j++)
25747
+ if (matches[j])
25748
+ (state.pending || (state.pending = [])).push({text: matches[j], token: token[j - 1]});
25749
+ stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
25750
+ return token[0];
25751
+ } else if (token && token.join) {
25752
+ return token[0];
25753
+ } else {
25754
+ return token;
25755
+ }
25756
+ }
25757
+ }
25758
+ stream.next();
25759
+ return null;
25760
+ };
25761
+ }
25762
+ function cmp(a, b) {
25763
+ if (a === b)
25764
+ return true;
25765
+ if (!a || typeof a != "object" || !b || typeof b != "object")
25766
+ return false;
25767
+ var props = 0;
25768
+ for (var prop in a)
25769
+ if (a.hasOwnProperty(prop)) {
25770
+ if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop]))
25771
+ return false;
25772
+ props++;
25773
+ }
25774
+ for (var prop in b)
25775
+ if (b.hasOwnProperty(prop))
25776
+ props--;
25777
+ return props == 0;
25778
+ }
25779
+ function enterLocalMode(config, state, spec, token) {
25780
+ var pers;
25781
+ if (spec.persistent) {
25782
+ for (var p = state.persistentStates; p && !pers; p = p.next)
25783
+ if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode)
25784
+ pers = p;
25785
+ }
25786
+ var mode = pers ? pers.mode : spec.mode || import_codemirror.default.getMode(config, spec.spec);
25787
+ var lState = pers ? pers.state : import_codemirror.default.startState(mode);
25788
+ if (spec.persistent && !pers)
25789
+ state.persistentStates = {mode, spec: spec.spec, state: lState, next: state.persistentStates};
25790
+ state.localState = lState;
25791
+ state.local = {
25792
+ mode,
25793
+ end: spec.end && toRegex(spec.end),
25794
+ endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
25795
+ endToken: token && token.join ? token[token.length - 1] : token
25796
+ };
25797
+ }
25798
+ function indexOf(val, arr) {
25799
+ for (var i = 0; i < arr.length; i++)
25800
+ if (arr[i] === val)
25801
+ return true;
25802
+ }
25803
+ function indentFunction(states, meta) {
25804
+ return function(state, textAfter, line) {
25805
+ if (state.local && state.local.mode.indent)
25806
+ return state.local.mode.indent(state.localState, textAfter, line);
25807
+ if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
25808
+ return import_codemirror.default.Pass;
25809
+ var pos = state.indent.length - 1, rules2 = states[state.state];
25810
+ scan:
25811
+ for (; ; ) {
25812
+ for (var i = 0; i < rules2.length; i++) {
25813
+ var rule = rules2[i];
25814
+ if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
25815
+ var m = rule.regex.exec(textAfter);
25816
+ if (m && m[0]) {
25817
+ pos--;
25818
+ if (rule.next || rule.push)
25819
+ rules2 = states[rule.next || rule.push];
25820
+ textAfter = textAfter.slice(m[0].length);
25821
+ continue scan;
25822
+ }
25823
+ }
25824
+ }
25825
+ break;
25826
+ }
25827
+ return pos < 0 ? 0 : state.indent[pos];
25828
+ };
25829
+ }
25830
+
25831
+ // src/podlite-mode.js
25832
+ function ifBeginAbbrBlock(ifOk) {
25833
+ const res = [
25834
+ {
25835
+ regex: /\s*(=)(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
25836
+ token: "keyword",
25837
+ sol: true,
25838
+ push: ifOk
25839
+ }
25840
+ ];
25841
+ return res;
25842
+ }
25843
+ function getBlockNames() {
25844
+ const names = [
25845
+ "code",
25846
+ "comment",
25847
+ "data",
25848
+ "defn",
25849
+ "formula",
25850
+ "input",
25851
+ "markdown",
25852
+ "nested",
25853
+ "output",
25854
+ "para",
25855
+ "picture",
25856
+ "pod",
25857
+ "table",
25858
+ "toc",
25859
+ "include"
25860
+ ];
25861
+ names.push(...[...Array(10)].map((_, i) => `head${i + 1}`));
25862
+ names.push(...[...Array(10)].map((_, i) => `item${i + 1}`).reverse());
25863
+ names.push("item", "head");
25864
+ return names;
25865
+ }
25866
+ function getContentState(token = "content") {
25867
+ return [
25868
+ {
25869
+ regex: /(?=\s*=\w+)/,
25870
+ token: "content",
25871
+ sol: true,
25872
+ pop: true
25873
+ },
25874
+ ...getDefaultContentState(token)
25875
+ ];
25876
+ }
25877
+ function getDefaultContentState(token = "content") {
25878
+ const getStateForMarkupCodes = ({token: token2}) => {
25879
+ const allcodes = ["A", "B", "F", "I", "L", "O", "Z"].join("|");
25880
+ const handler = (token3) => (matches) => {
25881
+ var _a;
25882
+ const code = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.code) || "NONEXISTS";
25883
+ const mapCodeToToken = {
25884
+ A: `variable-3 ${token3}`,
25885
+ B: `strong ${token3}`,
25886
+ F: `${token3}`,
25887
+ I: `em ${token3}`,
25888
+ L: `link ${token3}`,
25889
+ O: `strikethrough ${token3}`,
25890
+ Z: `comment ${token3}`
25891
+ };
25892
+ const resultToken = matches[1];
25893
+ return ["keyword", "keyword", mapCodeToToken[resultToken] || token3, "keyword"];
25894
+ };
25895
+ return [
25896
+ {
25897
+ regex: new RegExp(`(?<code>${allcodes})(<)([^>]*)(>)`),
25898
+ token: handler(token2)
25899
+ },
25900
+ {
25901
+ regex: new RegExp(`(?<code>${allcodes})(\xAB)([^\xBB]*)(\xBB)`),
25902
+ token: handler(token2)
25903
+ },
25904
+ {
25905
+ regex: /./,
25906
+ token: token2
25907
+ }
25908
+ ];
25909
+ };
25910
+ return [
25911
+ ...getStateForMarkupCodes({token}),
25912
+ {
25913
+ regex: /./,
25914
+ token
25915
+ }
25916
+ ];
25917
+ }
25918
+ function getVerbatimContentState(token = "content") {
25919
+ return [
25920
+ {
25921
+ regex: /./,
25922
+ token
25923
+ }
25924
+ ];
25925
+ }
25926
+ function isBlankLine(attr = {}) {
25927
+ return [
25928
+ {
25929
+ regex: /^\s*$/,
25930
+ token: null,
25931
+ sol: true,
25932
+ pop: true,
25933
+ ...attr
25934
+ },
25935
+ {
25936
+ regex: /blankline/,
25937
+ token: null,
25938
+ blankline: true,
25939
+ pop: true,
25940
+ ...attr
25941
+ }
25942
+ ];
25943
+ }
25944
+ function getStatesForBlock(blockName, contentToken) {
25945
+ if (blockName.match(/^(?:code|comment|data)$/)) {
25946
+ return {
25947
+ [`${blockName}_content_Abbr`]: [...getVerbatimContentState(contentToken)],
25948
+ [`${blockName}_attr_Para`]: [
25949
+ ...ifNextStartAnyBlock({pop: true}),
25950
+ ...attributesContent({next: `${blockName}_content_Para`})
25951
+ ],
25952
+ [`${blockName}_content_Para`]: [...isBlankLine({pop: true}), ...getVerbatimContentState(contentToken)],
25953
+ [`${blockName}_attr_Delim`]: [...attributesContent({next: `${blockName}_content_Delim`})],
25954
+ [`${blockName}_content_Delim`]: [
25955
+ {
25956
+ regex: new RegExp(`(?=\\s*=end\\s*(?:${blockName}))`),
25957
+ token: null,
25958
+ sol: true,
25959
+ next: "endDelimBlock"
25960
+ },
25961
+ ...getVerbatimContentState(contentToken),
25962
+ {
25963
+ regex: /.*/,
25964
+ token: `content`
25965
+ }
25966
+ ]
25967
+ };
25968
+ }
25969
+ return {
25970
+ [`${blockName}_content_Abbr`]: [...isBlankLine({pop: true}), ...getContentState(contentToken)],
25971
+ [`${blockName}_attr_Para`]: [
25972
+ ...ifNextStartAnyBlock({pop: true}),
25973
+ ...attributesContent({next: `${blockName}_content_Para`})
25974
+ ],
25975
+ [`${blockName}_content_Para`]: [...isBlankLine({pop: true}), ...getContentState(contentToken)],
25976
+ [`${blockName}_attr_Delim`]: [
25977
+ ...ifNextStartAnyBlock({pop: true}),
25978
+ ...attributesContent({next: `${blockName}_content_Delim`})
25979
+ ],
25980
+ [`${blockName}_content_Delim`]: [
25981
+ ...ifNextAliasDirective("beginAliasDirective"),
25982
+ ...ifNextConfigDirective("beginConfigDirective"),
25983
+ ...ifBeginParaBlock("beginParaBlock"),
25984
+ ...ifBeginAbbrBlock("beginAbbrBlock"),
25985
+ ...ifBeginDelimBlock("beginDelimBlock"),
25986
+ ...ifNextEndDelimBlock({next: "endDelimBlock"}),
25987
+ ...getDefaultContentState(contentToken),
25988
+ {
25989
+ regex: /.*/,
25990
+ token: `content`
25991
+ }
25992
+ ]
25993
+ };
25994
+ }
25995
+ function getContentStates() {
25996
+ const names = getBlockNames();
25997
+ const getStateForBlock = (blockName) => {
25998
+ var _a, _b;
25999
+ const matchRes = blockName.match(/(?<blockname>[^\d]+)(?<level>\d*)/);
26000
+ const level = ((_a = matchRes == null ? void 0 : matchRes.groups) == null ? void 0 : _a.level) || 1;
26001
+ const blName = ((_b = matchRes == null ? void 0 : matchRes.groups) == null ? void 0 : _b.blockname) || blockName;
26002
+ if (blName === "head") {
26003
+ return getStatesForBlock(blockName, `header header-${level}`);
26004
+ }
26005
+ if (blName === "comment") {
26006
+ return getStatesForBlock(blockName, `comment`);
26007
+ }
26008
+ return getStatesForBlock(blockName);
26009
+ };
26010
+ return names.reduce((acc, name) => {
26011
+ return {...acc, ...getStateForBlock(name)};
26012
+ }, {});
26013
+ }
26014
+ function ifBlockName(ifOk = "content", attr = {}) {
26015
+ const names = getBlockNames();
26016
+ if (ifOk === "Para") {
26017
+ const res = {
26018
+ regex: /(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26019
+ token: function(matches) {
26020
+ var _a;
26021
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26022
+ return [`variable-2 ${blockName}`];
26023
+ },
26024
+ next: function(matches) {
26025
+ var _a;
26026
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26027
+ return `${blockName}_attr_Para`;
26028
+ }
26029
+ };
26030
+ return [res];
26031
+ }
26032
+ if (ifOk === "Abbr") {
26033
+ const res = {
26034
+ regex: /(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26035
+ token: function(matches) {
26036
+ var _a;
26037
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26038
+ return [`variable-2 ${blockName}`];
26039
+ },
26040
+ next: function(matches) {
26041
+ var _a;
26042
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26043
+ return `${blockName}_content_Abbr`;
26044
+ }
26045
+ };
26046
+ return [res];
26047
+ }
26048
+ if (ifOk === "Delim") {
26049
+ const res = {
26050
+ regex: /(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26051
+ token: function(matches) {
26052
+ var _a;
26053
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26054
+ return [`variable-2 ${blockName}`];
26055
+ },
26056
+ next: function(matches) {
26057
+ var _a;
26058
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26059
+ return `${blockName}_attr_Delim`;
26060
+ }
26061
+ };
26062
+ return [res];
26063
+ }
26064
+ throw new Error("[ifBlockName] Undefined parametr vlue " + ifOk);
26065
+ }
26066
+ function ifNextBeginDelimBlock(attr = {}) {
26067
+ return [
26068
+ {
26069
+ regex: /(?=\s*=begin\s*(?:head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+))/,
26070
+ token: null,
26071
+ sol: true,
26072
+ ...attr
26073
+ }
26074
+ ];
26075
+ }
26076
+ function ifNextEndDelimBlock(attr = {}) {
26077
+ return [
26078
+ {
26079
+ regex: /(?=\s*=end\s*(?:head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+))/,
26080
+ token: null,
26081
+ sol: true,
26082
+ ...attr
26083
+ }
26084
+ ];
26085
+ }
26086
+ function ifNextBeginAbbrBlock(attr = {}) {
26087
+ return [
26088
+ {
26089
+ regex: /(?=\s*=(?:head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include))/,
26090
+ token: null,
26091
+ sol: true,
26092
+ ...attr
26093
+ }
26094
+ ];
26095
+ }
26096
+ function ifNextBeginParaBlock(attr = {}) {
26097
+ return [
26098
+ {
26099
+ regex: /(?=\s*=for\s*(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+))/,
26100
+ token: "keyword",
26101
+ sol: true,
26102
+ ...attr
26103
+ }
26104
+ ];
26105
+ }
26106
+ function ifNextStartAnyBlock(attr = {}) {
26107
+ return [...ifNextBeginDelimBlock(attr), ...ifNextBeginAbbrBlock(attr), ...ifNextBeginParaBlock(attr)];
26108
+ }
26109
+ function attributesContent(attr = {}) {
26110
+ return [
26111
+ ...ifEndOfAttributes(attr),
26112
+ {
26113
+ regex: /(\s*)(=)(\s*)/,
26114
+ token: [null, "keyword", null],
26115
+ sol: true
26116
+ },
26117
+ {
26118
+ regex: /:\w+/,
26119
+ token: "attribute"
26120
+ },
26121
+ {
26122
+ regex: /[<(].*?[>)]/,
26123
+ token: "string"
26124
+ }
26125
+ ];
26126
+ }
26127
+ function ifEndOfAttributes(attr = {}) {
26128
+ return [
26129
+ {
26130
+ regex: /(?!\s*=\s+)/,
26131
+ token: null,
26132
+ sol: true,
26133
+ ...attr
26134
+ }
26135
+ ];
26136
+ }
26137
+ function ifBeginDelimBlock(ifOk) {
26138
+ return [
26139
+ {
26140
+ regex: /\s*(=begin)\s*(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+)/,
26141
+ token: "keyword",
26142
+ sol: true,
26143
+ push: ifOk
26144
+ }
26145
+ ];
26146
+ }
26147
+ function ifBeginParaBlock(ifOk) {
26148
+ return [
26149
+ {
26150
+ regex: /\s*(=for)\s*(?=head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include|\w+)/,
26151
+ token: "keyword",
26152
+ sol: true,
26153
+ push: ifOk
26154
+ }
26155
+ ];
26156
+ }
26157
+ function ifNextAliasDirective(ifOk) {
26158
+ return [
26159
+ {
26160
+ regex: /(?=\s*=alias)/,
26161
+ token: null,
26162
+ sol: true,
26163
+ push: ifOk
26164
+ }
26165
+ ];
26166
+ }
26167
+ function ifNextConfigDirective(ifOk) {
26168
+ return [
26169
+ {
26170
+ regex: /(?=\s*=config)/,
26171
+ token: null,
26172
+ sol: true,
26173
+ push: ifOk
26174
+ }
26175
+ ];
26176
+ }
26177
+ import_codemirror2.default.defineSimpleModePlus("podlite", {
26178
+ start: [
26179
+ ...ifNextAliasDirective("beginAliasDirective"),
26180
+ ...ifNextConfigDirective("beginConfigDirective"),
26181
+ ...ifBeginParaBlock("beginParaBlock"),
26182
+ ...ifBeginAbbrBlock("beginAbbrBlock"),
26183
+ ...ifBeginDelimBlock("beginDelimBlock"),
26184
+ ...getDefaultContentState()
26185
+ ],
26186
+ beginDelimBlock: [
26187
+ ...ifBlockName("Delim"),
26188
+ {
26189
+ regex: /(\w+)(\s*)/,
26190
+ token: [`variable-3`, null],
26191
+ next: "attributes_delim"
26192
+ }
26193
+ ],
26194
+ attributes_delim: [
26195
+ ...ifNextEndDelimBlock({next: "endDelimBlock"}),
26196
+ ...attributesContent({next: "contentDelimBlock"})
26197
+ ],
26198
+ contentDelimBlock: [
26199
+ ...ifBeginParaBlock("beginParaBlock"),
26200
+ ...ifBeginAbbrBlock("beginAbbrBlock"),
26201
+ ...ifBeginDelimBlock("beginDelimBlock"),
26202
+ ...ifNextEndDelimBlock({next: "endDelimBlock"}),
26203
+ ...getDefaultContentState(),
26204
+ {
26205
+ regex: /.*/,
26206
+ token: `content`
26207
+ }
26208
+ ],
26209
+ endDelimBlock: [
26210
+ {
26211
+ regex: /(\s*)(=end)(\s*)(?<blockName>head\d*|item\d*|code|comment|data|defn|formula|input|markdown|nested|output|para|picture|pod|table|toc|include)/,
26212
+ token: function(matches) {
26213
+ var _a;
26214
+ const blockName = ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.blockName) || "default";
26215
+ return [null, "keyword", null, blockName === "comment" ? "comment" : "variable-2"];
26216
+ },
26217
+ sol: true,
26218
+ pop: true
26219
+ },
26220
+ {
26221
+ regex: /(\s*)(=end)(\s*)(\w+)/,
26222
+ token: [null, "keyword", null, "variable-3"],
26223
+ sol: true,
26224
+ pop: true
26225
+ }
26226
+ ],
26227
+ beginAliasDirective: [
26228
+ {
26229
+ regex: /(\s*)(=)(\s+)(.*)$/,
26230
+ token: [null, "keyword", null, "content"],
26231
+ sol: true
26232
+ },
26233
+ {
26234
+ regex: /^(\s*)(=\w+)(\s*)(\w*)(.*)$/,
26235
+ token: [null, "keyword", null, "variable-3", "content"],
26236
+ sol: true
26237
+ },
26238
+ {
26239
+ regex: /(?!\s*=\s+)/,
26240
+ token: null,
26241
+ sol: true,
26242
+ pop: true
26243
+ }
26244
+ ],
26245
+ beginConfigDirective: [
26246
+ {
26247
+ regex: /(\s*)(=\w+)(\s*)/,
26248
+ token: [null, "keyword", null],
26249
+ sol: true,
26250
+ next: "config_attr"
26251
+ }
26252
+ ],
26253
+ config_attr: [...ifNextStartAnyBlock({pop: true}), ...attributesContent({pop: true})],
26254
+ beginParaBlock: [
26255
+ ...ifBlockName("Para"),
26256
+ {
26257
+ regex: /(\w+)(\s*)/,
26258
+ token: ["variable-3", null],
26259
+ next: "attributes"
26260
+ }
26261
+ ],
26262
+ attributes: [...ifNextStartAnyBlock({pop: true}), ...attributesContent({next: "content"})],
26263
+ beginAbbrBlock: [...ifBlockName("Abbr")],
26264
+ content: [...getContentState()],
26265
+ ...getContentStates()
26266
+ });
26267
+ import_codemirror2.default.defineMIME("text/podlite", "podlite");
26268
+
25465
26269
  // ../podlite-schema/src/index.ts
25466
26270
  var import_ajv = __toModule(require_ajv());
25467
26271
  var pointer = __toModule(require_json_pointer());
@@ -26999,7 +27803,8 @@ var Editor = ({
26999
27803
  },
27000
27804
  sourceType = "pod6",
27001
27805
  isControlled = false,
27002
- isAutoComplete = true
27806
+ isAutoComplete = true,
27807
+ isHighlightSource = false
27003
27808
  }) => {
27004
27809
  const [text, updateText] = (0, import_react2.useState)(content2);
27005
27810
  const [marks, updateMarks] = (0, import_react2.useState)([]);
@@ -27039,12 +27844,14 @@ var Editor = ({
27039
27844
  autofocus: true,
27040
27845
  lineWrapping: true,
27041
27846
  viewportMargin: Infinity,
27042
- mode: sourceType !== "md" ? null : {
27043
- name: "gfm",
27044
- tokenTypeOverrides: {
27045
- emoji: "emoji"
27847
+ ...isHighlightSource ? {
27848
+ mode: sourceType !== "md" ? {name: "podlite"} : {
27849
+ name: "gfm",
27850
+ tokenTypeOverrides: {
27851
+ emoji: "emoji"
27852
+ }
27046
27853
  }
27047
- },
27854
+ } : {mode: null},
27048
27855
  theme: isDarkTheme ? "duotone-dark" : "default"
27049
27856
  };
27050
27857
  const previewEl = (0, import_react2.useRef)(null);
@@ -27141,11 +27948,11 @@ var Editor = ({
27141
27948
  return;
27142
27949
  var onChange = function(instance, object) {
27143
27950
  if (object.text[0] === "=" && instance.getRange({ch: 0, line: object.to.line}, object.to).match(/^\s*$/)) {
27144
- import_codemirror.default.showHint(instanceCMLocal, import_codemirror.default.hint.dictionaryHint);
27951
+ import_codemirror3.default.showHint(instanceCMLocal, import_codemirror3.default.hint.dictionaryHint);
27145
27952
  }
27146
27953
  };
27147
27954
  instanceCMLocal.on("change", onChange);
27148
- import_codemirror.default.registerHelper("hint", "dictionaryHint", function(editor) {
27955
+ import_codemirror3.default.registerHelper("hint", "dictionaryHint", function(editor) {
27149
27956
  var cur = editor.getCursor();
27150
27957
  var curLine = editor.getLine(cur.line);
27151
27958
  var start = cur.ch;
@@ -27191,8 +27998,8 @@ var Editor = ({
27191
27998
  });
27192
27999
  return {
27193
28000
  list: resultDict,
27194
- from: import_codemirror.default.Pos(cur.line, start - 1),
27195
- to: import_codemirror.default.Pos(cur.line, end)
28001
+ from: import_codemirror3.default.Pos(cur.line, start - 1),
28002
+ to: import_codemirror3.default.Pos(cur.line, end)
27196
28003
  };
27197
28004
  });
27198
28005
  instanceCMLocal.refresh();