@podlite/editor-react 0.0.21 → 0.0.23

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Upcoming
4
4
 
5
+ ## 0.0.22
6
+
7
+ - support for `=Mermaid` block
8
+ - add text search in document / cmd-F
9
+ - support for `=picture` block
10
+ - fix detect markdown context for suggestions
11
+
12
+
5
13
  ## 0.0.20
6
14
 
7
15
  - support for `=toc` block
package/lib/index.cjs CHANGED
@@ -6918,6 +6918,9 @@ var require_AstTree = __commonJS({
6918
6918
  {
6919
6919
  $ref: "#/definitions/BlockImage"
6920
6920
  },
6921
+ {
6922
+ $ref: "#/definitions/BlockPicture"
6923
+ },
6921
6924
  {
6922
6925
  $ref: "#/definitions/BlockCaption"
6923
6926
  },
@@ -7256,6 +7259,71 @@ var require_AstTree = __commonJS({
7256
7259
  "value"
7257
7260
  ]
7258
7261
  },
7262
+ BlockPicture: {
7263
+ type: "object",
7264
+ properties: {
7265
+ name: {
7266
+ type: "string",
7267
+ enum: [
7268
+ "picture"
7269
+ ]
7270
+ },
7271
+ caption: {
7272
+ type: "string"
7273
+ },
7274
+ link: {
7275
+ type: "string"
7276
+ },
7277
+ content: {
7278
+ type: "array",
7279
+ items: [
7280
+ {
7281
+ $ref: "#/definitions/Image"
7282
+ },
7283
+ {
7284
+ $ref: "#/definitions/BlockCaption"
7285
+ }
7286
+ ],
7287
+ minItems: 2,
7288
+ maxItems: 2
7289
+ },
7290
+ type: {
7291
+ type: "string",
7292
+ enum: [
7293
+ "block"
7294
+ ]
7295
+ },
7296
+ location: {
7297
+ $ref: "#/definitions/Location"
7298
+ },
7299
+ margin: {
7300
+ type: "string"
7301
+ },
7302
+ config: {
7303
+ type: "array",
7304
+ items: {
7305
+ anyOf: [
7306
+ {
7307
+ $ref: "#/definitions/BrokenConfigItem"
7308
+ },
7309
+ {
7310
+ $ref: "#/definitions/ConfigItem"
7311
+ }
7312
+ ]
7313
+ }
7314
+ },
7315
+ id: {
7316
+ type: "string"
7317
+ }
7318
+ },
7319
+ required: [
7320
+ "content",
7321
+ "location",
7322
+ "margin",
7323
+ "name",
7324
+ "type"
7325
+ ]
7326
+ },
7259
7327
  RootBlock: {
7260
7328
  type: "object",
7261
7329
  properties: {
@@ -7975,6 +8043,9 @@ var require_AstTree = __commonJS({
7975
8043
  {
7976
8044
  $ref: "#/definitions/BlockImage"
7977
8045
  },
8046
+ {
8047
+ $ref: "#/definitions/BlockPicture"
8048
+ },
7978
8049
  {
7979
8050
  $ref: "#/definitions/BlockCaption"
7980
8051
  },
@@ -9350,6 +9421,9 @@ var require_PodliteDocument = __commonJS({
9350
9421
  {
9351
9422
  $ref: "#/definitions/BlockImage"
9352
9423
  },
9424
+ {
9425
+ $ref: "#/definitions/BlockPicture"
9426
+ },
9353
9427
  {
9354
9428
  $ref: "#/definitions/BlockCaption"
9355
9429
  },
@@ -9688,6 +9762,71 @@ var require_PodliteDocument = __commonJS({
9688
9762
  "value"
9689
9763
  ]
9690
9764
  },
9765
+ BlockPicture: {
9766
+ type: "object",
9767
+ properties: {
9768
+ name: {
9769
+ type: "string",
9770
+ enum: [
9771
+ "picture"
9772
+ ]
9773
+ },
9774
+ caption: {
9775
+ type: "string"
9776
+ },
9777
+ link: {
9778
+ type: "string"
9779
+ },
9780
+ content: {
9781
+ type: "array",
9782
+ items: [
9783
+ {
9784
+ $ref: "#/definitions/Image"
9785
+ },
9786
+ {
9787
+ $ref: "#/definitions/BlockCaption"
9788
+ }
9789
+ ],
9790
+ minItems: 2,
9791
+ maxItems: 2
9792
+ },
9793
+ type: {
9794
+ type: "string",
9795
+ enum: [
9796
+ "block"
9797
+ ]
9798
+ },
9799
+ location: {
9800
+ $ref: "#/definitions/Location"
9801
+ },
9802
+ margin: {
9803
+ type: "string"
9804
+ },
9805
+ config: {
9806
+ type: "array",
9807
+ items: {
9808
+ anyOf: [
9809
+ {
9810
+ $ref: "#/definitions/BrokenConfigItem"
9811
+ },
9812
+ {
9813
+ $ref: "#/definitions/ConfigItem"
9814
+ }
9815
+ ]
9816
+ }
9817
+ },
9818
+ id: {
9819
+ type: "string"
9820
+ }
9821
+ },
9822
+ required: [
9823
+ "content",
9824
+ "location",
9825
+ "margin",
9826
+ "name",
9827
+ "type"
9828
+ ]
9829
+ },
9691
9830
  RootBlock: {
9692
9831
  type: "object",
9693
9832
  properties: {
@@ -10407,6 +10546,9 @@ var require_PodliteDocument = __commonJS({
10407
10546
  {
10408
10547
  $ref: "#/definitions/BlockImage"
10409
10548
  },
10549
+ {
10550
+ $ref: "#/definitions/BlockPicture"
10551
+ },
10410
10552
  {
10411
10553
  $ref: "#/definitions/BlockCaption"
10412
10554
  },
@@ -12232,7 +12374,7 @@ var require_grammar = __commonJS({
12232
12374
  }, peg$c117 = function(number) {
12233
12375
  return parseInt(number, 10);
12234
12376
  }, peg$c118 = function(vmargin, name, config) {
12235
- return name.match(/code|comment|output|input|markdown|toc|data/) || isNamedBlock2(name);
12377
+ return name.match(/code|comment|output|input|markdown|picture|toc|data/) || isNamedBlock2(name);
12236
12378
  }, peg$c119 = function(vmargin, name, config, margins, ename) {
12237
12379
  return vmargin.length === margins.length && name === ename;
12238
12380
  }, peg$c120 = function(vmargin, name, config, margins, line) {
@@ -12381,7 +12523,7 @@ var require_grammar = __commonJS({
12381
12523
  }, peg$c151 = /^[s]/, peg$c152 = peg$classExpectation(["s"], false, false), peg$c153 = function(line) {
12382
12524
  return {text: text(), type: "ambient1"};
12383
12525
  }, peg$c154 = function(vmargin, name) {
12384
- return name.match(/code|comment|output|input|markdown|toc|data/) || isNamedBlock2(name);
12526
+ return name.match(/code|comment|output|input|markdown|picture|toc|data/) || isNamedBlock2(name);
12385
12527
  }, peg$c155 = function(vmargin, name, content2) {
12386
12528
  return {
12387
12529
  margin: vmargin,
@@ -12441,7 +12583,7 @@ var require_grammar = __commonJS({
12441
12583
  margin: vmargin
12442
12584
  };
12443
12585
  }, peg$c168 = function(vmargin, marker, name, config) {
12444
- return name.match(/code|comment|output|input|markdown|toc|data/) || isNamedBlock2(name);
12586
+ return name.match(/code|comment|output|input|markdown|picture|toc|data/) || isNamedBlock2(name);
12445
12587
  }, peg$c169 = function(vmargin, marker, name, config, content2) {
12446
12588
  return {
12447
12589
  type: "block",
@@ -17878,6 +18020,7 @@ var require_grammar = __commonJS({
17878
18020
  "nested",
17879
18021
  "output",
17880
18022
  "para",
18023
+ "picture",
17881
18024
  "pod",
17882
18025
  "table",
17883
18026
  "toc"
@@ -21765,7 +21908,7 @@ var require_package = __commonJS({
21765
21908
  "../podlite-schema/package.json"(exports, module2) {
21766
21909
  module2.exports = {
21767
21910
  name: "@podlite/schema",
21768
- version: "0.0.15",
21911
+ version: "0.0.17",
21769
21912
  description: "AST tools for Podlite markup language",
21770
21913
  main: "./src/index.ts",
21771
21914
  types: "./lib/index.d.ts",
@@ -21876,8 +22019,8 @@ var dict = [
21876
22019
  `
21877
22020
  },
21878
22021
  {
21879
- displayText: "Image \u{1F3F7}",
21880
- text: `=Image https://github.com/zag/podlite-desktop/blob/master/dist-assets/linux-icon/256x256.png?raw=true
22022
+ displayText: "picture \u{1F3F7}",
22023
+ text: `=picture https://github.com/zag/podlite-desktop/blob/master/dist-assets/linux-icon/256x256.png?raw=true
21881
22024
  `
21882
22025
  },
21883
22026
  {
@@ -21909,19 +22052,19 @@ Everything else 57
21909
22052
  `
21910
22053
  },
21911
22054
  {
21912
- displayText: "Diagram simple \u{1F3F7}",
21913
- text: `=begin Diagram :caption('Caption of diagram')
22055
+ displayText: "Mermaid diagram simple \u{1F3F7}",
22056
+ text: `=begin Mermaid :caption('Caption of diagram')
21914
22057
  graph LR
21915
22058
  A-->B
21916
22059
  B-->C
21917
22060
  C-->A
21918
22061
  D-->C
21919
- =end Diagram
22062
+ =end Mermaid
21920
22063
  `
21921
22064
  },
21922
22065
  {
21923
- displayText: "Diagram Sequence \u{1F3F7}",
21924
- text: `=for Diagram :caption('Caption of diagram')
22066
+ displayText: "Mermaid diagram Sequence \u{1F3F7}",
22067
+ text: `=for Mermaid :caption('Caption of diagram')
21925
22068
  sequenceDiagram
21926
22069
  autonumber
21927
22070
  Student->>Admin: Can I enrol this semester?
@@ -21936,8 +22079,8 @@ Everything else 57
21936
22079
  `
21937
22080
  },
21938
22081
  {
21939
- displayText: "Diagram flowchart \u{1F3F7}",
21940
- text: `=for Diagram :caption('Caption of diagram')
22082
+ displayText: "Mermaid flowchart \u{1F3F7}",
22083
+ text: `=for Mermaid :caption('Caption of diagram')
21941
22084
  graph LR
21942
22085
  A[Square Rect] -- Link text --> B((Circle))
21943
22086
  A --> C(Round Rect)
@@ -21947,8 +22090,8 @@ Everything else 57
21947
22090
  `
21948
22091
  },
21949
22092
  {
21950
- displayText: "Diagram class \u{1F3F7}",
21951
- text: `=for Diagram :caption('Caption of diagram')
22093
+ displayText: "Mermaid class \u{1F3F7}",
22094
+ text: `=for Mermaid :caption('Caption of diagram')
21952
22095
  classDiagram
21953
22096
  Person <|-- Student
21954
22097
  Person <|-- Professor
@@ -21981,7 +22124,7 @@ Everything else 57
21981
22124
  {
21982
22125
  displayText: "code block with formatting \u{1F3F7}",
21983
22126
  text: `=begin code :allow<I B Z>
21984
-
22127
+ {}
21985
22128
  =end code
21986
22129
  `
21987
22130
  },
@@ -21998,9 +22141,9 @@ head1, head2, head3
21998
22141
  `
21999
22142
  },
22000
22143
  {
22001
- displayText: "toc ( Images, Diagrams ) + tables \u{1F3F7}",
22144
+ displayText: "toc ( picture, Mermaid ) + tables \u{1F3F7}",
22002
22145
  text: `=for toc :title('List of media')
22003
- Image, Diagram
22146
+ picture, Mermaid
22004
22147
  =for toc :title('List of tables')
22005
22148
  table
22006
22149
 
@@ -22041,7 +22184,7 @@ table
22041
22184
  lang: "md"
22042
22185
  },
22043
22186
  {
22044
- displayText: "Image \u{1F3F7}",
22187
+ displayText: "picture \u{1F3F7}",
22045
22188
  text: `![Podlite](https://github.com/zag/podlite-desktop/blob/master/dist-assets/linux-icon/256x256.png?raw=true "Podlite logo")
22046
22189
 
22047
22190
  `,
@@ -22058,8 +22201,8 @@ table
22058
22201
  lang: "md"
22059
22202
  },
22060
22203
  {
22061
- displayText: "Diagram simple \u{1F3F7}",
22062
- text: `\`\`\`diagram
22204
+ displayText: "Mermaid simple \u{1F3F7}",
22205
+ text: `\`\`\`mermaid
22063
22206
  graph LR
22064
22207
  A-->B
22065
22208
  B-->C
@@ -22077,6 +22220,10 @@ var import_react_is = __toModule(require_react_is());
22077
22220
  var import_gfm = __toModule(require("codemirror/mode/gfm/gfm"));
22078
22221
  var import_show_hint = __toModule(require("codemirror/addon/hint/show-hint"));
22079
22222
  var import_show_hint2 = __toModule(require("codemirror/addon/hint/show-hint.css"));
22223
+ var import_search = __toModule(require("codemirror/addon/search/search"));
22224
+ var import_searchcursor = __toModule(require("codemirror/addon/search/searchcursor"));
22225
+ var import_dialog = __toModule(require("codemirror/addon/dialog/dialog"));
22226
+ var import_dialog2 = __toModule(require("codemirror/addon/dialog/dialog.css"));
22080
22227
 
22081
22228
  // ../podlite-schema/src/index.ts
22082
22229
  var import_ajv = __toModule(require_ajv());
@@ -22710,6 +22857,9 @@ var toAnyRules = (method, allplugins) => {
22710
22857
  };
22711
22858
 
22712
22859
  // ../podlite-schema/src/helpers/ids.ts
22860
+ var slugifyText = (text) => {
22861
+ return text.trim().replace(/\s+/g, "-").replace(/[\]\[\!\/\'\"\#\$\%\&\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\{\|\}\~\`。,、;:?!…—·ˉ¨‘’“”々~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}]/g, "").replace(/^\-+/, "");
22862
+ };
22713
22863
  var middleware = () => (tree) => {
22714
22864
  const transformerBlocks = makeTransformer({
22715
22865
  "*": (node, ctx, visiter) => {
@@ -22718,7 +22868,7 @@ var middleware = () => (tree) => {
22718
22868
  if (node2.name == "caption") {
22719
22869
  return node2;
22720
22870
  } else if (node2.name == "head") {
22721
- return {...node2, id: getTextContentFromNode(node2).trim()};
22871
+ return {...node2, id: slugifyText(getTextContentFromNode(node2))};
22722
22872
  } else {
22723
22873
  return {...node2, id: nanoid()};
22724
22874
  }
@@ -22875,8 +23025,9 @@ var middle2 = () => (tree) => {
22875
23025
  const isCodeBlock = "name" in n && n.name === "code";
22876
23026
  const isDataBlock = "name" in n && n.name === "data";
22877
23027
  const isMarkdownBlock = "name" in n && n.name === "markdown";
23028
+ const isPictureBlock = "name" in n && n.name === "picture";
22878
23029
  const allowValues = conf.getAllValues("allow");
22879
- if ((isCodeBlock || isDataBlock || isMarkdownBlock) && allowValues.length == 0)
23030
+ if ((isCodeBlock || isDataBlock || isMarkdownBlock || isPictureBlock) && allowValues.length == 0)
22880
23031
  return n;
22881
23032
  const allowed = allowValues.sort();
22882
23033
  const transformer = makeTransformer_default({
@@ -23541,7 +23692,7 @@ var parse4 = (str) => {
23541
23692
  };
23542
23693
  var getSuggestionContextForLine = (pod, line) => {
23543
23694
  const tree = parse4(pod);
23544
- const markdownBlocks = getFromTree(tree, "Markdown");
23695
+ const markdownBlocks = getFromTree(tree, "Markdown", "markdown");
23545
23696
  const isMd = markdownBlocks.findIndex(({
23546
23697
  location: {
23547
23698
  start: {line: lineStart},