MCPcopy Create free account
hub / github.com/docusealco/docuseal / buildExtensions

Function buildExtensions

app/javascript/elements/html_editor.js:149–427  ·  view source on GitHub ↗
({ Node, Mark, Extension, Plugin, Decoration, DecorationSet })

Source from the content-addressed store, hash-verified

147}
148
149function buildExtensions ({ Node, Mark, Extension, Plugin, Decoration, DecorationSet }) {
150 const blockNode = (name, tag, content, extra = {}) => Node.create({
151 name,
152 group: 'block',
153 content: content || 'block+',
154 ...extra,
155 addAttributes () {
156 return { htmlAttrs: { default: {} } }
157 },
158 parseHTML () {
159 return [{ tag, getAttrs: collectDomAttrs }]
160 },
161 renderHTML ({ node }) {
162 return [tag, node.attrs.htmlAttrs, 0]
163 }
164 })
165
166 const attrsMark = (name, tag) => Mark.create({
167 name,
168 addAttributes () {
169 return { htmlAttrs: { default: {} } }
170 },
171 parseHTML () {
172 return [{ tag, getAttrs: collectDomAttrs }]
173 },
174 renderHTML ({ mark }) {
175 return [tag, mark.attrs.htmlAttrs, 0]
176 }
177 })
178
179 const SpanMark = Mark.create({
180 name: 'span',
181 excludes: '',
182 addAttributes () {
183 return { htmlAttrs: { default: {} } }
184 },
185 parseHTML () {
186 return [{ tag: 'span', getAttrs: collectSpanDomAttrs }]
187 },
188 renderHTML ({ mark }) {
189 return ['span', mark.attrs.htmlAttrs, 0]
190 }
191 })
192
193 const toggleMark = (name, renderTag, parseRules, shortcuts) => Mark.create({
194 name,
195 parseHTML () {
196 return parseRules
197 },
198 renderHTML () {
199 return [renderTag, 0]
200 },
201 addCommands () {
202 const commandName = `toggle${name[0].toUpperCase()}${name.slice(1)}`
203
204 return {
205 [commandName]: () => ({ commands }) => commands.toggleMark(name)
206 }

Callers 1

connectedCallbackMethod · 0.85

Calls 4

blockNodeFunction · 0.85
toggleMarkFunction · 0.85
attrsMarkFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected