296 return |
296 return |
297 |
297 |
298 from .ImageMarkupDialog import ImageMarkupDialog |
298 from .ImageMarkupDialog import ImageMarkupDialog |
299 dlg = ImageMarkupDialog(ImageMarkupDialog.HtmlMode) |
299 dlg = ImageMarkupDialog(ImageMarkupDialog.HtmlMode) |
300 if dlg.exec_() == QDialog.Accepted: |
300 if dlg.exec_() == QDialog.Accepted: |
301 address, altText, title, originalSize, width, height = \ |
301 address, altText, title, originalSize, width, height = ( |
302 dlg.getData() |
302 dlg.getData() |
|
303 ) |
303 |
304 |
304 markup = '<img src="{0}"'.format(address) |
305 markup = '<img src="{0}"'.format(address) |
305 if altText: |
306 if altText: |
306 markup = '{0} alt="{1}"'.format(markup, altText) |
307 markup = '{0} alt="{1}"'.format(markup, altText) |
307 if title: |
308 if title: |
366 return |
367 return |
367 |
368 |
368 lineSeparator = editor.getLineSeparator() |
369 lineSeparator = editor.getLineSeparator() |
369 editor.beginUndoAction() |
370 editor.beginUndoAction() |
370 if editor.hasSelectedText(): |
371 if editor.hasSelectedText(): |
371 startLine, startIndex, endLine, endIndex = \ |
372 startLine, startIndex, endLine, endIndex = ( |
372 editor.getSelection() |
373 editor.getSelection() |
|
374 ) |
373 if endIndex == 0: |
375 if endIndex == 0: |
374 endLine -= 1 |
376 endLine -= 1 |
375 for line in range(startLine, endLine + 1): |
377 for line in range(startLine, endLine + 1): |
376 editor.insertAt("</li>", line, len(editor.text(line).rstrip())) |
378 editor.insertAt("</li>", line, len(editor.text(line).rstrip())) |
377 editor.insertAt(" <li>", line, 0) |
379 editor.insertAt(" <li>", line, 0) |
392 0, 0, 99, 1) |
394 0, 0, 99, 1) |
393 if ok: |
395 if ok: |
394 if listElements == 0: |
396 if listElements == 0: |
395 listElements = 1 |
397 listElements = 1 |
396 cline, cindex = editor.getCursorPosition() |
398 cline, cindex = editor.getCursorPosition() |
397 listBody = \ |
399 listBody = ( |
398 listElements * " <li></li>{0}".format(lineSeparator) |
400 listElements * " <li></li>{0}".format(lineSeparator) |
|
401 ) |
399 markup = "<{1}>{0}{2}</{1}>{0}".format( |
402 markup = "<{1}>{0}{2}</{1}>{0}".format( |
400 lineSeparator, listType, listBody) |
403 lineSeparator, listType, listBody) |
401 if cindex == 0: |
404 if cindex == 0: |
402 editor.insertAt(markup, cline, cindex) |
405 editor.insertAt(markup, cline, cindex) |
403 editor.setCursorPosition(cline + 1, 6) |
406 editor.setCursorPosition(cline + 1, 6) |