@lblod/ember-rdfa-editor 12.13.0 → 12.14.0

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
- {"version":3,"file":"transaction-utils.d.ts","sourceRoot":"","sources":["../../src/utils/transaction-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC;;OAEG;IACH,YAAY,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;CACX;AAED,eAAO,MAAM,UAAU,gBAAgB,CAAC;AACxC;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,CAAC;IACC,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC;CAGxB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,UAAU,CAAC,CAAC,GACrD,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;AAkB9C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAChC,KAAK,EAAE,WAAW;AAClB;;GAEG;AACH,eAAe,CAAC,EAAE,eAAe,KAC9B,sBAAsB,CAAC,CAAC,CAAC,CAAC;AAE/B,MAAM,WAAW,2BAA2B,CAAC,CAAC,CAC5C,SAAQ,sBAAsB,CAAC,CAAC,EAAE,CAAC;IACnC;;;;OAIG;IACH,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AACD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,YAAY,EAAE,WAAW,EACzB,kBAA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;;;OAIG;IACH,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AACD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,YAAY,EAAE,WAAW,EACzB,kBAAkB,CAAC,EAAE,WAAW,EAChC,eAAe,CAAC,EAAE,eAAe,uBAGZ,gBAAgB,CAAC,CAAC,CAAC,EAAE,KACvC,2BAA2B,CAAC,CAAC,CAAC,CAqDlC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,gBAAgB,CAAC,OAAO,CAAC,EAAE,GAC7D,gBAAgB,CAAC,OAAO,CAAC,CAc3B"}
@@ -63,22 +63,23 @@ function setTransactionMeta(transaction, meta) {
63
63
  */
64
64
  function transactionCombinator(initialState, initialTransaction, transactionMeta) {
65
65
  return function (transactionMonads) {
66
- const tr = initialState.tr;
66
+ const resultingTransaction = initialState.tr;
67
67
  const appliedTransactions = [];
68
+ let currentState = initialState;
69
+
70
+ // Apply steps from `initialTransaction` (if it exists)
68
71
  if (initialTransaction) {
69
- for (const step of initialTransaction.steps) {
70
- tr.step(step);
72
+ setTransactionMeta(initialTransaction, transactionMeta);
73
+ const {
74
+ state,
75
+ transactions
76
+ } = initialState.applyTransaction(initialTransaction);
77
+ currentState = state;
78
+ for (const step of transactions.flatMap(transaction => transaction.steps)) {
79
+ resultingTransaction.step(step);
71
80
  }
81
+ appliedTransactions.push(...transactions);
72
82
  }
73
-
74
- // Need to set metadata before applying transaction to a state
75
- setTransactionMeta(tr, transactionMeta);
76
- const {
77
- state,
78
- transactions
79
- } = initialState.applyTransaction(tr);
80
- let currentState = state;
81
- appliedTransactions.push(...transactions);
82
83
  const results = [];
83
84
  for (const monad of transactionMonads) {
84
85
  const {
@@ -94,12 +95,18 @@ function transactionCombinator(initialState, initialTransaction, transactionMeta
94
95
  currentState = state;
95
96
  appliedTransactions.push(...transactions);
96
97
  results.push(result);
97
- for (const step of transaction.steps) {
98
- tr.step(step);
98
+ for (const step of transactions.flatMap(transaction => transaction.steps)) {
99
+ resultingTransaction.step(step);
99
100
  }
100
101
  }
102
+
103
+ // Set the selection and storedMarks based on the state produced by the last transaction.
104
+ // We do not need to map these, as all steps have been applied
105
+ // We do need to serialize/deserialize the selection through a bookmark, as it needs to be resolved to the current document
106
+ resultingTransaction.setSelection(currentState.selection.getBookmark().resolve(resultingTransaction.doc));
107
+ resultingTransaction.setStoredMarks(currentState.storedMarks);
101
108
  return {
102
- transaction: tr,
109
+ transaction: resultingTransaction,
103
110
  result: results,
104
111
  initialState,
105
112
  transactions: appliedTransactions
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-utils.js","sources":["../../src/utils/transaction-utils.ts"],"sourcesContent":["import {\n type EditorState,\n type Plugin,\n type PluginKey,\n type Transaction,\n} from 'prosemirror-state';\n\n/**\n * A generic container for the result of a transaction monad\n * @template R The type of the result\n */\nexport interface TransactionMonadResult<R> {\n /**\n * The state that was passed to the monad\n */\n initialState: EditorState;\n /**\n * The resulting transaction\n */\n transaction: Transaction;\n /**\n * Whether the monad was successful, or any other extra result you might want to add\n */\n result: R;\n}\n\nexport const IS_DRY_RUN = 'sayIsDryRun';\n/**\n * An object or map which holds metadata properties to be appended to transactions.\n * There is one special meta key 'sayIsDryRun', which is used to flag transactions which are just\n * being generated to check that they work, e.g. when checking a command.\n */\nexport type TransactionMeta =\n | ({\n [IS_DRY_RUN]?: boolean;\n // sayIsDryRun being boolean is only enforced for an object of string keyed metadata, as I\n // couldn't find a way to enforce it for a Map\n } & Omit<Record<string, unknown>, typeof IS_DRY_RUN>)\n | Map<string | Plugin | PluginKey, unknown>;\n\nfunction setTransactionMeta(\n transaction: Transaction,\n meta?: TransactionMeta,\n): void {\n if (meta instanceof Map) {\n meta.forEach((val, key) => {\n transaction.setMeta(key, val);\n });\n } else {\n meta &&\n Object.entries(meta).forEach(([key, val]) => {\n transaction.setMeta(key, val);\n });\n }\n}\n\n/**\n * In simple terms, a transaction monad takes a state and builds a transaction and returns it.\n * We return a {@link TransactionMonadResult} here instead to allow for some flexibility regarding failure values.\n * It's generic in the result type, although it's most common to just use a boolean for a simple success/failure workflow.\n *\n * The reason for this particular shape is it's resemblance to monads from functional programming languages, which can be easily\n * chained. It's also relatively intuitive: start from a state, return what you wanna do with the state.\n *\n * By starting from a raw state instead of appending to a pre-existing transaction, these monads can be made much more generic\n * cause they can assume they start from a clean state and are in full control of the transaction they return (aka they don't need to\n * worry about previous steps)\n * @template R The result type for the {@link TransactionMonadResult} return value\n */\nexport type TransactionMonad<R> = (\n state: EditorState,\n /**\n * Metadata to be set on the transaction output from the monad\n */\n transactionMeta?: TransactionMeta,\n) => TransactionMonadResult<R>;\n\nexport interface TransactionCombinatorResult<R>\n extends TransactionMonadResult<R[]> {\n /**\n * All the transactions that were applied in sequence to achieve this result, including any potential extra transactions from plugins.\n * This allows calling code to inspect and use any non-document state that may have been lost\n * such as selections, storedMarks and custom metadata\n */\n transactions: Transaction[];\n}\n/**\n * Builds a function that can chain {@link TransactionMonad} functions together.\n * It starts from the initial state given as the first parameter. The resulting combinator\n * then applies each monad function in sequence, ultimately generating one {@link TransactionCombinatorResult} which combines\n * all operations.\n *\n * You can also optionally pass an initialtransaction, which is required to be made from the same state you pass as initialState.\n * This initial transaction will simply be processed before the monads are applied. This is handy in commands, where you usually\n * already have a transaction and you don't realy want to be forced to write a monad function.\n *\n * The combination happens by appending all the steps of each transaction to an \"accumulator\" transaction, a bit similar to a\n * reduce function.\n *\n * WARNING: the combinator does NOT carry over any selection changes, storedMarks changes, or metadata changes from the given transactions.\n * The logic to correctly carry over selections was simply too complex. Instead, the return value carries the full array of transactions\n * that were applied in sequence, so that calling code can restore any potentially lost state if needed.\n * It is however recommended to write transactionMonads in such a way that they only deal with document transforms.\n *\n * @param initialState the state to start from\n * @param initialTransaction optional initial transaction. If given, it must be made from the same state as you pass to initialState\n * @param transactionMeta metadata to be set on the transactions produced by the combination process\n * @returns The resulting combinator\n */\nexport function transactionCombinator<R>(\n initialState: EditorState,\n initialTransaction?: Transaction,\n transactionMeta?: TransactionMeta,\n) {\n return function (\n transactionMonads: TransactionMonad<R>[],\n ): TransactionCombinatorResult<R> {\n const tr = initialState.tr;\n const appliedTransactions: Transaction[] = [];\n if (initialTransaction) {\n for (const step of initialTransaction.steps) {\n tr.step(step);\n }\n }\n\n // Need to set metadata before applying transaction to a state\n setTransactionMeta(tr, transactionMeta);\n const { state, transactions } = initialState.applyTransaction(tr);\n let currentState = state;\n appliedTransactions.push(...transactions);\n const results: R[] = [];\n for (const monad of transactionMonads) {\n const { transaction, result } = monad(currentState, transactionMeta);\n // Need to set metadata before applying transaction to a state\n setTransactionMeta(transaction, transactionMeta);\n const { state, transactions } =\n currentState.applyTransaction(transaction);\n currentState = state;\n appliedTransactions.push(...transactions);\n\n results.push(result);\n for (const step of transaction.steps) {\n tr.step(step);\n }\n }\n return {\n transaction: tr,\n result: results,\n initialState,\n transactions: appliedTransactions,\n };\n };\n}\n\n/**\n * Creates a monad which applies the passed function to generate a list of monads based on the\n * incoming EditorState and applies them all.\n */\nexport function composeMonads(\n generator: (state: EditorState) => TransactionMonad<boolean>[],\n): TransactionMonad<boolean> {\n return (state, transactionMeta) => {\n const monads: TransactionMonad<boolean>[] = generator(state);\n const {\n transactions: _,\n result,\n ...res\n } = transactionCombinator<boolean>(\n state,\n undefined,\n transactionMeta,\n )(monads);\n return { ...res, result: result.every(Boolean) };\n };\n}\n"],"names":["IS_DRY_RUN","setTransactionMeta","transaction","meta","Map","forEach","val","key","setMeta","Object","entries","transactionCombinator","initialState","initialTransaction","transactionMeta","transactionMonads","tr","appliedTransactions","step","steps","state","transactions","applyTransaction","currentState","push","results","monad","result","composeMonads","generator","monads","_","res","undefined","every","Boolean"],"mappings":";;AAOA;AACA;AACA;AACA;;AAgBO,MAAMA,UAAU,GAAG;AAC1B;AACA;AACA;AACA;AACA;;AASA,SAASC,kBAAkBA,CACzBC,WAAwB,EACx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sourcesContent":["import {\n type EditorState,\n type Plugin,\n type PluginKey,\n type Transaction,\n} from 'prosemirror-state';\n\n/**\n * A generic container for the result of a transaction monad\n * @template R The type of the result\n */\nexport interface TransactionMonadResult<R> {\n /**\n * The state that was passed to the monad\n */\n initialState: EditorState;\n /**\n * The resulting transaction\n */\n transaction: Transaction;\n /**\n * Whether the monad was successful, or any other extra result you might want to add\n */\n result: R;\n}\n\nexport const IS_DRY_RUN = 'sayIsDryRun';\n/**\n * An object or map which holds metadata properties to be appended to transactions.\n * There is one special meta key 'sayIsDryRun', which is used to flag transactions which are just\n * being generated to check that they work, e.g. when checking a command.\n */\nexport type TransactionMeta =\n | ({\n [IS_DRY_RUN]?: boolean;\n // sayIsDryRun being boolean is only enforced for an object of string keyed metadata, as I\n // couldn't find a way to enforce it for a Map\n } & Omit<Record<string, unknown>, typeof IS_DRY_RUN>)\n | Map<string | Plugin | PluginKey, unknown>;\n\nfunction setTransactionMeta(\n transaction: Transaction,\n meta?: TransactionMeta,\n): void {\n if (meta instanceof Map) {\n meta.forEach((val, key) => {\n transaction.setMeta(key, val);\n });\n } else {\n meta &&\n Object.entries(meta).forEach(([key, val]) => {\n transaction.setMeta(key, val);\n });\n }\n}\n\n/**\n * In simple terms, a transaction monad takes a state and builds a transaction and returns it.\n * We return a {@link TransactionMonadResult} here instead to allow for some flexibility regarding failure values.\n * It's generic in the result type, although it's most common to just use a boolean for a simple success/failure workflow.\n *\n * The reason for this particular shape is it's resemblance to monads from functional programming languages, which can be easily\n * chained. It's also relatively intuitive: start from a state, return what you wanna do with the state.\n *\n * By starting from a raw state instead of appending to a pre-existing transaction, these monads can be made much more generic\n * cause they can assume they start from a clean state and are in full control of the transaction they return (aka they don't need to\n * worry about previous steps)\n * @template R The result type for the {@link TransactionMonadResult} return value\n */\nexport type TransactionMonad<R> = (\n state: EditorState,\n /**\n * Metadata to be set on the transaction output from the monad\n */\n transactionMeta?: TransactionMeta,\n) => TransactionMonadResult<R>;\n\nexport interface TransactionCombinatorResult<R>\n extends TransactionMonadResult<R[]> {\n /**\n * All the transactions that were applied in sequence to achieve this result, including any potential extra transactions from plugins.\n * This allows calling code to inspect and use any non-document state that may have been lost\n * such as selections, storedMarks and custom metadata\n */\n transactions: Transaction[];\n}\n/**\n * Builds a function that can chain {@link TransactionMonad} functions together.\n * It starts from the initial state given as the first parameter. The resulting combinator\n * then applies each monad function in sequence, ultimately generating one {@link TransactionCombinatorResult} which combines\n * all operations.\n *\n * You can also optionally pass an initialtransaction, which is required to be made from the same state you pass as initialState.\n * This initial transaction will simply be processed before the monads are applied. This is handy in commands, where you usually\n * already have a transaction and you don't realy want to be forced to write a monad function.\n *\n * The combination happens by appending all the steps of each transaction to an \"accumulator\" transaction, a bit similar to a\n * reduce function.\n *\n * WARNING: the combinator does NOT carry over any selection changes, storedMarks changes, or metadata changes from the given transactions.\n * The logic to correctly carry over selections was simply too complex. Instead, the return value carries the full array of transactions\n * that were applied in sequence, so that calling code can restore any potentially lost state if needed.\n * It is however recommended to write transactionMonads in such a way that they only deal with document transforms.\n *\n * @param initialState the state to start from\n * @param initialTransaction optional initial transaction. If given, it must be made from the same state as you pass to initialState\n * @param transactionMeta metadata to be set on the transactions produced by the combination process\n * @returns The resulting combinator\n */\nexport function transactionCombinator<R>(\n initialState: EditorState,\n initialTransaction?: Transaction,\n transactionMeta?: TransactionMeta,\n) {\n return function (\n transactionMonads: TransactionMonad<R>[],\n ): TransactionCombinatorResult<R> {\n const resultingTransaction = initialState.tr;\n const appliedTransactions: Transaction[] = [];\n let currentState = initialState;\n\n // Apply steps from `initialTransaction` (if it exists)\n if (initialTransaction) {\n setTransactionMeta(initialTransaction, transactionMeta);\n const { state, transactions } =\n initialState.applyTransaction(initialTransaction);\n currentState = state;\n\n for (const step of transactions.flatMap(\n (transaction) => transaction.steps,\n )) {\n resultingTransaction.step(step);\n }\n appliedTransactions.push(...transactions);\n }\n\n const results: R[] = [];\n for (const monad of transactionMonads) {\n const { transaction, result } = monad(currentState, transactionMeta);\n // Need to set metadata before applying transaction to a state\n setTransactionMeta(transaction, transactionMeta);\n const { state, transactions } =\n currentState.applyTransaction(transaction);\n currentState = state;\n appliedTransactions.push(...transactions);\n\n results.push(result);\n for (const step of transactions.flatMap(\n (transaction) => transaction.steps,\n )) {\n resultingTransaction.step(step);\n }\n }\n\n // Set the selection and storedMarks based on the state produced by the last transaction.\n // We do not need to map these, as all steps have been applied\n // We do need to serialize/deserialize the selection through a bookmark, as it needs to be resolved to the current document\n resultingTransaction.setSelection(\n currentState.selection.getBookmark().resolve(resultingTransaction.doc),\n );\n resultingTransaction.setStoredMarks(currentState.storedMarks);\n\n return {\n transaction: resultingTransaction,\n result: results,\n initialState,\n transactions: appliedTransactions,\n };\n };\n}\n\n/**\n * Creates a monad which applies the passed function to generate a list of monads based on the\n * incoming EditorState and applies them all.\n */\nexport function composeMonads(\n generator: (state: EditorState) => TransactionMonad<boolean>[],\n): TransactionMonad<boolean> {\n return (state, transactionMeta) => {\n const monads: TransactionMonad<boolean>[] = generator(state);\n const {\n transactions: _,\n result,\n ...res\n } = transactionCombinator<boolean>(\n state,\n undefined,\n transactionMeta,\n )(monads);\n return { ...res, result: result.every(Boolean) };\n };\n}\n"],"names":["IS_DRY_RUN","setTransactionMeta","transaction","meta","Map","forEach","val","key","setMeta","Object","entries","transactionCombinator","initialState","initialTransaction","transactionMeta","transactionMonads","resultingTransaction","tr","appliedTransactions","currentState","state","transactions","applyTransaction","step","flatMap","steps","push","results","monad","result","setSelection","selection","getBookmark","resolve","doc","setStoredMarks","storedMarks","composeMonads","generator","monads","_","res","undefined","every","Boolean"],"mappings":";;AAOA;AACA;AACA;AACA;;AAgBO,MAAMA,UAAU,GAAG;AAC1B;AACA;AACA;AACA;AACA;;AASA,SAASC,kBAAkBA,CACzBC,WAAwB,EACxBC,IAAsB,EAChB;EACN,IAAIA,IAAI,YAAYC,GAAG,EAAE;AACvBD,IAAAA,IAAI,CAACE,OAAO,CAAC,CAACC,GAAG,EAAEC,GA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GAAG9B,qBAAqB,CACvBS,KAAK,EACLsB,SAAS,EACT5B,eACF,CAAC,CAACyB,MAAM,CAAC;IACT,OAAO;AAAE,MAAA,GAAGE,GAAG;AAAEZ,MAAAA,MAAM,EAAEA,MAAM,CAACc,KAAK,CAACC,OAAO;KAAG;GACjD;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor",
3
- "version": "12.13.0",
3
+ "version": "12.14.0",
4
4
  "description": "Ember addon wrapping an RDFa editor with a public API",
5
5
  "keywords": [
6
6
  "ember-addon"