@omegagrid/markdown 0.10.42 → 0.10.44

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.
@@ -1 +1 @@
1
- import{isInCodeBlock,isInList}from"./utils";import{msg}from"@omegagrid/localize";function isDocEmpty(e){return e.childCount<=1&&!e.firstChild?.content.size}function createPlaceholderDecoration(e,t,o){const{selection:n}=t;if(!n.empty)return null;const r=n.$anchor,c=r.parent;if(c.content.size>0)return null;const i=e.prose.findParent((e=>"table"===e.type.name))(r);if(i)return null;const l=r.before();return e.prose.view.Decoration.node(l,l+c.nodeSize,{class:"crepe-placeholder","data-placeholder":o})}export const createDefaultPlaceholderConfig=()=>({text:msg("Start typing..."),mode:"block"});export const createPlaceHolder=e=>{const t=e.utils.$ctx(createDefaultPlaceholderConfig(),"placeholderConfigCtx");return{plugin:e.utils.$prose((o=>new e.prose.state.Plugin({key:new e.prose.state.PluginKey("MARKDOWN_PLACEHOLDER"),props:{decorations:n=>{const r=o.get(e.core.editorViewCtx);if(r&&!r.editable)return null;const c=o.get(t.key);if("doc"===c.mode&&!isDocEmpty(n.doc))return null;if(isInCodeBlock(n.selection)||isInList(n.selection))return null;const i=c.text??msg("Start typing..."),l=createPlaceholderDecoration(e,n,i);return l?e.prose.view.DecorationSet.create(n.doc,[l]):null}}}))),config:t}};
1
+ import{isInCodeBlock,isInList}from"./utils";import{msg}from"@omegagrid/localize";function isDocEmpty(e){return e.childCount<=1&&!e.firstChild?.content.size}function createPlaceholderDecoration(e,t,o){const{selection:n}=t;if(!n.empty)return null;const r=n.$anchor,c=r.parent;if(c.content.size>0)return null;const i=e.prose.findParent((e=>"table"===e.type.name))(r);if(i)return null;const l=r.before();return e.prose.view.Decoration.node(l,l+c.nodeSize,{class:"crepe-placeholder","data-placeholder":o})}export const createDefaultPlaceholderConfig=()=>({text:msg("Start typing..."),mode:"block"});export const createPlaceHolder=e=>{const t=e.utils.$ctx(createDefaultPlaceholderConfig(),"placeholderConfigCtx");return{plugin:e.utils.$prose((o=>new e.prose.state.Plugin({key:new e.prose.state.PluginKey("MARKDOWN_PLACEHOLDER"),props:{decorations:n=>{const r=o.get(e.core.editorViewCtx);if(r&&!1===r.editable)return null;const c=o.get(t.key);if("doc"===c.mode&&!isDocEmpty(n.doc))return null;if(isInCodeBlock(n.selection)||isInList(n.selection))return null;const i=c.text??msg("Start typing..."),l=createPlaceholderDecoration(e,n,i);return l?e.prose.view.DecorationSet.create(n.doc,[l]):null}}}))),config:t}};
@@ -1 +1 @@
1
- {"version":3,"file":"placeholder.js","sourceRoot":"","sources":["../../../src/components/features/placeholder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,SAAS,UAAU,CAAC,GAAS;IAC5B,OAAO,GAAG,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;AAC7D,CAAC;AAED,SAAS,2BAA2B,CAAC,EAAmB,EAAE,KAAkB,EAAE,eAAuB;IACpG,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,SAAS,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,OAAO;QAAE,OAAO,IAAI,CAAC;IAEzB,MAAM,M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I,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAE7E,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBAC9D,MAAM,IAAI,GAAG,2BAA2B,CAAC,EAAE,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;gBACrE,IAAI,CAAC,IAAI;oBAAE,OAAO,IAAI,CAAC;gBAEvB,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9D,CAAC;SACD;KACD,CAAC,CAAC,CAAC;IAEJ,OAAO;QACN,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,iBAAiB;KACzB,CAAA;AACF,CAAC,CAAC","sourcesContent":["import type { Node } from '@omegagrid/milkdown-kit/dist/prose/model';\nimport type { EditorState } from '@omegagrid/milkdown-kit/dist/prose/state';\nimport { isInCodeBlock, isInList } from './utils';\nimport type * as milkdown from '@omegagrid/milkdown-kit';\nimport { msg } from '@omegagrid/localize';\n\nfunction isDocEmpty(doc: Node) {\n\treturn doc.childCount <= 1 && !doc.firstChild?.content.size;\n}\n\nfunction createPlaceholderDecoration(md: typeof milkdown, state: EditorState, placeholderText: string) {\n\tconst { selection } = state;\n\tif (!selection.empty) return null;\n\n\tconst $pos = selection.$anchor;\n\tconst node = $pos.parent;\n\tif (node.content.size > 0) return null;\n\n\tconst inTable = md.prose.findParent((node) => node.type.name === 'table')($pos);\n\tif (inTable) return null;\n\n\tconst before = $pos.before();\n\n\treturn md.prose.view.Decoration.node(before, before + node.nodeSize, {\n\t\tclass: 'crepe-placeholder',\n\t\t'data-placeholder': placeholderText,\n\t});\n}\n\ninterface PlaceholderConfig {\n\ttext: string;\n\tmode: 'doc' | 'block';\n}\n\nexport type PlaceHolderFeatureConfig = Partial<PlaceholderConfig>;\n\nexport const createDefaultPlaceholderConfig = (): PlaceholderConfig => ({\n\ttext: msg('Start typing...'),\n\tmode: 'block',\n});\n\nexport const createPlaceHolder = (md: typeof milkdown) => {\n\tconst placeholderConfig = md.utils.$ctx(createDefaultPlaceholderConfig(), 'placeholderConfigCtx');\n\tconst placeholderPlugin = md.utils.$prose(ctx => new md.prose.state.Plugin({\n\t\tkey: new md.prose.state.PluginKey('MARKDOWN_PLACEHOLDER'),\n\t\tprops: {\n\t\t\tdecorations: (state) => {\n\t\t\t\tconst view = ctx.get(md.core.editorViewCtx);\n\t\t\t\tif (view && !view.editable) return null;\n\n\t\t\t\tconst config = ctx.get(placeholderConfig.key);\n\t\t\t\tif (config.mode === 'doc' && !isDocEmpty(state.doc)) return null;\n\n\t\t\t\tif (isInCodeBlock(state.selection) || isInList(state.selection)) return null;\n\n\t\t\t\tconst placeholderText = config.text ?? msg('Start typing...');\n\t\t\t\tconst deco = createPlaceholderDecoration(md, state, placeholderText);\n\t\t\t\tif (!deco) return null;\n\n\t\t\t\treturn md.prose.view.DecorationSet.create(state.doc, [deco]);\n\t\t\t},\n\t\t}\n\t}));\n\n\treturn {\n\t\tplugin: placeholderPlugin,\n\t\tconfig: placeholderConfig,\n\t}\n};\n"]}
1
+ {"version":3,"file":"placeholder.js","sourceRoot":"","sources":["../../../src/components/features/placeholder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,SAAS,UAAU,CAAC,GAAS;IAC5B,OAAO,GAAG,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;AAC7D,CAAC;AAED,SAAS,2BAA2B,CAAC,EAAmB,EAAE,KAAkB,EAAE,eAAuB;IACpG,MAAM,EAAE,SAAS,EAAE,G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K,CAAC,SAAS,CAAC,sBAAsB,CAAC;QACzD,KAAK,EAAE;YACN,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;gBACtB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC5C,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK;oBAAE,OAAO,IAAI,CAAC;gBAEjD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;gBAC9C,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAEjE,IAAI,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAE7E,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBAC9D,MAAM,IAAI,GAAG,2BAA2B,CAAC,EAAE,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;gBACrE,IAAI,CAAC,IAAI;oBAAE,OAAO,IAAI,CAAC;gBAEvB,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9D,CAAC;SACD;KACD,CAAC,CAAC,CAAC;IAEJ,OAAO;QACN,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,iBAAiB;KACzB,CAAA;AACF,CAAC,CAAC","sourcesContent":["import type { Node } from '@omegagrid/milkdown-kit/dist/prose/model';\nimport type { EditorState } from '@omegagrid/milkdown-kit/dist/prose/state';\nimport { isInCodeBlock, isInList } from './utils';\nimport type * as milkdown from '@omegagrid/milkdown-kit';\nimport { msg } from '@omegagrid/localize';\n\nfunction isDocEmpty(doc: Node) {\n\treturn doc.childCount <= 1 && !doc.firstChild?.content.size;\n}\n\nfunction createPlaceholderDecoration(md: typeof milkdown, state: EditorState, placeholderText: string) {\n\tconst { selection } = state;\n\tif (!selection.empty) return null;\n\n\tconst $pos = selection.$anchor;\n\tconst node = $pos.parent;\n\tif (node.content.size > 0) return null;\n\n\tconst inTable = md.prose.findParent((node) => node.type.name === 'table')($pos);\n\tif (inTable) return null;\n\n\tconst before = $pos.before();\n\n\treturn md.prose.view.Decoration.node(before, before + node.nodeSize, {\n\t\tclass: 'crepe-placeholder',\n\t\t'data-placeholder': placeholderText,\n\t});\n}\n\ninterface PlaceholderConfig {\n\ttext: string;\n\tmode: 'doc' | 'block';\n}\n\nexport type PlaceHolderFeatureConfig = Partial<PlaceholderConfig>;\n\nexport const createDefaultPlaceholderConfig = (): PlaceholderConfig => ({\n\ttext: msg('Start typing...'),\n\tmode: 'block',\n});\n\nexport const createPlaceHolder = (md: typeof milkdown) => {\n\tconst placeholderConfig = md.utils.$ctx(createDefaultPlaceholderConfig(), 'placeholderConfigCtx');\n\tconst placeholderPlugin = md.utils.$prose(ctx => new md.prose.state.Plugin({\n\t\tkey: new md.prose.state.PluginKey('MARKDOWN_PLACEHOLDER'),\n\t\tprops: {\n\t\t\tdecorations: (state) => {\n\t\t\t\tconst view = ctx.get(md.core.editorViewCtx);\n\t\t\t\tif (view && view.editable === false) return null;\n\n\t\t\t\tconst config = ctx.get(placeholderConfig.key);\n\t\t\t\tif (config.mode === 'doc' && !isDocEmpty(state.doc)) return null;\n\n\t\t\t\tif (isInCodeBlock(state.selection) || isInList(state.selection)) return null;\n\n\t\t\t\tconst placeholderText = config.text ?? msg('Start typing...');\n\t\t\t\tconst deco = createPlaceholderDecoration(md, state, placeholderText);\n\t\t\t\tif (!deco) return null;\n\n\t\t\t\treturn md.prose.view.DecorationSet.create(state.doc, [deco]);\n\t\t\t},\n\t\t}\n\t}));\n\n\treturn {\n\t\tplugin: placeholderPlugin,\n\t\tconfig: placeholderConfig,\n\t}\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/markdown",
3
- "version": "0.10.42",
3
+ "version": "0.10.44",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Markdown view webcomponent",
6
6
  "main": "./dist/index.js",
@@ -28,11 +28,11 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@fortawesome/fontawesome-svg-core": "^7.0.1",
31
- "@omegagrid/code": "^0.10.42",
32
- "@omegagrid/core": "^0.10.42",
33
- "@omegagrid/localize": "^0.10.42",
34
- "@omegagrid/milkdown-kit": "^0.10.42",
35
- "@omegagrid/tabs": "^0.10.42",
31
+ "@omegagrid/code": "^0.10.44",
32
+ "@omegagrid/core": "^0.10.44",
33
+ "@omegagrid/localize": "^0.10.44",
34
+ "@omegagrid/milkdown-kit": "^0.10.44",
35
+ "@omegagrid/tabs": "^0.10.44",
36
36
  "lit": "^3.1.1",
37
37
  "markdown-it": "^14.1.0",
38
38
  "ts-debounce": "^4.0.0"